@reltio/components 1.4.1558 → 1.4.1559

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.
@@ -116,7 +116,7 @@ var AttributeRenderer = function (_a) {
116
116
  isEditableMode && react_1.default.createElement(CardinalityMessage_1.default, { cardinality: cardinality }),
117
117
  isEditableMode && react_1.default.createElement(ErrorMessage_1.default, { message: errorMessage, className: styles.typeError }),
118
118
  react_1.default.createElement("div", { className: styles.attributesWrapper },
119
- shownValues.map(function (value, idx) { return (react_1.default.createElement(Attribute_1.default, { key: value.uri, attributeValue: value, attributeType: attributeType, lazy: showEmpty && !isRequired, showEmptyEditors: showEmptyEditors, errors: errors, ownError: (0, mdm_sdk_1.getAttributeOwnError)(value, idx, attributeType.uri, errors), mode: mode, crosswalks: crosswalks, onAddOneMore: lastIndex === idx ? onAddOneMore : null, onAddAttributes: onAddAttributes, onDeleteAttribute: onDelete, onChangeAttribute: onChangeAttribute, onDeactivateError: onDeactivateError, additionalControlsRenderer: additionalControlsRenderer, className: idx === 0 ? highlightedClassName : null, ref: idx === 0 ? attributeRef : null })); }),
119
+ shownValues.map(function (value, idx) { return (react_1.default.createElement(Attribute_1.default, { key: value.uri, attributeValue: value, attributeType: attributeType, lazy: showEmpty && !isRequired, showEmptyEditors: showEmptyEditors, errors: errors, ownError: (0, mdm_sdk_1.getAttributeOwnError)(value, idx, attributeType.uri, errors), mode: mode, crosswalks: crosswalks, onAddOneMore: lastIndex === idx ? onAddOneMore : null, onAddAttributes: onAddAttributes, onDeleteAttribute: onDelete, onChangeAttribute: onChangeAttribute, onDeactivateError: onDeactivateError, additionalControlsRenderer: additionalControlsRenderer, className: idx === 0 ? highlightedClassName : null, ref: idx === 0 ? attributeRef : null, isEmptyEditor: showEmpty })); }),
120
120
  showMore && (react_1.default.createElement(ShowMore_1.default, { moreNumber: (0, ramda_1.min)(max, hiddenValuesCount), valueNumber: hiddenValuesCount, onClick: onShowMore })),
121
121
  showLess && react_1.default.createElement(ShowLess_1.default, { onClick: onShowLess })))));
122
122
  };
@@ -113,7 +113,7 @@ var ComplexAttribute = function (_a) {
113
113
  ui_i18n_1.default.text('edited'),
114
114
  ")")),
115
115
  additionalControlsRenderer && additionalControlsRenderer({ attributeType: attributeType, attributeValue: attributeValue }),
116
- showDeleteButton && react_1.default.createElement(SmallIconButton_1.default, { icon: Delete_1.default, onClick: onDeleteThis, size: "L" }))),
116
+ showDeleteButton && (react_1.default.createElement(SmallIconButton_1.default, { icon: Delete_1.default, onClick: onDeleteThis, size: "L", "data-reltio-id": "reltio-delete-complex-attribute-button" })))),
117
117
  expanded && (react_1.default.createElement(AttributesList_1.default, { parentAttributeType: attributeType, attrTypes: attributeTypesList, entity: attributeListEntity, showEmptyEditors: showEmptyEditors || isNew, drawLines: true, parentUri: uri, mode: mode, crosswalks: crosswalks, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute, additionalControlsRenderer: additionalControlsRenderer, showNonOv: showNonOv }, children))));
118
118
  };
119
119
  ComplexAttribute.propTypes = __assign({ label: prop_types_1.default.string, children: prop_types_1.default.node, attributeTypesList: prop_types_1.default.arrayOf(mdm_sdk_1.AttributeTypeType), attributeValue: prop_types_1.default.oneOfType([mdm_sdk_1.NestedAttributeValueType, mdm_sdk_1.ReferenceAttributeValueType]), highlightedError: prop_types_1.default.object, isHighlightedPath: prop_types_1.default.bool }, mdm_sdk_1.ComplexAttributeType);
@@ -76,7 +76,7 @@ var AsyncMountPlaceholder = function () {
76
76
  };
77
77
  var SimpleAttributeEditor = function (_a) {
78
78
  var _b, _c;
79
- var className = _a.className, attributeValue = _a.attributeValue, attributeType = _a.attributeType, isReltioCrosswalk = _a.isReltioCrosswalk, ownError = _a.ownError, mode = _a.mode, onAddOneMore = _a.onAddOneMore, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onDeactivateError = _a.onDeactivateError, additionalControlsRenderer = _a.additionalControlsRenderer, state = _a.state, highlightedError = _a.highlightedError, otherProps = __rest(_a, ["className", "attributeValue", "attributeType", "isReltioCrosswalk", "ownError", "mode", "onAddOneMore", "onDeleteAttribute", "onChangeAttribute", "onDeactivateError", "additionalControlsRenderer", "state", "highlightedError"]);
79
+ var className = _a.className, attributeValue = _a.attributeValue, attributeType = _a.attributeType, isReltioCrosswalk = _a.isReltioCrosswalk, ownError = _a.ownError, mode = _a.mode, onAddOneMore = _a.onAddOneMore, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onDeactivateError = _a.onDeactivateError, additionalControlsRenderer = _a.additionalControlsRenderer, state = _a.state, highlightedError = _a.highlightedError, _d = _a.isEmptyEditor, isEmptyEditor = _d === void 0 ? false : _d, otherProps = __rest(_a, ["className", "attributeValue", "attributeType", "isReltioCrosswalk", "ownError", "mode", "onAddOneMore", "onDeleteAttribute", "onChangeAttribute", "onDeactivateError", "additionalControlsRenderer", "state", "highlightedError", "isEmptyEditor"]);
80
80
  var styles = (0, styles_1.useStyles)();
81
81
  var deleted = state === 'deleted';
82
82
  var edited = state === 'edited';
@@ -91,7 +91,18 @@ var SimpleAttributeEditor = function (_a) {
91
91
  ? (0, getDependentLookupEditorContext_1.getDependentLookupEditorContext)(state, attributeValue, attributeType === null || attributeType === void 0 ? void 0 : attributeType.uri)
92
92
  : null;
93
93
  });
94
- var _d = (0, hooks_1.useScrollToAttributeError)({ highlightedError: highlightedError, isSimple: true }), ref = _d.ref, errorClassName = _d.errorClassName;
94
+ var _e = (0, hooks_1.useScrollToAttributeError)({ highlightedError: highlightedError, isSimple: true }), ref = _e.ref, errorClassName = _e.errorClassName;
95
+ (0, react_1.useEffect)(function () {
96
+ // when editor is empty but has default lookup code, onChangeAttribute will be called by useLookupsResolver
97
+ if (isEmptyEditor && (0, mdm_sdk_1.isDependentLookupAttrType)(attributeType) && !(0, ramda_1.has)('lookupCode', attributeValue)) {
98
+ onChangeAttribute({
99
+ attributeType: attributeType,
100
+ uri: attributeValue.uri,
101
+ value: attributeValue.value,
102
+ silent: true
103
+ });
104
+ }
105
+ }, [isEmptyEditor]);
95
106
  var dataTypeDefinition = (0, react_1.useMemo)(function () { return (0, mdm_sdk_1.getAttrDataTypeDefinition)(attributeType); }, [attributeType]);
96
107
  var value = (0, react_1.useMemo)(function () { return (0, utils_1.attributeValueToEditorValue)(attributeValue, dataTypeDefinition); }, [attributeValue, dataTypeDefinition]);
97
108
  var deactivateError = (0, react_1.useCallback)(function () {
@@ -127,7 +138,7 @@ var SimpleAttributeEditor = function (_a) {
127
138
  ")")),
128
139
  showAddButton && (react_1.default.createElement(SmallIconButton_1.default, { icon: Add_1.default, onClick: onAddOneMore, size: "L", className: (0, classnames_1.default)(styles.addButton, styles.button) })),
129
140
  additionalControlsRenderer && additionalControlsRenderer({ attributeType: attributeType, attributeValue: attributeValue }),
130
- showDeleteButton && (react_1.default.createElement(SmallIconButton_1.default, { className: styles.button, icon: Delete_1.default, onClick: onDelete, size: "L" })))));
141
+ showDeleteButton && (react_1.default.createElement(SmallIconButton_1.default, { className: styles.button, icon: Delete_1.default, onClick: onDelete, size: "L", "data-reltio-id": "reltio-delete-simple-attribute-button" })))));
131
142
  };
132
143
  SimpleAttributeEditor.propTypes = {
133
144
  className: prop_types_1.default.string,
@@ -142,7 +153,8 @@ SimpleAttributeEditor.propTypes = {
142
153
  onChangeAttribute: prop_types_1.default.func,
143
154
  onDeactivateError: prop_types_1.default.func,
144
155
  additionalControlsRenderer: prop_types_1.default.func,
145
- highlightedError: prop_types_1.default.object
156
+ highlightedError: prop_types_1.default.object,
157
+ isEmptyEditor: prop_types_1.default.bool
146
158
  };
147
159
  exports.default = (0, withAsyncMount_1.default)((0, HOCs_1.withContext)(contexts_1.ScrollToElementContext, function (contextValue, _a) {
148
160
  var attributeValue = _a.attributeValue;
@@ -88,7 +88,7 @@ var AttributeRenderer = function (_a) {
88
88
  isEditableMode && React.createElement(Cardinality, { cardinality: cardinality }),
89
89
  isEditableMode && React.createElement(ErrorMessage, { message: errorMessage, className: styles.typeError }),
90
90
  React.createElement("div", { className: styles.attributesWrapper },
91
- shownValues.map(function (value, idx) { return (React.createElement(Attribute, { key: value.uri, attributeValue: value, attributeType: attributeType, lazy: showEmpty && !isRequired, showEmptyEditors: showEmptyEditors, errors: errors, ownError: getAttributeOwnError(value, idx, attributeType.uri, errors), mode: mode, crosswalks: crosswalks, onAddOneMore: lastIndex === idx ? onAddOneMore : null, onAddAttributes: onAddAttributes, onDeleteAttribute: onDelete, onChangeAttribute: onChangeAttribute, onDeactivateError: onDeactivateError, additionalControlsRenderer: additionalControlsRenderer, className: idx === 0 ? highlightedClassName : null, ref: idx === 0 ? attributeRef : null })); }),
91
+ shownValues.map(function (value, idx) { return (React.createElement(Attribute, { key: value.uri, attributeValue: value, attributeType: attributeType, lazy: showEmpty && !isRequired, showEmptyEditors: showEmptyEditors, errors: errors, ownError: getAttributeOwnError(value, idx, attributeType.uri, errors), mode: mode, crosswalks: crosswalks, onAddOneMore: lastIndex === idx ? onAddOneMore : null, onAddAttributes: onAddAttributes, onDeleteAttribute: onDelete, onChangeAttribute: onChangeAttribute, onDeactivateError: onDeactivateError, additionalControlsRenderer: additionalControlsRenderer, className: idx === 0 ? highlightedClassName : null, ref: idx === 0 ? attributeRef : null, isEmptyEditor: showEmpty })); }),
92
92
  showMore && (React.createElement(ShowMore, { moreNumber: min(max, hiddenValuesCount), valueNumber: hiddenValuesCount, onClick: onShowMore })),
93
93
  showLess && React.createElement(ShowLess, { onClick: onShowLess })))));
94
94
  };
@@ -85,7 +85,7 @@ var ComplexAttribute = function (_a) {
85
85
  i18n.text('edited'),
86
86
  ")")),
87
87
  additionalControlsRenderer && additionalControlsRenderer({ attributeType: attributeType, attributeValue: attributeValue }),
88
- showDeleteButton && React.createElement(SmallIconButton, { icon: DeleteIcon, onClick: onDeleteThis, size: "L" }))),
88
+ showDeleteButton && (React.createElement(SmallIconButton, { icon: DeleteIcon, onClick: onDeleteThis, size: "L", "data-reltio-id": "reltio-delete-complex-attribute-button" })))),
89
89
  expanded && (React.createElement(AttributesList, { parentAttributeType: attributeType, attrTypes: attributeTypesList, entity: attributeListEntity, showEmptyEditors: showEmptyEditors || isNew, drawLines: true, parentUri: uri, mode: mode, crosswalks: crosswalks, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute, additionalControlsRenderer: additionalControlsRenderer, showNonOv: showNonOv }, children))));
90
90
  };
91
91
  ComplexAttribute.propTypes = __assign({ label: PropTypes.string, children: PropTypes.node, attributeTypesList: PropTypes.arrayOf(AttributeTypeType), attributeValue: PropTypes.oneOfType([NestedAttributeValueType, ReferenceAttributeValueType]), highlightedError: PropTypes.object, isHighlightedPath: PropTypes.bool }, ComplexAttributeType);
@@ -20,11 +20,11 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import React, { useCallback, useContext, useMemo } from 'react';
23
+ import React, { useCallback, useContext, useEffect, useMemo } from 'react';
24
24
  import PropTypes from 'prop-types';
25
25
  import { useSelector } from 'react-redux';
26
26
  import classnames from 'classnames';
27
- import { pipe } from 'ramda';
27
+ import { has, pipe } from 'ramda';
28
28
  import AddIcon from '@material-ui/icons/Add';
29
29
  import DeleteIcon from '@material-ui/icons/Delete';
30
30
  import Typography from '@material-ui/core/Typography';
@@ -48,7 +48,7 @@ var AsyncMountPlaceholder = function () {
48
48
  };
49
49
  var SimpleAttributeEditor = function (_a) {
50
50
  var _b, _c;
51
- var className = _a.className, attributeValue = _a.attributeValue, attributeType = _a.attributeType, isReltioCrosswalk = _a.isReltioCrosswalk, ownError = _a.ownError, mode = _a.mode, onAddOneMore = _a.onAddOneMore, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onDeactivateError = _a.onDeactivateError, additionalControlsRenderer = _a.additionalControlsRenderer, state = _a.state, highlightedError = _a.highlightedError, otherProps = __rest(_a, ["className", "attributeValue", "attributeType", "isReltioCrosswalk", "ownError", "mode", "onAddOneMore", "onDeleteAttribute", "onChangeAttribute", "onDeactivateError", "additionalControlsRenderer", "state", "highlightedError"]);
51
+ var className = _a.className, attributeValue = _a.attributeValue, attributeType = _a.attributeType, isReltioCrosswalk = _a.isReltioCrosswalk, ownError = _a.ownError, mode = _a.mode, onAddOneMore = _a.onAddOneMore, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onDeactivateError = _a.onDeactivateError, additionalControlsRenderer = _a.additionalControlsRenderer, state = _a.state, highlightedError = _a.highlightedError, _d = _a.isEmptyEditor, isEmptyEditor = _d === void 0 ? false : _d, otherProps = __rest(_a, ["className", "attributeValue", "attributeType", "isReltioCrosswalk", "ownError", "mode", "onAddOneMore", "onDeleteAttribute", "onChangeAttribute", "onDeactivateError", "additionalControlsRenderer", "state", "highlightedError", "isEmptyEditor"]);
52
52
  var styles = useStyles();
53
53
  var deleted = state === 'deleted';
54
54
  var edited = state === 'edited';
@@ -63,7 +63,18 @@ var SimpleAttributeEditor = function (_a) {
63
63
  ? getDependentLookupEditorContext(state, attributeValue, attributeType === null || attributeType === void 0 ? void 0 : attributeType.uri)
64
64
  : null;
65
65
  });
66
- var _d = useScrollToAttributeError({ highlightedError: highlightedError, isSimple: true }), ref = _d.ref, errorClassName = _d.errorClassName;
66
+ var _e = useScrollToAttributeError({ highlightedError: highlightedError, isSimple: true }), ref = _e.ref, errorClassName = _e.errorClassName;
67
+ useEffect(function () {
68
+ // when editor is empty but has default lookup code, onChangeAttribute will be called by useLookupsResolver
69
+ if (isEmptyEditor && isDependentLookupAttrType(attributeType) && !has('lookupCode', attributeValue)) {
70
+ onChangeAttribute({
71
+ attributeType: attributeType,
72
+ uri: attributeValue.uri,
73
+ value: attributeValue.value,
74
+ silent: true
75
+ });
76
+ }
77
+ }, [isEmptyEditor]);
67
78
  var dataTypeDefinition = useMemo(function () { return getAttrDataTypeDefinition(attributeType); }, [attributeType]);
68
79
  var value = useMemo(function () { return attributeValueToEditorValue(attributeValue, dataTypeDefinition); }, [attributeValue, dataTypeDefinition]);
69
80
  var deactivateError = useCallback(function () {
@@ -99,7 +110,7 @@ var SimpleAttributeEditor = function (_a) {
99
110
  ")")),
100
111
  showAddButton && (React.createElement(SmallIconButton, { icon: AddIcon, onClick: onAddOneMore, size: "L", className: classnames(styles.addButton, styles.button) })),
101
112
  additionalControlsRenderer && additionalControlsRenderer({ attributeType: attributeType, attributeValue: attributeValue }),
102
- showDeleteButton && (React.createElement(SmallIconButton, { className: styles.button, icon: DeleteIcon, onClick: onDelete, size: "L" })))));
113
+ showDeleteButton && (React.createElement(SmallIconButton, { className: styles.button, icon: DeleteIcon, onClick: onDelete, size: "L", "data-reltio-id": "reltio-delete-simple-attribute-button" })))));
103
114
  };
104
115
  SimpleAttributeEditor.propTypes = {
105
116
  className: PropTypes.string,
@@ -114,7 +125,8 @@ SimpleAttributeEditor.propTypes = {
114
125
  onChangeAttribute: PropTypes.func,
115
126
  onDeactivateError: PropTypes.func,
116
127
  additionalControlsRenderer: PropTypes.func,
117
- highlightedError: PropTypes.object
128
+ highlightedError: PropTypes.object,
129
+ isEmptyEditor: PropTypes.bool
118
130
  };
119
131
  export default withAsyncMount(withContext(ScrollToElementContext, function (contextValue, _a) {
120
132
  var attributeValue = _a.attributeValue;
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1558",
3
+ "version": "1.4.1559",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
7
7
  "dependencies": {
8
8
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "2.7.0",
10
- "@reltio/mdm-module": "^1.4.1558",
11
- "@reltio/mdm-sdk": "^1.4.1558",
10
+ "@reltio/mdm-module": "^1.4.1559",
11
+ "@reltio/mdm-sdk": "^1.4.1559",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",