@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,51 +1,124 @@
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);
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
11
36
  };
12
37
  import React from 'react';
13
- import { shallow } from 'enzyme';
38
+ import { render, screen } from '@testing-library/react';
39
+ import userEvent from '@testing-library/user-event';
40
+ import { Provider } from 'react-redux';
14
41
  import CrosswalkIcon from '../CrosswalkIcon';
15
- import * as crosswalksDisplay from '../../../../../contexts/CrosswalksDisplayContext';
16
- import LightArrowTooltip from '../../../../LightArrowTooltip/LightArrowTooltip';
42
+ import { CrosswalksDisplayProvider } from '../../../../../contexts/CrosswalksDisplayContext';
43
+ import { createTestStore } from '../../../../../test-utils/store-utils';
44
+ jest.unmock('@material-ui/core/styles');
17
45
  describe('CrosswalkIcon tests', function () {
18
- var highlightCrosswalk = jest.fn();
19
- var removeHighlight = jest.fn();
20
- var color = '#FF0000';
21
- beforeAll(function () {
22
- jest.spyOn(crosswalksDisplay, 'useCrosswalkColor').mockReturnValue(color);
23
- jest.spyOn(crosswalksDisplay, 'useCrosswalkHighlight').mockReturnValue({
24
- isHighlighted: true,
25
- isDimmed: false,
26
- highlightCrosswalk: highlightCrosswalk,
27
- removeHighlight: removeHighlight
46
+ var setCrosswalkHighlighted = jest.fn();
47
+ var crosswalk = { type: 'Reltio', uri: 'crosswalkUri', value: '20' };
48
+ var disabledCrosswalk = { type: 'Reltio', uri: 'crosswalkUri', value: '20', deleteDate: 1000000 };
49
+ var setUp = function (crosswalk, className, color) {
50
+ if (className === void 0) { className = ''; }
51
+ if (color === void 0) { color = '#F0F'; }
52
+ var store = createTestStore({
53
+ metadata: {
54
+ tenant: {
55
+ sources: [{ uri: 'configuration/sources/Reltio', label: 'Reltio' }]
56
+ }
57
+ },
58
+ tenant: {
59
+ id: 'tenant'
60
+ }
28
61
  });
29
- });
30
- var props = {
31
- crosswalk: { type: 'testType', uri: 'crosswalkUri', value: '20' },
32
- className: 'testClassName'
62
+ var Providers = function (_a) {
63
+ var children = _a.children;
64
+ return (React.createElement(Provider, { store: store },
65
+ React.createElement(CrosswalksDisplayProvider, { setCrosswalkHighlighted: setCrosswalkHighlighted, getCrosswalkColor: function () { return color; } }, children)));
66
+ };
67
+ return render(React.createElement(CrosswalkIcon, { crosswalk: crosswalk, className: className }), { wrapper: Providers });
33
68
  };
34
- it('should render CrosswalkIcon correctly', function () {
35
- var wrapper = shallow(React.createElement(CrosswalkIcon, __assign({}, props)));
36
- var tooltip = wrapper.find(LightArrowTooltip);
37
- var title = tooltip.prop('title');
38
- expect(title.props.crosswalk).toEqual(props.crosswalk);
39
- expect(title.props.color).toEqual(color);
40
- expect(wrapper.find('div').length).toBe(1);
41
- });
42
- it('should support highlighting', function () {
43
- var wrapper = shallow(React.createElement(CrosswalkIcon, __assign({}, props)));
44
- var div = wrapper.find('div');
45
- expect(div.prop('className')).toBe('crosswalkIcon testClassName');
46
- div.simulate('mouseenter');
47
- expect(highlightCrosswalk).toBeCalledTimes(1);
48
- div.simulate('mouseleave');
49
- expect(removeHighlight).toBeCalledTimes(1);
69
+ it('should render CrosswalkIcon correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
70
+ var user, icon;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0:
74
+ user = userEvent.setup();
75
+ setUp(crosswalk);
76
+ icon = screen.getByTestId('crosswalk-icon');
77
+ return [4 /*yield*/, user.hover(icon)];
78
+ case 1:
79
+ _a.sent();
80
+ return [4 /*yield*/, screen.findByRole('tooltip')];
81
+ case 2:
82
+ _a.sent();
83
+ expect(screen.getByText('R')).toBeInTheDocument();
84
+ return [2 /*return*/];
85
+ }
86
+ });
87
+ }); });
88
+ it('should support highlighting', function () { return __awaiter(void 0, void 0, void 0, function () {
89
+ var user, icon, hoverArgs, unhoverArgs;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0:
93
+ setCrosswalkHighlighted.mockReset();
94
+ user = userEvent.setup();
95
+ setUp(crosswalk);
96
+ icon = screen.getByTestId('crosswalk-icon');
97
+ return [4 /*yield*/, user.hover(icon)];
98
+ case 1:
99
+ _a.sent();
100
+ expect(setCrosswalkHighlighted).toHaveBeenCalledTimes(1);
101
+ hoverArgs = setCrosswalkHighlighted.mock.calls[0];
102
+ expect(hoverArgs[0]).toBe(crosswalk);
103
+ expect(hoverArgs[1]).toBeTruthy();
104
+ return [4 /*yield*/, user.unhover(icon)];
105
+ case 2:
106
+ _a.sent();
107
+ expect(setCrosswalkHighlighted).toHaveBeenCalledTimes(2);
108
+ unhoverArgs = setCrosswalkHighlighted.mock.calls[1];
109
+ expect(unhoverArgs[0]).toBe(crosswalk);
110
+ expect(unhoverArgs[1]).toBeFalsy();
111
+ return [2 /*return*/];
112
+ }
113
+ });
114
+ }); });
115
+ it('should render correct icon for disabled crosswalk', function () {
116
+ setUp(disabledCrosswalk);
117
+ var element = screen.getByTestId('crosswalk-icon');
118
+ var style = getComputedStyle(element);
119
+ expect(style).toMatchObject({
120
+ border: '2px solid #f0f',
121
+ 'box-sizing': 'border-box'
122
+ });
50
123
  });
51
124
  });
@@ -2,6 +2,7 @@ declare type StylesProps = {
2
2
  color: string;
3
3
  isOpaque?: boolean;
4
4
  isFocused?: boolean;
5
+ isDisabled?: boolean;
5
6
  };
6
7
  export declare const useStyles: (props: StylesProps) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "crosswalkValue" | "sourceItem" | "eyeIcon" | "sourceInfo" | "sourceIcon" | "crosswalkIcon">;
7
8
  export declare const useComplexAttributeLabelStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label">;
@@ -38,11 +38,13 @@ export var useStyles = makeStyles({
38
38
  });
39
39
  },
40
40
  crosswalkIcon: function (_a) {
41
- var color = _a.color, isOpaque = _a.isOpaque;
41
+ var color = _a.color, isOpaque = _a.isOpaque, isDisabled = _a.isDisabled;
42
42
  return ({
43
- backgroundColor: color,
43
+ backgroundColor: isDisabled ? '#fff' : color,
44
+ border: isDisabled ? "2px solid ".concat(color) : null,
44
45
  height: '12px',
45
46
  width: '12px',
47
+ boxSizing: 'border-box',
46
48
  borderRadius: '30px',
47
49
  opacity: isOpaque ? 1 : 0.38,
48
50
  transition: 'opacity 0.3s'
@@ -1,2 +1,3 @@
1
- import { ApiError } from '@reltio/mdm-sdk';
2
- export declare const showWorkflowError: (error?: ApiError) => void;
1
+ import { ApiError, WorkflowApiError } from '@reltio/mdm-sdk';
2
+ export declare const showApiError: (error?: ApiError) => void;
3
+ export declare const showWorkflowError: (apiError?: WorkflowApiError) => void;
@@ -1,14 +1,19 @@
1
1
  import i18n from 'ui-i18n';
2
2
  import { ApiErrorCode } from '@reltio/mdm-sdk';
3
3
  import ErrorPopup from '../../ErrorPopup/ErrorPopup';
4
- export var showWorkflowError = function (error) {
4
+ export var showApiError = function (error) {
5
5
  if (error === void 0) { error = {}; }
6
- var errorMessage = error.errorMessage, errorCode = error.errorCode;
7
- if (errorCode !== ApiErrorCode.WORKFLOW_IS_NOT_REGISTERED_ERROR) {
8
- console.error(error); // eslint-disable-line
9
- ErrorPopup.addError({
10
- title: i18n.text('Error'),
11
- message: errorMessage || i18n.text('Something went wrong...')
12
- });
6
+ console.error(error); // eslint-disable-line
7
+ ErrorPopup.addError({
8
+ title: i18n.text('Error'),
9
+ message: error.errorMessage || i18n.text('Something went wrong...')
10
+ });
11
+ };
12
+ export var showWorkflowError = function (apiError) {
13
+ if (apiError === void 0) { apiError = {}; }
14
+ var error = apiError.error;
15
+ if ((error === null || error === void 0 ? void 0 : error.errorCode) === ApiErrorCode.WORKFLOW_IS_NOT_REGISTERED_ERROR) {
16
+ return;
13
17
  }
18
+ showApiError(error);
14
19
  };
@@ -14,7 +14,7 @@ import { flatten, has, isEmpty, map, partition, path, pipe, reduce, values } fro
14
14
  import { getDataChangeRequest, getEntitiesByUris } from '@reltio/mdm-sdk';
15
15
  import { useSafePromise } from '../../../hooks';
16
16
  import { concatEntityRelationsObjects, createEntityRelationsObjectByEntity, createEntityRelationsObjectByRelation, extractObjectsFromChangeRequest, getEntitiesObjects, getRelationsObjects } from '../helpers/dcrHelpers';
17
- import { showWorkflowError } from '../helpers/errors';
17
+ import { showApiError } from '../helpers/errors';
18
18
  export var useChangeRequest = function (dcrUri) {
19
19
  var _a = useState([]), groupedObjects = _a[0], setGroupedObjects = _a[1];
20
20
  var _b = useState(null), dcr = _b[0], setDcr = _b[1];
@@ -45,10 +45,10 @@ export var useChangeRequest = function (dcrUri) {
45
45
  relationsObjectsWithRequestedEntities
46
46
  ]);
47
47
  })
48
- .catch(showWorkflowError);
48
+ .catch(showApiError);
49
49
  setDcr(dcr);
50
50
  })
51
- .catch(showWorkflowError);
51
+ .catch(showApiError);
52
52
  }, [dcrUri, requestEntities]);
53
53
  return { dcr: dcr, groupedObjects: groupedObjects };
54
54
  };
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ export declare enum ScrollType {
3
+ Error = "Error",
4
+ NewAttribute = "NewAttribute"
5
+ }
6
+ declare type ScrollToElementContextProps = {
7
+ element: unknown;
8
+ type: ScrollType;
9
+ highlightError?: (element: unknown) => void;
10
+ highlightAttribute?: (element: unknown) => void;
11
+ scrollIntoRef: (ref: React.MutableRefObject<HTMLDivElement>) => void;
12
+ };
13
+ export declare const isHighlightedErrorType: (type: ScrollType) => boolean;
14
+ export declare const isHighlightedAttributeType: (type: ScrollType) => boolean;
15
+ export declare const ScrollToElementContext: React.Context<ScrollToElementContextProps>;
16
+ declare type Props = {
17
+ children: React.ReactNode;
18
+ };
19
+ export declare const ScrollToElementProvider: ({ children }: Props) => JSX.Element;
20
+ export {};
@@ -0,0 +1,44 @@
1
+ import React, { useCallback, useMemo, useRef, useState } from 'react';
2
+ import { noop } from '../../core';
3
+ export var ScrollType;
4
+ (function (ScrollType) {
5
+ ScrollType["Error"] = "Error";
6
+ ScrollType["NewAttribute"] = "NewAttribute";
7
+ })(ScrollType || (ScrollType = {}));
8
+ export var isHighlightedErrorType = function (type) { return type === ScrollType.Error; };
9
+ export var isHighlightedAttributeType = function (type) { return type === ScrollType.NewAttribute; };
10
+ export var ScrollToElementContext = React.createContext({
11
+ element: null,
12
+ type: null,
13
+ highlightError: noop,
14
+ highlightAttribute: noop,
15
+ scrollIntoRef: noop
16
+ });
17
+ export var ScrollToElementProvider = function (_a) {
18
+ var children = _a.children;
19
+ var _b = useState(null), element = _b[0], setElement = _b[1];
20
+ var highlightTimer = useRef(null);
21
+ var scrollIntoRef = useCallback(function (ref) {
22
+ ref.current.scrollIntoView({ behavior: 'smooth', block: 'center' });
23
+ if (highlightTimer) {
24
+ clearTimeout(highlightTimer.current);
25
+ }
26
+ highlightTimer.current = setTimeout(function () {
27
+ setElement(null);
28
+ }, 2000);
29
+ }, []);
30
+ var handleHighlightError = useCallback(function (highlightedError) {
31
+ setElement({ value: highlightedError, type: ScrollType.Error });
32
+ }, []);
33
+ var handleHighlightAttribute = useCallback(function (highlightedAttribute) {
34
+ setTimeout(function () { return setElement({ value: highlightedAttribute, type: ScrollType.NewAttribute }); }, 300);
35
+ }, []);
36
+ var contextValue = useMemo(function () { return ({
37
+ element: element === null || element === void 0 ? void 0 : element.value,
38
+ highlightError: handleHighlightError,
39
+ highlightAttribute: handleHighlightAttribute,
40
+ scrollIntoRef: scrollIntoRef,
41
+ type: element === null || element === void 0 ? void 0 : element.type
42
+ }); }, [element, scrollIntoRef]);
43
+ return React.createElement(ScrollToElementContext.Provider, { value: contextValue }, children);
44
+ };
@@ -23,7 +23,7 @@ export { SnackbarContext } from './SnackbarContext';
23
23
  export { HighlightedValuesContext } from './HighlightedValuesContext';
24
24
  export { InterceptHandlersContext } from './InterceptHandlersContext';
25
25
  export { SearchValueContext } from './SearchValueContext';
26
- export { ScrollToErrorContext, ScrollToErrorProvider } from './ScrollToErrorContext';
26
+ export { ScrollToElementContext, ScrollToElementProvider, ScrollType, isHighlightedErrorType, isHighlightedAttributeType } from './ScrollToElementContext';
27
27
  export { UrlGeneratorsContext } from './UrlGeneratorsContext';
28
28
  export { LabelsContext } from './LabelsContext';
29
29
  export { FeaturesContext } from './FeaturesContext';
@@ -23,7 +23,7 @@ export { SnackbarContext } from './SnackbarContext';
23
23
  export { HighlightedValuesContext } from './HighlightedValuesContext';
24
24
  export { InterceptHandlersContext } from './InterceptHandlersContext';
25
25
  export { SearchValueContext } from './SearchValueContext';
26
- export { ScrollToErrorContext, ScrollToErrorProvider } from './ScrollToErrorContext';
26
+ export { ScrollToElementContext, ScrollToElementProvider, ScrollType, isHighlightedErrorType, isHighlightedAttributeType } from './ScrollToElementContext';
27
27
  export { UrlGeneratorsContext } from './UrlGeneratorsContext';
28
28
  export { LabelsContext } from './LabelsContext';
29
29
  export { FeaturesContext } from './FeaturesContext';
@@ -1,7 +1,7 @@
1
1
  import { ContextType } from 'react';
2
- import { ScrollToErrorContext } from '../../contexts';
2
+ import { ScrollToElementContext } from '../../contexts';
3
3
  declare type Props = {
4
- highlightedError: ContextType<typeof ScrollToErrorContext> | null;
4
+ highlightedError: ContextType<typeof ScrollToElementContext> | null;
5
5
  isSimple?: boolean;
6
6
  };
7
7
  export declare const useScrollToAttributeError: ({ highlightedError: context, isSimple }: Props) => {
@@ -8,8 +8,8 @@ export var useScrollToAttributeError = function (_a) {
8
8
  var context = _a.highlightedError, _c = _a.isSimple, isSimple = _c === void 0 ? false : _c;
9
9
  var styles = useStyles();
10
10
  var ref = useRef(null);
11
- var _d = context || {}, error = _d.error, scrollIntoRef = _d.scrollIntoRef;
12
- var severity = useMemo(function () { return propOr(ErrorSeverity.ERROR, 'severity')(error); }, [error]);
11
+ var _d = context || {}, element = _d.element, scrollIntoRef = _d.scrollIntoRef;
12
+ var severity = useMemo(function () { return propOr(ErrorSeverity.ERROR, 'severity')(element); }, [element]);
13
13
  var errorClassName = classnames((_b = {},
14
14
  _b[styles.highlightError] = severity === ErrorSeverity.ERROR,
15
15
  _b[styles.highlightWarning] = severity === ErrorSeverity.WARNING,
@@ -0,0 +1,78 @@
1
+ export declare const createTestStore: (initialState: any) => import("redux-dynamic-modules").IModuleStore<{
2
+ dataTenants: any;
3
+ tenants: any;
4
+ metadata: any;
5
+ profile: import("redux").CombinedState<{
6
+ dependentLookups: import("@reltio/mdm-module/src/profile/dependentLookups/constants").DependentLookupsState;
7
+ entity: import("@reltio/mdm-sdk").Entity;
8
+ errors: import("@reltio/mdm-sdk").AttributeError[];
9
+ history: import("@reltio/mdm-module").History;
10
+ lastLoadedTime: any;
11
+ lookups: any;
12
+ mode: import("@reltio/mdm-sdk").Mode;
13
+ modifiedEntities: import("@reltio/mdm-module/src/profile/modifiedEntities/constants").ModifiedEntitiesState;
14
+ relations: any;
15
+ trees: import("@reltio/mdm-sdk").TreesState;
16
+ operation: import("@reltio/mdm-sdk").Operation;
17
+ views: import("@reltio/mdm-module/src/profile/views/constants").ProfileViewsState;
18
+ sidePanelViews: string[] | import("@reltio/mdm-sdk").SidePanelViewConfig[];
19
+ }>;
20
+ tenant: any;
21
+ environment: any;
22
+ user: any;
23
+ ui: any;
24
+ search: {
25
+ searchResults: any;
26
+ keyword: any;
27
+ searchOptions: {
28
+ searchByOv: boolean;
29
+ ovOnly: boolean;
30
+ };
31
+ activityFilter: string;
32
+ globalFilter: {
33
+ query: any;
34
+ savedSearchesUris: any[];
35
+ isMuted: boolean;
36
+ };
37
+ searchProviderData: any;
38
+ searchNavigationData: any;
39
+ } | {
40
+ keyword: any;
41
+ searchOptions: any;
42
+ activityFilter: string;
43
+ globalFilter: {
44
+ query: any;
45
+ savedSearchesUris: any[];
46
+ isMuted: boolean;
47
+ };
48
+ searchNavigationData: any;
49
+ searchProviderData: any;
50
+ searchResults: any[];
51
+ } | {
52
+ activityFilter: any;
53
+ searchResults: any[];
54
+ keyword: any;
55
+ searchOptions: {
56
+ searchByOv: boolean;
57
+ ovOnly: boolean;
58
+ };
59
+ globalFilter: {
60
+ query: any;
61
+ savedSearchesUris: any[];
62
+ isMuted: boolean;
63
+ };
64
+ searchProviderData: any;
65
+ searchNavigationData: any;
66
+ } | {
67
+ globalFilter: any;
68
+ searchResults: any[];
69
+ keyword: any;
70
+ searchOptions: {
71
+ searchByOv: boolean;
72
+ ovOnly: boolean;
73
+ };
74
+ activityFilter: string;
75
+ searchProviderData: any;
76
+ searchNavigationData: any;
77
+ };
78
+ }>;
@@ -0,0 +1,12 @@
1
+ /// we do it temporary because of rootDir
2
+ import { getSagaExtension } from 'redux-dynamic-modules-saga';
3
+ import { getThunkExtension } from 'redux-dynamic-modules-thunk';
4
+ import { createStore } from 'redux-dynamic-modules';
5
+ import mdmModule from '@reltio/mdm-module';
6
+ export var createTestStore = function (initialState) {
7
+ return createStore({
8
+ initialState: initialState,
9
+ enhancers: [],
10
+ extensions: [getThunkExtension(), getSagaExtension()]
11
+ }, mdmModule.getModule());
12
+ };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1511",
3
+ "version": "1.4.1515",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
7
7
  "dependencies": {
8
8
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "2.7.0",
10
- "@reltio/mdm-module": "^1.4.1511",
11
- "@reltio/mdm-sdk": "^1.4.1511",
10
+ "@reltio/mdm-module": "^1.4.1515",
11
+ "@reltio/mdm-sdk": "^1.4.1515",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { AttributeError } from '@reltio/mdm-sdk';
3
- declare type ScrollToErrorContextProps = {
4
- error: AttributeError | null;
5
- highlightError: (error: AttributeError) => void;
6
- scrollIntoRef: (ref: React.MutableRefObject<HTMLDivElement>) => void;
7
- };
8
- export declare const ScrollToErrorContext: React.Context<ScrollToErrorContextProps>;
9
- declare type Props = {
10
- children: React.ReactNode;
11
- };
12
- export declare const ScrollToErrorProvider: ({ children }: Props) => JSX.Element;
13
- export {};
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ScrollToErrorProvider = exports.ScrollToErrorContext = void 0;
27
- var react_1 = __importStar(require("react"));
28
- var core_1 = require("../../core");
29
- exports.ScrollToErrorContext = react_1.default.createContext({
30
- error: null,
31
- highlightError: core_1.noop,
32
- scrollIntoRef: core_1.noop
33
- });
34
- var ScrollToErrorProvider = function (_a) {
35
- var children = _a.children;
36
- var _b = (0, react_1.useState)(null), error = _b[0], setError = _b[1];
37
- var highlightTimer = (0, react_1.useRef)(null);
38
- var scrollIntoRef = (0, react_1.useCallback)(function (ref) {
39
- ref.current.scrollIntoView({ behavior: 'smooth', block: 'center' });
40
- if (highlightTimer) {
41
- clearTimeout(highlightTimer.current);
42
- }
43
- highlightTimer.current = setTimeout(function () { return setError(null); }, 2000);
44
- }, []);
45
- var contextValue = (0, react_1.useMemo)(function () { return ({ error: error, highlightError: setError, scrollIntoRef: scrollIntoRef }); }, [error, scrollIntoRef]);
46
- return react_1.default.createElement(exports.ScrollToErrorContext.Provider, { value: contextValue }, children);
47
- };
48
- exports.ScrollToErrorProvider = ScrollToErrorProvider;
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { AttributeError } from '@reltio/mdm-sdk';
3
- declare type ScrollToErrorContextProps = {
4
- error: AttributeError | null;
5
- highlightError: (error: AttributeError) => void;
6
- scrollIntoRef: (ref: React.MutableRefObject<HTMLDivElement>) => void;
7
- };
8
- export declare const ScrollToErrorContext: React.Context<ScrollToErrorContextProps>;
9
- declare type Props = {
10
- children: React.ReactNode;
11
- };
12
- export declare const ScrollToErrorProvider: ({ children }: Props) => JSX.Element;
13
- export {};
@@ -1,21 +0,0 @@
1
- import React, { useCallback, useMemo, useRef, useState } from 'react';
2
- import { noop } from '../../core';
3
- export var ScrollToErrorContext = React.createContext({
4
- error: null,
5
- highlightError: noop,
6
- scrollIntoRef: noop
7
- });
8
- export var ScrollToErrorProvider = function (_a) {
9
- var children = _a.children;
10
- var _b = useState(null), error = _b[0], setError = _b[1];
11
- var highlightTimer = useRef(null);
12
- var scrollIntoRef = useCallback(function (ref) {
13
- ref.current.scrollIntoView({ behavior: 'smooth', block: 'center' });
14
- if (highlightTimer) {
15
- clearTimeout(highlightTimer.current);
16
- }
17
- highlightTimer.current = setTimeout(function () { return setError(null); }, 2000);
18
- }, []);
19
- var contextValue = useMemo(function () { return ({ error: error, highlightError: setError, scrollIntoRef: scrollIntoRef }); }, [error, scrollIntoRef]);
20
- return React.createElement(ScrollToErrorContext.Provider, { value: contextValue }, children);
21
- };