@reltio/components 1.4.896 → 1.4.900
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/components/SmallIconButton/SmallIconButton.d.ts +1 -1
- package/cjs/components/SmallIconButton/index.d.ts +2 -2
- package/cjs/components/attributes/PivotingAttributes/PivotingTooltipContent.js +11 -3
- package/cjs/components/attributes/PivotingAttributes/helpers.d.ts +4 -0
- package/cjs/components/attributes/PivotingAttributes/helpers.js +17 -1
- package/cjs/components/attributes/PivotingAttributes/styles.d.ts +1 -1
- package/cjs/components/attributes/PivotingAttributes/styles.js +3 -0
- package/cjs/components/workflow/cards/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +6 -12
- package/cjs/components/workflow/components/AttributesChanges/AttributesChanges.d.ts +8 -0
- package/cjs/components/workflow/components/AttributesChanges/AttributesChanges.js +47 -0
- package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.d.ts +11 -0
- package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.js +27 -0
- package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/styles.d.ts +1 -0
- package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/styles.js +55 -0
- package/cjs/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.d.ts +7 -0
- package/cjs/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.js +25 -0
- package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.d.ts +15 -0
- package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.js +61 -0
- package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.d.ts +5 -0
- package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.js +18 -0
- package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.d.ts +9 -0
- package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.js +18 -0
- package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.d.ts +1 -0
- package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.js +12 -0
- package/cjs/components/workflow/components/AttributesChanges/constants/operations.d.ts +25 -0
- package/cjs/components/workflow/components/AttributesChanges/constants/operations.js +30 -0
- package/cjs/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.d.ts +3 -0
- package/cjs/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.js +9 -0
- package/cjs/components/workflow/components/AttributesChanges/helpers/attributesHelpers.d.ts +2 -0
- package/cjs/components/workflow/components/AttributesChanges/helpers/attributesHelpers.js +89 -0
- package/cjs/components/workflow/components/AttributesChanges/helpers/contextHelpers.d.ts +1 -0
- package/cjs/components/workflow/components/AttributesChanges/helpers/contextHelpers.js +5 -0
- package/cjs/components/workflow/components/AttributesChanges/helpers/helpers.d.ts +12 -0
- package/cjs/components/workflow/components/AttributesChanges/helpers/helpers.js +88 -0
- package/cjs/components/workflow/components/AttributesChanges/helpers/mergeHelpers.d.ts +4 -0
- package/cjs/components/workflow/components/AttributesChanges/helpers/mergeHelpers.js +137 -0
- package/cjs/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.d.ts +6 -0
- package/cjs/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.js +18 -0
- package/cjs/components/workflow/components/AttributesChanges/styles.d.ts +1 -0
- package/cjs/components/workflow/components/AttributesChanges/styles.js +27 -0
- package/cjs/components/workflow/components/AttributesChanges/types/DCRTypes.d.ts +63 -0
- package/cjs/components/workflow/components/AttributesChanges/types/DCRTypes.js +2 -0
- package/cjs/components/workflow/components/LineDecorator/styles.js +4 -2
- package/esm/components/SmallIconButton/SmallIconButton.d.ts +1 -1
- package/esm/components/SmallIconButton/index.d.ts +2 -2
- package/esm/components/attributes/PivotingAttributes/PivotingTooltipContent.js +13 -5
- package/esm/components/attributes/PivotingAttributes/helpers.d.ts +4 -0
- package/esm/components/attributes/PivotingAttributes/helpers.js +15 -1
- package/esm/components/attributes/PivotingAttributes/styles.d.ts +1 -1
- package/esm/components/attributes/PivotingAttributes/styles.js +3 -0
- package/esm/components/workflow/cards/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +7 -13
- package/esm/components/workflow/components/AttributesChanges/AttributesChanges.d.ts +8 -0
- package/esm/components/workflow/components/AttributesChanges/AttributesChanges.js +23 -0
- package/esm/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.d.ts +11 -0
- package/esm/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.js +22 -0
- package/esm/components/workflow/components/AttributesChanges/components/ChangeView/styles.d.ts +1 -0
- package/esm/components/workflow/components/AttributesChanges/components/ChangeView/styles.js +52 -0
- package/esm/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.d.ts +7 -0
- package/esm/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.js +20 -0
- package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.d.ts +15 -0
- package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.js +37 -0
- package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.d.ts +5 -0
- package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.js +15 -0
- package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.d.ts +9 -0
- package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.js +13 -0
- package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.d.ts +1 -0
- package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.js +9 -0
- package/esm/components/workflow/components/AttributesChanges/constants/operations.d.ts +25 -0
- package/esm/components/workflow/components/AttributesChanges/constants/operations.js +27 -0
- package/esm/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.d.ts +3 -0
- package/esm/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.js +3 -0
- package/esm/components/workflow/components/AttributesChanges/helpers/attributesHelpers.d.ts +2 -0
- package/esm/components/workflow/components/AttributesChanges/helpers/attributesHelpers.js +86 -0
- package/esm/components/workflow/components/AttributesChanges/helpers/contextHelpers.d.ts +1 -0
- package/esm/components/workflow/components/AttributesChanges/helpers/contextHelpers.js +2 -0
- package/esm/components/workflow/components/AttributesChanges/helpers/helpers.d.ts +12 -0
- package/esm/components/workflow/components/AttributesChanges/helpers/helpers.js +77 -0
- package/esm/components/workflow/components/AttributesChanges/helpers/mergeHelpers.d.ts +4 -0
- package/esm/components/workflow/components/AttributesChanges/helpers/mergeHelpers.js +134 -0
- package/esm/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.d.ts +6 -0
- package/esm/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.js +14 -0
- package/esm/components/workflow/components/AttributesChanges/styles.d.ts +1 -0
- package/esm/components/workflow/components/AttributesChanges/styles.js +24 -0
- package/esm/components/workflow/components/AttributesChanges/types/DCRTypes.d.ts +63 -0
- package/esm/components/workflow/components/AttributesChanges/types/DCRTypes.js +1 -0
- package/esm/components/workflow/components/LineDecorator/styles.js +4 -2
- package/package.json +3 -3
package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
var react_1 = __importStar(require("react"));
|
|
26
|
+
var react_redux_1 = require("react-redux");
|
|
27
|
+
var ramda_1 = require("ramda");
|
|
28
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
29
|
+
var mdm_module_1 = __importDefault(require("@reltio/mdm-module"));
|
|
30
|
+
var ChangeView_1 = __importDefault(require("../ChangeView/ChangeView"));
|
|
31
|
+
var helpers_1 = require("../../helpers/helpers");
|
|
32
|
+
var EntityUriLink_1 = __importDefault(require("../../../../../EntityUriLink/EntityUriLink"));
|
|
33
|
+
var AttributesChangesContext_1 = require("../../contexts/AttributesChangesContext");
|
|
34
|
+
var DataTypeValue_1 = __importDefault(require("../../../../../DataTypeValue/DataTypeValue"));
|
|
35
|
+
var styles_1 = require("./styles");
|
|
36
|
+
var DiffRenderer = function (_a) {
|
|
37
|
+
var label = _a.label, level = _a.level, attributeType = _a.attributeType, attributeValue = _a.attributeValue, oldValue = _a.oldValue, newValue = _a.newValue, operation = _a.operation;
|
|
38
|
+
var styles = styles_1.useStyles({ level: level });
|
|
39
|
+
var entity = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntity);
|
|
40
|
+
var objectsInfo = react_1.useContext(AttributesChangesContext_1.AttributesChangesContext);
|
|
41
|
+
var renderLink = react_1.useCallback(function () {
|
|
42
|
+
if (mdm_sdk_1.isReference(attributeType)) {
|
|
43
|
+
var value = ramda_1.when(ramda_1.anyPass([ramda_1.hasPath(['value', 'newValue']), ramda_1.hasPath(['value', 'oldValue'])]), ramda_1.ifElse(ramda_1.hasPath(['value', 'newValue']), ramda_1.path(['value', 'newValue']), ramda_1.path(['value', 'oldValue'])))(attributeValue);
|
|
44
|
+
var _a = helpers_1.getAttributeDescription(attributeType, value, entity.uri, objectsInfo), objectUri = _a.objectUri, objectLabel = _a.objectLabel;
|
|
45
|
+
return (react_1.default.createElement(EntityUriLink_1.default, { value: objectUri, className: styles.uri },
|
|
46
|
+
react_1.default.createElement("span", null, mdm_sdk_1.getLabel(objectLabel))));
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}, [attributeType, attributeValue, entity.uri, objectsInfo, styles.uri]);
|
|
50
|
+
var changeLabel = react_1.useMemo(function () {
|
|
51
|
+
return (react_1.default.createElement("div", null,
|
|
52
|
+
label,
|
|
53
|
+
renderLink()));
|
|
54
|
+
}, [label, renderLink]);
|
|
55
|
+
var renderValue = react_1.useCallback(function (value) {
|
|
56
|
+
var attrValue = mdm_sdk_1.getAttributeValue(value);
|
|
57
|
+
return (react_1.default.createElement(DataTypeValue_1.default, { value: attrValue, dataTypeDefinition: helpers_1.getDataTypeDefinition(attributeType, attrValue) }));
|
|
58
|
+
}, [attributeType]);
|
|
59
|
+
return (react_1.default.createElement(ChangeView_1.default, { className: styles.change, label: changeLabel, oldValue: oldValue && renderValue(oldValue), newValue: newValue && renderValue(newValue), operation: operation }));
|
|
60
|
+
};
|
|
61
|
+
exports.default = DiffRenderer;
|
package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStyles = void 0;
|
|
4
|
+
var styles_1 = require("@material-ui/core/styles");
|
|
5
|
+
exports.useStyles = styles_1.makeStyles(function (theme) { return ({
|
|
6
|
+
uri: {
|
|
7
|
+
color: theme.palette.primary.main,
|
|
8
|
+
textDecoration: 'none',
|
|
9
|
+
cursor: 'pointer',
|
|
10
|
+
marginLeft: '4px'
|
|
11
|
+
},
|
|
12
|
+
change: function (_a) {
|
|
13
|
+
var _b = _a.level, level = _b === void 0 ? 0 : _b;
|
|
14
|
+
return ({
|
|
15
|
+
marginLeft: level * 16 + "px"
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}); });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Props = {
|
|
3
|
+
onClick: () => void;
|
|
4
|
+
suggestionsCount: number;
|
|
5
|
+
isExpanded: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const ShowMoreLink: ({ suggestionsCount, isExpanded, onClick, className }: Props) => JSX.Element;
|
|
9
|
+
export default ShowMoreLink;
|
package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
8
|
+
var Link_1 = __importDefault(require("@material-ui/core/Link"));
|
|
9
|
+
var styles_1 = require("./styles");
|
|
10
|
+
var ShowMoreLink = function (_a) {
|
|
11
|
+
var suggestionsCount = _a.suggestionsCount, isExpanded = _a.isExpanded, onClick = _a.onClick, className = _a.className;
|
|
12
|
+
var styles = styles_1.useStyles();
|
|
13
|
+
return (react_1.default.createElement(Link_1.default, { component: "button", variant: "caption", underline: "none", onClick: onClick, className: className },
|
|
14
|
+
react_1.default.createElement("span", { className: styles.linkLabel }, isExpanded
|
|
15
|
+
? ui_i18n_1.default.text('View less suggestions')
|
|
16
|
+
: ui_i18n_1.default.text('View ${suggestionsCount} more suggestions', { suggestionsCount: suggestionsCount }))));
|
|
17
|
+
};
|
|
18
|
+
exports.default = ShowMoreLink;
|
package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"linkLabel">;
|
package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStyles = void 0;
|
|
4
|
+
var styles_1 = require("@material-ui/core/styles");
|
|
5
|
+
exports.useStyles = styles_1.makeStyles(function (theme) { return ({
|
|
6
|
+
linkLabel: {
|
|
7
|
+
color: theme.palette.primary.main,
|
|
8
|
+
fontSize: '12px',
|
|
9
|
+
letterSpacing: 0,
|
|
10
|
+
lineHeight: '16px'
|
|
11
|
+
}
|
|
12
|
+
}); });
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare enum OperationTypes {
|
|
2
|
+
ADDED = "added",
|
|
3
|
+
EDITED = "edited",
|
|
4
|
+
DELETED = "deleted",
|
|
5
|
+
PINNED = "pinned",
|
|
6
|
+
IGNORED = "ignored",
|
|
7
|
+
PIN_DELETED = "pin_deleted",
|
|
8
|
+
IGNORE_DELETED = "ignore_deleted"
|
|
9
|
+
}
|
|
10
|
+
export declare enum DCRTypes {
|
|
11
|
+
INSERT_ATTRIBUTE = "INSERT_ATTRIBUTE",
|
|
12
|
+
UPDATE_ATTRIBUTE = "UPDATE_ATTRIBUTE",
|
|
13
|
+
DELETE_ATTRIBUTE = "DELETE_ATTRIBUTE",
|
|
14
|
+
PIN_ATTRIBUTE = "PIN_ATTRIBUTE",
|
|
15
|
+
IGNORE_ATTRIBUTE = "IGNORE_ATTRIBUTE",
|
|
16
|
+
CREATE_ENTITY = "CREATE_ENTITY",
|
|
17
|
+
CREATE_RELATIONSHIP = "CREATE_RELATIONSHIP",
|
|
18
|
+
UPDATE_TAGS = "UPDATE_TAGS",
|
|
19
|
+
UPDATE_ROLES = "UPDATE_ROLES",
|
|
20
|
+
UPDATE_START_DATE = "UPDATE_START_DATE",
|
|
21
|
+
UPDATE_END_DATE = "UPDATE_END_DATE",
|
|
22
|
+
UPDATE_PROFILE_PIC_BY_URL = "UPDATE_PROFILE_PIC_BY_URL",
|
|
23
|
+
UPDATE_PROFILE_PIC_BY_URI = "UPDATE_PROFILE_PIC_BY_URI",
|
|
24
|
+
DELETE_RELATIONSHIP = "DELETE_RELATIONSHIP"
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DCRTypes = exports.OperationTypes = void 0;
|
|
4
|
+
var OperationTypes;
|
|
5
|
+
(function (OperationTypes) {
|
|
6
|
+
OperationTypes["ADDED"] = "added";
|
|
7
|
+
OperationTypes["EDITED"] = "edited";
|
|
8
|
+
OperationTypes["DELETED"] = "deleted";
|
|
9
|
+
OperationTypes["PINNED"] = "pinned";
|
|
10
|
+
OperationTypes["IGNORED"] = "ignored";
|
|
11
|
+
OperationTypes["PIN_DELETED"] = "pin_deleted";
|
|
12
|
+
OperationTypes["IGNORE_DELETED"] = "ignore_deleted";
|
|
13
|
+
})(OperationTypes = exports.OperationTypes || (exports.OperationTypes = {}));
|
|
14
|
+
var DCRTypes;
|
|
15
|
+
(function (DCRTypes) {
|
|
16
|
+
DCRTypes["INSERT_ATTRIBUTE"] = "INSERT_ATTRIBUTE";
|
|
17
|
+
DCRTypes["UPDATE_ATTRIBUTE"] = "UPDATE_ATTRIBUTE";
|
|
18
|
+
DCRTypes["DELETE_ATTRIBUTE"] = "DELETE_ATTRIBUTE";
|
|
19
|
+
DCRTypes["PIN_ATTRIBUTE"] = "PIN_ATTRIBUTE";
|
|
20
|
+
DCRTypes["IGNORE_ATTRIBUTE"] = "IGNORE_ATTRIBUTE";
|
|
21
|
+
DCRTypes["CREATE_ENTITY"] = "CREATE_ENTITY";
|
|
22
|
+
DCRTypes["CREATE_RELATIONSHIP"] = "CREATE_RELATIONSHIP";
|
|
23
|
+
DCRTypes["UPDATE_TAGS"] = "UPDATE_TAGS";
|
|
24
|
+
DCRTypes["UPDATE_ROLES"] = "UPDATE_ROLES";
|
|
25
|
+
DCRTypes["UPDATE_START_DATE"] = "UPDATE_START_DATE";
|
|
26
|
+
DCRTypes["UPDATE_END_DATE"] = "UPDATE_END_DATE";
|
|
27
|
+
DCRTypes["UPDATE_PROFILE_PIC_BY_URL"] = "UPDATE_PROFILE_PIC_BY_URL";
|
|
28
|
+
DCRTypes["UPDATE_PROFILE_PIC_BY_URI"] = "UPDATE_PROFILE_PIC_BY_URI";
|
|
29
|
+
DCRTypes["DELETE_RELATIONSHIP"] = "DELETE_RELATIONSHIP";
|
|
30
|
+
})(DCRTypes = exports.DCRTypes || (exports.DCRTypes = {}));
|
package/cjs/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AttributesChangesContext = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
exports.AttributesChangesContext = react_1.default.createContext(null);
|
|
9
|
+
exports.AttributesChangesContext.displayName = 'AttributesChangesContext';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChanges = void 0;
|
|
4
|
+
var ramda_1 = require("ramda");
|
|
5
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
6
|
+
var attributesView_1 = require("../../../../attributes/helpers/attributesView");
|
|
7
|
+
var helpers_1 = require("./helpers");
|
|
8
|
+
var operations_1 = require("../constants/operations");
|
|
9
|
+
var getValues = function (attributes, attrType) {
|
|
10
|
+
if ('newValue' in attributes || 'oldValue' in attributes) {
|
|
11
|
+
var newValue = attributes.newValue, oldValue = attributes.oldValue, type_1 = attributes.type;
|
|
12
|
+
var newAttrValues_1 = ramda_1.pathOr([], ['value', attrType.name])(newValue);
|
|
13
|
+
var oldAttrValues_1 = ramda_1.pathOr([], ['value', attrType.name])(oldValue);
|
|
14
|
+
var length_1 = Math.max(newAttrValues_1.length, oldAttrValues_1.length);
|
|
15
|
+
return ramda_1.times(function (index) {
|
|
16
|
+
var attributeValue = {
|
|
17
|
+
newValue: newAttrValues_1[index],
|
|
18
|
+
oldValue: oldAttrValues_1[index],
|
|
19
|
+
type: type_1
|
|
20
|
+
};
|
|
21
|
+
return [{ value: attributeValue }];
|
|
22
|
+
}, length_1);
|
|
23
|
+
}
|
|
24
|
+
var values = attributes[attrType.name];
|
|
25
|
+
return values ? [values] : [];
|
|
26
|
+
};
|
|
27
|
+
var getChanges = ramda_1.curry(function (metadata, objectInfo, changes) {
|
|
28
|
+
var attrTypes = attributesView_1.getFilteredAttrTypes(metadata, objectInfo.type, [], []);
|
|
29
|
+
return getAttributesList(metadata, attrTypes, changes);
|
|
30
|
+
});
|
|
31
|
+
exports.getChanges = getChanges;
|
|
32
|
+
var getAttributesList = function (metadata, attrTypes, attributes, level) {
|
|
33
|
+
if (level === void 0) { level = 0; }
|
|
34
|
+
return ramda_1.flatten(attrTypes
|
|
35
|
+
.map(function (attrType) {
|
|
36
|
+
return getValues(attributes, attrType).map(function (value) {
|
|
37
|
+
return value.map(function (attributeValue) {
|
|
38
|
+
return dcrAttributesFactory(metadata, attrType, attributeValue, level);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
})
|
|
42
|
+
.filter(ramda_1.complement(ramda_1.isEmpty)));
|
|
43
|
+
};
|
|
44
|
+
var dcrAttributesFactory = function (metadata, attributeType, attributeValue, level) {
|
|
45
|
+
switch (attributeType.type) {
|
|
46
|
+
case mdm_sdk_1.DataTypes.TYPE_NESTED:
|
|
47
|
+
case mdm_sdk_1.DataTypes.TYPE_IMAGE:
|
|
48
|
+
return getNestedAttributeChange(metadata, attributeType, attributeValue, level);
|
|
49
|
+
case mdm_sdk_1.DataTypes.TYPE_REFERENCE:
|
|
50
|
+
return getReferenceAttributeChange(metadata, attributeType, attributeValue, level);
|
|
51
|
+
default: {
|
|
52
|
+
var value = mdm_sdk_1.isSpecialAttribute(attributeType) ? attributeValue : attributeValue.value;
|
|
53
|
+
return getSimpleAttributeChange(attributeType, value, level);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var getNestedAttributeChange = function (metadata, attributeType, attributeValue, level) {
|
|
58
|
+
var attributeTypeList = mdm_sdk_1.getAttributeTypeSubAttributes({}, attributeType);
|
|
59
|
+
var label = mdm_sdk_1.getLabel((attributeType === null || attributeType === void 0 ? void 0 : attributeType.label) || (attributeType === null || attributeType === void 0 ? void 0 : attributeType.name));
|
|
60
|
+
return [
|
|
61
|
+
{ level: level, label: label, attributeType: attributeType, attributeValue: attributeValue },
|
|
62
|
+
getAttributesList(metadata, attributeTypeList, attributeValue.value, level + 1)
|
|
63
|
+
];
|
|
64
|
+
};
|
|
65
|
+
var getReferenceAttributeChange = function (metadata, attributeType, attributeValue, level) {
|
|
66
|
+
var attributeTypeList = mdm_sdk_1.getAttributeTypeSubAttributes(metadata, attributeType);
|
|
67
|
+
var label = (attributeType === null || attributeType === void 0 ? void 0 : attributeType.label) || (attributeType === null || attributeType === void 0 ? void 0 : attributeType.name);
|
|
68
|
+
return [
|
|
69
|
+
{ level: level, label: label, attributeType: attributeType, attributeValue: attributeValue },
|
|
70
|
+
getAttributesList(metadata, attributeTypeList, attributeValue.value, level + 1)
|
|
71
|
+
];
|
|
72
|
+
};
|
|
73
|
+
var getDiffParameters = function (_a) {
|
|
74
|
+
var newValue = _a.newValue, oldValue = _a.oldValue, type = _a.type;
|
|
75
|
+
return type === operations_1.DCRTypes.UPDATE_ATTRIBUTE ? { type: type, newValue: newValue, oldValue: oldValue } : { type: type, newValue: oldValue || newValue };
|
|
76
|
+
};
|
|
77
|
+
var getSimpleAttributeChange = function (attributeType, attributeValue, level) {
|
|
78
|
+
var _a = getDiffParameters(attributeValue), newValue = _a.newValue, oldValue = _a.oldValue, type = _a.type;
|
|
79
|
+
var operation = helpers_1.getOperationType(type, oldValue);
|
|
80
|
+
var label = (attributeType === null || attributeType === void 0 ? void 0 : attributeType.label) || (attributeType === null || attributeType === void 0 ? void 0 : attributeType.name);
|
|
81
|
+
return {
|
|
82
|
+
attributeType: attributeType,
|
|
83
|
+
newValue: newValue,
|
|
84
|
+
oldValue: oldValue,
|
|
85
|
+
operation: operation,
|
|
86
|
+
label: label,
|
|
87
|
+
level: level
|
|
88
|
+
};
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getSuggestionsCount: any;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AttributeType } from '@reltio/mdm-sdk';
|
|
2
|
+
import { OperationTypes } from '../constants/operations';
|
|
3
|
+
import { ChangeRequest, DCRAttributeValue, DCRObjectsInfo, Value } from '../types/DCRTypes';
|
|
4
|
+
export declare const getOperationType: (type: string, oldValue?: DCRAttributeValue) => OperationTypes;
|
|
5
|
+
export declare const getOperationLabel: (operation: OperationTypes) => string;
|
|
6
|
+
export declare const getAttributeDescription: (attrType: AttributeType, value: DCRAttributeValue, currentEntityUri: string, objectsInfo?: DCRObjectsInfo) => {
|
|
7
|
+
objectUri: any;
|
|
8
|
+
objectLabel: any;
|
|
9
|
+
entityTypeUri: any;
|
|
10
|
+
};
|
|
11
|
+
export declare const extractObjectsFromChangeRequest: ({ objectsInfo, changes }: ChangeRequest) => any;
|
|
12
|
+
export declare const getDataTypeDefinition: (attributeType: AttributeType, attributeValue: Value) => any;
|
|
@@ -0,0 +1,88 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.getDataTypeDefinition = exports.extractObjectsFromChangeRequest = exports.getAttributeDescription = exports.getOperationLabel = exports.getOperationType = void 0;
|
|
18
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
19
|
+
var ramda_1 = require("ramda");
|
|
20
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
21
|
+
var operations_1 = require("../constants/operations");
|
|
22
|
+
var getOperationType = function (type, oldValue) {
|
|
23
|
+
switch (type) {
|
|
24
|
+
case operations_1.DCRTypes.CREATE_RELATIONSHIP:
|
|
25
|
+
case operations_1.DCRTypes.INSERT_ATTRIBUTE:
|
|
26
|
+
return operations_1.OperationTypes.ADDED;
|
|
27
|
+
case operations_1.DCRTypes.UPDATE_TAGS:
|
|
28
|
+
case operations_1.DCRTypes.UPDATE_ROLES:
|
|
29
|
+
case operations_1.DCRTypes.UPDATE_ATTRIBUTE:
|
|
30
|
+
return operations_1.OperationTypes.EDITED;
|
|
31
|
+
case operations_1.DCRTypes.DELETE_ATTRIBUTE:
|
|
32
|
+
case operations_1.DCRTypes.DELETE_RELATIONSHIP:
|
|
33
|
+
return operations_1.OperationTypes.DELETED;
|
|
34
|
+
case operations_1.DCRTypes.PIN_ATTRIBUTE:
|
|
35
|
+
return (oldValue === null || oldValue === void 0 ? void 0 : oldValue.pin) ? operations_1.OperationTypes.PIN_DELETED : operations_1.OperationTypes.PINNED;
|
|
36
|
+
case operations_1.DCRTypes.IGNORE_ATTRIBUTE:
|
|
37
|
+
return (oldValue === null || oldValue === void 0 ? void 0 : oldValue.ignored) ? operations_1.OperationTypes.IGNORE_DELETED : operations_1.OperationTypes.IGNORED;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.getOperationType = getOperationType;
|
|
41
|
+
var getOperationLabel = function (operation) {
|
|
42
|
+
var _a;
|
|
43
|
+
var labels = (_a = {},
|
|
44
|
+
_a[operations_1.OperationTypes.ADDED] = ui_i18n_1.default.text('added'),
|
|
45
|
+
_a[operations_1.OperationTypes.EDITED] = ui_i18n_1.default.text('edited'),
|
|
46
|
+
_a[operations_1.OperationTypes.DELETED] = ui_i18n_1.default.text('deleted'),
|
|
47
|
+
_a[operations_1.OperationTypes.PINNED] = ui_i18n_1.default.text('pinned'),
|
|
48
|
+
_a[operations_1.OperationTypes.PIN_DELETED] = ui_i18n_1.default.text('pin deleted'),
|
|
49
|
+
_a[operations_1.OperationTypes.IGNORED] = ui_i18n_1.default.text('ignored'),
|
|
50
|
+
_a[operations_1.OperationTypes.IGNORE_DELETED] = ui_i18n_1.default.text('ignore deleted'),
|
|
51
|
+
_a);
|
|
52
|
+
return labels[operation] || '';
|
|
53
|
+
};
|
|
54
|
+
exports.getOperationLabel = getOperationLabel;
|
|
55
|
+
var getAttributeDescription = function (attrType, value, currentEntityUri, objectsInfo) {
|
|
56
|
+
if (objectsInfo === void 0) { objectsInfo = {}; }
|
|
57
|
+
var objectLabel, objectUri, entityTypeUri;
|
|
58
|
+
var relation = objectsInfo[value.refObjectURI];
|
|
59
|
+
if (relation) {
|
|
60
|
+
objectUri = currentEntityUri === relation.startObjectUri ? relation.endObjectUri : relation.startObjectUri;
|
|
61
|
+
objectLabel =
|
|
62
|
+
currentEntityUri === relation.startObjectUri ? relation.endObjectLabel : relation.startObjectLabel;
|
|
63
|
+
}
|
|
64
|
+
else if (value.refEntity) {
|
|
65
|
+
objectUri = value.refEntity.objectURI;
|
|
66
|
+
objectLabel = objectsInfo[objectUri].label;
|
|
67
|
+
}
|
|
68
|
+
if (objectUri && objectLabel) {
|
|
69
|
+
var objectInfo = objectsInfo[objectUri];
|
|
70
|
+
entityTypeUri = objectInfo ? objectInfo.type : attrType.referencedEntityTypeURI;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
objectUri: objectUri,
|
|
74
|
+
objectLabel: objectLabel,
|
|
75
|
+
entityTypeUri: entityTypeUri
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
exports.getAttributeDescription = getAttributeDescription;
|
|
79
|
+
var extractObjectsFromChangeRequest = function (_a) {
|
|
80
|
+
var _b = _a.objectsInfo, objectsInfo = _b === void 0 ? {} : _b, _c = _a.changes, changes = _c === void 0 ? {} : _c;
|
|
81
|
+
var getChange = function (key) { return ramda_1.prop([key], changes); };
|
|
82
|
+
return ramda_1.pipe(ramda_1.keys, ramda_1.filter(getChange), ramda_1.map(function (key) { return (__assign(__assign({}, objectsInfo[key]), { uri: key })); }))(objectsInfo);
|
|
83
|
+
};
|
|
84
|
+
exports.extractObjectsFromChangeRequest = extractObjectsFromChangeRequest;
|
|
85
|
+
var getDataTypeDefinition = function (attributeType, attributeValue) {
|
|
86
|
+
return ramda_1.when(ramda_1.allPass([ramda_1.pipe(ramda_1.prop('type'), ramda_1.equals(mdm_sdk_1.DataTypes.TYPE_STRING)), function () { return mdm_sdk_1.isUrl(attributeValue); }]), ramda_1.evolve({ type: ramda_1.always(mdm_sdk_1.DataTypes.TYPE_URL) }))(mdm_sdk_1.getAttrDataTypeDefinition(attributeType));
|
|
87
|
+
};
|
|
88
|
+
exports.getDataTypeDefinition = getDataTypeDefinition;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeChanges = void 0;
|
|
4
|
+
var ramda_1 = require("ramda");
|
|
5
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
6
|
+
var operations_1 = require("../constants/operations");
|
|
7
|
+
var attributesHelpers_1 = require("./attributesHelpers");
|
|
8
|
+
var ATTRIBUTE_DELIMITER = '/';
|
|
9
|
+
var SPECIAL_ATTRIBUTES_NAMES = [
|
|
10
|
+
'defaultProfilePicValue',
|
|
11
|
+
mdm_sdk_1.EntityAttrTypes.tags.name,
|
|
12
|
+
mdm_sdk_1.EntityAttrTypes.roles.name,
|
|
13
|
+
mdm_sdk_1.EntityAttrTypes.startDate.name,
|
|
14
|
+
mdm_sdk_1.EntityAttrTypes.endDate.name
|
|
15
|
+
];
|
|
16
|
+
var prepareStartOrEndDate = function (_a) {
|
|
17
|
+
var newValue = _a.newValue, oldValue = _a.oldValue;
|
|
18
|
+
var parseValue = function (value) { return (ramda_1.is(String) ? parseInt(value) : value); };
|
|
19
|
+
var isExistedValue = function (value) { return (value === null || value === void 0 ? void 0 : value.length) && !mdm_sdk_1.isEmptyValue(value); };
|
|
20
|
+
var isExistNewValue = isExistedValue(newValue);
|
|
21
|
+
var isExistOldValue = isExistedValue(oldValue);
|
|
22
|
+
if (isExistNewValue && isExistOldValue) {
|
|
23
|
+
return {
|
|
24
|
+
type: operations_1.DCRTypes.UPDATE_ATTRIBUTE,
|
|
25
|
+
oldValue: { value: parseValue(oldValue[0]) },
|
|
26
|
+
newValue: { value: parseValue(newValue[0]) }
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
else if (isExistNewValue) {
|
|
30
|
+
return {
|
|
31
|
+
type: operations_1.DCRTypes.INSERT_ATTRIBUTE,
|
|
32
|
+
newValue: { value: parseValue(newValue[0]) }
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else if (isExistOldValue) {
|
|
36
|
+
return {
|
|
37
|
+
type: operations_1.DCRTypes.DELETE_ATTRIBUTE,
|
|
38
|
+
oldValue: { value: parseValue(oldValue[0]) }
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var prepareRolesOrTags = function (change, metadata) {
|
|
43
|
+
var _a = change.newValue, newValue = _a === void 0 ? [] : _a, _b = change.oldValue, oldValue = _b === void 0 ? [] : _b, type = change.type;
|
|
44
|
+
var getLabel = type === operations_1.DCRTypes.UPDATE_ROLES ? mdm_sdk_1.getRoleLabel(metadata) : ramda_1.identity;
|
|
45
|
+
var diffNewValue = ramda_1.difference(newValue, oldValue);
|
|
46
|
+
var diffOldValue = ramda_1.difference(oldValue, newValue);
|
|
47
|
+
var items = [];
|
|
48
|
+
if (diffNewValue.length) {
|
|
49
|
+
items.push({
|
|
50
|
+
type: operations_1.DCRTypes.INSERT_ATTRIBUTE,
|
|
51
|
+
newValue: { value: diffNewValue.map(getLabel).join(', ') }
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (diffOldValue.length) {
|
|
55
|
+
items.push({
|
|
56
|
+
type: operations_1.DCRTypes.DELETE_ATTRIBUTE,
|
|
57
|
+
oldValue: { value: diffOldValue.map(getLabel).join(', ') }
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return items;
|
|
61
|
+
};
|
|
62
|
+
var getPath = function (change) {
|
|
63
|
+
var type = change.type, attributePath = change.attributePath, refObjectURI = change.refObjectURI, refAttributeType = change.refAttributeType;
|
|
64
|
+
var path = type === operations_1.DCRTypes.INSERT_ATTRIBUTE ? mdm_sdk_1.generateTempUri(attributePath) : attributePath;
|
|
65
|
+
if (refObjectURI) {
|
|
66
|
+
var typePath = refAttributeType.split('/attributes/');
|
|
67
|
+
var id = refObjectURI.split(ATTRIBUTE_DELIMITER)[1];
|
|
68
|
+
return [typePath[1], id, path].join(ATTRIBUTE_DELIMITER);
|
|
69
|
+
}
|
|
70
|
+
return path;
|
|
71
|
+
};
|
|
72
|
+
var prepareAttribute = function (container, change) {
|
|
73
|
+
var _a;
|
|
74
|
+
var changePath = getPath(change);
|
|
75
|
+
var pathArray = changePath.split(ATTRIBUTE_DELIMITER);
|
|
76
|
+
var holder = container;
|
|
77
|
+
for (var i = 0; i < pathArray.length - 1; i = i + 2) {
|
|
78
|
+
var key = pathArray[i];
|
|
79
|
+
var id = pathArray[i + 1];
|
|
80
|
+
var currentValue = (holder[key] || []).find(ramda_1.propEq('id', id));
|
|
81
|
+
var newValue = pathArray.length === i + 2 ? change : {};
|
|
82
|
+
var value = currentValue ? currentValue : { id: id, value: newValue };
|
|
83
|
+
var refObjectURI = ((_a = change.refObjectURI) === null || _a === void 0 ? void 0 : _a.indexOf(id)) >= 0 && change.refObjectURI;
|
|
84
|
+
if (refObjectURI) {
|
|
85
|
+
value.refObjectURI = refObjectURI;
|
|
86
|
+
}
|
|
87
|
+
if (ramda_1.isNil(currentValue)) {
|
|
88
|
+
holder[key] = (holder[key] || []).concat(value);
|
|
89
|
+
}
|
|
90
|
+
holder = value.value;
|
|
91
|
+
}
|
|
92
|
+
return container;
|
|
93
|
+
};
|
|
94
|
+
var mergeAttributesInChange = function (metadata, objectInfo, change, container) {
|
|
95
|
+
if (container === void 0) { container = {}; }
|
|
96
|
+
var type = change.type;
|
|
97
|
+
switch (type) {
|
|
98
|
+
case operations_1.DCRTypes.UPDATE_PROFILE_PIC_BY_URL:
|
|
99
|
+
container['defaultProfilePicValue'] = [change.newValue];
|
|
100
|
+
break;
|
|
101
|
+
case operations_1.DCRTypes.UPDATE_TAGS:
|
|
102
|
+
container[mdm_sdk_1.EntityAttrTypes.tags.name] = prepareRolesOrTags(change, metadata);
|
|
103
|
+
break;
|
|
104
|
+
case operations_1.DCRTypes.UPDATE_ROLES: {
|
|
105
|
+
container[mdm_sdk_1.EntityAttrTypes.roles.name] = prepareRolesOrTags(change, metadata);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case operations_1.DCRTypes.UPDATE_START_DATE:
|
|
109
|
+
container[mdm_sdk_1.EntityAttrTypes.startDate.name] = [prepareStartOrEndDate(change)];
|
|
110
|
+
break;
|
|
111
|
+
case operations_1.DCRTypes.UPDATE_END_DATE:
|
|
112
|
+
container[mdm_sdk_1.EntityAttrTypes.endDate.name] = [prepareStartOrEndDate(change)];
|
|
113
|
+
break;
|
|
114
|
+
default: {
|
|
115
|
+
prepareAttribute(container, change);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return container;
|
|
120
|
+
};
|
|
121
|
+
var mergeChanges = function (metadata, changes, objectInfo) {
|
|
122
|
+
var getAttributeChanges = function (attributeName) { return ramda_1.pipe(ramda_1.pick([attributeName]), attributesHelpers_1.getChanges(metadata, objectInfo)); };
|
|
123
|
+
var concatChanges = ramda_1.curry(function (getters, attributesTree) {
|
|
124
|
+
return ramda_1.reduce(function (acc, getter) { return ramda_1.concat(acc, getter(attributesTree)); }, [], getters);
|
|
125
|
+
});
|
|
126
|
+
var changesTree = changes.reduce(function (result, change) {
|
|
127
|
+
return mergeAttributesInChange(metadata, objectInfo, change, result);
|
|
128
|
+
}, {});
|
|
129
|
+
return concatChanges([
|
|
130
|
+
ramda_1.pipe(ramda_1.omit(SPECIAL_ATTRIBUTES_NAMES), attributesHelpers_1.getChanges(metadata, objectInfo)),
|
|
131
|
+
getAttributeChanges(mdm_sdk_1.EntityAttrTypes.roles.name),
|
|
132
|
+
getAttributeChanges(mdm_sdk_1.EntityAttrTypes.tags.name),
|
|
133
|
+
getAttributeChanges(mdm_sdk_1.EntityAttrTypes.startDate.name),
|
|
134
|
+
getAttributeChanges(mdm_sdk_1.EntityAttrTypes.endDate.name)
|
|
135
|
+
], changesTree);
|
|
136
|
+
};
|
|
137
|
+
exports.mergeChanges = mergeChanges;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCollapsibleList = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var contextHelpers_1 = require("../helpers/contextHelpers");
|
|
6
|
+
var DEFAULT_VISIBLE_ITEMS_COUNT = 3;
|
|
7
|
+
var useCollapsibleList = function (changes, limit) {
|
|
8
|
+
if (limit === void 0) { limit = DEFAULT_VISIBLE_ITEMS_COUNT; }
|
|
9
|
+
var _a = react_1.useState(false), isExpanded = _a[0], setIsExpanded = _a[1];
|
|
10
|
+
var onToggle = react_1.useCallback(function () { return setIsExpanded(function (value) { return !value; }); }, []);
|
|
11
|
+
var collapsedItems = react_1.useMemo(function () { return changes.slice(0, limit); }, [changes, limit]);
|
|
12
|
+
var suggestionsCount = react_1.useMemo(function () { return contextHelpers_1.getSuggestionsCount(changes); }, [changes]);
|
|
13
|
+
var visibleSuggestionsCount = react_1.useMemo(function () { return contextHelpers_1.getSuggestionsCount(collapsedItems); }, [collapsedItems]);
|
|
14
|
+
var itemsToShow = isExpanded ? changes : collapsedItems;
|
|
15
|
+
var collapsedSuggestionsCount = suggestionsCount - visibleSuggestionsCount;
|
|
16
|
+
return { isExpanded: isExpanded, onToggle: onToggle, itemsToShow: itemsToShow, collapsedSuggestionsCount: collapsedSuggestionsCount };
|
|
17
|
+
};
|
|
18
|
+
exports.useCollapsibleList = useCollapsibleList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"uri" | "label" | "container" | "showMoreLink">;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStyles = void 0;
|
|
4
|
+
var styles_1 = require("@material-ui/core/styles");
|
|
5
|
+
exports.useStyles = styles_1.makeStyles(function (theme) { return ({
|
|
6
|
+
container: {
|
|
7
|
+
boxSizing: 'border-box',
|
|
8
|
+
border: '1px solid rgba(0,0,0,0.03)',
|
|
9
|
+
borderRadius: '3px',
|
|
10
|
+
backgroundColor: 'rgba(0,0,0,0.03)',
|
|
11
|
+
padding: '10px',
|
|
12
|
+
margin: '12px 16px 12px 0'
|
|
13
|
+
},
|
|
14
|
+
uri: {
|
|
15
|
+
color: theme.palette.primary.main,
|
|
16
|
+
textDecoration: 'none',
|
|
17
|
+
cursor: 'pointer'
|
|
18
|
+
},
|
|
19
|
+
label: {
|
|
20
|
+
fontSize: '12px',
|
|
21
|
+
letterSpacing: 0,
|
|
22
|
+
lineHeight: '16px'
|
|
23
|
+
},
|
|
24
|
+
showMoreLink: {
|
|
25
|
+
marginTop: '8px'
|
|
26
|
+
}
|
|
27
|
+
}); });
|