@reltio/components 1.4.832 → 1.4.836
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/components/DropDownMenuButton/DropDownMenuButton.js +1 -1
- package/components/attributes/inline/ComplexAttribute/ComplexAttribute.js +2 -2
- package/components/attributes/inline/SimpleAttribute/SimpleAttribute.js +8 -2
- package/components/attributes/inline/hooks/useAttributeState.d.ts +2 -2
- package/components/attributes/inline/hooks/useAttributeState.js +4 -4
- package/components/crosswalks/hooks/useModifiedEntity.d.ts +1 -1
- package/components/crosswalks/hooks/useModifiedEntity.js +23 -20
- package/package.json +3 -3
|
@@ -50,7 +50,7 @@ function DropDownMenuButton(_a) {
|
|
|
50
50
|
var _k = react_1.useState(false), isOpen = _k[0], setIsOpen = _k[1];
|
|
51
51
|
hooks_1.useDidUpdateEffect(function () {
|
|
52
52
|
isOpen ? onMenuOpen() : onMenuClose();
|
|
53
|
-
}, [isOpen
|
|
53
|
+
}, [isOpen]);
|
|
54
54
|
var handleToggle = react_1.useCallback(function (e) {
|
|
55
55
|
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
56
56
|
setIsOpen(function (open) { return !open; });
|
|
@@ -39,7 +39,7 @@ var styles_1 = require("./styles");
|
|
|
39
39
|
var ComplexAttribute = function (_a) {
|
|
40
40
|
var attributeType = _a.attributeType, attributeValue = _a.attributeValue, attributeTypesList = _a.attributeTypesList, label = _a.label, crosswalksMap = _a.crosswalksMap, _b = _a.allowEdit, allowEdit = _b === void 0 ? true : _b, _c = _a.allowDelete, allowDelete = _c === void 0 ? true : _c, onPin = _a.onPin, onIgnore = _a.onIgnore, onDelete = _a.onDelete, onEdit = _a.onEdit, onAdd = _a.onAdd;
|
|
41
41
|
var styles = styles_1.useStyles();
|
|
42
|
-
var _d = useAttributeState_1.useAttributeState(), isReadingMode = _d.isReadingMode,
|
|
42
|
+
var _d = useAttributeState_1.useAttributeState(), isReadingMode = _d.isReadingMode, onMouseEnter = _d.onMouseEnter, onMouseLeave = _d.onMouseLeave;
|
|
43
43
|
var canEdit = allowEdit && mdm_sdk_1.checkMetadataForUpdate(mdm_sdk_1.ModeTypes.EDITING, attributeType);
|
|
44
44
|
var canDelete = allowDelete && mdm_sdk_1.checkMetadataForDelete(mdm_sdk_1.ModeTypes.EDITING, attributeType);
|
|
45
45
|
var isTemporary = mdm_sdk_1.isTempUri(attributeValue.uri);
|
|
@@ -54,7 +54,7 @@ var ComplexAttribute = function (_a) {
|
|
|
54
54
|
}, [expandedFromContext]);
|
|
55
55
|
var crosswalks = ramda_1.pipe(ramda_1.pickBy(function (val, attrUri) { return mdm_sdk_1.areOneHierarchyUris(attrUri, attributeValue === null || attributeValue === void 0 ? void 0 : attributeValue.uri); }), ramda_1.values, ramda_1.flatten, ramda_1.uniqBy(ramda_1.prop('uri')))(crosswalksMap);
|
|
56
56
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
57
|
-
react_1.default.createElement("div", { className: styles.root,
|
|
57
|
+
react_1.default.createElement("div", { className: styles.root, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave },
|
|
58
58
|
react_1.default.createElement(ArrowExpandButton_1.default, { onClick: function () { return setExpanded(function (value) { return !value; }); }, expanded: expanded }),
|
|
59
59
|
react_1.default.createElement("span", null,
|
|
60
60
|
label,
|
|
@@ -41,7 +41,7 @@ var contexts_1 = require("../../../../contexts");
|
|
|
41
41
|
var styles_1 = require("./styles");
|
|
42
42
|
var SimpleAttribute = function (_a) {
|
|
43
43
|
var className = _a.className, dataReltioId = _a.dataReltioId, _b = _a.attributeType, attributeType = _b === void 0 ? null : _b, attributeValue = _a.attributeValue, crosswalk = _a.crosswalk, _c = _a.allowEdit, allowEdit = _c === void 0 ? true : _c, _d = _a.allowDelete, allowDelete = _d === void 0 ? true : _d, onIgnore = _a.onIgnore, onEdit = _a.onEdit, onPin = _a.onPin, onDelete = _a.onDelete;
|
|
44
|
-
var _e = useAttributeState_1.useAttributeState(), isReadingMode = _e.isReadingMode, isEditingMode = _e.isEditingMode, isHovered = _e.isHovered,
|
|
44
|
+
var _e = useAttributeState_1.useAttributeState(), isReadingMode = _e.isReadingMode, isEditingMode = _e.isEditingMode, isHovered = _e.isHovered, onMouseEnter = _e.onMouseEnter, onMouseLeave = _e.onMouseLeave, setReadingMode = _e.setReadingMode, setEditingMode = _e.setEditingMode;
|
|
45
45
|
var containerRef = react_1.useRef();
|
|
46
46
|
var id = mdm_sdk_1.getLastUriPart(attributeValue.uri);
|
|
47
47
|
var crosswalkDisabled = mdm_sdk_1.isCrosswalkDisabled(crosswalk);
|
|
@@ -91,7 +91,13 @@ var SimpleAttribute = function (_a) {
|
|
|
91
91
|
removeHighlight();
|
|
92
92
|
setReadingMode();
|
|
93
93
|
};
|
|
94
|
-
return (react_1.default.createElement("div", { ref: containerRef, className: classnames_1.default(className, styles.root), onMouseEnter: function () {
|
|
94
|
+
return (react_1.default.createElement("div", { ref: containerRef, className: classnames_1.default(className, styles.root), onMouseEnter: function () {
|
|
95
|
+
highlightCrosswalk();
|
|
96
|
+
onMouseEnter();
|
|
97
|
+
}, onMouseLeave: function () {
|
|
98
|
+
removeHighlight();
|
|
99
|
+
onMouseLeave();
|
|
100
|
+
}, "data-reltio-id": dataReltioId },
|
|
95
101
|
react_1.default.createElement("div", { className: styles.attributeValue },
|
|
96
102
|
react_1.default.createElement(DataTypeValue_1.default, { value: mdm_sdk_1.getAttributeValue(attributeValue), dataTypeDefinition: mdm_sdk_1.getAttrDataTypeDefinition(attributeType) })),
|
|
97
103
|
react_1.default.createElement("div", { className: styles.actions },
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const useAttributeState: () => {
|
|
2
2
|
setReadingMode: () => void;
|
|
3
3
|
setEditingMode: () => void;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
onMouseLeave: () => void;
|
|
5
|
+
onMouseEnter: () => void;
|
|
6
6
|
isReadingMode: boolean;
|
|
7
7
|
isEditingMode: boolean;
|
|
8
8
|
isHovered: boolean;
|
|
@@ -20,11 +20,11 @@ var useAttributeState = function () {
|
|
|
20
20
|
}, []);
|
|
21
21
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
22
|
var setAttributeStateDebounced = react_1.useCallback(mdm_sdk_1.debounce(setAttributeState, HIDE_INTERVAL), []);
|
|
23
|
-
var
|
|
23
|
+
var onMouseEnter = react_1.useCallback(function () {
|
|
24
24
|
if (!isEditingMode)
|
|
25
25
|
setAttributeStateDebounced(AttributeStates.HOVERED);
|
|
26
26
|
}, [setAttributeStateDebounced, isEditingMode]);
|
|
27
|
-
var
|
|
27
|
+
var onMouseLeave = react_1.useCallback(function () {
|
|
28
28
|
if (!isEditingMode)
|
|
29
29
|
setAttributeStateDebounced(AttributeStates.READING);
|
|
30
30
|
}, [setAttributeStateDebounced, isEditingMode]);
|
|
@@ -33,8 +33,8 @@ var useAttributeState = function () {
|
|
|
33
33
|
return {
|
|
34
34
|
setReadingMode: setReadingMode,
|
|
35
35
|
setEditingMode: setEditingMode,
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
onMouseLeave: onMouseLeave,
|
|
37
|
+
onMouseEnter: onMouseEnter,
|
|
38
38
|
isReadingMode: isReadingMode,
|
|
39
39
|
isEditingMode: isEditingMode,
|
|
40
40
|
isHovered: isHovered
|
|
@@ -15,6 +15,6 @@ export declare const useModifiedEntity: ({ entity, onLoad, onModify, onError }:
|
|
|
15
15
|
onPinAttribute: ({ attributeValue }: import("../../attributes/inline").PinInlineAttributeEvent) => void;
|
|
16
16
|
onIgnoreAttribute: ({ attributeValue }: import("../../attributes/inline").IgnoreInlineAttributeEvent) => void;
|
|
17
17
|
onEditAttribute: (event: EditInlineAttributeEvent) => void;
|
|
18
|
-
|
|
18
|
+
newlyCreatedAttributes: string[];
|
|
19
19
|
};
|
|
20
20
|
export {};
|
|
@@ -22,16 +22,17 @@ var useAttributeActions_1 = require("./useAttributeActions");
|
|
|
22
22
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
23
23
|
var ramda_1 = require("ramda");
|
|
24
24
|
var core_1 = require("../../../core");
|
|
25
|
+
var emptyArray = [];
|
|
25
26
|
var useModifiedEntity = function (_a) {
|
|
26
27
|
var entity = _a.entity, _b = _a.onLoad, onLoad = _b === void 0 ? core_1.noop : _b, _c = _a.onModify, onModify = _c === void 0 ? core_1.noop : _c, _d = _a.onError, onError = _d === void 0 ? core_1.noop : _d;
|
|
27
28
|
var _e = react_1.useState(null), modifiedEntity = _e[0], setModifiedEntity = _e[1];
|
|
28
29
|
var _f = react_1.useState(null), crosswalksMap = _f[0], setCrosswalksMap = _f[1];
|
|
29
30
|
var temporaryAttributes = react_1.useRef([]);
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
|
|
31
|
+
var crosswalkForNewAttributes = react_1.useRef(null);
|
|
32
|
+
var resetCrosswalkForNewAttributes = react_1.useCallback(function () {
|
|
33
|
+
crosswalkForNewAttributes.current = null;
|
|
33
34
|
}, []);
|
|
34
|
-
var _g = react_1.useState(
|
|
35
|
+
var _g = react_1.useState(emptyArray), newlyCreatedAttributes = _g[0], setNewlyCreatedAttributes = _g[1];
|
|
35
36
|
var groupCrosswalksByAttrUri = function (crosswalks) {
|
|
36
37
|
if (crosswalks === void 0) { crosswalks = []; }
|
|
37
38
|
return crosswalks.reduce(function (acc, crosswalk) {
|
|
@@ -42,23 +43,28 @@ var useModifiedEntity = function (_a) {
|
|
|
42
43
|
}, {});
|
|
43
44
|
};
|
|
44
45
|
react_1.useEffect(function () {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
var newCrosswalksMap = {
|
|
47
|
+
entity: groupCrosswalksByAttrUri(entity === null || entity === void 0 ? void 0 : entity.crosswalks),
|
|
48
|
+
relation: ramda_1.pipe(mdm_sdk_1.getRelationCrosswalks, groupCrosswalksByAttrUri)(entity)
|
|
49
|
+
};
|
|
50
|
+
if ((modifiedEntity === null || modifiedEntity === void 0 ? void 0 : modifiedEntity.uri) === (entity === null || entity === void 0 ? void 0 : entity.uri) && crosswalkForNewAttributes.current) {
|
|
51
|
+
var ownerType = crosswalkForNewAttributes.current.ownerType;
|
|
52
|
+
var newAttributes = Object.keys(newCrosswalksMap[ownerType]);
|
|
53
|
+
var oldAttributes = Object.keys(crosswalksMap[ownerType]);
|
|
54
|
+
setNewlyCreatedAttributes(ramda_1.difference(newAttributes, oldAttributes));
|
|
49
55
|
}
|
|
50
56
|
else {
|
|
51
|
-
|
|
57
|
+
setNewlyCreatedAttributes(emptyArray);
|
|
52
58
|
}
|
|
53
|
-
|
|
59
|
+
resetCrosswalkForNewAttributes();
|
|
54
60
|
setModifiedEntity(entity);
|
|
55
|
-
setCrosswalksMap(
|
|
56
|
-
entity: groupCrosswalksByAttrUri(entity === null || entity === void 0 ? void 0 : entity.crosswalks),
|
|
57
|
-
relation: ramda_1.pipe(mdm_sdk_1.getRelationCrosswalks, groupCrosswalksByAttrUri)(entity)
|
|
58
|
-
});
|
|
61
|
+
setCrosswalksMap(newCrosswalksMap);
|
|
59
62
|
temporaryAttributes.current = [];
|
|
60
63
|
}, [entity]);
|
|
61
|
-
var handleError = react_1.useCallback(ramda_1.pipe(onError,
|
|
64
|
+
var handleError = react_1.useCallback(ramda_1.pipe(onError, resetCrosswalkForNewAttributes), [
|
|
65
|
+
onError,
|
|
66
|
+
resetCrosswalkForNewAttributes
|
|
67
|
+
]);
|
|
62
68
|
var _h = useAttributeActions_1.useAttributeActions({
|
|
63
69
|
onLoad: onLoad,
|
|
64
70
|
onSuccess: onModify,
|
|
@@ -118,10 +124,7 @@ var useModifiedEntity = function (_a) {
|
|
|
118
124
|
attributeValue: mdm_sdk_1.findAttributeValueByUri(editedEntity, tempAttributeUri),
|
|
119
125
|
crosswalk: crosswalk
|
|
120
126
|
});
|
|
121
|
-
|
|
122
|
-
if (!mdm_sdk_1.isFirstLevelAttributeValueUri(uri_1) && mdm_sdk_1.isTempUri(parentUri)) {
|
|
123
|
-
futureNestedAttributes.current.push(parentUri);
|
|
124
|
-
}
|
|
127
|
+
crosswalkForNewAttributes.current = crosswalk;
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
130
|
else {
|
|
@@ -136,7 +139,7 @@ var useModifiedEntity = function (_a) {
|
|
|
136
139
|
onPinAttribute: pinAttribute,
|
|
137
140
|
onIgnoreAttribute: ignoreAttribute,
|
|
138
141
|
onEditAttribute: onEditAttribute,
|
|
139
|
-
|
|
142
|
+
newlyCreatedAttributes: newlyCreatedAttributes
|
|
140
143
|
};
|
|
141
144
|
};
|
|
142
145
|
exports.useModifiedEntity = useModifiedEntity;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.836",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@date-io/moment": "^1.3.5",
|
|
8
8
|
"@react-google-maps/api": "^2.7.0",
|
|
9
|
-
"@reltio/mdm-module": "^1.4.
|
|
10
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
9
|
+
"@reltio/mdm-module": "^1.4.836",
|
|
10
|
+
"@reltio/mdm-sdk": "^1.4.836",
|
|
11
11
|
"classnames": "^2.2.5",
|
|
12
12
|
"frontend-collective-react-dnd-scrollzone": "^1.0.2",
|
|
13
13
|
"nanoid": "^2.0.0",
|