@reltio/components 1.4.1961 → 1.4.1962

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.
@@ -10,6 +10,42 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
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
+ };
13
49
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
51
  };
@@ -19,6 +55,7 @@ var mdm_sdk_1 = require("@reltio/mdm-sdk");
19
55
  var AttributesView_1 = require("./AttributesView");
20
56
  var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
21
57
  var react_2 = require("@testing-library/react");
58
+ var user_event_1 = __importDefault(require("@testing-library/user-event"));
22
59
  describe('AttributesView tests', function () {
23
60
  var entity = {
24
61
  type: 'configuration/entityTypes/HCP',
@@ -70,7 +107,8 @@ describe('AttributesView tests', function () {
70
107
  var mdmDefaultValues = {
71
108
  metadata: metadata,
72
109
  modifiedEntities: { 'entities/02ZRRE9': entity },
73
- dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] }
110
+ dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] },
111
+ controlAttributes: ['configuration/entityTypes/HCP/attributes/Phone']
74
112
  };
75
113
  var setUp = function (props, mdmValues) {
76
114
  if (props === void 0) { props = {}; }
@@ -79,7 +117,8 @@ describe('AttributesView tests', function () {
79
117
  var children = _a.children;
80
118
  return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues, actions: actions }, children));
81
119
  };
82
- return (0, react_2.render)(react_1.default.createElement(AttributesView_1.AttributesView, __assign({}, props)), { wrapper: Providers });
120
+ var user = user_event_1.default.setup();
121
+ return __assign(__assign({}, (0, react_2.render)(react_1.default.createElement(AttributesView_1.AttributesView, __assign({}, props)), { wrapper: Providers })), { user: user });
83
122
  };
84
123
  it('should render ReadOnlyAttributesView in read mode if mode is "viewing"', function () {
85
124
  setUp({ mode: mdm_sdk_1.Mode.Viewing, entity: entity });
@@ -123,4 +162,29 @@ describe('AttributesView tests', function () {
123
162
  expect(react_2.screen.getByText('Last Name')).toBeInTheDocument();
124
163
  expect(react_2.screen.getByText('Phone')).toBeInTheDocument();
125
164
  });
165
+ it('should show control attribute icon if an attribute is a always visible control attribute in view mode', function () { return __awaiter(void 0, void 0, void 0, function () {
166
+ var alwaysVisible, user, controlAttribute, icon, _a;
167
+ return __generator(this, function (_b) {
168
+ switch (_b.label) {
169
+ case 0:
170
+ alwaysVisible = [
171
+ 'configuration/entityTypes/HCP/attributes/LastName',
172
+ 'configuration/entityTypes/HCP/attributes/Phone'
173
+ ];
174
+ user = setUp({ mode: mdm_sdk_1.Mode.Editing, entity: entity, alwaysVisible: alwaysVisible }).user;
175
+ expect(react_2.screen.getByText('Last Name')).toBeInTheDocument();
176
+ expect(react_2.screen.getByText('Phone')).toBeInTheDocument();
177
+ controlAttribute = react_2.screen.getByText('Phone').closest('div');
178
+ icon = (0, react_2.within)(controlAttribute).getByTestId('reltio-control-attribute-icon');
179
+ return [4 /*yield*/, user.hover(icon)];
180
+ case 1:
181
+ _b.sent();
182
+ _a = expect;
183
+ return [4 /*yield*/, react_2.screen.findByText('This is a control attribute. Changing this value will affect availability of other conditional attributes.')];
184
+ case 2:
185
+ _a.apply(void 0, [_b.sent()]).toBeInTheDocument();
186
+ return [2 /*return*/];
187
+ }
188
+ });
189
+ }); });
126
190
  });
@@ -1,20 +1,48 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.EmptyRenderer = void 0;
7
- var react_1 = __importDefault(require("react"));
30
+ var react_1 = __importStar(require("react"));
8
31
  var classnames_1 = __importDefault(require("classnames"));
9
32
  var AttributeTitle_1 = require("../../../AttributeTitle");
10
33
  var DescriptionIcon_1 = require("../../../DescriptionIcon");
34
+ var ControlAttributeIcon_1 = require("../../../ControlAttributeIcon");
35
+ var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
11
36
  var styles_1 = require("../../styles");
12
37
  var EmptyRenderer = function (_a) {
13
38
  var attributeType = _a.attributeType, classes = _a.classes;
14
39
  var styles = (0, styles_1.useEmptyStyles)();
15
40
  var label = attributeType.label, description = attributeType.description;
41
+ var controlAttributes = (0, MdmModuleContext_1.useMdmControlAttributes)();
42
+ var isControlAttribute = (0, react_1.useMemo)(function () { return controlAttributes.includes(attributeType.uri); }, [controlAttributes, attributeType.uri]);
16
43
  return (react_1.default.createElement("div", { "data-reltio-id": "reltio-empty-renderer", className: (0, classnames_1.default)(styles.titleRow, styles.wrapper) },
17
44
  react_1.default.createElement(AttributeTitle_1.AttributeTitle, { label: label, className: (0, classnames_1.default)(styles.title, classes === null || classes === void 0 ? void 0 : classes.title), "data-reltio-id": "reltio-attribute-label" }),
45
+ isControlAttribute && react_1.default.createElement(ControlAttributeIcon_1.ControlAttributeIcon, null),
18
46
  react_1.default.createElement(DescriptionIcon_1.DescriptionIcon, { description: description, className: styles.descriptionIcon })));
19
47
  };
20
48
  exports.EmptyRenderer = EmptyRenderer;
@@ -9,11 +9,48 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
+ };
12
48
  import React from 'react';
13
49
  import { Mode } from '@reltio/mdm-sdk';
14
50
  import { AttributesView } from './AttributesView';
15
51
  import { MdmModuleProvider } from '../contexts/MdmModuleContext';
16
- import { render, screen } from '@testing-library/react';
52
+ import { render, screen, within } from '@testing-library/react';
53
+ import userEvent from '@testing-library/user-event';
17
54
  describe('AttributesView tests', function () {
18
55
  var entity = {
19
56
  type: 'configuration/entityTypes/HCP',
@@ -65,7 +102,8 @@ describe('AttributesView tests', function () {
65
102
  var mdmDefaultValues = {
66
103
  metadata: metadata,
67
104
  modifiedEntities: { 'entities/02ZRRE9': entity },
68
- dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] }
105
+ dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] },
106
+ controlAttributes: ['configuration/entityTypes/HCP/attributes/Phone']
69
107
  };
70
108
  var setUp = function (props, mdmValues) {
71
109
  if (props === void 0) { props = {}; }
@@ -74,7 +112,8 @@ describe('AttributesView tests', function () {
74
112
  var children = _a.children;
75
113
  return (React.createElement(MdmModuleProvider, { values: mdmValues, actions: actions }, children));
76
114
  };
77
- return render(React.createElement(AttributesView, __assign({}, props)), { wrapper: Providers });
115
+ var user = userEvent.setup();
116
+ return __assign(__assign({}, render(React.createElement(AttributesView, __assign({}, props)), { wrapper: Providers })), { user: user });
78
117
  };
79
118
  it('should render ReadOnlyAttributesView in read mode if mode is "viewing"', function () {
80
119
  setUp({ mode: Mode.Viewing, entity: entity });
@@ -118,4 +157,29 @@ describe('AttributesView tests', function () {
118
157
  expect(screen.getByText('Last Name')).toBeInTheDocument();
119
158
  expect(screen.getByText('Phone')).toBeInTheDocument();
120
159
  });
160
+ it('should show control attribute icon if an attribute is a always visible control attribute in view mode', function () { return __awaiter(void 0, void 0, void 0, function () {
161
+ var alwaysVisible, user, controlAttribute, icon, _a;
162
+ return __generator(this, function (_b) {
163
+ switch (_b.label) {
164
+ case 0:
165
+ alwaysVisible = [
166
+ 'configuration/entityTypes/HCP/attributes/LastName',
167
+ 'configuration/entityTypes/HCP/attributes/Phone'
168
+ ];
169
+ user = setUp({ mode: Mode.Editing, entity: entity, alwaysVisible: alwaysVisible }).user;
170
+ expect(screen.getByText('Last Name')).toBeInTheDocument();
171
+ expect(screen.getByText('Phone')).toBeInTheDocument();
172
+ controlAttribute = screen.getByText('Phone').closest('div');
173
+ icon = within(controlAttribute).getByTestId('reltio-control-attribute-icon');
174
+ return [4 /*yield*/, user.hover(icon)];
175
+ case 1:
176
+ _b.sent();
177
+ _a = expect;
178
+ return [4 /*yield*/, screen.findByText('This is a control attribute. Changing this value will affect availability of other conditional attributes.')];
179
+ case 2:
180
+ _a.apply(void 0, [_b.sent()]).toBeInTheDocument();
181
+ return [2 /*return*/];
182
+ }
183
+ });
184
+ }); });
121
185
  });
@@ -1,13 +1,18 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { AttributeTitle } from '../../../AttributeTitle';
4
4
  import { DescriptionIcon } from '../../../DescriptionIcon';
5
+ import { ControlAttributeIcon } from '../../../ControlAttributeIcon';
6
+ import { useMdmControlAttributes } from '../../../contexts/MdmModuleContext';
5
7
  import { useEmptyStyles } from '../../styles';
6
8
  export var EmptyRenderer = function (_a) {
7
9
  var attributeType = _a.attributeType, classes = _a.classes;
8
10
  var styles = useEmptyStyles();
9
11
  var label = attributeType.label, description = attributeType.description;
12
+ var controlAttributes = useMdmControlAttributes();
13
+ var isControlAttribute = useMemo(function () { return controlAttributes.includes(attributeType.uri); }, [controlAttributes, attributeType.uri]);
10
14
  return (React.createElement("div", { "data-reltio-id": "reltio-empty-renderer", className: classnames(styles.titleRow, styles.wrapper) },
11
15
  React.createElement(AttributeTitle, { label: label, className: classnames(styles.title, classes === null || classes === void 0 ? void 0 : classes.title), "data-reltio-id": "reltio-attribute-label" }),
16
+ isControlAttribute && React.createElement(ControlAttributeIcon, null),
12
17
  React.createElement(DescriptionIcon, { description: description, className: styles.descriptionIcon })));
13
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1961",
3
+ "version": "1.4.1962",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",