@reltio/components 1.4.1829 → 1.4.1830

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,3 +29,4 @@ export { useLayoutResetter } from './useLayoutResetter';
29
29
  export { useExpandInvalidRelations } from './useExpandInvalidRelations';
30
30
  export { useAutoFocus } from './useAutoFocus';
31
31
  export { useRequestDCRReview } from './useRequestDCRReview';
32
+ export { useSavedSearchesRequest } from './useSavedSearchesRequest';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useRequestDCRReview = exports.useAutoFocus = exports.useExpandInvalidRelations = exports.useLayoutResetter = exports.useIsMountedRef = exports.useSnackbar = exports.useSavedStateForEntityType = exports.useReadableSearchState = exports.useEditableConnection = exports.useCustomScripts = exports.useMarkAsNotMatchRequest = exports.useMergeAllRequest = 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.useCommentsEntitiesMap = exports.useCollaboration = exports.useAsyncMount = exports.useAPI = exports.useActions = exports.useMatchesColumnsData = exports.useScrollToAttributeError = void 0;
3
+ exports.useSavedSearchesRequest = exports.useRequestDCRReview = exports.useAutoFocus = exports.useExpandInvalidRelations = exports.useLayoutResetter = exports.useIsMountedRef = exports.useSnackbar = exports.useSavedStateForEntityType = exports.useReadableSearchState = exports.useEditableConnection = exports.useCustomScripts = exports.useMarkAsNotMatchRequest = exports.useMergeAllRequest = 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.useCommentsEntitiesMap = exports.useCollaboration = exports.useAsyncMount = exports.useAPI = exports.useActions = exports.useMatchesColumnsData = exports.useScrollToAttributeError = void 0;
4
4
  var useScrollToAttributeError_1 = require("./useScrollToAttributeError/useScrollToAttributeError");
5
5
  Object.defineProperty(exports, "useScrollToAttributeError", { enumerable: true, get: function () { return useScrollToAttributeError_1.useScrollToAttributeError; } });
6
6
  var useMatchesColumnsData_1 = require("./useMatchesColumnsData/useMatchesColumnsData");
@@ -63,3 +63,5 @@ var useAutoFocus_1 = require("./useAutoFocus");
63
63
  Object.defineProperty(exports, "useAutoFocus", { enumerable: true, get: function () { return useAutoFocus_1.useAutoFocus; } });
64
64
  var useRequestDCRReview_1 = require("./useRequestDCRReview");
65
65
  Object.defineProperty(exports, "useRequestDCRReview", { enumerable: true, get: function () { return useRequestDCRReview_1.useRequestDCRReview; } });
66
+ var useSavedSearchesRequest_1 = require("./useSavedSearchesRequest");
67
+ Object.defineProperty(exports, "useSavedSearchesRequest", { enumerable: true, get: function () { return useSavedSearchesRequest_1.useSavedSearchesRequest; } });
@@ -0,0 +1,28 @@
1
+ import { SavedSearchData, SavedSearchesOptions, deleteSavedSearch, updateSavedSearch } from '@reltio/mdm-sdk';
2
+ import { RequestStates } from '../types';
3
+ type Props = {
4
+ options?: SavedSearchesOptions;
5
+ offset: number;
6
+ max: number;
7
+ queryEstimatorEnabled?: boolean;
8
+ };
9
+ export declare const useSavedSearchesRequest: ({ options, offset, max, queryEstimatorEnabled }: Props) => {
10
+ state: RequestStates;
11
+ data: SavedSearchData[];
12
+ reload: () => void;
13
+ total: number;
14
+ loadTotalForSearchByUri: (uri: string) => Promise<void>;
15
+ saveSearch: (savedSearch: Partial<SavedSearchData> & {
16
+ name: string;
17
+ query: string;
18
+ uiState: Record<string, any>;
19
+ }) => Promise<SavedSearchData>;
20
+ updateSearch: (savedSearch: Parameters<typeof updateSavedSearch>[0]) => Promise<SavedSearchData>;
21
+ deleteSearch: (savedSearch: Parameters<typeof deleteSavedSearch>[0]) => Promise<{
22
+ success: true;
23
+ } | {
24
+ success: false;
25
+ error: unknown;
26
+ }>;
27
+ };
28
+ export {};
@@ -0,0 +1,182 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __rest = (this && this.__rest) || function (s, e) {
50
+ var t = {};
51
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
52
+ t[p] = s[p];
53
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
54
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
55
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
56
+ t[p[i]] = s[p[i]];
57
+ }
58
+ return t;
59
+ };
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ exports.useSavedSearchesRequest = void 0;
62
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
63
+ var ramda_1 = require("ramda");
64
+ var react_1 = require("react");
65
+ var contexts_1 = require("../contexts");
66
+ var types_1 = require("../types");
67
+ var useSavedSearchesRequest = function (_a) {
68
+ var options = _a.options, offset = _a.offset, max = _a.max, queryEstimatorEnabled = _a.queryEstimatorEnabled;
69
+ var _b = (0, react_1.useState)([]), data = _b[0], setData = _b[1];
70
+ var _c = (0, react_1.useState)(0), total = _c[0], setTotal = _c[1];
71
+ var _d = (0, react_1.useState)(types_1.RequestStates.INIT), requestState = _d[0], setRequestState = _d[1];
72
+ var onError = function (error) {
73
+ console.warn(error); // eslint-disable-line
74
+ if (!(0, mdm_sdk_1.isAbortError)(error)) {
75
+ setRequestState(types_1.RequestStates.ERROR);
76
+ setData([]);
77
+ }
78
+ };
79
+ var signal = (0, react_1.useContext)(contexts_1.PageRequestsAbortingContext);
80
+ var loadData = (0, react_1.useCallback)(function () {
81
+ setRequestState(types_1.RequestStates.LOADING);
82
+ var onRequestFinished = function (data) {
83
+ setData(data.result || []);
84
+ setTotal(data.total);
85
+ setRequestState(types_1.RequestStates.LOADED);
86
+ };
87
+ var _a = (options || {}), countResults = _a.countResults, restOptions = __rest(_a, ["countResults"]);
88
+ var getData = function () { return __awaiter(void 0, void 0, void 0, function () {
89
+ var _a, _b, savedSearches, total, totalRequests, totalResults, searchesWithCount;
90
+ return __generator(this, function (_c) {
91
+ switch (_c.label) {
92
+ case 0: return [4 /*yield*/, (0, mdm_sdk_1.getSavedSearches)(__assign({ offset: offset, max: max }, restOptions), signal)];
93
+ case 1:
94
+ _a = _c.sent(), _b = _a.result, savedSearches = _b === void 0 ? [] : _b, total = _a.total;
95
+ if (!countResults) return [3 /*break*/, 3];
96
+ totalRequests = savedSearches.map(function (search) {
97
+ return (0, mdm_sdk_1.getTotalsForQuery)((0, mdm_sdk_1.replacePlaceholdersInQuery)(search.query), queryEstimatorEnabled, signal);
98
+ });
99
+ return [4 /*yield*/, (0, mdm_sdk_1.promiseAllSettled)(totalRequests)];
100
+ case 2:
101
+ totalResults = _c.sent();
102
+ searchesWithCount = totalResults.reduce(function (searchesWithTotal, _a, searchIndex) {
103
+ var status = _a.status, value = _a.value, reason = _a.reason;
104
+ switch (status) {
105
+ case 'fulfilled':
106
+ return (0, ramda_1.assocPath)([searchIndex, 'count'], value.total, searchesWithTotal);
107
+ case 'rejected':
108
+ console.warn(reason);
109
+ break;
110
+ }
111
+ return searchesWithTotal;
112
+ }, savedSearches);
113
+ onRequestFinished({ result: searchesWithCount, total: total });
114
+ return [3 /*break*/, 4];
115
+ case 3:
116
+ onRequestFinished({ result: savedSearches, total: total });
117
+ _c.label = 4;
118
+ case 4: return [2 /*return*/];
119
+ }
120
+ });
121
+ }); };
122
+ getData().catch(onError);
123
+ }, [options, offset, max, signal, queryEstimatorEnabled]);
124
+ var refreshAction = function () {
125
+ try {
126
+ loadData();
127
+ }
128
+ catch (e) {
129
+ onError(e);
130
+ }
131
+ };
132
+ var loadTotalForUri = (0, react_1.useCallback)(function (uri) { return __awaiter(void 0, void 0, void 0, function () {
133
+ var searchIndex, search, total_1, e_1;
134
+ return __generator(this, function (_a) {
135
+ switch (_a.label) {
136
+ case 0:
137
+ searchIndex = data.findIndex((0, ramda_1.propEq)('uri', uri));
138
+ search = data[searchIndex];
139
+ setData((0, ramda_1.assocPath)([searchIndex, 'isLoadingTotal'], true));
140
+ _a.label = 1;
141
+ case 1:
142
+ _a.trys.push([1, 3, , 4]);
143
+ return [4 /*yield*/, (0, mdm_sdk_1.getTotalsForQuery)((0, mdm_sdk_1.replacePlaceholdersInQuery)(search.query), false, signal)];
144
+ case 2:
145
+ total_1 = (_a.sent()).total;
146
+ setData((0, ramda_1.assocPath)([searchIndex, 'count'], total_1));
147
+ return [3 /*break*/, 4];
148
+ case 3:
149
+ e_1 = _a.sent();
150
+ console.warn(e_1);
151
+ return [3 /*break*/, 4];
152
+ case 4:
153
+ setData((0, ramda_1.assocPath)([searchIndex, 'isLoadingTotal'], false));
154
+ return [2 /*return*/];
155
+ }
156
+ });
157
+ }); }, [data, signal]);
158
+ var saveSearch = (0, react_1.useCallback)(function (savedSearch) {
159
+ var type = (options || {}).type;
160
+ return (0, mdm_sdk_1.createSavedSearch)([__assign(__assign({}, savedSearch), { type: type })]);
161
+ }, [options]);
162
+ var updateSearch = (0, react_1.useCallback)(function (savedSearch) {
163
+ return (0, mdm_sdk_1.updateSavedSearch)(savedSearch);
164
+ }, []);
165
+ var deleteSearch = (0, react_1.useCallback)(function (savedSearch) {
166
+ return (0, mdm_sdk_1.deleteSavedSearch)(savedSearch);
167
+ }, []);
168
+ (0, react_1.useEffect)(function () {
169
+ refreshAction();
170
+ }, [loadData]);
171
+ return {
172
+ state: requestState,
173
+ data: data,
174
+ reload: refreshAction,
175
+ total: total,
176
+ loadTotalForSearchByUri: loadTotalForUri,
177
+ saveSearch: saveSearch,
178
+ updateSearch: updateSearch,
179
+ deleteSearch: deleteSearch
180
+ };
181
+ };
182
+ exports.useSavedSearchesRequest = useSavedSearchesRequest;
@@ -29,3 +29,4 @@ export { useLayoutResetter } from './useLayoutResetter';
29
29
  export { useExpandInvalidRelations } from './useExpandInvalidRelations';
30
30
  export { useAutoFocus } from './useAutoFocus';
31
31
  export { useRequestDCRReview } from './useRequestDCRReview';
32
+ export { useSavedSearchesRequest } from './useSavedSearchesRequest';
@@ -29,3 +29,4 @@ export { useLayoutResetter } from './useLayoutResetter';
29
29
  export { useExpandInvalidRelations } from './useExpandInvalidRelations';
30
30
  export { useAutoFocus } from './useAutoFocus';
31
31
  export { useRequestDCRReview } from './useRequestDCRReview';
32
+ export { useSavedSearchesRequest } from './useSavedSearchesRequest';
@@ -0,0 +1,28 @@
1
+ import { SavedSearchData, SavedSearchesOptions, deleteSavedSearch, updateSavedSearch } from '@reltio/mdm-sdk';
2
+ import { RequestStates } from '../types';
3
+ type Props = {
4
+ options?: SavedSearchesOptions;
5
+ offset: number;
6
+ max: number;
7
+ queryEstimatorEnabled?: boolean;
8
+ };
9
+ export declare const useSavedSearchesRequest: ({ options, offset, max, queryEstimatorEnabled }: Props) => {
10
+ state: RequestStates;
11
+ data: SavedSearchData[];
12
+ reload: () => void;
13
+ total: number;
14
+ loadTotalForSearchByUri: (uri: string) => Promise<void>;
15
+ saveSearch: (savedSearch: Partial<SavedSearchData> & {
16
+ name: string;
17
+ query: string;
18
+ uiState: Record<string, any>;
19
+ }) => Promise<SavedSearchData>;
20
+ updateSearch: (savedSearch: Parameters<typeof updateSavedSearch>[0]) => Promise<SavedSearchData>;
21
+ deleteSearch: (savedSearch: Parameters<typeof deleteSavedSearch>[0]) => Promise<{
22
+ success: true;
23
+ } | {
24
+ success: false;
25
+ error: unknown;
26
+ }>;
27
+ };
28
+ export {};
@@ -0,0 +1,178 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ 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;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __rest = (this && this.__rest) || function (s, e) {
49
+ var t = {};
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
+ t[p] = s[p];
52
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
+ t[p[i]] = s[p[i]];
56
+ }
57
+ return t;
58
+ };
59
+ import { createSavedSearch, deleteSavedSearch, getSavedSearches, getTotalsForQuery, isAbortError, promiseAllSettled, replacePlaceholdersInQuery, updateSavedSearch } from '@reltio/mdm-sdk';
60
+ import { assocPath, propEq } from 'ramda';
61
+ import { useCallback, useContext, useEffect, useState } from 'react';
62
+ import { PageRequestsAbortingContext } from '../contexts';
63
+ import { RequestStates } from '../types';
64
+ export var useSavedSearchesRequest = function (_a) {
65
+ var options = _a.options, offset = _a.offset, max = _a.max, queryEstimatorEnabled = _a.queryEstimatorEnabled;
66
+ var _b = useState([]), data = _b[0], setData = _b[1];
67
+ var _c = useState(0), total = _c[0], setTotal = _c[1];
68
+ var _d = useState(RequestStates.INIT), requestState = _d[0], setRequestState = _d[1];
69
+ var onError = function (error) {
70
+ console.warn(error); // eslint-disable-line
71
+ if (!isAbortError(error)) {
72
+ setRequestState(RequestStates.ERROR);
73
+ setData([]);
74
+ }
75
+ };
76
+ var signal = useContext(PageRequestsAbortingContext);
77
+ var loadData = useCallback(function () {
78
+ setRequestState(RequestStates.LOADING);
79
+ var onRequestFinished = function (data) {
80
+ setData(data.result || []);
81
+ setTotal(data.total);
82
+ setRequestState(RequestStates.LOADED);
83
+ };
84
+ var _a = (options || {}), countResults = _a.countResults, restOptions = __rest(_a, ["countResults"]);
85
+ var getData = function () { return __awaiter(void 0, void 0, void 0, function () {
86
+ var _a, _b, savedSearches, total, totalRequests, totalResults, searchesWithCount;
87
+ return __generator(this, function (_c) {
88
+ switch (_c.label) {
89
+ case 0: return [4 /*yield*/, getSavedSearches(__assign({ offset: offset, max: max }, restOptions), signal)];
90
+ case 1:
91
+ _a = _c.sent(), _b = _a.result, savedSearches = _b === void 0 ? [] : _b, total = _a.total;
92
+ if (!countResults) return [3 /*break*/, 3];
93
+ totalRequests = savedSearches.map(function (search) {
94
+ return getTotalsForQuery(replacePlaceholdersInQuery(search.query), queryEstimatorEnabled, signal);
95
+ });
96
+ return [4 /*yield*/, promiseAllSettled(totalRequests)];
97
+ case 2:
98
+ totalResults = _c.sent();
99
+ searchesWithCount = totalResults.reduce(function (searchesWithTotal, _a, searchIndex) {
100
+ var status = _a.status, value = _a.value, reason = _a.reason;
101
+ switch (status) {
102
+ case 'fulfilled':
103
+ return assocPath([searchIndex, 'count'], value.total, searchesWithTotal);
104
+ case 'rejected':
105
+ console.warn(reason);
106
+ break;
107
+ }
108
+ return searchesWithTotal;
109
+ }, savedSearches);
110
+ onRequestFinished({ result: searchesWithCount, total: total });
111
+ return [3 /*break*/, 4];
112
+ case 3:
113
+ onRequestFinished({ result: savedSearches, total: total });
114
+ _c.label = 4;
115
+ case 4: return [2 /*return*/];
116
+ }
117
+ });
118
+ }); };
119
+ getData().catch(onError);
120
+ }, [options, offset, max, signal, queryEstimatorEnabled]);
121
+ var refreshAction = function () {
122
+ try {
123
+ loadData();
124
+ }
125
+ catch (e) {
126
+ onError(e);
127
+ }
128
+ };
129
+ var loadTotalForUri = useCallback(function (uri) { return __awaiter(void 0, void 0, void 0, function () {
130
+ var searchIndex, search, total_1, e_1;
131
+ return __generator(this, function (_a) {
132
+ switch (_a.label) {
133
+ case 0:
134
+ searchIndex = data.findIndex(propEq('uri', uri));
135
+ search = data[searchIndex];
136
+ setData(assocPath([searchIndex, 'isLoadingTotal'], true));
137
+ _a.label = 1;
138
+ case 1:
139
+ _a.trys.push([1, 3, , 4]);
140
+ return [4 /*yield*/, getTotalsForQuery(replacePlaceholdersInQuery(search.query), false, signal)];
141
+ case 2:
142
+ total_1 = (_a.sent()).total;
143
+ setData(assocPath([searchIndex, 'count'], total_1));
144
+ return [3 /*break*/, 4];
145
+ case 3:
146
+ e_1 = _a.sent();
147
+ console.warn(e_1);
148
+ return [3 /*break*/, 4];
149
+ case 4:
150
+ setData(assocPath([searchIndex, 'isLoadingTotal'], false));
151
+ return [2 /*return*/];
152
+ }
153
+ });
154
+ }); }, [data, signal]);
155
+ var saveSearch = useCallback(function (savedSearch) {
156
+ var type = (options || {}).type;
157
+ return createSavedSearch([__assign(__assign({}, savedSearch), { type: type })]);
158
+ }, [options]);
159
+ var updateSearch = useCallback(function (savedSearch) {
160
+ return updateSavedSearch(savedSearch);
161
+ }, []);
162
+ var deleteSearch = useCallback(function (savedSearch) {
163
+ return deleteSavedSearch(savedSearch);
164
+ }, []);
165
+ useEffect(function () {
166
+ refreshAction();
167
+ }, [loadData]);
168
+ return {
169
+ state: requestState,
170
+ data: data,
171
+ reload: refreshAction,
172
+ total: total,
173
+ loadTotalForSearchByUri: loadTotalForUri,
174
+ saveSearch: saveSearch,
175
+ updateSearch: updateSearch,
176
+ deleteSearch: deleteSearch
177
+ };
178
+ };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1829",
3
+ "version": "1.4.1830",
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
  "@fluentui/react-context-selector": "^9.1.26",
9
9
  "@react-google-maps/api": "2.7.0",
10
- "@reltio/mdm-sdk": "^1.4.1788",
10
+ "@reltio/mdm-sdk": "^1.4.1789",
11
11
  "classnames": "^2.2.5",
12
12
  "d3-cloud": "^1.2.5",
13
13
  "d3-geo": "^2.0.1",