@reltio/components 1.4.1908 → 1.4.1910
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.
- package/cjs/MatchRulesTooltip/MatchRulesTooltip.js +11 -7
- package/cjs/MatchRulesTooltip/MatchRulesTooltip.test.js +20 -24
- package/cjs/MatchRulesTooltip/styles.d.ts +1 -1
- package/cjs/MatchRulesTooltip/styles.js +5 -1
- package/cjs/ProfileResizablePanes/ProfileResizablePanes.spec.js +113 -68
- package/cjs/ResizablePanes/ResizablePanes.d.ts +3 -2
- package/cjs/ResizablePanes/ResizablePanes.js +83 -16
- package/cjs/ResizablePanes/ResizablePanes.test.js +289 -0
- package/cjs/ResizablePanes/styles.d.ts +1 -1
- package/cjs/ResizablePanes/styles.js +47 -38
- package/cjs/SimpleMatchRules/SimpleMatchRules.js +16 -13
- package/cjs/SimpleMatchRules/SimpleMatchRules.test.js +8 -35
- package/cjs/SimpleMatchRules/styles.d.ts +1 -1
- package/cjs/SimpleMatchRules/styles.js +8 -0
- package/cjs/SimpleMatchRulesBlock/SimpleMatchRulesBlock.js +3 -3
- package/cjs/SimpleMatchRulesBlock/SimpleMatchRulesBlock.test.js +1 -1
- package/cjs/icons/AIPowered.d.ts +5 -0
- package/cjs/icons/AIPowered.js +76 -0
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +2 -1
- package/cjs/test-utils/index.d.ts +1 -0
- package/cjs/test-utils/index.js +15 -1
- package/esm/MatchRulesTooltip/MatchRulesTooltip.js +11 -7
- package/esm/MatchRulesTooltip/MatchRulesTooltip.test.js +20 -24
- package/esm/MatchRulesTooltip/styles.d.ts +1 -1
- package/esm/MatchRulesTooltip/styles.js +5 -1
- package/esm/ProfileResizablePanes/ProfileResizablePanes.spec.js +113 -68
- package/esm/ResizablePanes/ResizablePanes.d.ts +3 -2
- package/esm/ResizablePanes/ResizablePanes.js +84 -17
- package/esm/ResizablePanes/ResizablePanes.test.js +284 -0
- package/esm/ResizablePanes/styles.d.ts +1 -1
- package/esm/ResizablePanes/styles.js +47 -38
- package/esm/SimpleMatchRules/SimpleMatchRules.js +16 -13
- package/esm/SimpleMatchRules/SimpleMatchRules.test.js +8 -35
- package/esm/SimpleMatchRules/styles.d.ts +1 -1
- package/esm/SimpleMatchRules/styles.js +8 -0
- package/esm/SimpleMatchRulesBlock/SimpleMatchRulesBlock.js +3 -3
- package/esm/SimpleMatchRulesBlock/SimpleMatchRulesBlock.test.js +1 -1
- package/esm/icons/AIPowered.d.ts +5 -0
- package/esm/icons/AIPowered.js +71 -0
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/test-utils/index.d.ts +1 -0
- package/esm/test-utils/index.js +13 -0
- package/package.json +3 -3
- package/cjs/MatchRulesTitle/MatchRulesTitle.d.ts +0 -5
- package/cjs/MatchRulesTitle/MatchRulesTitle.js +0 -13
- package/cjs/MatchRulesTitle/MatchRulesTitle.test.js +0 -18
- package/cjs/MatchRulesTitle/index.d.ts +0 -1
- package/cjs/MatchRulesTitle/index.js +0 -5
- package/cjs/ResizablePanes/ResizablePanes.spec.js +0 -192
- package/esm/MatchRulesTitle/MatchRulesTitle.d.ts +0 -5
- package/esm/MatchRulesTitle/MatchRulesTitle.js +0 -6
- package/esm/MatchRulesTitle/MatchRulesTitle.test.d.ts +0 -1
- package/esm/MatchRulesTitle/MatchRulesTitle.test.js +0 -13
- package/esm/MatchRulesTitle/index.d.ts +0 -1
- package/esm/MatchRulesTitle/index.js +0 -1
- package/esm/ResizablePanes/ResizablePanes.spec.d.ts +0 -1
- package/esm/ResizablePanes/ResizablePanes.spec.js +0 -164
- /package/cjs/{MatchRulesTitle/MatchRulesTitle.test.d.ts → ResizablePanes/ResizablePanes.test.d.ts} +0 -0
- /package/{cjs/ResizablePanes/ResizablePanes.spec.d.ts → esm/ResizablePanes/ResizablePanes.test.d.ts} +0 -0
|
@@ -0,0 +1,289 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var react_1 = __importDefault(require("react"));
|
|
54
|
+
var react_2 = require("@testing-library/react");
|
|
55
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
56
|
+
var ResizablePanes_1 = require("./ResizablePanes");
|
|
57
|
+
var test_utils_1 = require("../test-utils");
|
|
58
|
+
var defaultProps = {
|
|
59
|
+
allowResize: true,
|
|
60
|
+
children: []
|
|
61
|
+
};
|
|
62
|
+
var setUp = function (props) {
|
|
63
|
+
if (props === void 0) { props = defaultProps; }
|
|
64
|
+
var user = user_event_1.default.setup();
|
|
65
|
+
return __assign(__assign({}, (0, react_2.render)(react_1.default.createElement(ResizablePanes_1.ResizablePanes, __assign({}, props),
|
|
66
|
+
react_1.default.createElement("div", null, "Panel 1 content"),
|
|
67
|
+
react_1.default.createElement("div", null, "Panel 2 content")))), { user: user });
|
|
68
|
+
};
|
|
69
|
+
var getPanel1 = function (container) { return container.querySelectorAll('[data-panel-id]')[0]; };
|
|
70
|
+
var getPanel2 = function (container) { return container.querySelectorAll('[data-panel-id]')[1]; };
|
|
71
|
+
var getResizeHandle = function (container) { return container.querySelector('[data-resize-handle]'); };
|
|
72
|
+
var isResizingDisabled = function (container) {
|
|
73
|
+
return getResizeHandle(container).getAttribute('data-panel-resize-handle-enabled') === 'false';
|
|
74
|
+
};
|
|
75
|
+
var checkPanelSize = function (panel, size) { return expect(panel.getAttribute('data-panel-size')).toBe(size); };
|
|
76
|
+
var moveResizeHandle = function (container, user, from, to) { return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
+
var resizeHandle;
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
resizeHandle = getResizeHandle(container);
|
|
82
|
+
return [4 /*yield*/, user.pointer([
|
|
83
|
+
{
|
|
84
|
+
keys: '[MouseLeft>]',
|
|
85
|
+
target: resizeHandle,
|
|
86
|
+
coords: {
|
|
87
|
+
x: from.x,
|
|
88
|
+
y: from.y
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
target: resizeHandle,
|
|
93
|
+
coords: {
|
|
94
|
+
x: to.x,
|
|
95
|
+
y: to.y
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
keys: '[/MouseLeft]',
|
|
100
|
+
target: resizeHandle,
|
|
101
|
+
coords: {
|
|
102
|
+
x: to.x,
|
|
103
|
+
y: to.y
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
])];
|
|
107
|
+
case 1:
|
|
108
|
+
_a.sent();
|
|
109
|
+
return [2 /*return*/];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}); };
|
|
113
|
+
describe('ResizablePanes tests', function () {
|
|
114
|
+
beforeAll(function () {
|
|
115
|
+
jest.spyOn(HTMLElement.prototype, 'clientWidth', 'get').mockReturnValue(1000);
|
|
116
|
+
jest.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
|
|
117
|
+
width: 1000,
|
|
118
|
+
height: 1000,
|
|
119
|
+
top: 0,
|
|
120
|
+
left: 0,
|
|
121
|
+
right: 1000,
|
|
122
|
+
bottom: 1000,
|
|
123
|
+
x: 0,
|
|
124
|
+
y: 0,
|
|
125
|
+
toJSON: function () { return ''; }
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
it('should render main parts', function () {
|
|
129
|
+
var container = setUp().container;
|
|
130
|
+
expect(getPanel1(container)).toBeInTheDocument();
|
|
131
|
+
expect(react_2.screen.getByText('Panel 1 content')).toBeInTheDocument();
|
|
132
|
+
expect(getPanel2(container)).toBeInTheDocument();
|
|
133
|
+
expect(react_2.screen.getByText('Panel 2 content')).toBeInTheDocument();
|
|
134
|
+
expect(getResizeHandle(container)).toBeInTheDocument();
|
|
135
|
+
});
|
|
136
|
+
it('should allow to resize the panels', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
137
|
+
var _a, container, user;
|
|
138
|
+
return __generator(this, function (_b) {
|
|
139
|
+
switch (_b.label) {
|
|
140
|
+
case 0:
|
|
141
|
+
_a = setUp(__assign(__assign({}, defaultProps), { size: '320px', minSize: '320px', maxSize: '640px', onChange: function () { }, debounceInterval: 0 })), container = _a.container, user = _a.user;
|
|
142
|
+
expect(isResizingDisabled(container)).toBe(false);
|
|
143
|
+
checkPanelSize(getPanel1(container), '32.0');
|
|
144
|
+
checkPanelSize(getPanel2(container), '68.0');
|
|
145
|
+
// move mouse to an x-coordinate between minSize and maxSize
|
|
146
|
+
return [4 /*yield*/, moveResizeHandle(container, user, { x: 320, y: 0 }, { x: 500, y: 20 })];
|
|
147
|
+
case 1:
|
|
148
|
+
// move mouse to an x-coordinate between minSize and maxSize
|
|
149
|
+
_b.sent();
|
|
150
|
+
checkPanelSize(getPanel1(container), '50.0');
|
|
151
|
+
checkPanelSize(getPanel2(container), '50.0');
|
|
152
|
+
// move mouse to a larger x-coordinate than max size
|
|
153
|
+
return [4 /*yield*/, moveResizeHandle(container, user, { x: 500, y: 0 }, { x: 650, y: 20 })];
|
|
154
|
+
case 2:
|
|
155
|
+
// move mouse to a larger x-coordinate than max size
|
|
156
|
+
_b.sent();
|
|
157
|
+
checkPanelSize(getPanel1(container), '64.0');
|
|
158
|
+
checkPanelSize(getPanel2(container), '36.0');
|
|
159
|
+
// move mouse to a smaller x-coordinate than min size
|
|
160
|
+
return [4 /*yield*/, moveResizeHandle(container, user, { x: 640, y: 0 }, { x: 310, y: 20 })];
|
|
161
|
+
case 3:
|
|
162
|
+
// move mouse to a smaller x-coordinate than min size
|
|
163
|
+
_b.sent();
|
|
164
|
+
checkPanelSize(getPanel1(container), '32.0');
|
|
165
|
+
checkPanelSize(getPanel2(container), '68.0');
|
|
166
|
+
return [2 /*return*/];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}); });
|
|
170
|
+
it('should call onChange prop with debounce on panels resizing', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
171
|
+
var debounceInterval, props, _a, user, container;
|
|
172
|
+
return __generator(this, function (_b) {
|
|
173
|
+
switch (_b.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
debounceInterval = 200;
|
|
176
|
+
props = __assign(__assign({}, defaultProps), { size: 320, debounceInterval: debounceInterval, onChange: jest.fn() });
|
|
177
|
+
_a = setUp(props), user = _a.user, container = _a.container;
|
|
178
|
+
return [4 /*yield*/, moveResizeHandle(container, user, { x: 320, y: 0 }, { x: 510, y: 20 })];
|
|
179
|
+
case 1:
|
|
180
|
+
_b.sent();
|
|
181
|
+
expect(props.onChange).not.toHaveBeenCalled();
|
|
182
|
+
return [4 /*yield*/, (0, test_utils_1.delayPromise)(debounceInterval + 1)];
|
|
183
|
+
case 2:
|
|
184
|
+
_b.sent();
|
|
185
|
+
expect(props.onChange).toHaveBeenCalledWith({
|
|
186
|
+
isMaxSize: false,
|
|
187
|
+
isMinSize: false,
|
|
188
|
+
percentageSize: '51%',
|
|
189
|
+
size: 510
|
|
190
|
+
});
|
|
191
|
+
return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}); });
|
|
195
|
+
it('should set correct isMaxSize in props.onChange argument for positive props.maxSize', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
196
|
+
var debounceInterval, props, _a, user, container;
|
|
197
|
+
return __generator(this, function (_b) {
|
|
198
|
+
switch (_b.label) {
|
|
199
|
+
case 0:
|
|
200
|
+
debounceInterval = 0;
|
|
201
|
+
props = __assign(__assign({}, defaultProps), { size: 320, maxSize: 500, debounceInterval: debounceInterval, onChange: jest.fn() });
|
|
202
|
+
_a = setUp(props), user = _a.user, container = _a.container;
|
|
203
|
+
return [4 /*yield*/, moveResizeHandle(container, user, { x: 320, y: 0 }, { x: 510, y: 20 })];
|
|
204
|
+
case 1:
|
|
205
|
+
_b.sent();
|
|
206
|
+
expect(props.onChange).toHaveBeenCalledWith({
|
|
207
|
+
isMaxSize: true,
|
|
208
|
+
isMinSize: false,
|
|
209
|
+
percentageSize: '50%',
|
|
210
|
+
size: 500
|
|
211
|
+
});
|
|
212
|
+
return [2 /*return*/];
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}); });
|
|
216
|
+
it('should set correct isMaxSize in props.onChange argument for negative props.maxSize', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
217
|
+
var debounceInterval, props, _a, user, container;
|
|
218
|
+
return __generator(this, function (_b) {
|
|
219
|
+
switch (_b.label) {
|
|
220
|
+
case 0:
|
|
221
|
+
debounceInterval = 0;
|
|
222
|
+
props = __assign(__assign({}, defaultProps), { size: 320, maxSize: -200, debounceInterval: debounceInterval, onChange: jest.fn() });
|
|
223
|
+
_a = setUp(props), user = _a.user, container = _a.container;
|
|
224
|
+
return [4 /*yield*/, moveResizeHandle(container, user, { x: 320, y: 0 }, { x: 800, y: 20 })];
|
|
225
|
+
case 1:
|
|
226
|
+
_b.sent();
|
|
227
|
+
expect(props.onChange).toHaveBeenCalledWith({
|
|
228
|
+
isMaxSize: true,
|
|
229
|
+
isMinSize: false,
|
|
230
|
+
percentageSize: '80%',
|
|
231
|
+
size: 800
|
|
232
|
+
});
|
|
233
|
+
return [2 /*return*/];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}); });
|
|
237
|
+
it('should set correct isMaxSize in props.onChange argument if props.maxSize omitted', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
238
|
+
var debounceInterval, props, _a, user, container;
|
|
239
|
+
return __generator(this, function (_b) {
|
|
240
|
+
switch (_b.label) {
|
|
241
|
+
case 0:
|
|
242
|
+
debounceInterval = 0;
|
|
243
|
+
props = __assign(__assign({}, defaultProps), { size: 320, debounceInterval: debounceInterval, onChange: jest.fn() });
|
|
244
|
+
_a = setUp(props), user = _a.user, container = _a.container;
|
|
245
|
+
return [4 /*yield*/, moveResizeHandle(container, user, { x: 320, y: 0 }, { x: 1000, y: 20 })];
|
|
246
|
+
case 1:
|
|
247
|
+
_b.sent();
|
|
248
|
+
expect(props.onChange).toHaveBeenCalledWith({
|
|
249
|
+
isMaxSize: true,
|
|
250
|
+
isMinSize: false,
|
|
251
|
+
percentageSize: '100%',
|
|
252
|
+
size: 1000
|
|
253
|
+
});
|
|
254
|
+
return [2 /*return*/];
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}); });
|
|
258
|
+
it('should set correct isMinSize in props.onChange argument for positive props.minSize', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
259
|
+
var debounceInterval, props, _a, user, container;
|
|
260
|
+
return __generator(this, function (_b) {
|
|
261
|
+
switch (_b.label) {
|
|
262
|
+
case 0:
|
|
263
|
+
debounceInterval = 0;
|
|
264
|
+
props = __assign(__assign({}, defaultProps), { size: 320, minSize: 200, debounceInterval: debounceInterval, onChange: jest.fn() });
|
|
265
|
+
_a = setUp(props), user = _a.user, container = _a.container;
|
|
266
|
+
return [4 /*yield*/, moveResizeHandle(container, user, { x: 320, y: 0 }, { x: 200, y: 20 })];
|
|
267
|
+
case 1:
|
|
268
|
+
_b.sent();
|
|
269
|
+
expect(props.onChange).toHaveBeenCalledWith({
|
|
270
|
+
isMaxSize: false,
|
|
271
|
+
isMinSize: true,
|
|
272
|
+
percentageSize: '20%',
|
|
273
|
+
size: 200
|
|
274
|
+
});
|
|
275
|
+
return [2 /*return*/];
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}); });
|
|
279
|
+
it('should apply negative size correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
280
|
+
var props, container;
|
|
281
|
+
return __generator(this, function (_a) {
|
|
282
|
+
props = __assign(__assign({}, defaultProps), { size: -40 });
|
|
283
|
+
container = setUp(props).container;
|
|
284
|
+
checkPanelSize(getPanel1(container), '96.0');
|
|
285
|
+
checkPanelSize(getPanel2(container), '4.0');
|
|
286
|
+
return [2 /*return*/];
|
|
287
|
+
});
|
|
288
|
+
}); });
|
|
289
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"container">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"container" | "horizontal" | "vertical" | "resizer" | "disabled" | "panel">;
|
|
@@ -4,46 +4,55 @@ exports.useStyles = void 0;
|
|
|
4
4
|
var styles_1 = require("@mui/styles");
|
|
5
5
|
exports.useStyles = (0, styles_1.makeStyles)(function () { return ({
|
|
6
6
|
container: {
|
|
7
|
-
position: 'relative'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
position: 'relative'
|
|
8
|
+
},
|
|
9
|
+
panel: {
|
|
10
|
+
position: 'relative'
|
|
11
|
+
},
|
|
12
|
+
horizontal: {},
|
|
13
|
+
vertical: {},
|
|
14
|
+
disabled: {},
|
|
15
|
+
resizer: {
|
|
16
|
+
zIndex: 1,
|
|
17
|
+
boxSizing: 'border-box',
|
|
18
|
+
backgroundClip: 'padding-box',
|
|
19
|
+
'&$disabled': {
|
|
20
|
+
cursor: 'initial',
|
|
21
|
+
height: 0,
|
|
22
|
+
margin: 0
|
|
23
|
+
},
|
|
24
|
+
'&$horizontal': {
|
|
25
|
+
height: '11px',
|
|
26
|
+
backgroundImage: 'linear-gradient(rgba(0,0,0,0.33), rgba(0,0,0,0.33))',
|
|
27
|
+
backgroundRepeat: 'no-repeat',
|
|
28
|
+
backgroundSize: '100% 1px',
|
|
29
|
+
backgroundPosition: 'top',
|
|
30
|
+
width: '100%',
|
|
31
|
+
marginBottom: '-10px',
|
|
32
|
+
'&$disabled': {
|
|
33
|
+
background: 'transparent'
|
|
16
34
|
},
|
|
17
|
-
'
|
|
18
|
-
|
|
19
|
-
backgroundImage: 'linear-gradient(rgba(0,0,0,0.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
'&:not($disabled):hover': {
|
|
36
|
+
cursor: 'ns-resize',
|
|
37
|
+
backgroundImage: 'linear-gradient(rgba(0, 114, 206, 0), rgba(0, 114, 206, 0.35), rgba(0, 114, 206, 1))',
|
|
38
|
+
backgroundSize: '100% 3px'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
'&$vertical': {
|
|
42
|
+
width: '11px',
|
|
43
|
+
backgroundImage: 'linear-gradient(rgba(0,0,0,0.33), rgba(0,0,0,0.33))',
|
|
44
|
+
backgroundRepeat: 'no-repeat',
|
|
45
|
+
backgroundSize: '1px 100%',
|
|
46
|
+
backgroundPosition: 'left',
|
|
47
|
+
height: '100%',
|
|
48
|
+
marginRight: '-10px',
|
|
49
|
+
'&$disabled': {
|
|
50
|
+
background: 'transparent'
|
|
33
51
|
},
|
|
34
|
-
'
|
|
35
|
-
|
|
36
|
-
backgroundImage: 'linear-gradient(rgba(0,
|
|
37
|
-
|
|
38
|
-
backgroundSize: '1px 100%',
|
|
39
|
-
backgroundPosition: 'left',
|
|
40
|
-
height: '100%',
|
|
41
|
-
marginRight: '-10px',
|
|
42
|
-
'&:not(.disabled):hover': {
|
|
43
|
-
cursor: 'col-resize',
|
|
44
|
-
backgroundImage: 'linear-gradient(to left, rgba(0, 114, 206, 0.35), rgba(0, 114, 206, 1), rgba(0, 114, 206, 0.35))',
|
|
45
|
-
backgroundSize: '3px 100%'
|
|
46
|
-
}
|
|
52
|
+
'&:not($disabled):hover': {
|
|
53
|
+
cursor: 'ew-resize',
|
|
54
|
+
backgroundImage: 'linear-gradient(to left, rgba(0, 114, 206, 0.35), rgba(0, 114, 206, 1), rgba(0, 114, 206, 0.35))',
|
|
55
|
+
backgroundSize: '3px 100%'
|
|
47
56
|
}
|
|
48
57
|
}
|
|
49
58
|
}
|
|
@@ -10,23 +10,26 @@ var classnames_1 = __importDefault(require("classnames"));
|
|
|
10
10
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
11
11
|
var Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
|
|
12
12
|
var NegativeRuleIcon_1 = __importDefault(require("../icons/NegativeRuleIcon"));
|
|
13
|
-
var MatchRulesTitle_1 = require("../MatchRulesTitle");
|
|
14
13
|
var styles_1 = require("./styles");
|
|
15
14
|
var SimpleMatchRules = function (_a) {
|
|
16
15
|
var isMlMatch = _a.isMlMatch, matchRules = _a.matchRules, className = _a.className, matchRuleSummaries = _a.matchRuleSummaries;
|
|
17
16
|
var styles = (0, styles_1.useStyles)();
|
|
17
|
+
var hasMatchRules = matchRules.length > 0;
|
|
18
|
+
var showTitle = !isMlMatch && hasMatchRules;
|
|
18
19
|
return (react_1.default.createElement("div", { "data-reltio-id": "simple-match-rules", className: (0, classnames_1.default)(styles.container, className) },
|
|
19
|
-
react_1.default.createElement("div", { className: styles.
|
|
20
|
-
react_1.default.createElement(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
react_1.default.createElement("div", { className: showTitle ? styles.bodyWithMargin : styles.bodyWithoutMargin },
|
|
21
|
+
showTitle && react_1.default.createElement("div", { className: styles.title }, ui_i18n_1.default.text('Match rules')),
|
|
22
|
+
react_1.default.createElement("div", { className: styles.labelsContainer }, hasMatchRules
|
|
23
|
+
? matchRules.map(function (matchRule) {
|
|
24
|
+
var matchRuleSummary = (0, mdm_sdk_1.getMatchRuleSummary)(matchRuleSummaries, matchRule.uri);
|
|
25
|
+
var relevancePercentage = (0, mdm_sdk_1.formatRelevanceScore)(matchRuleSummary);
|
|
26
|
+
return (react_1.default.createElement("div", { className: styles.matchRuleInfo, key: matchRule.uri, "data-reltio-id": "match-rule-info" },
|
|
27
|
+
react_1.default.createElement("div", { className: styles.matchRuleLabel },
|
|
28
|
+
'- ',
|
|
29
|
+
matchRule.negativeRule && (react_1.default.createElement(NegativeRuleIcon_1.default, { className: styles.negativeRuleIcon })), "".concat(matchRule.label)),
|
|
30
|
+
relevancePercentage && (react_1.default.createElement(Tooltip_1.default, { title: ui_i18n_1.default.text('Relevance score') },
|
|
31
|
+
react_1.default.createElement("div", { className: styles.relevanceScore }, relevancePercentage)))));
|
|
32
|
+
})
|
|
33
|
+
: null))));
|
|
31
34
|
};
|
|
32
35
|
exports.SimpleMatchRules = SimpleMatchRules;
|
|
@@ -4,47 +4,20 @@ 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
|
|
8
|
-
var MatchRulesTitle_1 = require("../MatchRulesTitle");
|
|
9
|
-
var NegativeRuleIcon_1 = __importDefault(require("../icons/NegativeRuleIcon"));
|
|
7
|
+
var react_2 = require("@testing-library/react");
|
|
10
8
|
var SimpleMatchRules_1 = require("./SimpleMatchRules");
|
|
11
9
|
describe('SimpleMatchRules tests', function () {
|
|
12
|
-
var getMatchRulesTitle = function (component) { return component.find(MatchRulesTitle_1.MatchRulesTitle); };
|
|
13
|
-
var getLabelContainer = function (component) { return component.find('.labelsContainer'); };
|
|
14
|
-
var getContainer = function (component) { return component.find('.container'); };
|
|
15
|
-
it('should provide isMlMatch prop to MatchRulesTitle', function () {
|
|
16
|
-
var component = (0, enzyme_1.shallow)(react_1.default.createElement(SimpleMatchRules_1.SimpleMatchRules, { isMlMatch: true, matchRules: [] }));
|
|
17
|
-
expect(getMatchRulesTitle(component).prop('isMlMatch')).toBe(true);
|
|
18
|
-
component.setProps({ isMlMatch: false });
|
|
19
|
-
expect(getMatchRulesTitle(component).prop('isMlMatch')).toBe(false);
|
|
20
|
-
});
|
|
21
|
-
it('should render match rule correctly', function () {
|
|
22
|
-
var matchRules = [
|
|
23
|
-
{ uri: 'uri1', label: 'label1' },
|
|
24
|
-
{ uri: 'uri2', label: 'label2' }
|
|
25
|
-
];
|
|
26
|
-
var component = (0, enzyme_1.shallow)(react_1.default.createElement(SimpleMatchRules_1.SimpleMatchRules, { matchRules: matchRules }));
|
|
27
|
-
var labelContainer = getLabelContainer(component);
|
|
28
|
-
expect(labelContainer.children()).toHaveLength(2);
|
|
29
|
-
expect(labelContainer.childAt(0).text()).toContain(matchRules[0].label);
|
|
30
|
-
expect(labelContainer.childAt(1).text()).toContain(matchRules[1].label);
|
|
31
|
-
});
|
|
32
|
-
it('should provide className prop to container', function () {
|
|
33
|
-
var className = 'myClassName';
|
|
34
|
-
var component = (0, enzyme_1.shallow)(react_1.default.createElement(SimpleMatchRules_1.SimpleMatchRules, { className: className, matchRules: [] }));
|
|
35
|
-
expect(getContainer(component).prop('className')).toContain(className);
|
|
36
|
-
});
|
|
37
10
|
it('should render negative rule correctly', function () {
|
|
38
11
|
var matchRules = [
|
|
39
12
|
{ uri: 'uri1', label: 'label1' },
|
|
40
13
|
{ uri: 'uri2', label: 'label2', negativeRule: {} }
|
|
41
14
|
];
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
47
|
-
expect(
|
|
48
|
-
expect(
|
|
15
|
+
(0, react_2.render)(react_1.default.createElement(SimpleMatchRules_1.SimpleMatchRules, { matchRules: matchRules }));
|
|
16
|
+
var ruleItems = react_2.screen.getAllByText(/^-\s+/);
|
|
17
|
+
expect(ruleItems).toHaveLength(2);
|
|
18
|
+
expect(ruleItems[0]).toHaveTextContent(matchRules[0].label);
|
|
19
|
+
expect(ruleItems[0].querySelector('svg')).not.toBeInTheDocument();
|
|
20
|
+
expect(ruleItems[1]).toHaveTextContent(matchRules[1].label);
|
|
21
|
+
expect(ruleItems[1].querySelector('svg')).toBeInTheDocument();
|
|
49
22
|
});
|
|
50
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"container" | "title" | "relevanceScore" | "negativeRuleIcon" | "labelsContainer" | "matchRuleInfo" | "matchRuleLabel">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"container" | "title" | "relevanceScore" | "bodyWithMargin" | "bodyWithoutMargin" | "negativeRuleIcon" | "labelsContainer" | "matchRuleInfo" | "matchRuleLabel">;
|
|
@@ -11,6 +11,14 @@ exports.useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
|
|
|
11
11
|
color: theme.palette.text.secondary,
|
|
12
12
|
marginBottom: '7px'
|
|
13
13
|
},
|
|
14
|
+
bodyWithMargin: {
|
|
15
|
+
fontWeight: 'normal',
|
|
16
|
+
marginLeft: '16px'
|
|
17
|
+
},
|
|
18
|
+
bodyWithoutMargin: {
|
|
19
|
+
fontWeight: 'normal',
|
|
20
|
+
marginLeft: '0px'
|
|
21
|
+
},
|
|
14
22
|
labelsContainer: {
|
|
15
23
|
color: theme.palette.text.primary,
|
|
16
24
|
marginBottom: '8px'
|
|
@@ -33,7 +33,7 @@ var MatchRulesTooltip_1 = require("../MatchRulesTooltip");
|
|
|
33
33
|
var SimpleMatchRules_1 = require("../SimpleMatchRules");
|
|
34
34
|
var MatchRulesBadge_1 = require("../MatchRulesBadge");
|
|
35
35
|
var withTooltip_1 = require("../HOCs/withTooltip");
|
|
36
|
-
var
|
|
36
|
+
var AIPowered_1 = __importDefault(require("../icons/AIPowered"));
|
|
37
37
|
var styles_1 = require("./styles");
|
|
38
38
|
exports.MatchRuleBadgeWithTooltip = (0, withTooltip_1.withTooltip)(MatchRulesBadge_1.MatchRulesBadge);
|
|
39
39
|
var SimpleMatchRulesBlock = function (_a) {
|
|
@@ -43,8 +43,8 @@ var SimpleMatchRulesBlock = function (_a) {
|
|
|
43
43
|
var handleOnExpand = (0, react_1.useCallback)(function () { return setExpanded(function (expand) { return !expand; }); }, []);
|
|
44
44
|
return (react_1.default.createElement("div", { className: styles.container, "data-reltio-id": "simple-match-rules-block" },
|
|
45
45
|
react_1.default.createElement(exports.MatchRuleBadgeWithTooltip, { tooltipTitle: react_1.default.createElement(MatchRulesTooltip_1.MatchRulesTooltip, { matchRules: matchRules, isMlMatch: isMlMatch }), tooltipPlacement: "bottom-start", onExpand: handleOnExpand, expanded: expanded }, isMlMatch ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
46
|
-
react_1.default.createElement(
|
|
47
|
-
ui_i18n_1.default.text('
|
|
46
|
+
react_1.default.createElement(AIPowered_1.default, { className: styles.icon }),
|
|
47
|
+
ui_i18n_1.default.text('AI-powered'))) : (ui_i18n_1.default.text('Rules'))),
|
|
48
48
|
expanded ? (react_1.default.createElement(SimpleMatchRules_1.SimpleMatchRules, { className: styles.rulesContainer, matchRules: matchRules, isMlMatch: isMlMatch, matchRuleSummaries: matchRuleSummaries })) : null));
|
|
49
49
|
};
|
|
50
50
|
exports.SimpleMatchRulesBlock = SimpleMatchRulesBlock;
|
|
@@ -36,7 +36,7 @@ describe('SimpleMatchRulesBlock test', function () {
|
|
|
36
36
|
});
|
|
37
37
|
it('should render correct MatchRuleBadgeWithTooltip for Ml match', function () {
|
|
38
38
|
var component = (0, enzyme_1.shallow)(react_1.default.createElement(SimpleMatchRulesBlock_1.SimpleMatchRulesBlock, { isMlMatch: true, matchRules: matchRules }));
|
|
39
|
-
expect(getMatchRuleBadgeWithTooltip(component).text()).toBe('<
|
|
39
|
+
expect(getMatchRuleBadgeWithTooltip(component).text()).toBe('<AIPowered />AI-powered');
|
|
40
40
|
});
|
|
41
41
|
it('should render correct MatchRuleBadgeWithTooltip for non Ml match', function () {
|
|
42
42
|
var component = (0, enzyme_1.shallow)(react_1.default.createElement(SimpleMatchRulesBlock_1.SimpleMatchRulesBlock, { matchRules: matchRules }));
|