@reltio/components 1.4.1511 → 1.4.1515

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 (79) hide show
  1. package/cjs/components/ProfilesList/styles.d.ts +1 -1
  2. package/cjs/components/RelationEditor/RelationEditor.js +4 -4
  3. package/cjs/components/attributes/editMode/AttributesFactory/Attribute.d.ts +6 -1
  4. package/cjs/components/attributes/editMode/AttributesFactory/Attribute.js +40 -4
  5. package/cjs/components/attributes/editMode/AttributesList/AttributesList.d.ts +3 -39
  6. package/cjs/components/attributes/editMode/AttributesList/AttributesList.js +10 -3
  7. package/cjs/components/attributes/editMode/AttributesPager/AttributeRenderer.d.ts +9 -7
  8. package/cjs/components/attributes/editMode/AttributesPager/AttributeRenderer.js +8 -12
  9. package/cjs/components/attributes/editMode/AttributesPager/AttributesPager.d.ts +38 -2
  10. package/cjs/components/attributes/editMode/AttributesPager/AttributesPager.js +19 -28
  11. package/cjs/components/attributes/editMode/AttributesPager/ImageLineRenderer.d.ts +4 -2
  12. package/cjs/components/attributes/editMode/AttributesPager/ImageLineRenderer.js +5 -2
  13. package/cjs/components/attributes/editMode/AttributesPager/SpecialRenderer.d.ts +3 -1
  14. package/cjs/components/attributes/editMode/AttributesPager/SpecialRenderer.js +6 -3
  15. package/cjs/components/attributes/editMode/AttributesPager/index.d.ts +4 -1
  16. package/cjs/components/attributes/editMode/ComplexAttribute/ComplexAttribute.js +5 -4
  17. package/cjs/components/attributes/editMode/ReferenceAttribute/ReferenceAttribute.js +3 -3
  18. package/cjs/components/attributes/editMode/SimpleAttributeEditor/SimpleAttributeEditor.js +3 -3
  19. package/cjs/components/attributes/editMode/hooks/useScrollToAttribute/styles.d.ts +1 -0
  20. package/cjs/components/attributes/editMode/hooks/useScrollToAttribute/styles.js +38 -0
  21. package/cjs/components/attributes/editMode/hooks/useScrollToAttribute/useScrollToAttribute.d.ts +8 -0
  22. package/cjs/components/attributes/editMode/hooks/useScrollToAttribute/useScrollToAttribute.js +17 -0
  23. package/cjs/components/attributes/inline/common/CrosswalkIcon.js +4 -2
  24. package/cjs/components/attributes/inline/common/__test__/CrosswalkIcon.spec.js +114 -64
  25. package/cjs/components/attributes/inline/common/styles.d.ts +1 -0
  26. package/cjs/components/attributes/inline/common/styles.js +4 -2
  27. package/cjs/components/workflow/helpers/errors.d.ts +3 -2
  28. package/cjs/components/workflow/helpers/errors.js +15 -9
  29. package/cjs/components/workflow/hooks/useChangeRequest.js +2 -2
  30. package/cjs/contexts/ScrollToElementContext/index.d.ts +20 -0
  31. package/cjs/contexts/ScrollToElementContext/index.js +73 -0
  32. package/cjs/contexts/index.d.ts +1 -1
  33. package/cjs/contexts/index.js +7 -4
  34. package/cjs/hooks/useScrollToAttributeError/useScrollToAttributeError.d.ts +2 -2
  35. package/cjs/hooks/useScrollToAttributeError/useScrollToAttributeError.js +2 -2
  36. package/cjs/test-utils/store-utils.d.ts +78 -0
  37. package/cjs/test-utils/store-utils.js +19 -0
  38. package/esm/components/ProfilesList/styles.d.ts +1 -1
  39. package/esm/components/RelationEditor/RelationEditor.js +5 -5
  40. package/esm/components/attributes/editMode/AttributesFactory/Attribute.d.ts +6 -1
  41. package/esm/components/attributes/editMode/AttributesFactory/Attribute.js +17 -4
  42. package/esm/components/attributes/editMode/AttributesList/AttributesList.d.ts +3 -39
  43. package/esm/components/attributes/editMode/AttributesList/AttributesList.js +12 -5
  44. package/esm/components/attributes/editMode/AttributesPager/AttributeRenderer.d.ts +9 -7
  45. package/esm/components/attributes/editMode/AttributesPager/AttributeRenderer.js +10 -14
  46. package/esm/components/attributes/editMode/AttributesPager/AttributesPager.d.ts +38 -2
  47. package/esm/components/attributes/editMode/AttributesPager/AttributesPager.js +20 -6
  48. package/esm/components/attributes/editMode/AttributesPager/ImageLineRenderer.d.ts +4 -2
  49. package/esm/components/attributes/editMode/AttributesPager/ImageLineRenderer.js +5 -2
  50. package/esm/components/attributes/editMode/AttributesPager/SpecialRenderer.d.ts +3 -1
  51. package/esm/components/attributes/editMode/AttributesPager/SpecialRenderer.js +6 -3
  52. package/esm/components/attributes/editMode/AttributesPager/index.d.ts +4 -1
  53. package/esm/components/attributes/editMode/ComplexAttribute/ComplexAttribute.js +6 -5
  54. package/esm/components/attributes/editMode/ReferenceAttribute/ReferenceAttribute.js +4 -4
  55. package/esm/components/attributes/editMode/SimpleAttributeEditor/SimpleAttributeEditor.js +4 -4
  56. package/esm/components/attributes/editMode/hooks/useScrollToAttribute/styles.d.ts +1 -0
  57. package/esm/components/attributes/editMode/hooks/useScrollToAttribute/styles.js +35 -0
  58. package/esm/components/attributes/editMode/hooks/useScrollToAttribute/useScrollToAttribute.d.ts +8 -0
  59. package/esm/components/attributes/editMode/hooks/useScrollToAttribute/useScrollToAttribute.js +13 -0
  60. package/esm/components/attributes/inline/common/CrosswalkIcon.js +4 -2
  61. package/esm/components/attributes/inline/common/__test__/CrosswalkIcon.spec.js +116 -43
  62. package/esm/components/attributes/inline/common/styles.d.ts +1 -0
  63. package/esm/components/attributes/inline/common/styles.js +4 -2
  64. package/esm/components/workflow/helpers/errors.d.ts +3 -2
  65. package/esm/components/workflow/helpers/errors.js +13 -8
  66. package/esm/components/workflow/hooks/useChangeRequest.js +3 -3
  67. package/esm/contexts/ScrollToElementContext/index.d.ts +20 -0
  68. package/esm/contexts/ScrollToElementContext/index.js +44 -0
  69. package/esm/contexts/index.d.ts +1 -1
  70. package/esm/contexts/index.js +1 -1
  71. package/esm/hooks/useScrollToAttributeError/useScrollToAttributeError.d.ts +2 -2
  72. package/esm/hooks/useScrollToAttributeError/useScrollToAttributeError.js +2 -2
  73. package/esm/test-utils/store-utils.d.ts +78 -0
  74. package/esm/test-utils/store-utils.js +12 -0
  75. package/package.json +3 -3
  76. package/cjs/contexts/ScrollToErrorContext/index.d.ts +0 -13
  77. package/cjs/contexts/ScrollToErrorContext/index.js +0 -48
  78. package/esm/contexts/ScrollToErrorContext/index.d.ts +0 -13
  79. package/esm/contexts/ScrollToErrorContext/index.js +0 -21
@@ -1,6 +1,19 @@
1
- import EditModeAttributesFactory from './AttributesFactory';
2
- var Attribute = function (props) {
3
- var attributeType = props.attributeType;
4
- return EditModeAttributesFactory.build(attributeType, props);
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
5
11
  };
12
+ import React, { forwardRef } from 'react';
13
+ import EditModeAttributesFactory from './AttributesFactory';
14
+ var Attribute = forwardRef(function (props, ref) {
15
+ var className = props.className, otherProps = __rest(props, ["className"]);
16
+ return (React.createElement("div", { ref: ref, className: className }, EditModeAttributesFactory.build(props.attributeType, otherProps)));
17
+ });
18
+ Attribute.displayName = 'Attribute';
6
19
  export default Attribute;
@@ -1,41 +1,5 @@
1
- declare const _default: React.MemoExoticComponent<{
2
- ({ parentAttributeType, attrTypes, entity, parentUri, showEmptyEditors, mode, crosswalks, drawLines, children, className, alwaysVisibleTypeUris, onAddAttributes, onChangeAttribute, onDeleteAttribute, additionalControlsRenderer, showNonOv }: {
3
- parentAttributeType: any;
4
- attrTypes: any;
5
- entity: any;
6
- parentUri: any;
7
- showEmptyEditors: any;
8
- mode: any;
9
- crosswalks: any;
10
- drawLines: any;
11
- children: any;
12
- className: any;
13
- alwaysVisibleTypeUris?: string[];
14
- onAddAttributes: any;
15
- onChangeAttribute: any;
16
- onDeleteAttribute: any;
17
- additionalControlsRenderer: any;
18
- showNonOv: any;
19
- }): JSX.Element;
20
- propTypes: {
21
- parentAttributeType: PropTypes.Requireable<object>;
22
- attrTypes: PropTypes.Requireable<any[]>;
23
- entity: PropTypes.Requireable<object>;
24
- parentUri: PropTypes.Requireable<string>;
25
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
26
- showEmptyEditors: PropTypes.Requireable<boolean>;
27
- mode: PropTypes.Requireable<any>;
28
- crosswalks: PropTypes.Requireable<any[]>;
29
- drawLines: PropTypes.Requireable<boolean>;
30
- showNonOv: PropTypes.Requireable<boolean>;
31
- className: PropTypes.Requireable<string>;
32
- alwaysVisibleTypeUris: PropTypes.Requireable<any[]>;
33
- onAddAttributes: PropTypes.Requireable<(...args: any[]) => any>;
34
- onChangeAttribute: PropTypes.Requireable<(...args: any[]) => any>;
35
- onDeleteAttribute: PropTypes.Requireable<(...args: any[]) => any>;
36
- additionalControlsRenderer: PropTypes.Requireable<(...args: any[]) => any>;
37
- };
38
- }>;
1
+ declare const _default: React.ComponentType<{
2
+ [x: string]: unknown;
3
+ }> | ((props: any) => JSX.Element);
39
4
  export default _default;
40
- import PropTypes from "prop-types";
41
5
  import React from "react";
@@ -9,11 +9,11 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import React, { memo, useCallback, useContext, useMemo, useState, useEffect } from 'react';
12
+ import React, { useCallback, useContext, useMemo, useState, useEffect } from 'react';
13
13
  import PropTypes from 'prop-types';
14
14
  import i18n from 'ui-i18n';
15
15
  import { getCreatableAttributeTypes, getAttributesListForEditMode, ModeType, getParentUri, checkCanCreateAttribute } from '@reltio/mdm-sdk';
16
- import { path } from 'ramda';
16
+ import { last, path } from 'ramda';
17
17
  import AttributesPager from '../AttributesPager';
18
18
  import BranchDecorator from '../../BranchDecorator/BranchDecorator';
19
19
  import MoreAttributesButton from '../MoreAttributesButton';
@@ -22,8 +22,10 @@ import { splitPagersData } from '../../helpers/attributesView';
22
22
  import { getMoreAttrTypes } from './helpers';
23
23
  import { PinnedAttributesContext } from '../contexts/PinnedAttributesContext';
24
24
  import { HasDeletionsContext } from '../contexts/HasDeletionsContext';
25
+ import { withContext } from '../../../../HOCs';
26
+ import { ScrollType, ScrollToElementContext } from '../../../../contexts';
25
27
  var AttributesList = function (_a) {
26
- var parentAttributeType = _a.parentAttributeType, attrTypes = _a.attrTypes, entity = _a.entity, parentUri = _a.parentUri, showEmptyEditors = _a.showEmptyEditors, mode = _a.mode, crosswalks = _a.crosswalks, drawLines = _a.drawLines, children = _a.children, className = _a.className, _b = _a.alwaysVisibleTypeUris, alwaysVisibleTypeUris = _b === void 0 ? ALWAYS_VISIBLE_TYPE_URIS : _b, onAddAttributes = _a.onAddAttributes, onChangeAttribute = _a.onChangeAttribute, onDeleteAttribute = _a.onDeleteAttribute, additionalControlsRenderer = _a.additionalControlsRenderer, showNonOv = _a.showNonOv;
28
+ var parentAttributeType = _a.parentAttributeType, attrTypes = _a.attrTypes, entity = _a.entity, parentUri = _a.parentUri, showEmptyEditors = _a.showEmptyEditors, mode = _a.mode, crosswalks = _a.crosswalks, drawLines = _a.drawLines, children = _a.children, className = _a.className, _b = _a.alwaysVisibleTypeUris, alwaysVisibleTypeUris = _b === void 0 ? ALWAYS_VISIBLE_TYPE_URIS : _b, onAddAttributes = _a.onAddAttributes, onChangeAttribute = _a.onChangeAttribute, onDeleteAttribute = _a.onDeleteAttribute, additionalControlsRenderer = _a.additionalControlsRenderer, showNonOv = _a.showNonOv, highlightAttribute = _a.highlightAttribute;
27
29
  var _c = entity.attributes, attributes = _c === void 0 ? {} : _c;
28
30
  var _d = useState({}), hasDeletionsMap = _d[0], setHasDeletionsMap = _d[1];
29
31
  var setHasDeletions = useCallback(function (attrTypeUri, value) {
@@ -46,6 +48,7 @@ var AttributesList = function (_a) {
46
48
  attributeType: attributeType,
47
49
  parentUri: attributeType === parentAttributeType ? getParentUri(parentUri) : parentUri
48
50
  }); }));
51
+ highlightAttribute(last(attributeTypes), ScrollType.NewAttribute);
49
52
  }, [onAddAttributes, parentUri, parentAttributeType]);
50
53
  var decoratorProps = {
51
54
  enabled: drawLines
@@ -78,6 +81,10 @@ AttributesList.propTypes = {
78
81
  onAddAttributes: PropTypes.func,
79
82
  onChangeAttribute: PropTypes.func,
80
83
  onDeleteAttribute: PropTypes.func,
81
- additionalControlsRenderer: PropTypes.func
84
+ additionalControlsRenderer: PropTypes.func,
85
+ highlightAttribute: PropTypes.func
82
86
  };
83
- export default memo(AttributesList);
87
+ export default withContext(ScrollToElementContext, function (contextValue) {
88
+ var highlightAttribute = (contextValue || {}).highlightAttribute;
89
+ return { highlightAttribute: highlightAttribute };
90
+ }, AttributesList);
@@ -1,13 +1,15 @@
1
1
  import React from 'react';
2
2
  import { AttributeValue, NestedAttributeValue, ReferenceAttributeValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
3
3
  import { AttributePagerProps } from './index';
4
- declare const _default: React.ComponentType<Required<Omit<AttributePagerProps, "values">> & {
4
+ import { ScrollToElementContext } from '../../../../contexts';
5
+ declare type Props = Required<Omit<AttributePagerProps, 'values'>> & {
5
6
  values?: (SimpleAttributeValue | NestedAttributeValue | ReferenceAttributeValue)[];
6
7
  nonVisibleValues: AttributeValue[];
7
- highlightedError?: {
8
- error: import("@reltio/mdm-sdk").AttributeError;
9
- highlightError: (error: import("@reltio/mdm-sdk").AttributeError) => void;
10
- scrollIntoRef: (ref: React.MutableRefObject<HTMLDivElement>) => void;
11
- };
12
- }> | ((props: any) => JSX.Element);
8
+ highlightedError?: React.ContextType<typeof ScrollToElementContext>;
9
+ highlightedAttribute?: React.ContextType<typeof ScrollToElementContext>;
10
+ };
11
+ declare const _default: React.MemoExoticComponent<{
12
+ ({ max, values, attributeType, parentUri, mode, drawLines, showEmptyEditors, errorMessage, errors, paging, crosswalks, showNonOv, nonVisibleValues, highlightedError, highlightedAttribute, onAddAttributes, onDeleteAttribute, onChangeAttribute, onDeactivateError, additionalControlsRenderer, requestNextPageOfAttributeValues }: Props): JSX.Element;
13
+ displayName: string;
14
+ }>;
13
15
  export default _default;
@@ -1,6 +1,6 @@
1
- import React, { useCallback, useRef, useState, useContext, useMemo } from 'react';
1
+ import React, { useCallback, useRef, useState, useContext, useMemo, memo } from 'react';
2
2
  import classNames from 'classnames';
3
- import { createNewAttribute, getAttributeOwnError, isComplexAttribute, isEditableMode as checkIsEditableMode, isEmptyValue, isAttributeTypeError } from '@reltio/mdm-sdk';
3
+ import { createNewAttribute, getAttributeOwnError, isComplexAttribute, isEditableMode as checkIsEditableMode, isEmptyValue } from '@reltio/mdm-sdk';
4
4
  import { add, always, has, ifElse, min, pipe, prop, T } from 'ramda';
5
5
  import BranchDecorator from '../../BranchDecorator/BranchDecorator';
6
6
  import ErrorMessage from '../../../ErrorWrapper/ErrorMessage';
@@ -11,20 +11,20 @@ import ShowMore from '../../pagersCommon/ShowMore';
11
11
  import Attribute from '../AttributesFactory/Attribute';
12
12
  import Cardinality from './CardinalityMessage';
13
13
  import { filterNewValues } from './utils';
14
- import { withContext } from '../../../../HOCs';
15
14
  import { PinnedAttributesContext } from '../contexts/PinnedAttributesContext';
16
15
  import { useScrollToAttributeError } from '../../../../hooks';
17
- import { ScrollToErrorContext } from '../../../../contexts';
18
16
  import DescriptionIcon from '../../DescriptionIcon/DescriptionIcon';
17
+ import { useScrollToAttribute } from '../hooks/useScrollToAttribute/useScrollToAttribute';
19
18
  import { useStyles } from './styles';
20
19
  var AttributeRenderer = function (_a) {
21
- var max = _a.max, values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, drawLines = _a.drawLines, showEmptyEditors = _a.showEmptyEditors, errorMessage = _a.errorMessage, errors = _a.errors, paging = _a.paging, crosswalks = _a.crosswalks, showNonOv = _a.showNonOv, nonVisibleValues = _a.nonVisibleValues, highlightedError = _a.highlightedError, onAddAttributes = _a.onAddAttributes, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onDeactivateError = _a.onDeactivateError, additionalControlsRenderer = _a.additionalControlsRenderer, requestNextPageOfAttributeValues = _a.requestNextPageOfAttributeValues;
20
+ var max = _a.max, values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, drawLines = _a.drawLines, showEmptyEditors = _a.showEmptyEditors, errorMessage = _a.errorMessage, errors = _a.errors, paging = _a.paging, crosswalks = _a.crosswalks, showNonOv = _a.showNonOv, nonVisibleValues = _a.nonVisibleValues, highlightedError = _a.highlightedError, highlightedAttribute = _a.highlightedAttribute, onAddAttributes = _a.onAddAttributes, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onDeactivateError = _a.onDeactivateError, additionalControlsRenderer = _a.additionalControlsRenderer, requestNextPageOfAttributeValues = _a.requestNextPageOfAttributeValues;
22
21
  var styles = useStyles();
23
22
  var _b = useState(max), visibleValuesCount = _b[0], setVisibleValuesCount = _b[1];
24
23
  var _c = useState(false), hadDeletions = _c[0], setHadDeletions = _c[1];
25
24
  var label = attributeType.label, isRequired = attributeType.required, cardinality = attributeType.cardinality, name = attributeType.name, attributeTypeUri = attributeType.uri, description = attributeType.description;
26
25
  var isEditableMode = checkIsEditableMode(mode);
27
- var _d = useScrollToAttributeError({ highlightedError: highlightedError }), ref = _d.ref, errorClassName = _d.errorClassName;
26
+ var _d = useScrollToAttributeError({ highlightedError: highlightedError }), errorRef = _d.ref, errorClassName = _d.errorClassName;
27
+ var _e = useScrollToAttribute(highlightedAttribute), attributeRef = _e.ref, highlightedClassName = _e.highlightedClassName;
28
28
  var pinnedAttributes = useContext(PinnedAttributesContext);
29
29
  var isPinned = useMemo(function () { return pinnedAttributes === null || pinnedAttributes === void 0 ? void 0 : pinnedAttributes.includes(attributeTypeUri); }, [attributeTypeUri, pinnedAttributes]);
30
30
  var isEmptyValues = isEmptyValue(values);
@@ -80,7 +80,7 @@ var AttributeRenderer = function (_a) {
80
80
  var lastIndex = shownValues ? shownValues.length - 1 : 0;
81
81
  var hiddenValuesCount = totalVisibleValues - visibleValuesCount;
82
82
  return (React.createElement(BranchDecorator, { enabled: drawLines },
83
- React.createElement("div", { ref: ref, className: classNames(styles.wrapper, errorClassName) },
83
+ React.createElement("div", { ref: errorRef, className: classNames(styles.wrapper, errorClassName) },
84
84
  React.createElement("div", { className: styles.titleWrapper },
85
85
  React.createElement(Title, { label: label, isRequired: isRequired, className: styles.title, "data-reltio-id": "reltio-attribute-label" }),
86
86
  React.createElement(DescriptionIcon, { description: description, className: styles.description }),
@@ -88,13 +88,9 @@ var AttributeRenderer = function (_a) {
88
88
  isEditableMode && React.createElement(Cardinality, { cardinality: cardinality }),
89
89
  isEditableMode && React.createElement(ErrorMessage, { message: errorMessage, className: styles.typeError }),
90
90
  React.createElement("div", { className: styles.attributesWrapper },
91
- shownValues.map(function (value, idx) { return (React.createElement(Attribute, { key: value.uri, attributeValue: value, attributeType: attributeType, lazy: showEmpty && !isRequired, showEmptyEditors: showEmptyEditors, errors: errors, ownError: getAttributeOwnError(value, idx, attributeType.uri, errors), mode: mode, crosswalks: crosswalks, onAddOneMore: lastIndex === idx ? onAddOneMore : null, onAddAttributes: onAddAttributes, onDeleteAttribute: onDelete, onChangeAttribute: onChangeAttribute, onDeactivateError: onDeactivateError, additionalControlsRenderer: additionalControlsRenderer })); }),
91
+ shownValues.map(function (value, idx) { return (React.createElement(Attribute, { key: value.uri, attributeValue: value, attributeType: attributeType, lazy: showEmpty && !isRequired, showEmptyEditors: showEmptyEditors, errors: errors, ownError: getAttributeOwnError(value, idx, attributeType.uri, errors), mode: mode, crosswalks: crosswalks, onAddOneMore: lastIndex === idx ? onAddOneMore : null, onAddAttributes: onAddAttributes, onDeleteAttribute: onDelete, onChangeAttribute: onChangeAttribute, onDeactivateError: onDeactivateError, additionalControlsRenderer: additionalControlsRenderer, className: idx === 0 ? highlightedClassName : null, ref: idx === 0 ? attributeRef : null })); }),
92
92
  showMore && (React.createElement(ShowMore, { moreNumber: min(max, hiddenValuesCount), valueNumber: hiddenValuesCount, onClick: onShowMore })),
93
93
  showLess && React.createElement(ShowLess, { onClick: onShowLess })))));
94
94
  };
95
- export default withContext(ScrollToErrorContext, function (contextValue, _a) {
96
- var parentUri = _a.parentUri, attributeType = _a.attributeType;
97
- var error = (contextValue || {}).error;
98
- var isHighlighted = isAttributeTypeError(error, parentUri, attributeType.uri);
99
- return { highlightedError: isHighlighted ? contextValue : null };
100
- }, AttributeRenderer);
95
+ AttributeRenderer.displayName = 'AttributeRenderer';
96
+ export default memo(AttributeRenderer);
@@ -1,4 +1,40 @@
1
1
  import React from 'react';
2
- import { AttributePagerProps } from './index';
3
- declare const _default: React.MemoExoticComponent<({ values, attributeType, mode, crosswalks, drawLines, paging, parentUri, errors, errorMessage, max, showEmptyEditors, showNonOv, onAddAttributes, onDeleteAttribute, onChangeAttribute, onDeactivateError, additionalControlsRenderer, requestNextPageOfAttributeValues }: AttributePagerProps) => JSX.Element>;
2
+ import { AttributeError, AttributeType, Mode, NestedAttributeValue, ReferenceAttributeValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
3
+ declare const _default: React.ComponentType<{
4
+ errorMessage: string;
5
+ errors: AttributeError[];
6
+ max: number;
7
+ } & {
8
+ onDeactivateError: (id: string) => void;
9
+ requestNextPageOfAttributeValues: (payload: import("@reltio/mdm-module").RequestNextPageOfAttributeValuesPayload) => void;
10
+ } & {
11
+ values: (string | number | SimpleAttributeValue | NestedAttributeValue | ReferenceAttributeValue | import("@reltio/mdm-sdk").ImageAttributeValue)[];
12
+ attributeType: AttributeType;
13
+ paging?: import("@reltio/mdm-sdk").Paging;
14
+ mode?: Mode;
15
+ crosswalks?: import("@reltio/mdm-sdk").Crosswalk[];
16
+ parentUri: string;
17
+ drawLines: boolean;
18
+ max?: number;
19
+ showEmptyEditors: boolean;
20
+ showNonOv?: boolean;
21
+ onAddAttributes: (params: import("@reltio/mdm-sdk").AttributeItem[]) => void;
22
+ onDeleteAttribute: (param: import("@reltio/mdm-sdk").AttributeItem) => void;
23
+ onChangeAttribute: (param: import("@reltio/mdm-sdk").AttributeItem) => void;
24
+ additionalControlsRenderer?: (props: any) => JSX.Element;
25
+ highlightedError?: {
26
+ element: unknown;
27
+ type: import("../../../../contexts").ScrollType;
28
+ highlightError?: (element: unknown) => void;
29
+ highlightAttribute?: (element: unknown) => void;
30
+ scrollIntoRef: (ref: React.MutableRefObject<HTMLDivElement>) => void;
31
+ };
32
+ highlightedAttribute?: {
33
+ element: unknown;
34
+ type: import("../../../../contexts").ScrollType;
35
+ highlightError?: (element: unknown) => void;
36
+ highlightAttribute?: (element: unknown) => void;
37
+ scrollIntoRef: (ref: React.MutableRefObject<HTMLDivElement>) => void;
38
+ };
39
+ }> | ((props: any) => JSX.Element);
4
40
  export default _default;
@@ -9,13 +9,15 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import React, { memo } from 'react';
13
- import { isImage, isOv, isSpecialAttribute, Mode } from '@reltio/mdm-sdk';
12
+ import React from 'react';
13
+ import { isAttributeTypeError, isImage, isOv, isSpecialAttribute, Mode } from '@reltio/mdm-sdk';
14
14
  import { always, cond, T, partition } from 'ramda';
15
15
  import BranchDecorator from '../../BranchDecorator/BranchDecorator';
16
16
  import AttributeRenderer from './AttributeRenderer';
17
17
  import SpecialRenderer from './SpecialRenderer';
18
18
  import { ImageLineRenderer } from './ImageLineRenderer';
19
+ import { withContext } from '../../../../HOCs';
20
+ import { isHighlightedAttributeType, isHighlightedErrorType, ScrollToElementContext } from '../../../../contexts';
19
21
  var RENDERER_TYPES;
20
22
  (function (RENDERER_TYPES) {
21
23
  RENDERER_TYPES["imageLine"] = "imageLine";
@@ -23,7 +25,7 @@ var RENDERER_TYPES;
23
25
  RENDERER_TYPES["default"] = "default";
24
26
  })(RENDERER_TYPES || (RENDERER_TYPES = {}));
25
27
  var AttributesPager = function (_a) {
26
- var values = _a.values, attributeType = _a.attributeType, _b = _a.mode, mode = _b === void 0 ? Mode.Viewing : _b, crosswalks = _a.crosswalks, drawLines = _a.drawLines, _c = _a.paging, paging = _c === void 0 ? {} : _c, parentUri = _a.parentUri, errors = _a.errors, errorMessage = _a.errorMessage, _d = _a.max, max = _d === void 0 ? Infinity : _d, showEmptyEditors = _a.showEmptyEditors, showNonOv = _a.showNonOv, onAddAttributes = _a.onAddAttributes, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onDeactivateError = _a.onDeactivateError, additionalControlsRenderer = _a.additionalControlsRenderer, requestNextPageOfAttributeValues = _a.requestNextPageOfAttributeValues;
28
+ var values = _a.values, attributeType = _a.attributeType, _b = _a.mode, mode = _b === void 0 ? Mode.Viewing : _b, crosswalks = _a.crosswalks, drawLines = _a.drawLines, _c = _a.paging, paging = _c === void 0 ? {} : _c, parentUri = _a.parentUri, errors = _a.errors, errorMessage = _a.errorMessage, _d = _a.max, max = _d === void 0 ? Infinity : _d, showEmptyEditors = _a.showEmptyEditors, showNonOv = _a.showNonOv, highlightedError = _a.highlightedError, highlightedAttribute = _a.highlightedAttribute, onAddAttributes = _a.onAddAttributes, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onDeactivateError = _a.onDeactivateError, additionalControlsRenderer = _a.additionalControlsRenderer, requestNextPageOfAttributeValues = _a.requestNextPageOfAttributeValues;
27
29
  var partitionByOv = partition(isOv);
28
30
  var _e = partitionByOv(values), ovValues = _e[0], nonOvValues = _e[1];
29
31
  var visibleValues = showNonOv ? values : ovValues;
@@ -38,7 +40,9 @@ var AttributesPager = function (_a) {
38
40
  onChangeAttribute: onChangeAttribute,
39
41
  onDeactivateError: onDeactivateError,
40
42
  additionalControlsRenderer: additionalControlsRenderer,
41
- showEmptyEditors: showEmptyEditors
43
+ showEmptyEditors: showEmptyEditors,
44
+ highlightedError: highlightedError,
45
+ highlightedAttribute: highlightedAttribute
42
46
  };
43
47
  var renderAttribute = function () {
44
48
  var type = cond([
@@ -53,11 +57,21 @@ var AttributesPager = function (_a) {
53
57
  }
54
58
  case RENDERER_TYPES.imageLine:
55
59
  return (React.createElement(BranchDecorator, { enabled: drawLines },
56
- React.createElement(ImageLineRenderer, { attributeValues: visibleValues, attributeType: attributeType, paging: paging, onDeleteAttribute: onDeleteAttribute, parentUri: parentUri, onChangeAttribute: onChangeAttribute, requestNextPageOfAttributeValues: requestNextPageOfAttributeValues, showNonOv: showNonOv })));
60
+ React.createElement(ImageLineRenderer, { attributeValues: visibleValues, attributeType: attributeType, paging: paging, onDeleteAttribute: onDeleteAttribute, parentUri: parentUri, onChangeAttribute: onChangeAttribute, requestNextPageOfAttributeValues: requestNextPageOfAttributeValues, showNonOv: showNonOv, highlightedAttribute: highlightedAttribute })));
57
61
  default:
58
62
  return (React.createElement(AttributeRenderer, __assign({ values: visibleValues, attributeType: attributeType, max: max, paging: paging, crosswalks: crosswalks, drawLines: drawLines, requestNextPageOfAttributeValues: requestNextPageOfAttributeValues, showNonOv: showNonOv, nonVisibleValues: nonVisibleValues }, commonProps)));
59
63
  }
60
64
  };
61
65
  return renderAttribute();
62
66
  };
63
- export default memo(AttributesPager);
67
+ export default withContext(ScrollToElementContext, function (contextValue, _a) {
68
+ var attributeType = _a.attributeType, parentUri = _a.parentUri;
69
+ var _b = contextValue || {}, element = _b.element, type = _b.type;
70
+ var isHighlightedAttribute = isHighlightedAttributeType(type) && element.uri === attributeType.uri;
71
+ var isHighlightedError = isHighlightedErrorType(type) &&
72
+ isAttributeTypeError(element, parentUri, attributeType.uri);
73
+ return {
74
+ highlightedAttribute: isHighlightedAttribute ? contextValue : null,
75
+ highlightedError: isHighlightedError ? contextValue : null
76
+ };
77
+ }, AttributesPager);
@@ -1,6 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { AttributeItem, AttributeType, ImageAttributeValue, Paging } from '@reltio/mdm-sdk';
3
3
  import { RequestNextPageOfAttributeValuesPayload } from '@reltio/mdm-module';
4
+ import { ScrollToElementContext } from '../../../../contexts';
4
5
  declare type Props = {
5
6
  attributeType: AttributeType;
6
7
  attributeValues: ImageAttributeValue[];
@@ -10,6 +11,7 @@ declare type Props = {
10
11
  onDeleteAttribute: (param: AttributeItem) => void;
11
12
  onChangeAttribute: (param: AttributeItem) => void;
12
13
  requestNextPageOfAttributeValues?: (payload: RequestNextPageOfAttributeValuesPayload) => void;
14
+ highlightedAttribute?: React.ContextType<typeof ScrollToElementContext>;
13
15
  };
14
- export declare const ImageLineRenderer: ({ attributeType, attributeValues, paging, parentUri, showNonOv, onDeleteAttribute, onChangeAttribute, requestNextPageOfAttributeValues }: Props) => JSX.Element;
16
+ export declare const ImageLineRenderer: ({ attributeType, attributeValues, paging, parentUri, showNonOv, onDeleteAttribute, onChangeAttribute, requestNextPageOfAttributeValues, highlightedAttribute }: Props) => JSX.Element;
15
17
  export {};
@@ -1,13 +1,16 @@
1
1
  import React from 'react';
2
+ import classnames from 'classnames';
2
3
  import Title from '../../../Title/Title';
3
4
  import DescriptionIcon from '../../DescriptionIcon';
4
5
  import ImageAttributesLine from '../ImageAttributesLine';
6
+ import { useScrollToAttribute } from '../hooks/useScrollToAttribute/useScrollToAttribute';
5
7
  import { useStyles } from './styles';
6
8
  export var ImageLineRenderer = function (_a) {
7
- var attributeType = _a.attributeType, attributeValues = _a.attributeValues, paging = _a.paging, parentUri = _a.parentUri, showNonOv = _a.showNonOv, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, requestNextPageOfAttributeValues = _a.requestNextPageOfAttributeValues;
9
+ var attributeType = _a.attributeType, attributeValues = _a.attributeValues, paging = _a.paging, parentUri = _a.parentUri, showNonOv = _a.showNonOv, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, requestNextPageOfAttributeValues = _a.requestNextPageOfAttributeValues, highlightedAttribute = _a.highlightedAttribute;
8
10
  var styles = useStyles();
9
11
  var label = attributeType.label, description = attributeType.description;
10
- return (React.createElement("div", { className: styles.wrapper },
12
+ var _b = useScrollToAttribute(highlightedAttribute), ref = _b.ref, highlightedClassName = _b.highlightedClassName;
13
+ return (React.createElement("div", { ref: ref, className: classnames(styles.wrapper, highlightedClassName) },
11
14
  React.createElement("div", { className: styles.titleWrapper },
12
15
  React.createElement(Title, { className: styles.title, label: label, "data-reltio-id": "reltio-attribute-label" }),
13
16
  React.createElement(DescriptionIcon, { className: styles.description, description: description })),
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { AttributeType, Mode, AttributeItem } from '@reltio/mdm-sdk';
3
+ import { ScrollToElementContext } from '../../../../contexts';
3
4
  declare type Props = {
4
5
  values: string[] | number[];
5
6
  attributeType: AttributeType;
@@ -11,7 +12,8 @@ declare type Props = {
11
12
  showEmptyEditors?: boolean;
12
13
  hasDeletions?: boolean;
13
14
  setHasDeletions?: (attrTypeUri: string, value: boolean) => void;
15
+ highlightedAttribute?: React.ContextType<typeof ScrollToElementContext>;
14
16
  };
15
- export declare const SpecialRenderer: ({ values, attributeType, parentUri, mode, errorMessage, onDeleteAttribute, onChangeAttribute, showEmptyEditors, hasDeletions: hasDeletionsProp, setHasDeletions, ...otherProps }: Props) => JSX.Element;
17
+ export declare const SpecialRenderer: ({ values, attributeType, parentUri, mode, errorMessage, onDeleteAttribute, onChangeAttribute, showEmptyEditors, hasDeletions: hasDeletionsProp, setHasDeletions, highlightedAttribute, ...otherProps }: Props) => JSX.Element;
16
18
  declare const _default: React.ComponentType<Props> | ((props: any) => JSX.Element);
17
19
  export default _default;
@@ -22,6 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  };
23
23
  import React, { useCallback, useRef, useState } from 'react';
24
24
  import { createNewAttribute, EntityAttrTypes, isEditableMode as checkIsEditableMode, isEmptyValue, isActivenessAttrType } from '@reltio/mdm-sdk';
25
+ import classnames from 'classnames';
25
26
  import { pipe, T } from 'ramda';
26
27
  import Box from '@material-ui/core/Box';
27
28
  import Title from '../../../Title/Title';
@@ -33,8 +34,9 @@ import Tags from '../Tags';
33
34
  import { useStyles } from './styles';
34
35
  import { HasDeletionsContext } from '../contexts/HasDeletionsContext';
35
36
  import { withContext } from '../../../../HOCs';
37
+ import { useScrollToAttribute } from '../hooks/useScrollToAttribute/useScrollToAttribute';
36
38
  export var SpecialRenderer = function (_a) {
37
- var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, showEmptyEditors = _a.showEmptyEditors, hasDeletionsProp = _a.hasDeletions, setHasDeletions = _a.setHasDeletions, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage", "onDeleteAttribute", "onChangeAttribute", "showEmptyEditors", "hasDeletions", "setHasDeletions"]);
39
+ var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, showEmptyEditors = _a.showEmptyEditors, hasDeletionsProp = _a.hasDeletions, setHasDeletions = _a.setHasDeletions, highlightedAttribute = _a.highlightedAttribute, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage", "onDeleteAttribute", "onChangeAttribute", "showEmptyEditors", "hasDeletions", "setHasDeletions", "highlightedAttribute"]);
38
40
  var styles = useStyles();
39
41
  var label = attributeType.label, isRequired = attributeType.required, cardinality = attributeType.cardinality;
40
42
  var isEditableMode = checkIsEditableMode(mode);
@@ -55,6 +57,7 @@ export var SpecialRenderer = function (_a) {
55
57
  parentUri: parentUri,
56
58
  attributeType: attributeType
57
59
  }));
60
+ var _c = useScrollToAttribute(highlightedAttribute), ref = _c.ref, highlightedClassName = _c.highlightedClassName;
58
61
  var renderValue = function () {
59
62
  switch (attributeType.uri) {
60
63
  case EntityAttrTypes.tags.uri:
@@ -71,8 +74,8 @@ export var SpecialRenderer = function (_a) {
71
74
  if (isActivenessAttrType(attributeType) && isEmptyValues && !showEmpty) {
72
75
  return null;
73
76
  }
74
- return (React.createElement(Box, { className: styles.wrapper },
75
- React.createElement(Title, { label: label, isRequired: isRequired, className: styles.title, "data-reltio-id": "reltio-attribute-label" }),
77
+ return (React.createElement("div", { ref: ref, className: classnames(highlightedClassName, styles.wrapper) },
78
+ React.createElement(Title, { label: label, isRequired: isRequired, className: classnames(styles.title, styles.titleWrapper), "data-reltio-id": "reltio-attribute-label" }),
76
79
  isEditableMode && React.createElement(Cardinality, { cardinality: cardinality }),
77
80
  isEditableMode && React.createElement(ErrorMessage, { message: errorMessage }),
78
81
  React.createElement(Box, { className: styles.attributesWrapper }, renderValue())));
@@ -3,6 +3,7 @@ import { RequestNextPageOfAttributeValuesPayload } from '@reltio/mdm-module';
3
3
  import { AttributeError, AttributeType, Crosswalk, ImageAttributeValue, Mode, NestedAttributeValue, Paging, ReferenceAttributeValue, SimpleAttributeValue, AttributeItem } from '@reltio/mdm-sdk';
4
4
  import AttributesPager from './AttributesPager';
5
5
  import CardinalityMessage from './CardinalityMessage';
6
+ import { ScrollToElementContext } from '../../../../contexts';
6
7
  declare type StateProps = {
7
8
  errorMessage: string;
8
9
  errors: AttributeError[];
@@ -27,8 +28,10 @@ declare type OwnProps = {
27
28
  onDeleteAttribute: (param: AttributeItem) => void;
28
29
  onChangeAttribute: (param: AttributeItem) => void;
29
30
  additionalControlsRenderer?: (props: any) => JSX.Element;
31
+ highlightedError?: React.ContextType<typeof ScrollToElementContext>;
32
+ highlightedAttribute?: React.ContextType<typeof ScrollToElementContext>;
30
33
  };
31
34
  export declare type AttributePagerProps = StateProps & DispatchProps & OwnProps;
32
35
  export { AttributesPager, CardinalityMessage };
33
- declare const _default: import("react-redux").ConnectedComponent<import("react").MemoExoticComponent<({ values, attributeType, mode, crosswalks, drawLines, paging, parentUri, errors, errorMessage, max, showEmptyEditors, showNonOv, onAddAttributes, onDeleteAttribute, onChangeAttribute, onDeactivateError, additionalControlsRenderer, requestNextPageOfAttributeValues }: AttributePagerProps) => JSX.Element>, import("react-redux").Omit<StateProps & DispatchProps & OwnProps, "max" | "errorMessage" | "errors" | "requestNextPageOfAttributeValues" | "onDeactivateError"> & OwnProps>;
36
+ declare const _default: import("react-redux").ConnectedComponent<import("react").ComponentType<StateProps & DispatchProps & OwnProps> | ((props: any) => JSX.Element), import("react-redux").Omit<any, "max" | "errorMessage" | "errors" | "requestNextPageOfAttributeValues" | "onDeactivateError"> & OwnProps>;
34
37
  export default _default;
@@ -23,7 +23,7 @@ import ArrowExpandButton from '../../../ArrowExpandButton/ArrowExpandButton';
23
23
  import ErrorWrapper from '../../../ErrorWrapper/ErrorWrapper';
24
24
  import AttributesList from '../AttributesList/AttributesList';
25
25
  import { withContext } from '../../../../HOCs';
26
- import { ScrollToErrorContext } from '../../../../contexts';
26
+ import { isHighlightedErrorType, ScrollToElementContext } from '../../../../contexts';
27
27
  import { useScrollToAttributeError } from '../../../../hooks';
28
28
  import { useStyles } from './styles';
29
29
  var ComplexAttribute = function (_a) {
@@ -89,11 +89,12 @@ var ComplexAttribute = function (_a) {
89
89
  expanded && (React.createElement(AttributesList, { parentAttributeType: attributeType, attrTypes: attributeTypesList, entity: attributeListEntity, showEmptyEditors: showEmptyEditors || isNew, drawLines: true, parentUri: uri, mode: mode, crosswalks: crosswalks, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute, additionalControlsRenderer: additionalControlsRenderer, showNonOv: showNonOv }, children))));
90
90
  };
91
91
  ComplexAttribute.propTypes = __assign({ label: PropTypes.string, children: PropTypes.node, attributeTypesList: PropTypes.arrayOf(AttributeTypeType), attributeValue: PropTypes.oneOfType([NestedAttributeValueType, ReferenceAttributeValueType]), highlightedError: PropTypes.object, isHighlightedPath: PropTypes.bool }, ComplexAttributeType);
92
- export default withContext(ScrollToErrorContext, function (contextValue, _a) {
92
+ export default withContext(ScrollToElementContext, function (contextValue, _a) {
93
93
  var attributeValue = _a.attributeValue;
94
- var error = (contextValue || {}).error;
95
- var isHighlighted = (error === null || error === void 0 ? void 0 : error.uri) === attributeValue.uri;
96
- var isHighlightedPath = pipe(propOr([], 'path'), any(pathEq(['value', 'uri'], attributeValue.uri)))(error);
94
+ var _b = contextValue || {}, element = _b.element, type = _b.type;
95
+ var isError = isHighlightedErrorType(type);
96
+ var isHighlighted = isError && (element === null || element === void 0 ? void 0 : element.uri) === attributeValue.uri;
97
+ var isHighlightedPath = isError && pipe(propOr([], 'path'), any(pathEq(['value', 'uri'], attributeValue.uri)))(element);
97
98
  return {
98
99
  highlightedError: isHighlighted ? contextValue : null,
99
100
  isHighlightedPath: isHighlightedPath
@@ -29,7 +29,7 @@ import ComplexAttribute from '../ComplexAttribute/ComplexAttribute';
29
29
  import EntitySelector from '../EntitySelector/EntitySelector';
30
30
  import { ErrorWrapper } from '../../../index';
31
31
  import { withContext } from '../../../../HOCs';
32
- import { ScrollToErrorContext } from '../../../../contexts';
32
+ import { isHighlightedErrorType, ScrollToElementContext } from '../../../../contexts';
33
33
  import { useScrollToAttributeError } from '../../../../hooks';
34
34
  import { useStyles } from './styles';
35
35
  var ReferenceAttribute = function (props) {
@@ -121,9 +121,9 @@ var ReferenceAttribute = function (props) {
121
121
  _a)), entity: selectedEntity || {}, entityTypesUris: entityTypesUris, max: 20, globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, isDisabled: !canChangeReferencedEntity, onChange: onChangeEntity, onCreate: canCreateReferencedEntity ? onCreateEntity : undefined, metadata: metadata, attributeTypesSelectionStrategy: newEntityAttrTypesSelectionStrategy })))));
122
122
  };
123
123
  ReferenceAttribute.propTypes = __assign(__assign({}, ReferenceAttributeType), { modifiedEntity: EntityType, metadata: MetadataType, globalSearchRequestOptions: PropTypes.object, onDeleteModifiedEntity: PropTypes.func, onUpdateModifiedEntity: PropTypes.func, onDeactivateError: PropTypes.func, highlightedError: PropTypes.object });
124
- export default withContext(ScrollToErrorContext, function (contextValue, _a) {
124
+ export default withContext(ScrollToElementContext, function (contextValue, _a) {
125
125
  var attributeValue = _a.attributeValue, attributeType = _a.attributeType;
126
- var error = (contextValue || {}).error;
127
- var isHighlighted = isAttributeTypeError(error, attributeValue.uri, attributeType.uri);
126
+ var _b = contextValue || {}, element = _b.element, type = _b.type;
127
+ var isHighlighted = isHighlightedErrorType(type) && isAttributeTypeError(element, attributeValue.uri, attributeType.uri);
128
128
  return { highlightedError: isHighlighted ? contextValue : null };
129
129
  }, ReferenceAttribute);
@@ -38,7 +38,7 @@ import { attributeValueToEditorValue, prepareChangeData } from './utils';
38
38
  import withAsyncMount from '../../../../HOCs/withAsyncMount/withAsyncMount';
39
39
  import { getDependentLookupEditorContext } from './selectors/getDependentLookupEditorContext';
40
40
  import { withContext } from '../../../../HOCs';
41
- import { ScrollToErrorContext, DependentLookupAutopopulationContext, ProfilePerspectiveViewContext } from '../../../../contexts';
41
+ import { isHighlightedErrorType, ScrollToElementContext, DependentLookupAutopopulationContext, ProfilePerspectiveViewContext } from '../../../../contexts';
42
42
  import { useScrollToAttributeError } from '../../../../hooks';
43
43
  import { useAutopopulationContextValue } from './useAutopopulationContextValue';
44
44
  import { useStyles } from './styles';
@@ -116,9 +116,9 @@ SimpleAttributeEditor.propTypes = {
116
116
  additionalControlsRenderer: PropTypes.func,
117
117
  highlightedError: PropTypes.object
118
118
  };
119
- export default withAsyncMount(withContext(ScrollToErrorContext, function (contextValue, _a) {
119
+ export default withAsyncMount(withContext(ScrollToElementContext, function (contextValue, _a) {
120
120
  var attributeValue = _a.attributeValue;
121
- var error = (contextValue || {}).error;
122
- var isHighlighted = (error === null || error === void 0 ? void 0 : error.uri) === attributeValue.uri;
121
+ var _b = contextValue || {}, element = _b.element, type = _b.type;
122
+ var isHighlighted = isHighlightedErrorType(type) && (element === null || element === void 0 ? void 0 : element.uri) === attributeValue.uri;
123
123
  return { highlightedError: isHighlighted ? contextValue : null };
124
124
  }, SimpleAttributeEditor), AsyncMountPlaceholder);
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"@keyframes highlightAnimation" | "highlighted">;
@@ -0,0 +1,35 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { makeStyles } from '@material-ui/core/styles';
13
+ var highlightBeforeStyles = {
14
+ content: '""',
15
+ position: 'absolute',
16
+ left: '-1000px',
17
+ top: '-4px',
18
+ width: '5000px',
19
+ height: 'calc(100% + 8px)',
20
+ animationName: '$highlightAnimation',
21
+ animationDuration: '2s',
22
+ animationIterationCount: 1,
23
+ opacity: 0
24
+ };
25
+ export var useStyles = makeStyles(function () { return ({
26
+ '@keyframes highlightAnimation': {
27
+ '0%': { opacity: 0 },
28
+ '50%': { opacity: 1 },
29
+ '100%': { opacity: 0 }
30
+ },
31
+ highlighted: {
32
+ '&::before': __assign(__assign({}, highlightBeforeStyles), { background: 'rgba(228, 151, 0, 0.08)' }),
33
+ position: 'relative'
34
+ }
35
+ }); });
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare const useScrollToAttribute: (context: any) => {
3
+ ref: import("react").MutableRefObject<HTMLDivElement>;
4
+ highlightedClassName: string;
5
+ } | {
6
+ ref: import("react").MutableRefObject<HTMLDivElement>;
7
+ highlightedClassName?: undefined;
8
+ };
@@ -0,0 +1,13 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { useStyles } from './styles';
3
+ export var useScrollToAttribute = function (context) {
4
+ var styles = useStyles();
5
+ var ref = useRef(null);
6
+ var scrollIntoRef = (context || {}).scrollIntoRef;
7
+ useEffect(function () {
8
+ if (context) {
9
+ scrollIntoRef(ref);
10
+ }
11
+ }, [context, scrollIntoRef]);
12
+ return context ? { ref: ref, highlightedClassName: styles.highlighted } : { ref: ref };
13
+ };
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { isCrosswalkDisabled } from '@reltio/mdm-sdk';
2
3
  import { useCrosswalkColor, useCrosswalkHighlight } from '../../../../contexts';
3
4
  import SourceItem from './SourceItem';
4
5
  import LightArrowTooltip from '../../../LightArrowTooltip/LightArrowTooltip';
@@ -7,9 +8,10 @@ import { useStyles } from './styles';
7
8
  var CrosswalkIcon = function (_a) {
8
9
  var crosswalk = _a.crosswalk, className = _a.className;
9
10
  var color = useCrosswalkColor(crosswalk);
11
+ var isDisabled = isCrosswalkDisabled(crosswalk);
10
12
  var _b = useCrosswalkHighlight(crosswalk), isDimmed = _b.isDimmed, highlightCrosswalk = _b.highlightCrosswalk, removeHighlight = _b.removeHighlight;
11
- var styles = useStyles({ isOpaque: !isDimmed, color: color });
13
+ var styles = useStyles({ isOpaque: !isDimmed, color: color, isDisabled: isDisabled });
12
14
  return (React.createElement(LightArrowTooltip, { title: React.createElement(SourceItem, { crosswalk: crosswalk, color: color }), placement: 'top' },
13
- React.createElement("div", { className: classnames(styles.crosswalkIcon, className), onMouseEnter: function () { return highlightCrosswalk(); }, onMouseLeave: function () { return removeHighlight(); } })));
15
+ React.createElement("div", { "data-reltio-id": "crosswalk-icon", className: classnames(styles.crosswalkIcon, className), onMouseEnter: function () { return highlightCrosswalk(); }, onMouseLeave: function () { return removeHighlight(); } })));
14
16
  };
15
17
  export default CrosswalkIcon;