@reltio/components 1.4.919 → 1.4.923

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.
@@ -83,7 +83,7 @@ var DropDownSelector = function (_a) {
83
83
  Menu: Menu_1.default }, showIndicatorSeparator), components), menuPlacement: "auto", TextFieldProps: __assign(__assign({}, TextFieldProps), { label: label, variant: 'filled', margin: 'dense', classes: __assign(__assign({}, ramda_1.prop('classes', TextFieldProps)), { root: classnames_1.default(styles.formControl, ramda_1.path(['classes', 'root'], TextFieldProps)) }), inputProps: __assign({}, ramda_1.prop('inputProps', TextFieldProps)), InputProps: __assign(__assign({}, ramda_1.prop('InputProps', TextFieldProps)), { classes: __assign(__assign({}, ramda_1.path(['InputProps', 'classes'], TextFieldProps)), { root: classnames_1.default(styles.filledInputRoot, ramda_1.path(['InputProps', 'classes', 'root'], TextFieldProps)), underline: classnames_1.default((_b = {}, _b[underlineStyle.filledInputUnderline] = mdm_sdk_1.isEmptyValue(value), _b), ramda_1.path(['InputProps', 'classes', 'underline'], TextFieldProps)), focused: classnames_1.default('focused', ramda_1.path(['InputProps', 'classes', 'focused'], TextFieldProps)) }) }), InputLabelProps: __assign(__assign({}, ramda_1.prop('InputLabelProps', TextFieldProps)), { classes: __assign(__assign({}, ramda_1.path(['InputLabelProps', 'classes'], TextFieldProps)), { root: classnames_1.default(styles.inputLabel, ramda_1.path(['InputLabelProps', 'classes', 'root'], TextFieldProps)), shrink: classnames_1.default('shrink', ramda_1.path(['InputLabelProps', 'classes', 'shrink'], TextFieldProps)) }), shrink: !mdm_sdk_1.isEmptyValue(value) ? true : undefined }), ref: textFieldInputRef || inputRef }), inputRef: textFieldInputRef || inputRef, menuIsOpen: open, onMenuOpen: function () { return setOpen(true); }, onMenuClose: function () { return setOpen(false); } })));
84
84
  };
85
85
  exports.DropDownSelectorType = {
86
- value: prop_types_1.default.object,
86
+ value: prop_types_1.default.oneOfType([prop_types_1.default.object, prop_types_1.default.array]),
87
87
  label: prop_types_1.default.string.isRequired,
88
88
  getOptions: prop_types_1.default.func,
89
89
  options: prop_types_1.default.array,
@@ -1,16 +1,16 @@
1
+ import { Entity, HistoryWithTotal } from '@reltio/mdm-sdk';
1
2
  import { HistoryFilter } from '../types';
2
3
  declare type Props = {
3
- entityUri: string;
4
+ entity: Entity;
4
5
  enabled: boolean;
5
6
  };
6
- export declare const useHistory: ({ entityUri, enabled }: Props) => {
7
+ export declare const useHistory: ({ entity, enabled }: Props) => {
7
8
  isLoading: boolean;
8
9
  canLoadMore: boolean;
9
10
  onLoadMore: () => void;
10
11
  onApplyFilter: (filter: HistoryFilter) => void;
11
12
  historicUris: string[];
12
- historyWithTotal: import("@reltio/mdm-sdk").HistoryWithTotal;
13
+ historyWithTotal: HistoryWithTotal;
13
14
  historyFilter: HistoryFilter;
14
- reloadHistory: () => void;
15
15
  };
16
16
  export {};
@@ -1,32 +1,97 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
14
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
15
+ to[j] = from[i];
16
+ return to;
17
+ };
2
18
  Object.defineProperty(exports, "__esModule", { value: true });
3
19
  exports.useHistory = void 0;
4
20
  var react_1 = require("react");
5
- var useHistoricUris_1 = require("./useHistoricUris");
6
- var useHistoryWithTotal_1 = require("./useHistoryWithTotal");
21
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
7
22
  var types_1 = require("../types");
8
23
  var filters_1 = require("../utils/filters");
24
+ var hooks_1 = require("../../../hooks");
9
25
  var MAX_HISTORY_ROWS = 32;
10
26
  var useHistory = function (_a) {
11
- var entityUri = _a.entityUri, enabled = _a.enabled;
27
+ var entity = _a.entity, enabled = _a.enabled;
12
28
  var _b = react_1.useState({
13
29
  activities: [types_1.HistoryActivityType.MERGE, types_1.HistoryActivityType.UNMERGE, types_1.HistoryActivityType.UPDATE]
14
30
  }), historyFilter = _b[0], setHistoryFilter = _b[1];
15
31
  var _c = react_1.useState(0), historyPage = _c[0], setHistoryPage = _c[1];
16
32
  var historyFilterString = react_1.useMemo(function () { return filters_1.buildHistoryFilterString(historyFilter); }, [historyFilter]);
17
- var _d = useHistoricUris_1.useHistoricUris({
18
- entityUri: entityUri,
19
- enabled: enabled
20
- }), isHistoricUrisLoading = _d.isLoading, historicUris = _d.historicUris;
21
- var _e = useHistoryWithTotal_1.useHistoryWithTotal({
22
- entityUri: entityUri,
23
- enabled: enabled && !!historicUris,
24
- filter: historyFilterString,
25
- historicUris: historicUris,
26
- max: MAX_HISTORY_ROWS,
27
- offset: historyPage * MAX_HISTORY_ROWS,
28
- order: 'desc'
29
- }), isHistoryLoading = _e.isLoading, historyWithTotal = _e.historyWithTotal, loadMore = _e.loadMore, loadData = _e.loadData;
33
+ var _d = react_1.useState(null), historicUris = _d[0], setHistoricUris = _d[1];
34
+ var _e = react_1.useState(null), historyWithTotal = _e[0], setHistoryWithTotal = _e[1];
35
+ var _f = react_1.useState(false), isLoading = _f[0], setIsLoading = _f[1];
36
+ var safePromise = hooks_1.useSafePromise();
37
+ var entityUri = entity === null || entity === void 0 ? void 0 : entity.uri;
38
+ var options = { max: MAX_HISTORY_ROWS, order: 'desc' };
39
+ var showAll = mdm_sdk_1.isEmptyValue(historyFilter === null || historyFilter === void 0 ? void 0 : historyFilter.attributes) || undefined;
40
+ var loadHistoryWithTotal = function () {
41
+ setIsLoading(true);
42
+ return safePromise(mdm_sdk_1.getHistoryWithTotal(__assign({ entityUri: entityUri,
43
+ historicUris: historicUris, filter: historyFilterString, showAll: showAll }, options)))
44
+ .then(setHistoryWithTotal)
45
+ .catch(function (e) {
46
+ console.warn('Failed to load history data', e);
47
+ setHistoryWithTotal(null);
48
+ })
49
+ .finally(function () {
50
+ setIsLoading(false);
51
+ });
52
+ };
53
+ react_1.useEffect(function () {
54
+ if (entityUri && enabled) {
55
+ loadHistoryWithTotal();
56
+ }
57
+ }, [historyFilterString, showAll, historicUris]);
58
+ var loadHistoricUris = function () {
59
+ setIsLoading(true);
60
+ return safePromise(mdm_sdk_1.getHistoricUris({ entityUri: entityUri }))
61
+ .then(function (historicUris) {
62
+ setHistoricUris(historicUris);
63
+ })
64
+ .catch(function (e) {
65
+ console.warn('Failed to load history data', e);
66
+ setHistoricUris(null);
67
+ })
68
+ .finally(function () {
69
+ setIsLoading(false);
70
+ });
71
+ };
72
+ react_1.useEffect(function () {
73
+ if (entityUri && enabled) {
74
+ loadHistoricUris();
75
+ setHistoryPage(0);
76
+ }
77
+ }, [entityUri, entity === null || entity === void 0 ? void 0 : entity.updatedTime, enabled]);
78
+ var loadMore = react_1.useCallback(function (offset) {
79
+ if (entityUri && historicUris && enabled) {
80
+ setIsLoading(true);
81
+ safePromise(mdm_sdk_1.getHistoryWithTotal(__assign({ entityUri: entityUri,
82
+ historicUris: historicUris, filter: historyFilterString, showAll: showAll,
83
+ offset: offset }, options)))
84
+ .then(function (results) {
85
+ setHistoryWithTotal(function (prev) { return (__assign(__assign({}, prev), { changes: __spreadArray(__spreadArray([], prev === null || prev === void 0 ? void 0 : prev.changes), results.changes) })); });
86
+ })
87
+ .catch(function (e) {
88
+ console.warn('Failed to load history data', e);
89
+ })
90
+ .finally(function () {
91
+ setIsLoading(false);
92
+ });
93
+ }
94
+ }, [historicUris, historyFilterString, enabled]);
30
95
  var canLoadMore = react_1.useMemo(function () { return (historyPage + 1) * MAX_HISTORY_ROWS < (historyWithTotal === null || historyWithTotal === void 0 ? void 0 : historyWithTotal.total); }, [
31
96
  historyWithTotal,
32
97
  historyPage
@@ -41,19 +106,14 @@ var useHistory = function (_a) {
41
106
  loadMore((historyPage + 1) * MAX_HISTORY_ROWS);
42
107
  setHistoryPage(historyPage + 1);
43
108
  }, [loadMore, historyPage, canLoadMore]);
44
- var reloadHistory = react_1.useCallback(function () {
45
- loadData();
46
- setHistoryPage(0);
47
- }, [loadData]);
48
109
  return {
49
- isLoading: isHistoryLoading || isHistoricUrisLoading,
110
+ isLoading: isLoading,
50
111
  canLoadMore: canLoadMore,
51
112
  onLoadMore: onLoadMore,
52
113
  onApplyFilter: onApplyFilter,
53
114
  historicUris: historicUris,
54
115
  historyWithTotal: historyWithTotal,
55
- historyFilter: historyFilter,
56
- reloadHistory: reloadHistory
116
+ historyFilter: historyFilter
57
117
  };
58
118
  };
59
119
  exports.useHistory = useHistory;
@@ -1,2 +1,3 @@
1
1
  import { HistoryDiff } from '@reltio/mdm-sdk';
2
+ export declare const defaultHistoryDiff: HistoryDiff;
2
3
  export declare const useHistoryDiff: () => HistoryDiff;
@@ -19,13 +19,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.useHistoryDiff = void 0;
22
+ exports.useHistoryDiff = exports.defaultHistoryDiff = void 0;
23
23
  var react_1 = require("react");
24
24
  var react_redux_1 = require("react-redux");
25
25
  var ramda_1 = require("ramda");
26
26
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
27
27
  var mdm_module_1 = __importStar(require("@reltio/mdm-module"));
28
- var defaultHistoryDiff = {
28
+ exports.defaultHistoryDiff = {
29
29
  appearance: {},
30
30
  attributes: {},
31
31
  roles: [],
@@ -57,6 +57,6 @@ var useHistoryDiff = function () {
57
57
  dispatch(mdm_module_1.profile.history.actions.setHistoryDiff(historyDiff_1));
58
58
  }
59
59
  }, [historySlice, historyMode, dispatch, entity]);
60
- return historyDiff || defaultHistoryDiff;
60
+ return historyDiff || exports.defaultHistoryDiff;
61
61
  };
62
62
  exports.useHistoryDiff = useHistoryDiff;
@@ -1,5 +1,3 @@
1
- export { useHistoricUris } from './hooks/useHistoricUris';
2
- export { useHistoryWithTotal } from './hooks/useHistoryWithTotal';
3
1
  export { useHistorySlice } from './hooks/useHistorySlice';
4
2
  export { useHistory } from './hooks/useHistory';
5
3
  export { useHistoryDiff } from './hooks/useHistoryDiff';
@@ -13,11 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.ProfileBandHistory = exports.HistoryHeader = exports.HistoryView = exports.useHistoryDiff = exports.useHistory = exports.useHistorySlice = exports.useHistoryWithTotal = exports.useHistoricUris = void 0;
17
- var useHistoricUris_1 = require("./hooks/useHistoricUris");
18
- Object.defineProperty(exports, "useHistoricUris", { enumerable: true, get: function () { return useHistoricUris_1.useHistoricUris; } });
19
- var useHistoryWithTotal_1 = require("./hooks/useHistoryWithTotal");
20
- Object.defineProperty(exports, "useHistoryWithTotal", { enumerable: true, get: function () { return useHistoryWithTotal_1.useHistoryWithTotal; } });
16
+ exports.ProfileBandHistory = exports.HistoryHeader = exports.HistoryView = exports.useHistoryDiff = exports.useHistory = exports.useHistorySlice = void 0;
21
17
  var useHistorySlice_1 = require("./hooks/useHistorySlice");
22
18
  Object.defineProperty(exports, "useHistorySlice", { enumerable: true, get: function () { return useHistorySlice_1.useHistorySlice; } });
23
19
  var useHistory_1 = require("./hooks/useHistory");
@@ -58,7 +58,7 @@ var DropDownSelector = function (_a) {
58
58
  Menu: Menu }, showIndicatorSeparator), components), menuPlacement: "auto", TextFieldProps: __assign(__assign({}, TextFieldProps), { label: label, variant: 'filled', margin: 'dense', classes: __assign(__assign({}, prop('classes', TextFieldProps)), { root: classnames(styles.formControl, path(['classes', 'root'], TextFieldProps)) }), inputProps: __assign({}, prop('inputProps', TextFieldProps)), InputProps: __assign(__assign({}, prop('InputProps', TextFieldProps)), { classes: __assign(__assign({}, path(['InputProps', 'classes'], TextFieldProps)), { root: classnames(styles.filledInputRoot, path(['InputProps', 'classes', 'root'], TextFieldProps)), underline: classnames((_b = {}, _b[underlineStyle.filledInputUnderline] = isEmptyValue(value), _b), path(['InputProps', 'classes', 'underline'], TextFieldProps)), focused: classnames('focused', path(['InputProps', 'classes', 'focused'], TextFieldProps)) }) }), InputLabelProps: __assign(__assign({}, prop('InputLabelProps', TextFieldProps)), { classes: __assign(__assign({}, path(['InputLabelProps', 'classes'], TextFieldProps)), { root: classnames(styles.inputLabel, path(['InputLabelProps', 'classes', 'root'], TextFieldProps)), shrink: classnames('shrink', path(['InputLabelProps', 'classes', 'shrink'], TextFieldProps)) }), shrink: !isEmptyValue(value) ? true : undefined }), ref: textFieldInputRef || inputRef }), inputRef: textFieldInputRef || inputRef, menuIsOpen: open, onMenuOpen: function () { return setOpen(true); }, onMenuClose: function () { return setOpen(false); } })));
59
59
  };
60
60
  export var DropDownSelectorType = {
61
- value: PropTypes.object,
61
+ value: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
62
62
  label: PropTypes.string.isRequired,
63
63
  getOptions: PropTypes.func,
64
64
  options: PropTypes.array,
@@ -1,16 +1,16 @@
1
+ import { Entity, HistoryWithTotal } from '@reltio/mdm-sdk';
1
2
  import { HistoryFilter } from '../types';
2
3
  declare type Props = {
3
- entityUri: string;
4
+ entity: Entity;
4
5
  enabled: boolean;
5
6
  };
6
- export declare const useHistory: ({ entityUri, enabled }: Props) => {
7
+ export declare const useHistory: ({ entity, enabled }: Props) => {
7
8
  isLoading: boolean;
8
9
  canLoadMore: boolean;
9
10
  onLoadMore: () => void;
10
11
  onApplyFilter: (filter: HistoryFilter) => void;
11
12
  historicUris: string[];
12
- historyWithTotal: import("@reltio/mdm-sdk").HistoryWithTotal;
13
+ historyWithTotal: HistoryWithTotal;
13
14
  historyFilter: HistoryFilter;
14
- reloadHistory: () => void;
15
15
  };
16
16
  export {};
@@ -1,29 +1,94 @@
1
- import { useState, useMemo, useCallback } from 'react';
2
- import { useHistoricUris } from './useHistoricUris';
3
- import { useHistoryWithTotal } from './useHistoryWithTotal';
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
13
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
14
+ to[j] = from[i];
15
+ return to;
16
+ };
17
+ import { useState, useMemo, useCallback, useEffect } from 'react';
18
+ import { getHistoricUris, getHistoryWithTotal, isEmptyValue } from '@reltio/mdm-sdk';
4
19
  import { HistoryActivityType } from '../types';
5
20
  import { buildHistoryFilterString } from '../utils/filters';
21
+ import { useSafePromise } from '../../../hooks';
6
22
  var MAX_HISTORY_ROWS = 32;
7
23
  export var useHistory = function (_a) {
8
- var entityUri = _a.entityUri, enabled = _a.enabled;
24
+ var entity = _a.entity, enabled = _a.enabled;
9
25
  var _b = useState({
10
26
  activities: [HistoryActivityType.MERGE, HistoryActivityType.UNMERGE, HistoryActivityType.UPDATE]
11
27
  }), historyFilter = _b[0], setHistoryFilter = _b[1];
12
28
  var _c = useState(0), historyPage = _c[0], setHistoryPage = _c[1];
13
29
  var historyFilterString = useMemo(function () { return buildHistoryFilterString(historyFilter); }, [historyFilter]);
14
- var _d = useHistoricUris({
15
- entityUri: entityUri,
16
- enabled: enabled
17
- }), isHistoricUrisLoading = _d.isLoading, historicUris = _d.historicUris;
18
- var _e = useHistoryWithTotal({
19
- entityUri: entityUri,
20
- enabled: enabled && !!historicUris,
21
- filter: historyFilterString,
22
- historicUris: historicUris,
23
- max: MAX_HISTORY_ROWS,
24
- offset: historyPage * MAX_HISTORY_ROWS,
25
- order: 'desc'
26
- }), isHistoryLoading = _e.isLoading, historyWithTotal = _e.historyWithTotal, loadMore = _e.loadMore, loadData = _e.loadData;
30
+ var _d = useState(null), historicUris = _d[0], setHistoricUris = _d[1];
31
+ var _e = useState(null), historyWithTotal = _e[0], setHistoryWithTotal = _e[1];
32
+ var _f = useState(false), isLoading = _f[0], setIsLoading = _f[1];
33
+ var safePromise = useSafePromise();
34
+ var entityUri = entity === null || entity === void 0 ? void 0 : entity.uri;
35
+ var options = { max: MAX_HISTORY_ROWS, order: 'desc' };
36
+ var showAll = isEmptyValue(historyFilter === null || historyFilter === void 0 ? void 0 : historyFilter.attributes) || undefined;
37
+ var loadHistoryWithTotal = function () {
38
+ setIsLoading(true);
39
+ return safePromise(getHistoryWithTotal(__assign({ entityUri: entityUri,
40
+ historicUris: historicUris, filter: historyFilterString, showAll: showAll }, options)))
41
+ .then(setHistoryWithTotal)
42
+ .catch(function (e) {
43
+ console.warn('Failed to load history data', e);
44
+ setHistoryWithTotal(null);
45
+ })
46
+ .finally(function () {
47
+ setIsLoading(false);
48
+ });
49
+ };
50
+ useEffect(function () {
51
+ if (entityUri && enabled) {
52
+ loadHistoryWithTotal();
53
+ }
54
+ }, [historyFilterString, showAll, historicUris]);
55
+ var loadHistoricUris = function () {
56
+ setIsLoading(true);
57
+ return safePromise(getHistoricUris({ entityUri: entityUri }))
58
+ .then(function (historicUris) {
59
+ setHistoricUris(historicUris);
60
+ })
61
+ .catch(function (e) {
62
+ console.warn('Failed to load history data', e);
63
+ setHistoricUris(null);
64
+ })
65
+ .finally(function () {
66
+ setIsLoading(false);
67
+ });
68
+ };
69
+ useEffect(function () {
70
+ if (entityUri && enabled) {
71
+ loadHistoricUris();
72
+ setHistoryPage(0);
73
+ }
74
+ }, [entityUri, entity === null || entity === void 0 ? void 0 : entity.updatedTime, enabled]);
75
+ var loadMore = useCallback(function (offset) {
76
+ if (entityUri && historicUris && enabled) {
77
+ setIsLoading(true);
78
+ safePromise(getHistoryWithTotal(__assign({ entityUri: entityUri,
79
+ historicUris: historicUris, filter: historyFilterString, showAll: showAll,
80
+ offset: offset }, options)))
81
+ .then(function (results) {
82
+ setHistoryWithTotal(function (prev) { return (__assign(__assign({}, prev), { changes: __spreadArray(__spreadArray([], prev === null || prev === void 0 ? void 0 : prev.changes), results.changes) })); });
83
+ })
84
+ .catch(function (e) {
85
+ console.warn('Failed to load history data', e);
86
+ })
87
+ .finally(function () {
88
+ setIsLoading(false);
89
+ });
90
+ }
91
+ }, [historicUris, historyFilterString, enabled]);
27
92
  var canLoadMore = useMemo(function () { return (historyPage + 1) * MAX_HISTORY_ROWS < (historyWithTotal === null || historyWithTotal === void 0 ? void 0 : historyWithTotal.total); }, [
28
93
  historyWithTotal,
29
94
  historyPage
@@ -38,18 +103,13 @@ export var useHistory = function (_a) {
38
103
  loadMore((historyPage + 1) * MAX_HISTORY_ROWS);
39
104
  setHistoryPage(historyPage + 1);
40
105
  }, [loadMore, historyPage, canLoadMore]);
41
- var reloadHistory = useCallback(function () {
42
- loadData();
43
- setHistoryPage(0);
44
- }, [loadData]);
45
106
  return {
46
- isLoading: isHistoryLoading || isHistoricUrisLoading,
107
+ isLoading: isLoading,
47
108
  canLoadMore: canLoadMore,
48
109
  onLoadMore: onLoadMore,
49
110
  onApplyFilter: onApplyFilter,
50
111
  historicUris: historicUris,
51
112
  historyWithTotal: historyWithTotal,
52
- historyFilter: historyFilter,
53
- reloadHistory: reloadHistory
113
+ historyFilter: historyFilter
54
114
  };
55
115
  };
@@ -1,2 +1,3 @@
1
1
  import { HistoryDiff } from '@reltio/mdm-sdk';
2
+ export declare const defaultHistoryDiff: HistoryDiff;
2
3
  export declare const useHistoryDiff: () => HistoryDiff;
@@ -3,7 +3,7 @@ import { useDispatch, useSelector } from 'react-redux';
3
3
  import { evolve, map } from 'ramda';
4
4
  import { entity as History, wrapInArrayIfNeeded } from '@reltio/mdm-sdk';
5
5
  import mdmModule, { HistoryMode, profile } from '@reltio/mdm-module';
6
- var defaultHistoryDiff = {
6
+ export var defaultHistoryDiff = {
7
7
  appearance: {},
8
8
  attributes: {},
9
9
  roles: [],
@@ -1,5 +1,3 @@
1
- export { useHistoricUris } from './hooks/useHistoricUris';
2
- export { useHistoryWithTotal } from './hooks/useHistoryWithTotal';
3
1
  export { useHistorySlice } from './hooks/useHistorySlice';
4
2
  export { useHistory } from './hooks/useHistory';
5
3
  export { useHistoryDiff } from './hooks/useHistoryDiff';
@@ -1,5 +1,3 @@
1
- export { useHistoricUris } from './hooks/useHistoricUris';
2
- export { useHistoryWithTotal } from './hooks/useHistoryWithTotal';
3
1
  export { useHistorySlice } from './hooks/useHistorySlice';
4
2
  export { useHistory } from './hooks/useHistory';
5
3
  export { useHistoryDiff } from './hooks/useHistoryDiff';
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.919",
3
+ "version": "1.4.923",
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.919",
11
- "@reltio/mdm-sdk": "^1.4.919",
10
+ "@reltio/mdm-module": "^1.4.923",
11
+ "@reltio/mdm-sdk": "^1.4.923",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",
@@ -1,9 +0,0 @@
1
- declare type Props = {
2
- entityUri: string;
3
- enabled?: boolean;
4
- };
5
- export declare const useHistoricUris: ({ entityUri, enabled }: Props) => {
6
- isLoading: boolean;
7
- historicUris: string[];
8
- };
9
- export {};
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useHistoricUris = void 0;
4
- var react_1 = require("react");
5
- var mdm_sdk_1 = require("@reltio/mdm-sdk");
6
- var hooks_1 = require("../../../hooks");
7
- var useHistoricUris = function (_a) {
8
- var entityUri = _a.entityUri, _b = _a.enabled, enabled = _b === void 0 ? true : _b;
9
- var _c = react_1.useState(null), historicUris = _c[0], setHistoricUris = _c[1];
10
- var _d = react_1.useState(false), isLoading = _d[0], setIsLoading = _d[1];
11
- var safePromise = hooks_1.useSafePromise();
12
- var onError = function (e) {
13
- console.warn('Failed to load historic URIs', e);
14
- setHistoricUris(null);
15
- };
16
- var loadData = react_1.useCallback(function () {
17
- if (entityUri) {
18
- setIsLoading(true);
19
- safePromise(mdm_sdk_1.getHistoricUris({ entityUri: entityUri }))
20
- .then(function (results) {
21
- setHistoricUris(results);
22
- })
23
- .catch(onError)
24
- .finally(function () {
25
- setIsLoading(false);
26
- });
27
- }
28
- else {
29
- setHistoricUris(null);
30
- }
31
- }, [entityUri]);
32
- react_1.useEffect(function () {
33
- if (enabled) {
34
- loadData();
35
- }
36
- }, [loadData, enabled]);
37
- return { isLoading: isLoading, historicUris: historicUris };
38
- };
39
- exports.useHistoricUris = useHistoricUris;
@@ -1,18 +0,0 @@
1
- import { HistoryWithTotal } from '@reltio/mdm-sdk';
2
- declare type Props = {
3
- entityUri: string;
4
- enabled?: boolean;
5
- historicUris: string[];
6
- showAll?: boolean;
7
- max?: number;
8
- offset?: number;
9
- order?: string;
10
- filter?: string;
11
- };
12
- export declare const useHistoryWithTotal: ({ entityUri, enabled, historicUris, filter, ...options }: Props) => {
13
- isLoading: boolean;
14
- historyWithTotal: HistoryWithTotal;
15
- loadMore: (offset: number) => void;
16
- loadData: () => void;
17
- };
18
- export {};
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
25
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
26
- to[j] = from[i];
27
- return to;
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.useHistoryWithTotal = void 0;
31
- var react_1 = require("react");
32
- var mdm_sdk_1 = require("@reltio/mdm-sdk");
33
- var hooks_1 = require("../../../hooks");
34
- var useHistoryWithTotal = function (_a) {
35
- var entityUri = _a.entityUri, _b = _a.enabled, enabled = _b === void 0 ? true : _b, historicUris = _a.historicUris, filter = _a.filter, options = __rest(_a, ["entityUri", "enabled", "historicUris", "filter"]);
36
- var _c = react_1.useState(null), historyWithTotal = _c[0], setHistoryWithTotal = _c[1];
37
- var _d = react_1.useState(false), isLoading = _d[0], setIsLoading = _d[1];
38
- var safePromise = hooks_1.useSafePromise();
39
- var onError = function (e) {
40
- console.warn('Failed to load history', e);
41
- setHistoryWithTotal(null);
42
- };
43
- var loadData = react_1.useCallback(function () {
44
- if (entityUri && historicUris) {
45
- setIsLoading(true);
46
- safePromise(mdm_sdk_1.getHistoryWithTotal(__assign({ entityUri: entityUri, historicUris: historicUris, filter: filter }, options)))
47
- .then(function (results) {
48
- setHistoryWithTotal(results);
49
- })
50
- .catch(onError)
51
- .finally(function () {
52
- setIsLoading(false);
53
- });
54
- }
55
- else {
56
- setHistoryWithTotal(null);
57
- }
58
- }, [entityUri, historicUris, filter]);
59
- var loadMore = react_1.useCallback(function (offset) {
60
- if (entityUri && historicUris) {
61
- setIsLoading(true);
62
- safePromise(mdm_sdk_1.getHistoryWithTotal(__assign(__assign({ entityUri: entityUri, historicUris: historicUris, filter: filter }, options), { offset: offset })))
63
- .then(function (results) {
64
- setHistoryWithTotal(function (prev) { return (__assign(__assign({}, prev), { changes: __spreadArray(__spreadArray([], prev === null || prev === void 0 ? void 0 : prev.changes), results.changes) })); });
65
- })
66
- .catch(onError)
67
- .finally(function () {
68
- setIsLoading(false);
69
- });
70
- }
71
- }, [entityUri, historicUris, filter]);
72
- react_1.useEffect(function () {
73
- if (enabled) {
74
- loadData();
75
- }
76
- }, [loadData, enabled]);
77
- return { isLoading: isLoading, historyWithTotal: historyWithTotal, loadMore: loadMore, loadData: loadData };
78
- };
79
- exports.useHistoryWithTotal = useHistoryWithTotal;
@@ -1,9 +0,0 @@
1
- declare type Props = {
2
- entityUri: string;
3
- enabled?: boolean;
4
- };
5
- export declare const useHistoricUris: ({ entityUri, enabled }: Props) => {
6
- isLoading: boolean;
7
- historicUris: string[];
8
- };
9
- export {};
@@ -1,35 +0,0 @@
1
- import { useCallback, useEffect, useState } from 'react';
2
- import { getHistoricUris } from '@reltio/mdm-sdk';
3
- import { useSafePromise } from '../../../hooks';
4
- export var useHistoricUris = function (_a) {
5
- var entityUri = _a.entityUri, _b = _a.enabled, enabled = _b === void 0 ? true : _b;
6
- var _c = useState(null), historicUris = _c[0], setHistoricUris = _c[1];
7
- var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
8
- var safePromise = useSafePromise();
9
- var onError = function (e) {
10
- console.warn('Failed to load historic URIs', e);
11
- setHistoricUris(null);
12
- };
13
- var loadData = useCallback(function () {
14
- if (entityUri) {
15
- setIsLoading(true);
16
- safePromise(getHistoricUris({ entityUri: entityUri }))
17
- .then(function (results) {
18
- setHistoricUris(results);
19
- })
20
- .catch(onError)
21
- .finally(function () {
22
- setIsLoading(false);
23
- });
24
- }
25
- else {
26
- setHistoricUris(null);
27
- }
28
- }, [entityUri]);
29
- useEffect(function () {
30
- if (enabled) {
31
- loadData();
32
- }
33
- }, [loadData, enabled]);
34
- return { isLoading: isLoading, historicUris: historicUris };
35
- };
@@ -1,18 +0,0 @@
1
- import { HistoryWithTotal } from '@reltio/mdm-sdk';
2
- declare type Props = {
3
- entityUri: string;
4
- enabled?: boolean;
5
- historicUris: string[];
6
- showAll?: boolean;
7
- max?: number;
8
- offset?: number;
9
- order?: string;
10
- filter?: string;
11
- };
12
- export declare const useHistoryWithTotal: ({ entityUri, enabled, historicUris, filter, ...options }: Props) => {
13
- isLoading: boolean;
14
- historyWithTotal: HistoryWithTotal;
15
- loadMore: (offset: number) => void;
16
- loadData: () => void;
17
- };
18
- export {};
@@ -1,75 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
24
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
25
- to[j] = from[i];
26
- return to;
27
- };
28
- import { useCallback, useEffect, useState } from 'react';
29
- import { getHistoryWithTotal } from '@reltio/mdm-sdk';
30
- import { useSafePromise } from '../../../hooks';
31
- export var useHistoryWithTotal = function (_a) {
32
- var entityUri = _a.entityUri, _b = _a.enabled, enabled = _b === void 0 ? true : _b, historicUris = _a.historicUris, filter = _a.filter, options = __rest(_a, ["entityUri", "enabled", "historicUris", "filter"]);
33
- var _c = useState(null), historyWithTotal = _c[0], setHistoryWithTotal = _c[1];
34
- var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
35
- var safePromise = useSafePromise();
36
- var onError = function (e) {
37
- console.warn('Failed to load history', e);
38
- setHistoryWithTotal(null);
39
- };
40
- var loadData = useCallback(function () {
41
- if (entityUri && historicUris) {
42
- setIsLoading(true);
43
- safePromise(getHistoryWithTotal(__assign({ entityUri: entityUri, historicUris: historicUris, filter: filter }, options)))
44
- .then(function (results) {
45
- setHistoryWithTotal(results);
46
- })
47
- .catch(onError)
48
- .finally(function () {
49
- setIsLoading(false);
50
- });
51
- }
52
- else {
53
- setHistoryWithTotal(null);
54
- }
55
- }, [entityUri, historicUris, filter]);
56
- var loadMore = useCallback(function (offset) {
57
- if (entityUri && historicUris) {
58
- setIsLoading(true);
59
- safePromise(getHistoryWithTotal(__assign(__assign({ entityUri: entityUri, historicUris: historicUris, filter: filter }, options), { offset: offset })))
60
- .then(function (results) {
61
- setHistoryWithTotal(function (prev) { return (__assign(__assign({}, prev), { changes: __spreadArray(__spreadArray([], prev === null || prev === void 0 ? void 0 : prev.changes), results.changes) })); });
62
- })
63
- .catch(onError)
64
- .finally(function () {
65
- setIsLoading(false);
66
- });
67
- }
68
- }, [entityUri, historicUris, filter]);
69
- useEffect(function () {
70
- if (enabled) {
71
- loadData();
72
- }
73
- }, [loadData, enabled]);
74
- return { isLoading: isLoading, historyWithTotal: historyWithTotal, loadMore: loadMore, loadData: loadData };
75
- };