@reltio/components 1.4.2022 → 1.4.2024

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.
@@ -48,8 +48,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  import React from 'react';
49
49
  import { screen, render, within, fireEvent, act } from '@testing-library/react';
50
50
  import userEvent from '@testing-library/user-event';
51
- import { mockDndKit } from '../test-utils/dndKit';
52
- jest.mock('@dnd-kit/core', function () { return mockDndKit; });
53
51
  import { BasicTable } from './BasicTable';
54
52
  import { CollapseRowButton } from '../CollapseRowButton';
55
53
  import { mockBasicTableSizing } from '../test-utils';
@@ -74,15 +72,22 @@ var getRowCellRenderer = function (id) {
74
72
  return function () { return null; };
75
73
  }
76
74
  };
75
+ var onHeadClickFn = jest.fn();
76
+ var HeadCellRenderer = function (_a) {
77
+ var headCellData = _a.headCellData;
78
+ return (React.createElement("div", null,
79
+ React.createElement("button", { onClick: onHeadClickFn }, headCellData.label)));
80
+ };
77
81
  var columnsData = [
78
82
  {
79
83
  autoResize: false,
80
- headCellRenderer: function () { return 'first column'; },
84
+ headCellRenderer: HeadCellRenderer,
81
85
  id: 'id1',
82
86
  initialWidth: 300,
83
87
  label: 'column 1',
84
88
  minWidth: 250,
85
89
  resizable: true,
90
+ draggable: true,
86
91
  rowCellValueRenderer: getRowCellRenderer('id1'),
87
92
  sortable: false
88
93
  },
@@ -108,6 +113,8 @@ var defaultProps = {
108
113
  headRowHeight: 48,
109
114
  defaultColumnWidth: 250,
110
115
  defaultColumnMinWidth: 200,
116
+ dndColumnReorderingEnabled: true,
117
+ dndColumnReorderingHandler: function () { },
111
118
  dndRowReorderingEnabled: true,
112
119
  dndRowReorderingHandler: function () { },
113
120
  getIdFromRowValue: function (rowValue) { return rowValue.id1.name; },
@@ -121,10 +128,14 @@ var setUp = function (props) {
121
128
  };
122
129
  describe('basic table tests', function () {
123
130
  it('should collapse all rows after start dragging', function () { return __awaiter(void 0, void 0, void 0, function () {
124
- var unmockTableSizing, user, getRowByIndex, getCellByIndexes, dragIndicator;
131
+ var mouse, unmockTableSizing, user, getRowByIndex, getCellByIndexes, dragIndicator;
125
132
  return __generator(this, function (_a) {
126
133
  switch (_a.label) {
127
134
  case 0:
135
+ mouse = [
136
+ { clientX: 0, clientY: 0 },
137
+ { clientX: 20, clientY: 20 }
138
+ ];
128
139
  unmockTableSizing = mockBasicTableSizing();
129
140
  user = setUp(defaultProps).user;
130
141
  getRowByIndex = function (index) {
@@ -146,10 +157,11 @@ describe('basic table tests', function () {
146
157
  expect(within(getCellByIndexes(0, 1)).queryByText('row 1 value 3')).toBeInTheDocument();
147
158
  expect(within(getCellByIndexes(1, 1)).queryByText('row 2 value 1')).toBeInTheDocument();
148
159
  expect(within(getCellByIndexes(1, 1)).queryByText('row 2 value 2')).toBeInTheDocument();
149
- dragIndicator = within(getCellByIndexes(1, 0)).queryByText('drag el');
160
+ dragIndicator = within(getCellByIndexes(1, 0)).getByRole('button', { name: 'drag el' });
150
161
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
151
162
  return __generator(this, function (_a) {
152
- fireEvent.mouseDown(dragIndicator);
163
+ fireEvent.mouseDown(dragIndicator, mouse[0]);
164
+ fireEvent.mouseMove(dragIndicator, mouse[1]);
153
165
  return [2 /*return*/];
154
166
  });
155
167
  }); })];
@@ -160,9 +172,32 @@ describe('basic table tests', function () {
160
172
  expect(within(getCellByIndexes(0, 1)).queryByText('row 1 value 3')).not.toBeInTheDocument();
161
173
  expect(within(getCellByIndexes(1, 1)).queryByText('row 2 value 1')).toBeInTheDocument();
162
174
  expect(within(getCellByIndexes(1, 1)).queryByText('row 2 value 2')).not.toBeInTheDocument();
175
+ return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
176
+ return __generator(this, function (_a) {
177
+ fireEvent.mouseUp(dragIndicator);
178
+ return [2 /*return*/];
179
+ });
180
+ }); })];
181
+ case 4:
182
+ _a.sent();
163
183
  unmockTableSizing();
164
184
  return [2 /*return*/];
165
185
  }
166
186
  });
167
187
  }); });
188
+ it('should able to click on buttons in table head', function () { return __awaiter(void 0, void 0, void 0, function () {
189
+ var user;
190
+ return __generator(this, function (_a) {
191
+ switch (_a.label) {
192
+ case 0:
193
+ user = setUp(defaultProps).user;
194
+ expect(onHeadClickFn).not.toHaveBeenCalled();
195
+ return [4 /*yield*/, user.click(screen.getAllByRole('button', { name: columnsData[0].label })[1])];
196
+ case 1:
197
+ _a.sent();
198
+ expect(onHeadClickFn).toHaveBeenCalled();
199
+ return [2 /*return*/];
200
+ }
201
+ });
202
+ }); });
168
203
  });
@@ -53,8 +53,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
53
  var react_1 = __importDefault(require("react"));
54
54
  var react_2 = require("@testing-library/react");
55
55
  var user_event_1 = __importDefault(require("@testing-library/user-event"));
56
- var dndKit_1 = require("../test-utils/dndKit");
57
- jest.mock('@dnd-kit/core', function () { return dndKit_1.mockDndKit; });
58
56
  var BasicTable_1 = require("./BasicTable");
59
57
  var CollapseRowButton_1 = require("../CollapseRowButton");
60
58
  var test_utils_1 = require("../test-utils");
@@ -79,15 +77,22 @@ var getRowCellRenderer = function (id) {
79
77
  return function () { return null; };
80
78
  }
81
79
  };
80
+ var onHeadClickFn = jest.fn();
81
+ var HeadCellRenderer = function (_a) {
82
+ var headCellData = _a.headCellData;
83
+ return (react_1.default.createElement("div", null,
84
+ react_1.default.createElement("button", { onClick: onHeadClickFn }, headCellData.label)));
85
+ };
82
86
  var columnsData = [
83
87
  {
84
88
  autoResize: false,
85
- headCellRenderer: function () { return 'first column'; },
89
+ headCellRenderer: HeadCellRenderer,
86
90
  id: 'id1',
87
91
  initialWidth: 300,
88
92
  label: 'column 1',
89
93
  minWidth: 250,
90
94
  resizable: true,
95
+ draggable: true,
91
96
  rowCellValueRenderer: getRowCellRenderer('id1'),
92
97
  sortable: false
93
98
  },
@@ -113,6 +118,8 @@ var defaultProps = {
113
118
  headRowHeight: 48,
114
119
  defaultColumnWidth: 250,
115
120
  defaultColumnMinWidth: 200,
121
+ dndColumnReorderingEnabled: true,
122
+ dndColumnReorderingHandler: function () { },
116
123
  dndRowReorderingEnabled: true,
117
124
  dndRowReorderingHandler: function () { },
118
125
  getIdFromRowValue: function (rowValue) { return rowValue.id1.name; },
@@ -126,10 +133,14 @@ var setUp = function (props) {
126
133
  };
127
134
  describe('basic table tests', function () {
128
135
  it('should collapse all rows after start dragging', function () { return __awaiter(void 0, void 0, void 0, function () {
129
- var unmockTableSizing, user, getRowByIndex, getCellByIndexes, dragIndicator;
136
+ var mouse, unmockTableSizing, user, getRowByIndex, getCellByIndexes, dragIndicator;
130
137
  return __generator(this, function (_a) {
131
138
  switch (_a.label) {
132
139
  case 0:
140
+ mouse = [
141
+ { clientX: 0, clientY: 0 },
142
+ { clientX: 20, clientY: 20 }
143
+ ];
133
144
  unmockTableSizing = (0, test_utils_1.mockBasicTableSizing)();
134
145
  user = setUp(defaultProps).user;
135
146
  getRowByIndex = function (index) {
@@ -151,10 +162,11 @@ describe('basic table tests', function () {
151
162
  expect((0, react_2.within)(getCellByIndexes(0, 1)).queryByText('row 1 value 3')).toBeInTheDocument();
152
163
  expect((0, react_2.within)(getCellByIndexes(1, 1)).queryByText('row 2 value 1')).toBeInTheDocument();
153
164
  expect((0, react_2.within)(getCellByIndexes(1, 1)).queryByText('row 2 value 2')).toBeInTheDocument();
154
- dragIndicator = (0, react_2.within)(getCellByIndexes(1, 0)).queryByText('drag el');
165
+ dragIndicator = (0, react_2.within)(getCellByIndexes(1, 0)).getByRole('button', { name: 'drag el' });
155
166
  return [4 /*yield*/, (0, react_2.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
156
167
  return __generator(this, function (_a) {
157
- react_2.fireEvent.mouseDown(dragIndicator);
168
+ react_2.fireEvent.mouseDown(dragIndicator, mouse[0]);
169
+ react_2.fireEvent.mouseMove(dragIndicator, mouse[1]);
158
170
  return [2 /*return*/];
159
171
  });
160
172
  }); })];
@@ -165,9 +177,32 @@ describe('basic table tests', function () {
165
177
  expect((0, react_2.within)(getCellByIndexes(0, 1)).queryByText('row 1 value 3')).not.toBeInTheDocument();
166
178
  expect((0, react_2.within)(getCellByIndexes(1, 1)).queryByText('row 2 value 1')).toBeInTheDocument();
167
179
  expect((0, react_2.within)(getCellByIndexes(1, 1)).queryByText('row 2 value 2')).not.toBeInTheDocument();
180
+ return [4 /*yield*/, (0, react_2.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
181
+ return __generator(this, function (_a) {
182
+ react_2.fireEvent.mouseUp(dragIndicator);
183
+ return [2 /*return*/];
184
+ });
185
+ }); })];
186
+ case 4:
187
+ _a.sent();
168
188
  unmockTableSizing();
169
189
  return [2 /*return*/];
170
190
  }
171
191
  });
172
192
  }); });
193
+ it('should able to click on buttons in table head', function () { return __awaiter(void 0, void 0, void 0, function () {
194
+ var user;
195
+ return __generator(this, function (_a) {
196
+ switch (_a.label) {
197
+ case 0:
198
+ user = setUp(defaultProps).user;
199
+ expect(onHeadClickFn).not.toHaveBeenCalled();
200
+ return [4 /*yield*/, user.click(react_2.screen.getAllByRole('button', { name: columnsData[0].label })[1])];
201
+ case 1:
202
+ _a.sent();
203
+ expect(onHeadClickFn).toHaveBeenCalled();
204
+ return [2 /*return*/];
205
+ }
206
+ });
207
+ }); });
173
208
  });
@@ -85,28 +85,112 @@ exports.MaskedAttributesContext = (0, react_context_selector_1.createContext)({
85
85
  var MaskedAttributesProvider = function (_a) {
86
86
  var children = _a.children;
87
87
  var _b = (0, react_1.useState)({}), unmaskedAttributes = _b[0], setUnmaskedAttributes = _b[1];
88
+ var _c = (0, react_1.useState)({}), unmaskedEntities = _c[0], setUnmaskedEntities = _c[1];
89
+ var _d = (0, react_1.useState)(null), unmaskedCurrentEntity = _d[0], setUnmaskedCurrentEntity = _d[1];
88
90
  var profileLastLoadedTime = (0, MdmModuleContext_1.useMdmProfileLastLoadedTime)();
91
+ var historyMode = (0, MdmModuleContext_1.useMdmHistoryMode)();
92
+ var entityUri = (0, MdmModuleContext_1.useMdmEntityUri)();
93
+ var historyEvent = (0, MdmModuleContext_1.useMdmHistoryEvent)();
89
94
  var unmaskedAttributesRef = (0, react_1.useRef)(unmaskedAttributes);
90
95
  //performance optimization to avoid unnecessary re-renders
91
96
  unmaskedAttributesRef.current = unmaskedAttributes;
92
97
  (0, react_1.useEffect)(function () {
93
98
  setUnmaskedAttributes({});
94
- }, [profileLastLoadedTime]);
99
+ }, [profileLastLoadedTime, historyEvent]);
100
+ (0, react_1.useEffect)(function () {
101
+ setUnmaskedEntities({});
102
+ setUnmaskedCurrentEntity(null);
103
+ }, [entityUri]);
104
+ var getUnmaskedEntity = (0, react_1.useCallback)(function (timestamp) { return __awaiter(void 0, void 0, void 0, function () {
105
+ var unmaskedEntity_1, _a, unmaskedEntity, _b;
106
+ var _c;
107
+ return __generator(this, function (_d) {
108
+ switch (_d.label) {
109
+ case 0:
110
+ if (!!timestamp) return [3 /*break*/, 4];
111
+ if (!(unmaskedCurrentEntity !== null && unmaskedCurrentEntity !== void 0)) return [3 /*break*/, 1];
112
+ _a = unmaskedCurrentEntity;
113
+ return [3 /*break*/, 3];
114
+ case 1: return [4 /*yield*/, (0, mdm_sdk_1.getEntity)(entityUri)];
115
+ case 2:
116
+ _a = (_d.sent());
117
+ _d.label = 3;
118
+ case 3:
119
+ unmaskedEntity_1 = _a;
120
+ if (!unmaskedCurrentEntity) {
121
+ setUnmaskedCurrentEntity(unmaskedEntity_1);
122
+ }
123
+ return [2 /*return*/, unmaskedEntity_1];
124
+ case 4:
125
+ if (!((_c = unmaskedEntities[timestamp]) !== null && _c !== void 0)) return [3 /*break*/, 5];
126
+ _b = _c;
127
+ return [3 /*break*/, 7];
128
+ case 5: return [4 /*yield*/, (0, mdm_sdk_1.getEntityTimeSlice)(entityUri, timestamp)];
129
+ case 6:
130
+ _b = (_d.sent());
131
+ _d.label = 7;
132
+ case 7:
133
+ unmaskedEntity = _b;
134
+ if (!unmaskedEntities[timestamp]) {
135
+ setUnmaskedEntities(function (prev) {
136
+ var _a;
137
+ return (__assign(__assign({}, prev), (_a = {}, _a[timestamp] = unmaskedEntity, _a)));
138
+ });
139
+ }
140
+ return [2 /*return*/, unmaskedEntity];
141
+ }
142
+ });
143
+ }); }, [entityUri, unmaskedEntities, unmaskedCurrentEntity]);
144
+ var unmaskAttributeValueFromEntity = (0, react_1.useCallback)(function (attributeValueUri) { return __awaiter(void 0, void 0, void 0, function () {
145
+ var unmaskedEntity, attributeValue, _a;
146
+ return __generator(this, function (_b) {
147
+ switch (_b.label) {
148
+ case 0: return [4 /*yield*/, getUnmaskedEntity(historyEvent === null || historyEvent === void 0 ? void 0 : historyEvent.aStamp)];
149
+ case 1:
150
+ unmaskedEntity = _b.sent();
151
+ attributeValue = (0, mdm_sdk_1.findAttributeValueByUri)(unmaskedEntity, attributeValueUri);
152
+ if (attributeValue) {
153
+ return [2 /*return*/, attributeValue];
154
+ }
155
+ if (!(historyMode === mdm_sdk_1.HistoryMode.Current)) return [3 /*break*/, 3];
156
+ return [4 /*yield*/, getUnmaskedEntity()];
157
+ case 2:
158
+ _a = _b.sent();
159
+ return [3 /*break*/, 5];
160
+ case 3: return [4 /*yield*/, getUnmaskedEntity(historyEvent === null || historyEvent === void 0 ? void 0 : historyEvent.bStamp)];
161
+ case 4:
162
+ _a = _b.sent();
163
+ _b.label = 5;
164
+ case 5:
165
+ unmaskedEntity = _a;
166
+ attributeValue = (0, mdm_sdk_1.findAttributeValueByUri)(unmaskedEntity, attributeValueUri);
167
+ return [2 /*return*/, attributeValue];
168
+ }
169
+ });
170
+ }); }, [getUnmaskedEntity, historyEvent === null || historyEvent === void 0 ? void 0 : historyEvent.aStamp, historyEvent === null || historyEvent === void 0 ? void 0 : historyEvent.bStamp, historyMode]);
95
171
  var unmaskAttributeValue = (0, react_1.useCallback)(function (attributeValueUri) { return __awaiter(void 0, void 0, void 0, function () {
96
- var unmaskedAttributes_1, unmaskedAttributeValue_1, error_1;
97
- return __generator(this, function (_a) {
98
- switch (_a.label) {
172
+ var unmaskedAttributes_1, unmaskedAttributeValue_1, _a, error_1;
173
+ return __generator(this, function (_b) {
174
+ switch (_b.label) {
99
175
  case 0:
100
- _a.trys.push([0, 4, , 5]);
176
+ _b.trys.push([0, 7, , 8]);
101
177
  unmaskedAttributes_1 = unmaskedAttributesRef.current;
102
- if (!!unmaskedAttributes_1[attributeValueUri]) return [3 /*break*/, 2];
178
+ if (!!unmaskedAttributes_1[attributeValueUri]) return [3 /*break*/, 5];
103
179
  setUnmaskedAttributes(function (prev) {
104
180
  var _a;
105
181
  return (__assign(__assign({}, prev), (_a = {}, _a[attributeValueUri] = __assign(__assign({}, prev[attributeValueUri]), { loading: true }), _a)));
106
182
  });
107
- return [4 /*yield*/, (0, mdm_sdk_1.getUnmaskedAttributeValue)(attributeValueUri)];
183
+ if (!historyEvent) return [3 /*break*/, 2];
184
+ return [4 /*yield*/, unmaskAttributeValueFromEntity(attributeValueUri)];
108
185
  case 1:
109
- unmaskedAttributeValue_1 = _a.sent();
186
+ _a = _b.sent();
187
+ return [3 /*break*/, 4];
188
+ case 2: return [4 /*yield*/, (0, mdm_sdk_1.getUnmaskedAttributeValue)(attributeValueUri)];
189
+ case 3:
190
+ _a = _b.sent();
191
+ _b.label = 4;
192
+ case 4:
193
+ unmaskedAttributeValue_1 = _a;
110
194
  setUnmaskedAttributes(function (prev) {
111
195
  var _a;
112
196
  return (__assign(__assign({}, prev), (_a = {}, _a[attributeValueUri] = {
@@ -116,21 +200,21 @@ var MaskedAttributesProvider = function (_a) {
116
200
  }, _a)));
117
201
  });
118
202
  return [2 /*return*/, unmaskedAttributeValue_1];
119
- case 2:
203
+ case 5:
120
204
  setUnmaskedAttributes(function (prev) {
121
205
  var _a;
122
206
  return (__assign(__assign({}, prev), (_a = {}, _a[attributeValueUri] = __assign(__assign({}, prev[attributeValueUri]), { isUnmasked: true }), _a)));
123
207
  });
124
208
  return [2 /*return*/, unmaskedAttributes_1[attributeValueUri].attributeValue];
125
- case 3: return [3 /*break*/, 5];
126
- case 4:
127
- error_1 = _a.sent();
209
+ case 6: return [3 /*break*/, 8];
210
+ case 7:
211
+ error_1 = _b.sent();
128
212
  (0, errors_1.showErrorMessage)(error_1);
129
213
  return [2 /*return*/, null];
130
- case 5: return [2 /*return*/];
214
+ case 8: return [2 /*return*/];
131
215
  }
132
216
  });
133
- }); }, []);
217
+ }); }, [historyEvent, unmaskAttributeValueFromEntity]);
134
218
  var maskAttributeValue = (0, react_1.useCallback)(function (attributeValueUri) {
135
219
  setUnmaskedAttributes(function (prev) {
136
220
  var _a;
@@ -47,9 +47,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  import React, { useState, useCallback, useEffect, useRef } from 'react';
49
49
  import { createContext } from '@fluentui/react-context-selector';
50
- import { getUnmaskedAttributeValue } from '@reltio/mdm-sdk';
50
+ import { HistoryMode, findAttributeValueByUri, getEntity, getEntityTimeSlice, getUnmaskedAttributeValue } from '@reltio/mdm-sdk';
51
51
  import { showErrorMessage } from '../../helpers/errors';
52
- import { useMdmProfileLastLoadedTime } from '../MdmModuleContext';
52
+ import { useMdmEntityUri, useMdmHistoryEvent, useMdmHistoryMode, useMdmProfileLastLoadedTime } from '../MdmModuleContext';
53
53
  export var MaskedAttributesContext = createContext({
54
54
  unmaskedAttributes: {},
55
55
  unmaskAttributeValue: undefined,
@@ -59,28 +59,112 @@ export var MaskedAttributesContext = createContext({
59
59
  export var MaskedAttributesProvider = function (_a) {
60
60
  var children = _a.children;
61
61
  var _b = useState({}), unmaskedAttributes = _b[0], setUnmaskedAttributes = _b[1];
62
+ var _c = useState({}), unmaskedEntities = _c[0], setUnmaskedEntities = _c[1];
63
+ var _d = useState(null), unmaskedCurrentEntity = _d[0], setUnmaskedCurrentEntity = _d[1];
62
64
  var profileLastLoadedTime = useMdmProfileLastLoadedTime();
65
+ var historyMode = useMdmHistoryMode();
66
+ var entityUri = useMdmEntityUri();
67
+ var historyEvent = useMdmHistoryEvent();
63
68
  var unmaskedAttributesRef = useRef(unmaskedAttributes);
64
69
  //performance optimization to avoid unnecessary re-renders
65
70
  unmaskedAttributesRef.current = unmaskedAttributes;
66
71
  useEffect(function () {
67
72
  setUnmaskedAttributes({});
68
- }, [profileLastLoadedTime]);
73
+ }, [profileLastLoadedTime, historyEvent]);
74
+ useEffect(function () {
75
+ setUnmaskedEntities({});
76
+ setUnmaskedCurrentEntity(null);
77
+ }, [entityUri]);
78
+ var getUnmaskedEntity = useCallback(function (timestamp) { return __awaiter(void 0, void 0, void 0, function () {
79
+ var unmaskedEntity_1, _a, unmaskedEntity, _b;
80
+ var _c;
81
+ return __generator(this, function (_d) {
82
+ switch (_d.label) {
83
+ case 0:
84
+ if (!!timestamp) return [3 /*break*/, 4];
85
+ if (!(unmaskedCurrentEntity !== null && unmaskedCurrentEntity !== void 0)) return [3 /*break*/, 1];
86
+ _a = unmaskedCurrentEntity;
87
+ return [3 /*break*/, 3];
88
+ case 1: return [4 /*yield*/, getEntity(entityUri)];
89
+ case 2:
90
+ _a = (_d.sent());
91
+ _d.label = 3;
92
+ case 3:
93
+ unmaskedEntity_1 = _a;
94
+ if (!unmaskedCurrentEntity) {
95
+ setUnmaskedCurrentEntity(unmaskedEntity_1);
96
+ }
97
+ return [2 /*return*/, unmaskedEntity_1];
98
+ case 4:
99
+ if (!((_c = unmaskedEntities[timestamp]) !== null && _c !== void 0)) return [3 /*break*/, 5];
100
+ _b = _c;
101
+ return [3 /*break*/, 7];
102
+ case 5: return [4 /*yield*/, getEntityTimeSlice(entityUri, timestamp)];
103
+ case 6:
104
+ _b = (_d.sent());
105
+ _d.label = 7;
106
+ case 7:
107
+ unmaskedEntity = _b;
108
+ if (!unmaskedEntities[timestamp]) {
109
+ setUnmaskedEntities(function (prev) {
110
+ var _a;
111
+ return (__assign(__assign({}, prev), (_a = {}, _a[timestamp] = unmaskedEntity, _a)));
112
+ });
113
+ }
114
+ return [2 /*return*/, unmaskedEntity];
115
+ }
116
+ });
117
+ }); }, [entityUri, unmaskedEntities, unmaskedCurrentEntity]);
118
+ var unmaskAttributeValueFromEntity = useCallback(function (attributeValueUri) { return __awaiter(void 0, void 0, void 0, function () {
119
+ var unmaskedEntity, attributeValue, _a;
120
+ return __generator(this, function (_b) {
121
+ switch (_b.label) {
122
+ case 0: return [4 /*yield*/, getUnmaskedEntity(historyEvent === null || historyEvent === void 0 ? void 0 : historyEvent.aStamp)];
123
+ case 1:
124
+ unmaskedEntity = _b.sent();
125
+ attributeValue = findAttributeValueByUri(unmaskedEntity, attributeValueUri);
126
+ if (attributeValue) {
127
+ return [2 /*return*/, attributeValue];
128
+ }
129
+ if (!(historyMode === HistoryMode.Current)) return [3 /*break*/, 3];
130
+ return [4 /*yield*/, getUnmaskedEntity()];
131
+ case 2:
132
+ _a = _b.sent();
133
+ return [3 /*break*/, 5];
134
+ case 3: return [4 /*yield*/, getUnmaskedEntity(historyEvent === null || historyEvent === void 0 ? void 0 : historyEvent.bStamp)];
135
+ case 4:
136
+ _a = _b.sent();
137
+ _b.label = 5;
138
+ case 5:
139
+ unmaskedEntity = _a;
140
+ attributeValue = findAttributeValueByUri(unmaskedEntity, attributeValueUri);
141
+ return [2 /*return*/, attributeValue];
142
+ }
143
+ });
144
+ }); }, [getUnmaskedEntity, historyEvent === null || historyEvent === void 0 ? void 0 : historyEvent.aStamp, historyEvent === null || historyEvent === void 0 ? void 0 : historyEvent.bStamp, historyMode]);
69
145
  var unmaskAttributeValue = useCallback(function (attributeValueUri) { return __awaiter(void 0, void 0, void 0, function () {
70
- var unmaskedAttributes_1, unmaskedAttributeValue_1, error_1;
71
- return __generator(this, function (_a) {
72
- switch (_a.label) {
146
+ var unmaskedAttributes_1, unmaskedAttributeValue_1, _a, error_1;
147
+ return __generator(this, function (_b) {
148
+ switch (_b.label) {
73
149
  case 0:
74
- _a.trys.push([0, 4, , 5]);
150
+ _b.trys.push([0, 7, , 8]);
75
151
  unmaskedAttributes_1 = unmaskedAttributesRef.current;
76
- if (!!unmaskedAttributes_1[attributeValueUri]) return [3 /*break*/, 2];
152
+ if (!!unmaskedAttributes_1[attributeValueUri]) return [3 /*break*/, 5];
77
153
  setUnmaskedAttributes(function (prev) {
78
154
  var _a;
79
155
  return (__assign(__assign({}, prev), (_a = {}, _a[attributeValueUri] = __assign(__assign({}, prev[attributeValueUri]), { loading: true }), _a)));
80
156
  });
81
- return [4 /*yield*/, getUnmaskedAttributeValue(attributeValueUri)];
157
+ if (!historyEvent) return [3 /*break*/, 2];
158
+ return [4 /*yield*/, unmaskAttributeValueFromEntity(attributeValueUri)];
82
159
  case 1:
83
- unmaskedAttributeValue_1 = _a.sent();
160
+ _a = _b.sent();
161
+ return [3 /*break*/, 4];
162
+ case 2: return [4 /*yield*/, getUnmaskedAttributeValue(attributeValueUri)];
163
+ case 3:
164
+ _a = _b.sent();
165
+ _b.label = 4;
166
+ case 4:
167
+ unmaskedAttributeValue_1 = _a;
84
168
  setUnmaskedAttributes(function (prev) {
85
169
  var _a;
86
170
  return (__assign(__assign({}, prev), (_a = {}, _a[attributeValueUri] = {
@@ -90,21 +174,21 @@ export var MaskedAttributesProvider = function (_a) {
90
174
  }, _a)));
91
175
  });
92
176
  return [2 /*return*/, unmaskedAttributeValue_1];
93
- case 2:
177
+ case 5:
94
178
  setUnmaskedAttributes(function (prev) {
95
179
  var _a;
96
180
  return (__assign(__assign({}, prev), (_a = {}, _a[attributeValueUri] = __assign(__assign({}, prev[attributeValueUri]), { isUnmasked: true }), _a)));
97
181
  });
98
182
  return [2 /*return*/, unmaskedAttributes_1[attributeValueUri].attributeValue];
99
- case 3: return [3 /*break*/, 5];
100
- case 4:
101
- error_1 = _a.sent();
183
+ case 6: return [3 /*break*/, 8];
184
+ case 7:
185
+ error_1 = _b.sent();
102
186
  showErrorMessage(error_1);
103
187
  return [2 /*return*/, null];
104
- case 5: return [2 /*return*/];
188
+ case 8: return [2 /*return*/];
105
189
  }
106
190
  });
107
- }); }, []);
191
+ }); }, [historyEvent, unmaskAttributeValueFromEntity]);
108
192
  var maskAttributeValue = useCallback(function (attributeValueUri) {
109
193
  setUnmaskedAttributes(function (prev) {
110
194
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.2022",
3
+ "version": "1.4.2024",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",