@reltio/components 1.4.2253 → 1.4.2254

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.
Files changed (77) hide show
  1. package/ConfigureColumnsPopup/ConfigureColumnsPopup.d.ts +3 -3
  2. package/ConfigureColumnsPopup/ConfigureColumnsPopup.js +5 -5
  3. package/SelectionPopup/SelectionPopup.d.ts +4 -4
  4. package/SelectionPopup/SelectionPopup.js +4 -3
  5. package/SelectionPopup/SelectionPopup.spec.js +2 -2
  6. package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.d.ts +3 -3
  7. package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.js +5 -5
  8. package/cjs/SelectionPopup/SelectionPopup.d.ts +4 -4
  9. package/cjs/SelectionPopup/SelectionPopup.js +4 -3
  10. package/cjs/SelectionPopup/SelectionPopup.spec.js +2 -2
  11. package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +22 -6
  12. package/cjs/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +5 -2
  13. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.js +29 -13
  14. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.d.ts +41 -0
  15. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.js +161 -0
  16. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +52 -0
  17. package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +1 -1
  18. package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.js +2 -4
  19. package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.d.ts +2 -1
  20. package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +37 -3
  21. package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +2 -2
  22. package/cjs/features/workflow/contexts/AddedAttributesContext/index.d.ts +1 -0
  23. package/cjs/features/workflow/contexts/AddedAttributesContext/index.js +8 -3
  24. package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +1 -0
  25. package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.js +8 -2
  26. package/cjs/features/workflow/helpers/attributes.js +5 -4
  27. package/cjs/features/workflow/helpers/attributes.test.js +55 -0
  28. package/cjs/features/workflow/helpers/common.d.ts +2 -1
  29. package/cjs/features/workflow/helpers/common.js +5 -1
  30. package/cjs/features/workflow/helpers/dcr.js +2 -1
  31. package/cjs/features/workflow/helpers/dcr.test.js +47 -0
  32. package/cjs/features/workflow/helpers/merge.js +1 -1
  33. package/cjs/features/workflow/helpers/merge.test.js +34 -0
  34. package/cjs/features/workflow/helpers/metadata.test-data.js +9 -0
  35. package/cjs/features/workflow/helpers/validation.js +3 -2
  36. package/cjs/features/workflow/helpers/validation.test-data.d.ts +1 -0
  37. package/cjs/features/workflow/helpers/validation.test-data.js +34 -1
  38. package/cjs/features/workflow/helpers/validation.test.js +10 -0
  39. package/cjs/features/workflow/hooks/useChangeRequest.d.ts +1 -0
  40. package/cjs/features/workflow/hooks/useChangeRequest.js +8 -5
  41. package/cjs/features/workflow/hooks/useChangeRequest.test.js +11 -5
  42. package/cjs/features/workflow/hooks/useWorkflowActions.d.ts +2 -1
  43. package/cjs/features/workflow/hooks/useWorkflowActions.js +8 -3
  44. package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +23 -7
  45. package/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +5 -2
  46. package/features/workflow/ChangeRequestEditor/helpers/changesList.js +29 -13
  47. package/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.d.ts +41 -0
  48. package/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.js +153 -0
  49. package/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +52 -0
  50. package/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +1 -1
  51. package/features/workflow/ChangeRequestEditor/helpers/helpers.js +1 -3
  52. package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.d.ts +2 -1
  53. package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +14 -3
  54. package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +2 -2
  55. package/features/workflow/contexts/AddedAttributesContext/index.d.ts +1 -0
  56. package/features/workflow/contexts/AddedAttributesContext/index.js +8 -3
  57. package/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +1 -0
  58. package/features/workflow/contexts/ChangeRequestEditorContext/index.js +8 -2
  59. package/features/workflow/helpers/attributes.js +5 -4
  60. package/features/workflow/helpers/attributes.test.js +55 -0
  61. package/features/workflow/helpers/common.d.ts +2 -1
  62. package/features/workflow/helpers/common.js +3 -0
  63. package/features/workflow/helpers/dcr.js +2 -1
  64. package/features/workflow/helpers/dcr.test.js +47 -0
  65. package/features/workflow/helpers/merge.js +2 -2
  66. package/features/workflow/helpers/merge.test.js +34 -0
  67. package/features/workflow/helpers/metadata.test-data.js +9 -0
  68. package/features/workflow/helpers/validation.js +3 -2
  69. package/features/workflow/helpers/validation.test-data.d.ts +1 -0
  70. package/features/workflow/helpers/validation.test-data.js +32 -0
  71. package/features/workflow/helpers/validation.test.js +11 -1
  72. package/features/workflow/hooks/useChangeRequest.d.ts +1 -0
  73. package/features/workflow/hooks/useChangeRequest.js +8 -5
  74. package/features/workflow/hooks/useChangeRequest.test.js +11 -5
  75. package/features/workflow/hooks/useWorkflowActions.d.ts +2 -1
  76. package/features/workflow/hooks/useWorkflowActions.js +8 -3
  77. package/package.json +1 -1
@@ -11,14 +11,14 @@ type Item = AttributeOption & {
11
11
  children?: Item[];
12
12
  attributes?: Item[];
13
13
  };
14
- type Props = Omit<React.ComponentProps<typeof SelectionPopup>, 'title'> & {
15
- hideCheckBox: boolean;
14
+ type Props = Omit<React.ComponentProps<typeof SelectionPopup>, 'title' | 'children' | 'containerWidth' | 'searchInputOnKeyDown'> & {
15
+ hideCheckBox?: boolean;
16
16
  titleText?: string;
17
17
  filterText?: string;
18
18
  selected: Item[];
19
19
  data: Item[];
20
20
  onListItemClick: (item: Item, checked: boolean) => void;
21
- renderGroupTitle: VirtualGroupedListRenderGroupTitle<Item>;
21
+ renderGroupTitle?: VirtualGroupedListRenderGroupTitle<Item>;
22
22
  };
23
23
  export declare const ConfigureColumnsPopup: ({ open, anchorEl, data, onSearch, onClose, titleText, filterText, onListItemClick, selected, hideCheckBox, renderGroupTitle, ...otherProps }: Props) => React.JSX.Element;
24
24
  export {};
@@ -42,9 +42,9 @@ import { useKeyboardNavigation } from '../hooks/useKeyboardNavigation';
42
42
  import { useStyles } from './styles';
43
43
  var ITEM_HEIGHT = 32;
44
44
  var LIST_CONTAINER_HEIGHT = 300;
45
- var DEFAULT_MIN_CONTAINER_WIDTH = 308;
45
+ var DEFAULT_MIN_CONTAINER_WIDTH = 318;
46
46
  export var ConfigureColumnsPopup = function (_a) {
47
- var open = _a.open, anchorEl = _a.anchorEl, _b = _a.data, data = _b === void 0 ? [] : _b, onSearch = _a.onSearch, onClose = _a.onClose, _c = _a.titleText, titleText = _c === void 0 ? i18n.text('Show/hide columns') : _c, _d = _a.filterText, filterText = _d === void 0 ? '' : _d, onListItemClick = _a.onListItemClick, _e = _a.selected, selected = _e === void 0 ? [] : _e, hideCheckBox = _a.hideCheckBox, renderGroupTitle = _a.renderGroupTitle, otherProps = __rest(_a, ["open", "anchorEl", "data", "onSearch", "onClose", "titleText", "filterText", "onListItemClick", "selected", "hideCheckBox", "renderGroupTitle"]);
47
+ var open = _a.open, anchorEl = _a.anchorEl, _b = _a.data, data = _b === void 0 ? [] : _b, onSearch = _a.onSearch, onClose = _a.onClose, _c = _a.titleText, titleText = _c === void 0 ? i18n.text('Show/hide columns') : _c, _d = _a.filterText, filterText = _d === void 0 ? '' : _d, onListItemClick = _a.onListItemClick, _e = _a.selected, selected = _e === void 0 ? [] : _e, _f = _a.hideCheckBox, hideCheckBox = _f === void 0 ? false : _f, renderGroupTitle = _a.renderGroupTitle, otherProps = __rest(_a, ["open", "anchorEl", "data", "onSearch", "onClose", "titleText", "filterText", "onListItemClick", "selected", "hideCheckBox", "renderGroupTitle"]);
48
48
  var filterItem = useCallback(function (item) {
49
49
  return item.label.toLowerCase().includes(filterText.toLowerCase());
50
50
  }, [filterText]);
@@ -81,12 +81,12 @@ export var ConfigureColumnsPopup = function (_a) {
81
81
  }, [onListItemClick, selected]);
82
82
  var groupedItems = useMemo(function () { return (renderGroupTitle ? getGroupsData : getAttributesData)(data); }, [data, renderGroupTitle, getGroupsData, getAttributesData]);
83
83
  var items = useMemo(function () { return flattenGroupedItemsData(groupedItems); }, [groupedItems]);
84
- var _f = useKeyboardNavigation({
84
+ var _g = useKeyboardNavigation({
85
85
  items: items,
86
86
  open: open,
87
87
  onSelectFocusedItem: handleSearchOnEnter,
88
88
  selectedItems: selected
89
- }), focusIndex = _f.focusIndex, handleKeyDown = _f.handleKeyDown;
89
+ }), focusIndex = _g.focusIndex, handleKeyDown = _g.handleKeyDown;
90
90
  var focusIndexRef = useRef(null);
91
91
  focusIndexRef.current = focusIndex;
92
92
  var renderListItem = useCallback(function (style, _a, index) {
@@ -95,7 +95,7 @@ export var ConfigureColumnsPopup = function (_a) {
95
95
  var isFocused = focusIndexRef.current === index;
96
96
  return (React.createElement(AttributeListItem, { key: item.id, onClick: onListItemClick, checked: checked, level: level, data: item, label: React.createElement(Highlighter, { text: item.label, highlight: item.filterText }), labelInText: item.label, style: style, hideCheckBox: hideCheckBox, isFocused: isFocused, notSelectable: item.notSelectable, LogoIcon: item.LogoIcon }));
97
97
  }, [hideCheckBox, onListItemClick, selected]);
98
- var containerWidth = getMaxItemWidth('label')(groupedItems) || DEFAULT_MIN_CONTAINER_WIDTH;
98
+ var containerWidth = Math.max(getMaxItemWidth('label')(groupedItems), DEFAULT_MIN_CONTAINER_WIDTH);
99
99
  var classes = useStyles();
100
100
  return (React.createElement(SelectionPopup, __assign({ open: open, className: classnames(classes.container, classes.popupContainer), anchorEl: anchorEl, onClose: onClose, onSearch: onSearch, title: titleText, containerWidth: containerWidth, searchInputOnKeyDown: handleKeyDown }, otherProps),
101
101
  React.createElement(VirtualGroupedList, { height: LIST_CONTAINER_HEIGHT, renderItem: renderListItem, items: items, hideSubtitles: true, getItemSize: getItemSize, focusIndex: focusIndex, renderGroupTitle: renderGroupTitle })));
@@ -1,20 +1,20 @@
1
1
  import React from 'react';
2
2
  import { PopoverProps } from '@mui/material/Popover';
3
3
  type Props = {
4
- title: string;
4
+ title?: string;
5
5
  additionalInfo?: string;
6
6
  containerWidth: number;
7
- containerHeight: number;
7
+ containerHeight?: number;
8
8
  children: React.ReactNode;
9
9
  PaperProps?: Record<string, unknown>;
10
10
  searchInputOnKeyDown: (event: React.KeyboardEvent) => void;
11
11
  onSearch?: (value?: string) => void;
12
12
  className?: string;
13
- hideTitle?: boolean;
14
13
  hideSearchInput?: boolean;
15
14
  inputPlaceholder?: string;
16
15
  headerPlacement?: 'top' | 'bottom';
17
16
  searchInputRef?: React.Ref<unknown>;
17
+ toolbar?: React.ReactNode;
18
18
  } & PopoverProps;
19
- export declare const SelectionPopup: ({ title, className, onSearch, hideTitle, hideSearchInput, inputPlaceholder, headerPlacement, containerWidth, containerHeight, searchInputOnKeyDown, children, searchInputRef, anchorOrigin, transformOrigin, additionalInfo, ...otherProps }: Props) => React.JSX.Element;
19
+ export declare const SelectionPopup: ({ title, className, onSearch, hideSearchInput, inputPlaceholder, headerPlacement, containerWidth, containerHeight, searchInputOnKeyDown, children, searchInputRef, anchorOrigin, transformOrigin, additionalInfo, toolbar, ...otherProps }: Props) => React.JSX.Element;
20
20
  export {};
@@ -31,19 +31,20 @@ import { useTheme } from '@mui/styles';
31
31
  import styles from './SelectionPopup.module.css';
32
32
  export var SelectionPopup = function (_a) {
33
33
  var _b;
34
- var title = _a.title, className = _a.className, onSearch = _a.onSearch, hideTitle = _a.hideTitle, hideSearchInput = _a.hideSearchInput, inputPlaceholder = _a.inputPlaceholder, _c = _a.headerPlacement, headerPlacement = _c === void 0 ? 'top' : _c, containerWidth = _a.containerWidth, _d = _a.containerHeight, containerHeight = _d === void 0 ? 553 : _d, searchInputOnKeyDown = _a.searchInputOnKeyDown, children = _a.children, searchInputRef = _a.searchInputRef, _e = _a.anchorOrigin, anchorOrigin = _e === void 0 ? {
34
+ var title = _a.title, className = _a.className, onSearch = _a.onSearch, hideSearchInput = _a.hideSearchInput, inputPlaceholder = _a.inputPlaceholder, _c = _a.headerPlacement, headerPlacement = _c === void 0 ? 'top' : _c, containerWidth = _a.containerWidth, _d = _a.containerHeight, containerHeight = _d === void 0 ? 553 : _d, searchInputOnKeyDown = _a.searchInputOnKeyDown, children = _a.children, searchInputRef = _a.searchInputRef, _e = _a.anchorOrigin, anchorOrigin = _e === void 0 ? {
35
35
  vertical: 'top',
36
36
  horizontal: 'right'
37
37
  } : _e, _f = _a.transformOrigin, transformOrigin = _f === void 0 ? {
38
38
  vertical: 'top',
39
39
  horizontal: 'right'
40
- } : _f, additionalInfo = _a.additionalInfo, otherProps = __rest(_a, ["title", "className", "onSearch", "hideTitle", "hideSearchInput", "inputPlaceholder", "headerPlacement", "containerWidth", "containerHeight", "searchInputOnKeyDown", "children", "searchInputRef", "anchorOrigin", "transformOrigin", "additionalInfo"]);
40
+ } : _f, additionalInfo = _a.additionalInfo, toolbar = _a.toolbar, otherProps = __rest(_a, ["title", "className", "onSearch", "hideSearchInput", "inputPlaceholder", "headerPlacement", "containerWidth", "containerHeight", "searchInputOnKeyDown", "children", "searchInputRef", "anchorOrigin", "transformOrigin", "additionalInfo", "toolbar"]);
41
41
  var currentTheme = useTheme();
42
42
  var variableStyles = useCssVariableStyles({
43
43
  '--container-height': "".concat(containerHeight, "px")
44
44
  });
45
45
  var header = (React.createElement(React.Fragment, null,
46
- !hideTitle && (React.createElement("div", { className: styles.header },
46
+ toolbar,
47
+ title && !toolbar && (React.createElement("div", { className: styles.header },
47
48
  title,
48
49
  additionalInfo && React.createElement(InfoIcon, { className: styles.infoIcon, tooltipTitle: additionalInfo }))),
49
50
  !hideSearchInput && (React.createElement(SearchInput, { onSearch: onSearch, autofocus: true, onKeyDown: searchInputOnKeyDown, inputRef: searchInputRef, classes: { root: styles.searchInputContainer }, placeholder: inputPlaceholder || i18n.text('Search & add attributes'), height: 40 }))));
@@ -90,8 +90,8 @@ describe('SelectionPopup tests', function () {
90
90
  }
91
91
  });
92
92
  }); });
93
- it('should hide title if props.hideTitle is true', function () {
94
- setUp({ hideTitle: true });
93
+ it('should hide title when title is not provided', function () {
94
+ setUp({ title: undefined });
95
95
  expect(screen.queryByText('Title')).not.toBeInTheDocument();
96
96
  });
97
97
  it('should hide search input if props.hideSearchInput is true', function () {
@@ -11,14 +11,14 @@ type Item = AttributeOption & {
11
11
  children?: Item[];
12
12
  attributes?: Item[];
13
13
  };
14
- type Props = Omit<React.ComponentProps<typeof SelectionPopup>, 'title'> & {
15
- hideCheckBox: boolean;
14
+ type Props = Omit<React.ComponentProps<typeof SelectionPopup>, 'title' | 'children' | 'containerWidth' | 'searchInputOnKeyDown'> & {
15
+ hideCheckBox?: boolean;
16
16
  titleText?: string;
17
17
  filterText?: string;
18
18
  selected: Item[];
19
19
  data: Item[];
20
20
  onListItemClick: (item: Item, checked: boolean) => void;
21
- renderGroupTitle: VirtualGroupedListRenderGroupTitle<Item>;
21
+ renderGroupTitle?: VirtualGroupedListRenderGroupTitle<Item>;
22
22
  };
23
23
  export declare const ConfigureColumnsPopup: ({ open, anchorEl, data, onSearch, onClose, titleText, filterText, onListItemClick, selected, hideCheckBox, renderGroupTitle, ...otherProps }: Props) => React.JSX.Element;
24
24
  export {};
@@ -71,9 +71,9 @@ var useKeyboardNavigation_1 = require("../hooks/useKeyboardNavigation");
71
71
  var styles_1 = require("./styles");
72
72
  var ITEM_HEIGHT = 32;
73
73
  var LIST_CONTAINER_HEIGHT = 300;
74
- var DEFAULT_MIN_CONTAINER_WIDTH = 308;
74
+ var DEFAULT_MIN_CONTAINER_WIDTH = 318;
75
75
  var ConfigureColumnsPopup = function (_a) {
76
- var open = _a.open, anchorEl = _a.anchorEl, _b = _a.data, data = _b === void 0 ? [] : _b, onSearch = _a.onSearch, onClose = _a.onClose, _c = _a.titleText, titleText = _c === void 0 ? ui_i18n_1.default.text('Show/hide columns') : _c, _d = _a.filterText, filterText = _d === void 0 ? '' : _d, onListItemClick = _a.onListItemClick, _e = _a.selected, selected = _e === void 0 ? [] : _e, hideCheckBox = _a.hideCheckBox, renderGroupTitle = _a.renderGroupTitle, otherProps = __rest(_a, ["open", "anchorEl", "data", "onSearch", "onClose", "titleText", "filterText", "onListItemClick", "selected", "hideCheckBox", "renderGroupTitle"]);
76
+ var open = _a.open, anchorEl = _a.anchorEl, _b = _a.data, data = _b === void 0 ? [] : _b, onSearch = _a.onSearch, onClose = _a.onClose, _c = _a.titleText, titleText = _c === void 0 ? ui_i18n_1.default.text('Show/hide columns') : _c, _d = _a.filterText, filterText = _d === void 0 ? '' : _d, onListItemClick = _a.onListItemClick, _e = _a.selected, selected = _e === void 0 ? [] : _e, _f = _a.hideCheckBox, hideCheckBox = _f === void 0 ? false : _f, renderGroupTitle = _a.renderGroupTitle, otherProps = __rest(_a, ["open", "anchorEl", "data", "onSearch", "onClose", "titleText", "filterText", "onListItemClick", "selected", "hideCheckBox", "renderGroupTitle"]);
77
77
  var filterItem = (0, react_1.useCallback)(function (item) {
78
78
  return item.label.toLowerCase().includes(filterText.toLowerCase());
79
79
  }, [filterText]);
@@ -110,12 +110,12 @@ var ConfigureColumnsPopup = function (_a) {
110
110
  }, [onListItemClick, selected]);
111
111
  var groupedItems = (0, react_1.useMemo)(function () { return (renderGroupTitle ? getGroupsData : getAttributesData)(data); }, [data, renderGroupTitle, getGroupsData, getAttributesData]);
112
112
  var items = (0, react_1.useMemo)(function () { return (0, VirtualGroupedList_1.flattenGroupedItemsData)(groupedItems); }, [groupedItems]);
113
- var _f = (0, useKeyboardNavigation_1.useKeyboardNavigation)({
113
+ var _g = (0, useKeyboardNavigation_1.useKeyboardNavigation)({
114
114
  items: items,
115
115
  open: open,
116
116
  onSelectFocusedItem: handleSearchOnEnter,
117
117
  selectedItems: selected
118
- }), focusIndex = _f.focusIndex, handleKeyDown = _f.handleKeyDown;
118
+ }), focusIndex = _g.focusIndex, handleKeyDown = _g.handleKeyDown;
119
119
  var focusIndexRef = (0, react_1.useRef)(null);
120
120
  focusIndexRef.current = focusIndex;
121
121
  var renderListItem = (0, react_1.useCallback)(function (style, _a, index) {
@@ -124,7 +124,7 @@ var ConfigureColumnsPopup = function (_a) {
124
124
  var isFocused = focusIndexRef.current === index;
125
125
  return (react_1.default.createElement(AttributeListItem_1.AttributeListItem, { key: item.id, onClick: onListItemClick, checked: checked, level: level, data: item, label: react_1.default.createElement(Highlighter_1.Highlighter, { text: item.label, highlight: item.filterText }), labelInText: item.label, style: style, hideCheckBox: hideCheckBox, isFocused: isFocused, notSelectable: item.notSelectable, LogoIcon: item.LogoIcon }));
126
126
  }, [hideCheckBox, onListItemClick, selected]);
127
- var containerWidth = (0, mdm_sdk_1.getMaxItemWidth)('label')(groupedItems) || DEFAULT_MIN_CONTAINER_WIDTH;
127
+ var containerWidth = Math.max((0, mdm_sdk_1.getMaxItemWidth)('label')(groupedItems), DEFAULT_MIN_CONTAINER_WIDTH);
128
128
  var classes = (0, styles_1.useStyles)();
129
129
  return (react_1.default.createElement(SelectionPopup_1.SelectionPopup, __assign({ open: open, className: (0, classnames_1.default)(classes.container, classes.popupContainer), anchorEl: anchorEl, onClose: onClose, onSearch: onSearch, title: titleText, containerWidth: containerWidth, searchInputOnKeyDown: handleKeyDown }, otherProps),
130
130
  react_1.default.createElement(VirtualGroupedList_1.VirtualGroupedList, { height: LIST_CONTAINER_HEIGHT, renderItem: renderListItem, items: items, hideSubtitles: true, getItemSize: getItemSize, focusIndex: focusIndex, renderGroupTitle: renderGroupTitle })));
@@ -1,20 +1,20 @@
1
1
  import React from 'react';
2
2
  import { PopoverProps } from '@mui/material/Popover';
3
3
  type Props = {
4
- title: string;
4
+ title?: string;
5
5
  additionalInfo?: string;
6
6
  containerWidth: number;
7
- containerHeight: number;
7
+ containerHeight?: number;
8
8
  children: React.ReactNode;
9
9
  PaperProps?: Record<string, unknown>;
10
10
  searchInputOnKeyDown: (event: React.KeyboardEvent) => void;
11
11
  onSearch?: (value?: string) => void;
12
12
  className?: string;
13
- hideTitle?: boolean;
14
13
  hideSearchInput?: boolean;
15
14
  inputPlaceholder?: string;
16
15
  headerPlacement?: 'top' | 'bottom';
17
16
  searchInputRef?: React.Ref<unknown>;
17
+ toolbar?: React.ReactNode;
18
18
  } & PopoverProps;
19
- export declare const SelectionPopup: ({ title, className, onSearch, hideTitle, hideSearchInput, inputPlaceholder, headerPlacement, containerWidth, containerHeight, searchInputOnKeyDown, children, searchInputRef, anchorOrigin, transformOrigin, additionalInfo, ...otherProps }: Props) => React.JSX.Element;
19
+ export declare const SelectionPopup: ({ title, className, onSearch, hideSearchInput, inputPlaceholder, headerPlacement, containerWidth, containerHeight, searchInputOnKeyDown, children, searchInputRef, anchorOrigin, transformOrigin, additionalInfo, toolbar, ...otherProps }: Props) => React.JSX.Element;
20
20
  export {};
@@ -37,19 +37,20 @@ var styles_1 = require("@mui/styles");
37
37
  var SelectionPopup_module_css_1 = __importDefault(require("./SelectionPopup.module.css"));
38
38
  var SelectionPopup = function (_a) {
39
39
  var _b;
40
- var title = _a.title, className = _a.className, onSearch = _a.onSearch, hideTitle = _a.hideTitle, hideSearchInput = _a.hideSearchInput, inputPlaceholder = _a.inputPlaceholder, _c = _a.headerPlacement, headerPlacement = _c === void 0 ? 'top' : _c, containerWidth = _a.containerWidth, _d = _a.containerHeight, containerHeight = _d === void 0 ? 553 : _d, searchInputOnKeyDown = _a.searchInputOnKeyDown, children = _a.children, searchInputRef = _a.searchInputRef, _e = _a.anchorOrigin, anchorOrigin = _e === void 0 ? {
40
+ var title = _a.title, className = _a.className, onSearch = _a.onSearch, hideSearchInput = _a.hideSearchInput, inputPlaceholder = _a.inputPlaceholder, _c = _a.headerPlacement, headerPlacement = _c === void 0 ? 'top' : _c, containerWidth = _a.containerWidth, _d = _a.containerHeight, containerHeight = _d === void 0 ? 553 : _d, searchInputOnKeyDown = _a.searchInputOnKeyDown, children = _a.children, searchInputRef = _a.searchInputRef, _e = _a.anchorOrigin, anchorOrigin = _e === void 0 ? {
41
41
  vertical: 'top',
42
42
  horizontal: 'right'
43
43
  } : _e, _f = _a.transformOrigin, transformOrigin = _f === void 0 ? {
44
44
  vertical: 'top',
45
45
  horizontal: 'right'
46
- } : _f, additionalInfo = _a.additionalInfo, otherProps = __rest(_a, ["title", "className", "onSearch", "hideTitle", "hideSearchInput", "inputPlaceholder", "headerPlacement", "containerWidth", "containerHeight", "searchInputOnKeyDown", "children", "searchInputRef", "anchorOrigin", "transformOrigin", "additionalInfo"]);
46
+ } : _f, additionalInfo = _a.additionalInfo, toolbar = _a.toolbar, otherProps = __rest(_a, ["title", "className", "onSearch", "hideSearchInput", "inputPlaceholder", "headerPlacement", "containerWidth", "containerHeight", "searchInputOnKeyDown", "children", "searchInputRef", "anchorOrigin", "transformOrigin", "additionalInfo", "toolbar"]);
47
47
  var currentTheme = (0, styles_1.useTheme)();
48
48
  var variableStyles = (0, useCssVariableStyles_1.useCssVariableStyles)({
49
49
  '--container-height': "".concat(containerHeight, "px")
50
50
  });
51
51
  var header = (react_1.default.createElement(react_1.default.Fragment, null,
52
- !hideTitle && (react_1.default.createElement("div", { className: SelectionPopup_module_css_1.default.header },
52
+ toolbar,
53
+ title && !toolbar && (react_1.default.createElement("div", { className: SelectionPopup_module_css_1.default.header },
53
54
  title,
54
55
  additionalInfo && react_1.default.createElement(InfoIcon_1.InfoIcon, { className: SelectionPopup_module_css_1.default.infoIcon, tooltipTitle: additionalInfo }))),
55
56
  !hideSearchInput && (react_1.default.createElement(SearchInput_1.SearchInput, { onSearch: onSearch, autofocus: true, onKeyDown: searchInputOnKeyDown, inputRef: searchInputRef, classes: { root: SelectionPopup_module_css_1.default.searchInputContainer }, placeholder: inputPlaceholder || ui_i18n_1.default.text('Search & add attributes'), height: 40 }))));
@@ -95,8 +95,8 @@ describe('SelectionPopup tests', function () {
95
95
  }
96
96
  });
97
97
  }); });
98
- it('should hide title if props.hideTitle is true', function () {
99
- setUp({ hideTitle: true });
98
+ it('should hide title when title is not provided', function () {
99
+ setUp({ title: undefined });
100
100
  expect(react_2.screen.queryByText('Title')).not.toBeInTheDocument();
101
101
  });
102
102
  it('should hide search input if props.hideSearchInput is true', function () {
@@ -64,6 +64,22 @@ var EntityChangesGroup = function (_a) {
64
64
  relationsInfo: relationsInfo
65
65
  });
66
66
  var changesList = (0, react_1.useMemo)(function () { return (0, changesList_1.prepareChangesList)(rawChangesList); }, [rawChangesList]);
67
+ var objectUriByChangeIndex = (0, react_1.useMemo)(function () {
68
+ var _a, _b;
69
+ var result = [];
70
+ var currentObjectUri = entityInfo.uri;
71
+ for (var _i = 0, changesList_2 = changesList; _i < changesList_2.length; _i++) {
72
+ var item = changesList_2[_i];
73
+ if (!(0, helpers_1.isDiffChange)(item)) {
74
+ currentObjectUri = entityInfo.uri;
75
+ }
76
+ else if ((0, helpers_1.isRelationRow)(item)) {
77
+ currentObjectUri = (_b = (_a = item.attributeValue) === null || _a === void 0 ? void 0 : _a.uri) !== null && _b !== void 0 ? _b : entityInfo.uri;
78
+ }
79
+ result.push(currentObjectUri);
80
+ }
81
+ return result;
82
+ }, [changesList, entityInfo.uri]);
67
83
  var entityAttributeTypes = (0, react_1.useMemo)(function () {
68
84
  if (!(0, ramda_1.isNil)(entityInfo.isExist)) {
69
85
  return (0, moreAttributesScope_1.getAvailableAttributeTypesForEntity)(metadata, entityInfo.type);
@@ -93,7 +109,7 @@ var EntityChangesGroup = function (_a) {
93
109
  highlight(addedIds);
94
110
  };
95
111
  }, [addAddedAttributes, highlight]);
96
- var handleAddNestedAttributes = (0, react_1.useCallback)(function (change) { return function (attributeTypes) {
112
+ var handleAddNestedAttributes = (0, react_1.useCallback)(function (change, objectUri) { return function (attributeTypes) {
97
113
  var _a, _b, _c, _d, _e;
98
114
  var parentUri = (_a = change.attributeType) === null || _a === void 0 ? void 0 : _a.uri;
99
115
  var parentAttrs = attributeTypes.filter(function (attr) { return attr.uri === parentUri; });
@@ -105,7 +121,7 @@ var EntityChangesGroup = function (_a) {
105
121
  var addedId = (0, addedAttributes_1.getAddedId)(change);
106
122
  if (lineId && (0, addedAttributes_1.isRootAddedAttribute)(lineId)) {
107
123
  handleAddAttributes({
108
- objectUri: (0, addedAttributes_1.getObjectIdFromLineId)(lineId),
124
+ objectUri: objectUri,
109
125
  changeOverrides: siblingOverrides
110
126
  })(parentAttrs);
111
127
  }
@@ -118,7 +134,7 @@ var EntityChangesGroup = function (_a) {
118
134
  }
119
135
  else {
120
136
  handleAddAttributes({
121
- objectUri: entityInfo.uri,
137
+ objectUri: objectUri,
122
138
  changeOverrides: siblingOverrides
123
139
  })(parentAttrs);
124
140
  }
@@ -131,12 +147,12 @@ var EntityChangesGroup = function (_a) {
131
147
  }
132
148
  else {
133
149
  handleAddAttributes({
134
- objectUri: entityInfo.uri,
150
+ objectUri: objectUri,
135
151
  changeOverrides: childOverrides
136
152
  })(subAttrs);
137
153
  }
138
154
  }
139
- }; }, [handleAddAttributes, entityInfo.uri]);
155
+ }; }, [handleAddAttributes]);
140
156
  return (react_1.default.createElement(AttributesChangesContext_1.AttributesChangesContext.Provider, { value: objectsInfo },
141
157
  react_1.default.createElement(Accordion_1.default, { className: EntityChangesGroup_module_css_1.default.entityGroup, defaultExpanded: true, "data-reltio-id": "entity-changes-group" },
142
158
  react_1.default.createElement(AccordionSummary_1.default, { expandIcon: react_1.default.createElement(ExpandMore_1.default, null), className: EntityChangesGroup_module_css_1.default.entityHeader, classes: {
@@ -163,7 +179,7 @@ var EntityChangesGroup = function (_a) {
163
179
  objectUri: (_e = item === null || item === void 0 ? void 0 : item.attributeValue) === null || _e === void 0 ? void 0 : _e.uri,
164
180
  parentLineId: (_f = item.lineIds) === null || _f === void 0 ? void 0 : _f[0]
165
181
  }) })),
166
- allowAddAttributes && (0, helpers_1.isNestedOrReferenceParent)(item) && (react_1.default.createElement(editors_1.MoreAttributesEditor, { data: nestedAttrs, change: item, parent: item.attributeType, onApply: handleAddNestedAttributes(item) }))));
182
+ allowAddAttributes && (0, helpers_1.isNestedOrReferenceParent)(item) && (react_1.default.createElement(editors_1.MoreAttributesEditor, { data: nestedAttrs, change: item, parent: item.attributeType, onApply: handleAddNestedAttributes(item, objectUriByChangeIndex[index]) }))));
167
183
  })))));
168
184
  };
169
185
  exports.EntityChangesGroup = EntityChangesGroup;
@@ -63,10 +63,13 @@ var getParentChangeOverrides = function (change) {
63
63
  if (change.refAttributeType) {
64
64
  var parts = change.refAttributeType.split('/');
65
65
  if (parts.length > 2) {
66
- result.refAttributeType = parts.slice(0, -2).join('/');
66
+ var parentRefAttributeType = parts.slice(0, -2).join('/');
67
+ if (parentRefAttributeType.includes('/attributes/')) {
68
+ result.refAttributeType = parentRefAttributeType;
69
+ }
67
70
  }
68
71
  }
69
- if (change.refObjectURI) {
72
+ if (result.refAttributeType && change.refObjectURI) {
70
73
  result.refObjectURI = change.refObjectURI;
71
74
  }
72
75
  return Object.keys(result).length > 0 ? result : undefined;
@@ -10,6 +10,15 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
13
22
  Object.defineProperty(exports, "__esModule", { value: true });
14
23
  exports.prepareChangesList = void 0;
15
24
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
@@ -130,23 +139,30 @@ var extractPathFromInnerChange = function (attributeValue) {
130
139
  return __assign(__assign({ attributePath: inner.attributePath }, (inner.refAttributeType && { refAttributeType: inner.refAttributeType })), (inner.refObjectURI && { refObjectURI: inner.refObjectURI }));
131
140
  };
132
141
  var fillParentPaths = function (items) {
133
- return items.map(function (item, index) {
134
- var _a, _b;
142
+ var _a, _b;
143
+ var result = __spreadArray([], items, true);
144
+ for (var index = result.length - 1; index >= 0; index--) {
145
+ var item = result[index];
135
146
  if (!(0, helpers_1.isDiffChange)(item) || !(0, mdm_sdk_1.isComplexAttribute)(item.attributeType) || item.attributePath)
136
- return item;
147
+ continue;
137
148
  var innerPath = extractPathFromInnerChange(item.attributeValue);
138
- if (innerPath)
139
- return __assign(__assign({}, item), innerPath);
140
- var name = (_a = item.attributeType) === null || _a === void 0 ? void 0 : _a.name;
149
+ if (innerPath) {
150
+ result[index] = __assign(__assign({}, item), innerPath);
151
+ continue;
152
+ }
153
+ var name_1 = (_a = item.attributeType) === null || _a === void 0 ? void 0 : _a.name;
141
154
  var instanceId = (_b = item.attributeValue) === null || _b === void 0 ? void 0 : _b.id;
142
- if (!name || !instanceId)
143
- return item;
144
- var descendant = findDescendantWithPath(items, index, item.level);
155
+ if (!name_1 || !instanceId)
156
+ continue;
157
+ var descendant = findDescendantWithPath(result, index, item.level);
145
158
  if (!descendant)
146
- return item;
147
- var parentPath = deriveParentPath(descendant, name, instanceId);
148
- return parentPath ? __assign(__assign({}, item), parentPath) : item;
149
- });
159
+ continue;
160
+ var parentPath = deriveParentPath(descendant, name_1, instanceId);
161
+ if (parentPath) {
162
+ result[index] = __assign(__assign({}, item), parentPath);
163
+ }
164
+ }
165
+ return result;
150
166
  };
151
167
  var prepareChangesList = function (rawChangesList) {
152
168
  var withPaths = fillParentPaths(rawChangesList);
@@ -0,0 +1,41 @@
1
+ import { DCRTypes, type AttributeType } from '@reltio/mdm-sdk';
2
+ import type { Diff } from '../../types';
3
+ export declare const referenceAttributeType: AttributeType;
4
+ export declare const referenceAttributeValue: {
5
+ id: string;
6
+ value: {
7
+ RefFirstLevelNested: {
8
+ id: string;
9
+ value: {
10
+ FirstLevelNestedSub2: {
11
+ id: string;
12
+ value: {
13
+ id: string;
14
+ refObjectURI: string;
15
+ type: DCRTypes;
16
+ objectType: string;
17
+ attributePath: string;
18
+ oldValue: {
19
+ value: string;
20
+ lineIds: string[];
21
+ };
22
+ newValue: {
23
+ value: string;
24
+ lineIds: string[];
25
+ };
26
+ attributeType: string;
27
+ refAttributeType: string;
28
+ lineIds: string[];
29
+ };
30
+ }[];
31
+ };
32
+ }[];
33
+ };
34
+ refObjectURI: string;
35
+ };
36
+ export declare const affiliationsChangeRow: Diff;
37
+ export declare const deepNestedParentFromChildChanges: () => Diff[];
38
+ export declare const deepNestedInnerChangeRow: () => Diff[];
39
+ export declare const addressDeepNestedThreeLevelChanges: () => Diff[];
40
+ export declare const addressDeepNestedRefPropagationChanges: () => Diff[];
41
+ export declare const deepNestedRowWithExistingPath: () => Diff[];
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deepNestedRowWithExistingPath = exports.addressDeepNestedRefPropagationChanges = exports.addressDeepNestedThreeLevelChanges = exports.deepNestedInnerChangeRow = exports.deepNestedParentFromChildChanges = exports.affiliationsChangeRow = exports.referenceAttributeValue = exports.referenceAttributeType = void 0;
4
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
5
+ exports.referenceAttributeType = {
6
+ uri: 'configuration/entityTypes/HCP/attributes/Affiliations',
7
+ name: 'Affiliations',
8
+ label: 'HCP to HCA Affiliations',
9
+ type: 'Reference',
10
+ referencedEntityTypeURI: 'configuration/entityTypes/HCA',
11
+ relationshipTypeURI: 'configuration/relationTypes/HCPtoHCA'
12
+ };
13
+ exports.referenceAttributeValue = {
14
+ id: '0HocGCj',
15
+ value: {
16
+ RefFirstLevelNested: [
17
+ {
18
+ id: '2Cf73Q29',
19
+ value: {
20
+ FirstLevelNestedSub2: [
21
+ {
22
+ id: '2ph3wL7h',
23
+ value: {
24
+ id: '0aDhfxd',
25
+ refObjectURI: 'relations/0HocGCj',
26
+ type: mdm_sdk_1.DCRTypes.UPDATE_ATTRIBUTE,
27
+ objectType: 'configuration/entityTypes/HCP',
28
+ attributePath: 'RefFirstLevelNested/2Cf73Q29/FirstLevelNestedSub2/2ph3wL7h',
29
+ oldValue: { value: '555756', lineIds: ['BAliEK2/0aDhfxd/oldValue'] },
30
+ newValue: { value: '5557563462', lineIds: ['BAliEK2/0aDhfxd/newValue'] },
31
+ attributeType: 'configuration/relationTypes/HCPtoHCA/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub2',
32
+ refAttributeType: 'configuration/entityTypes/HCP/attributes/Affiliations/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub2',
33
+ lineIds: ['BAliEK2/0aDhfxd']
34
+ }
35
+ }
36
+ ]
37
+ }
38
+ }
39
+ ]
40
+ },
41
+ refObjectURI: 'relations/0HocGCj'
42
+ };
43
+ exports.affiliationsChangeRow = {
44
+ level: 0,
45
+ label: 'HCP to HCA Affiliations',
46
+ attributeType: exports.referenceAttributeType,
47
+ attributeValue: exports.referenceAttributeValue,
48
+ operation: mdm_sdk_1.DCROperationTypes.EDITED,
49
+ isReferenceSubAttribute: false
50
+ };
51
+ var nestedAttributeType = function (name) {
52
+ return ({
53
+ uri: "configuration/entityTypes/HCP/attributes/".concat(name),
54
+ name: name,
55
+ label: name,
56
+ type: 'Nested'
57
+ });
58
+ };
59
+ var firstLevelNestedSub2FloatType = {
60
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub2',
61
+ name: 'FirstLevelNestedSub2',
62
+ label: 'float',
63
+ type: 'Float'
64
+ };
65
+ var deepNestedParentFromChildChanges = function () { return [
66
+ {
67
+ level: 1,
68
+ label: 'DeepNested',
69
+ attributeType: nestedAttributeType('DeepNested'),
70
+ attributeValue: { id: '2ph3uHFx', value: { FirstLevelNestedSub2: [] } },
71
+ operation: mdm_sdk_1.DCROperationTypes.EDITED,
72
+ isReferenceSubAttribute: false
73
+ },
74
+ {
75
+ level: 2,
76
+ label: 'FirstLevelNestedSub2',
77
+ attributeType: firstLevelNestedSub2FloatType,
78
+ attributePath: 'DeepNested/2ph3uHFx/FirstLevelNestedSub2/2ph3uPmT',
79
+ operation: mdm_sdk_1.DCROperationTypes.EDITED,
80
+ isReferenceSubAttribute: false
81
+ }
82
+ ]; };
83
+ exports.deepNestedParentFromChildChanges = deepNestedParentFromChildChanges;
84
+ var deepNestedInnerChangeRow = function () { return [
85
+ {
86
+ level: 1,
87
+ label: 'DeepNested',
88
+ attributeType: nestedAttributeType('DeepNested'),
89
+ attributeValue: {
90
+ id: '4FcgXO5o',
91
+ value: {
92
+ attributePath: 'DeepNested/4FcgXO5o/SecondLevelNested',
93
+ refAttributeType: 'configuration/entityTypes/HCP/attributes/Address/attributes/DeepNested/attributes/SecondLevelNested',
94
+ refObjectURI: 'relations/0LbuUWU'
95
+ }
96
+ },
97
+ operation: mdm_sdk_1.DCROperationTypes.EDITED,
98
+ isReferenceSubAttribute: false
99
+ }
100
+ ]; };
101
+ exports.deepNestedInnerChangeRow = deepNestedInnerChangeRow;
102
+ var addressDeepNestedThreeLevelChanges = function () { return [
103
+ {
104
+ level: 1,
105
+ label: 'DeepNested',
106
+ attributeType: nestedAttributeType('DeepNested'),
107
+ attributeValue: { id: '4FcgXO5o', value: { SecondLevelNested: [] } },
108
+ operation: mdm_sdk_1.DCROperationTypes.EDITED,
109
+ isReferenceSubAttribute: false
110
+ },
111
+ {
112
+ level: 2,
113
+ label: 'SecondLevelNested',
114
+ attributeType: nestedAttributeType('SecondLevelNested'),
115
+ attributeValue: { id: '2v13QcOX', value: { FirstLevelNestedSubatr3: [] } },
116
+ operation: mdm_sdk_1.DCROperationTypes.EDITED,
117
+ isReferenceSubAttribute: false
118
+ },
119
+ {
120
+ level: 3,
121
+ label: 'FirstLevelNestedSubatr3',
122
+ attributeType: nestedAttributeType('FirstLevelNestedSubatr3'),
123
+ attributePath: 'DeepNested/4FcgXO5o/SecondLevelNested/2v13QcOX/FirstLevelNestedSubatr3/2v13Qgen',
124
+ operation: mdm_sdk_1.DCROperationTypes.EDITED,
125
+ isReferenceSubAttribute: false
126
+ }
127
+ ]; };
128
+ exports.addressDeepNestedThreeLevelChanges = addressDeepNestedThreeLevelChanges;
129
+ var addressDeepNestedRefPropagationChanges = function () { return [
130
+ {
131
+ level: 1,
132
+ label: 'DeepNested',
133
+ attributeType: nestedAttributeType('DeepNested'),
134
+ attributeValue: { id: '2ph3uHFx', value: { FirstLevelNestedSub2: [] } },
135
+ operation: mdm_sdk_1.DCROperationTypes.EDITED,
136
+ isReferenceSubAttribute: false
137
+ },
138
+ {
139
+ level: 2,
140
+ label: 'FirstLevelNestedSub2',
141
+ attributeType: firstLevelNestedSub2FloatType,
142
+ attributePath: 'DeepNested/2ph3uHFx/FirstLevelNestedSub2/2ph3uPmT',
143
+ refAttributeType: 'configuration/entityTypes/HCP/attributes/Address/attributes/DeepNested/attributes/FirstLevelNestedSub2',
144
+ refObjectURI: 'relations/0LbuUWU',
145
+ operation: mdm_sdk_1.DCROperationTypes.EDITED,
146
+ isReferenceSubAttribute: false
147
+ }
148
+ ]; };
149
+ exports.addressDeepNestedRefPropagationChanges = addressDeepNestedRefPropagationChanges;
150
+ var deepNestedRowWithExistingPath = function () { return [
151
+ {
152
+ level: 1,
153
+ label: 'DeepNested',
154
+ attributeType: nestedAttributeType('DeepNested'),
155
+ attributeValue: { id: '2ph3uHFx', value: { FirstLevelNestedSub2: [] } },
156
+ attributePath: 'DeepNested/2ph3uHFx',
157
+ operation: mdm_sdk_1.DCROperationTypes.EDITED,
158
+ isReferenceSubAttribute: false
159
+ }
160
+ ]; };
161
+ exports.deepNestedRowWithExistingPath = deepNestedRowWithExistingPath;