@reltio/components 1.4.1372 → 1.4.1373
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/RelationEditor/RelationEditor.d.ts +5 -32
- package/cjs/components/RelationEditor/RelationEditor.js +33 -22
- package/cjs/components/RelationEditor/index.d.ts +3 -152
- package/cjs/components/RelationEditor/styles.js +2 -1
- package/cjs/components/attributes/editMode/AttributesPager/AttributeRenderer.d.ts +10 -6
- package/cjs/components/attributes/editMode/AttributesPager/AttributeRenderer.js +19 -5
- package/cjs/components/attributes/editMode/AttributesPager/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/AttributesPager/styles.js +2 -1
- package/cjs/components/attributes/editMode/AttributesPager/utils.d.ts +2 -1
- package/cjs/components/attributes/editMode/AttributesView/styles.js +1 -0
- package/cjs/components/attributes/editMode/ComplexAttribute/ComplexAttribute.d.ts +5 -160
- package/cjs/components/attributes/editMode/ComplexAttribute/ComplexAttribute.js +29 -13
- package/cjs/components/attributes/editMode/ComplexAttribute/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/ComplexAttribute/styles.js +3 -0
- package/cjs/components/attributes/editMode/ReferenceAttribute/ReferenceAttribute.d.ts +1 -130
- package/cjs/components/attributes/editMode/ReferenceAttribute/ReferenceAttribute.js +24 -19
- package/cjs/components/attributes/editMode/ReferenceAttribute/index.d.ts +1 -129
- package/cjs/components/attributes/editMode/SimpleAttributeEditor/SimpleAttributeEditor.d.ts +1 -1
- package/cjs/components/attributes/editMode/SimpleAttributeEditor/SimpleAttributeEditor.js +23 -12
- package/cjs/components/attributes/editMode/SimpleAttributeEditor/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/SimpleAttributeEditor/styles.js +2 -1
- package/cjs/components/editors/DataTypeValueEditor/DataTypeValueEditor.d.ts +18 -17
- package/cjs/components/editors/DataTypeValueEditor/DataTypeValueEditor.js +3 -1
- package/cjs/contexts/ScrollToErrorContext/index.d.ts +13 -0
- package/cjs/contexts/ScrollToErrorContext/index.js +48 -0
- package/cjs/contexts/index.d.ts +1 -0
- package/cjs/contexts/index.js +4 -1
- package/cjs/hooks/index.d.ts +1 -0
- package/cjs/hooks/index.js +3 -1
- package/cjs/hooks/useScrollToAttributeError/styles.d.ts +1 -0
- package/cjs/hooks/useScrollToAttributeError/styles.js +49 -0
- package/cjs/hooks/useScrollToAttributeError/useScrollToAttributeError.d.ts +14 -0
- package/cjs/hooks/useScrollToAttributeError/useScrollToAttributeError.js +31 -0
- package/esm/components/RelationEditor/RelationEditor.d.ts +5 -32
- package/esm/components/RelationEditor/RelationEditor.js +33 -22
- package/esm/components/RelationEditor/index.d.ts +3 -152
- package/esm/components/RelationEditor/styles.js +2 -1
- package/esm/components/attributes/editMode/AttributesPager/AttributeRenderer.d.ts +10 -6
- package/esm/components/attributes/editMode/AttributesPager/AttributeRenderer.js +20 -6
- package/esm/components/attributes/editMode/AttributesPager/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/AttributesPager/styles.js +2 -1
- package/esm/components/attributes/editMode/AttributesPager/utils.d.ts +2 -1
- package/esm/components/attributes/editMode/AttributesView/styles.js +1 -0
- package/esm/components/attributes/editMode/ComplexAttribute/ComplexAttribute.d.ts +5 -160
- package/esm/components/attributes/editMode/ComplexAttribute/ComplexAttribute.js +29 -13
- package/esm/components/attributes/editMode/ComplexAttribute/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/ComplexAttribute/styles.js +3 -0
- package/esm/components/attributes/editMode/ReferenceAttribute/ReferenceAttribute.d.ts +1 -130
- package/esm/components/attributes/editMode/ReferenceAttribute/ReferenceAttribute.js +27 -22
- package/esm/components/attributes/editMode/ReferenceAttribute/index.d.ts +1 -129
- package/esm/components/attributes/editMode/SimpleAttributeEditor/SimpleAttributeEditor.d.ts +1 -1
- package/esm/components/attributes/editMode/SimpleAttributeEditor/SimpleAttributeEditor.js +24 -13
- package/esm/components/attributes/editMode/SimpleAttributeEditor/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/SimpleAttributeEditor/styles.js +2 -1
- package/esm/components/editors/DataTypeValueEditor/DataTypeValueEditor.d.ts +18 -17
- package/esm/components/editors/DataTypeValueEditor/DataTypeValueEditor.js +3 -1
- package/esm/contexts/ScrollToErrorContext/index.d.ts +13 -0
- package/esm/contexts/ScrollToErrorContext/index.js +21 -0
- package/esm/contexts/index.d.ts +1 -0
- package/esm/contexts/index.js +1 -0
- package/esm/hooks/index.d.ts +1 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/useScrollToAttributeError/styles.d.ts +1 -0
- package/esm/hooks/useScrollToAttributeError/styles.js +46 -0
- package/esm/hooks/useScrollToAttributeError/useScrollToAttributeError.d.ts +14 -0
- package/esm/hooks/useScrollToAttributeError/useScrollToAttributeError.js +24 -0
- package/package.json +3 -3
|
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React, {
|
|
23
|
+
import React, { useCallback, useMemo } from 'react';
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { useSelector } from 'react-redux';
|
|
26
26
|
import classnames from 'classnames';
|
|
@@ -37,6 +37,9 @@ import SmallIconButton from '../../../SmallIconButton/SmallIconButton';
|
|
|
37
37
|
import { attributeValueToEditorValue, prepareChangeData } from './utils';
|
|
38
38
|
import withAsyncMount from '../../../../HOCs/withAsyncMount/withAsyncMount';
|
|
39
39
|
import { getDependentLookupEditorContext } from './selectors/getDependentLookupEditorContext';
|
|
40
|
+
import { withContext } from '../../../../HOCs';
|
|
41
|
+
import { ScrollToErrorContext } from '../../../../contexts';
|
|
42
|
+
import { useScrollToAttributeError } from '../../../../hooks';
|
|
40
43
|
import { useStyles } from './styles';
|
|
41
44
|
var AsyncMountPlaceholder = function () {
|
|
42
45
|
var styles = useStyles();
|
|
@@ -44,13 +47,11 @@ var AsyncMountPlaceholder = function () {
|
|
|
44
47
|
};
|
|
45
48
|
var SimpleAttributeEditor = function (_a) {
|
|
46
49
|
var _b, _c;
|
|
47
|
-
var className = _a.className, attributeValue = _a.attributeValue, attributeType = _a.attributeType, isReltioCrosswalk = _a.isReltioCrosswalk, ownError = _a.ownError, mode = _a.mode, onAddOneMore = _a.onAddOneMore, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onDeactivateError = _a.onDeactivateError, additionalControlsRenderer = _a.additionalControlsRenderer, state = _a.state, otherProps = __rest(_a, ["className", "attributeValue", "attributeType", "isReltioCrosswalk", "ownError", "mode", "onAddOneMore", "onDeleteAttribute", "onChangeAttribute", "onDeactivateError", "additionalControlsRenderer", "state"]);
|
|
50
|
+
var className = _a.className, attributeValue = _a.attributeValue, attributeType = _a.attributeType, isReltioCrosswalk = _a.isReltioCrosswalk, ownError = _a.ownError, mode = _a.mode, onAddOneMore = _a.onAddOneMore, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onDeactivateError = _a.onDeactivateError, additionalControlsRenderer = _a.additionalControlsRenderer, state = _a.state, highlightedError = _a.highlightedError, otherProps = __rest(_a, ["className", "attributeValue", "attributeType", "isReltioCrosswalk", "ownError", "mode", "onAddOneMore", "onDeleteAttribute", "onChangeAttribute", "onDeactivateError", "additionalControlsRenderer", "state", "highlightedError"]);
|
|
48
51
|
var styles = useStyles();
|
|
49
52
|
var deleted = state === 'deleted';
|
|
50
53
|
var edited = state === 'edited';
|
|
51
54
|
var isEditableMode = checkIsEditableMode(mode);
|
|
52
|
-
var dataTypeDefinition = getAttrDataTypeDefinition(attributeType);
|
|
53
|
-
var value = attributeValueToEditorValue(attributeValue, dataTypeDefinition);
|
|
54
55
|
var canCreate = checkCanCreateAttribute({ attributeType: attributeType, mode: mode });
|
|
55
56
|
var canEdit = checkCanEditAttribute({ attributeType: attributeType, attributeValue: attributeValue, mode: mode, isReltioCrosswalk: isReltioCrosswalk });
|
|
56
57
|
var canDelete = checkCanDeleteAttribute({ attributeType: attributeType, attributeValue: attributeValue, mode: mode, isReltioCrosswalk: isReltioCrosswalk });
|
|
@@ -61,24 +62,28 @@ var SimpleAttributeEditor = function (_a) {
|
|
|
61
62
|
? getDependentLookupEditorContext(state, attributeValue, attributeType === null || attributeType === void 0 ? void 0 : attributeType.uri)
|
|
62
63
|
: null;
|
|
63
64
|
});
|
|
65
|
+
var _d = useScrollToAttributeError({ highlightedError: highlightedError, isSimple: true }), ref = _d.ref, errorClassName = _d.errorClassName;
|
|
66
|
+
var dataTypeDefinition = useMemo(function () { return getAttrDataTypeDefinition(attributeType); }, [attributeType]);
|
|
67
|
+
var value = useMemo(function () { return attributeValueToEditorValue(attributeValue, dataTypeDefinition); }, [attributeValue, dataTypeDefinition]);
|
|
68
|
+
var deactivateError = useCallback(function () {
|
|
69
|
+
if (ownError) {
|
|
70
|
+
onDeactivateError(getErrorId(ownError));
|
|
71
|
+
}
|
|
72
|
+
}, [ownError, onDeactivateError]);
|
|
73
|
+
var onValueEditorChange = useCallback(pipe(prepareChangeData(attributeValue, attributeType), onChangeAttribute, deactivateError), [attributeValue, attributeType, onChangeAttribute, deactivateError]);
|
|
64
74
|
var onDelete = function () {
|
|
65
75
|
onDeleteAttribute({ uri: attributeValue.uri, attributeType: attributeType });
|
|
66
76
|
if (getErrorType(ownError) !== ErrorType.missed) {
|
|
67
77
|
deactivateError();
|
|
68
78
|
}
|
|
69
79
|
};
|
|
70
|
-
var deactivateError = function () {
|
|
71
|
-
if (ownError) {
|
|
72
|
-
onDeactivateError(getErrorId(ownError));
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
80
|
var showAddButton = !!onAddOneMore && canCreate && !attributeType.singleValue;
|
|
76
81
|
var showDeleteButton = !deleted && !!onDeleteAttribute && canDelete;
|
|
77
82
|
var hasError = !!errorMessage;
|
|
78
83
|
var deletedProps = deleted ? { disabled: true } : {};
|
|
79
|
-
return (React.createElement("div", { className: classnames(styles.editor, className) },
|
|
84
|
+
return (React.createElement("div", { ref: ref, className: classnames(styles.editor, className, errorClassName) },
|
|
80
85
|
React.createElement(ErrorWrapper, { errorMessage: errorMessage, className: styles.errorWrapper },
|
|
81
|
-
React.createElement("div", { className: classnames(styles['editor-value'], (_b = {}, _b[styles.deleted] = deleted, _b), (_c = {}, _c[styles['editor-read-only-value']] = !showToEdit, _c)), "data-reltio-id": "reltio-attribute-value" }, showToEdit ? (React.createElement(DataTypeValueEditor, __assign({ fieldName: attributeUriToSearchUri(attributeType.uri), value: value, dataTypeDefinition: dataTypeDefinition, error: hasError, onChange:
|
|
86
|
+
React.createElement("div", { className: classnames(styles['editor-value'], (_b = {}, _b[styles.deleted] = deleted, _b), (_c = {}, _c[styles['editor-read-only-value']] = !showToEdit, _c)), "data-reltio-id": "reltio-attribute-value" }, showToEdit ? (React.createElement(DataTypeValueEditor, __assign({ fieldName: attributeUriToSearchUri(attributeType.uri), value: value, dataTypeDefinition: dataTypeDefinition, error: hasError, onChange: onValueEditorChange, fullWidth: true }, dependentLookupEditorContext, otherProps, deletedProps))) : (React.createElement(DataTypeValue, { value: getAttributeValue(attributeValue), dataTypeDefinition: dataTypeDefinition })))),
|
|
82
87
|
React.createElement("div", { className: styles['editor-actions'] },
|
|
83
88
|
edited && (React.createElement(Typography, { variant: "caption", className: styles.editedLabel },
|
|
84
89
|
"(",
|
|
@@ -100,6 +105,12 @@ SimpleAttributeEditor.propTypes = {
|
|
|
100
105
|
onDeleteAttribute: PropTypes.func,
|
|
101
106
|
onChangeAttribute: PropTypes.func,
|
|
102
107
|
onDeactivateError: PropTypes.func,
|
|
103
|
-
additionalControlsRenderer: PropTypes.func
|
|
108
|
+
additionalControlsRenderer: PropTypes.func,
|
|
109
|
+
highlightedError: PropTypes.object
|
|
104
110
|
};
|
|
105
|
-
export default
|
|
111
|
+
export default withAsyncMount(withContext(ScrollToErrorContext, function (contextValue, _a) {
|
|
112
|
+
var attributeValue = _a.attributeValue;
|
|
113
|
+
var error = (contextValue || {}).error;
|
|
114
|
+
var isHighlighted = (error === null || error === void 0 ? void 0 : error.uri) === attributeValue.uri;
|
|
115
|
+
return { highlightedError: isHighlighted ? contextValue : null };
|
|
116
|
+
}, SimpleAttributeEditor), AsyncMountPlaceholder);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"button" | "placeholder" | "deleted" | "editor" | "wrapper" | "addButton" | "errorWrapper" | "editor-value" | "editor-read-only-value" | "editor-actions" | "editedLabel">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"button" | "placeholder" | "deleted" | "editor" | "wrapper" | "addButton" | "errorWrapper" | "editor-value" | "editor-read-only-value" | "editor-actions" | "editedLabel">;
|
|
@@ -11,7 +11,8 @@ export var useStyles = makeStyles(function (theme) { return ({
|
|
|
11
11
|
display: 'flex',
|
|
12
12
|
flex: 1,
|
|
13
13
|
alignItems: 'flex-start',
|
|
14
|
-
marginBottom: "".concat(marginBottom, "px")
|
|
14
|
+
marginBottom: "".concat(marginBottom, "px"),
|
|
15
|
+
position: 'relative'
|
|
15
16
|
},
|
|
16
17
|
'editor-value': {
|
|
17
18
|
flex: '1 1 auto'
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}): JSX.Element;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
1
|
+
declare const _default: import("react").MemoExoticComponent<{
|
|
2
|
+
({ fieldName, value, onChange, dataTypeDefinition, TextFieldProps, ...otherProps }: {
|
|
3
|
+
[x: string]: any;
|
|
4
|
+
fieldName: any;
|
|
5
|
+
value: any;
|
|
6
|
+
onChange: any;
|
|
7
|
+
dataTypeDefinition: any;
|
|
8
|
+
TextFieldProps?: {};
|
|
9
|
+
}): JSX.Element;
|
|
10
|
+
propTypes: {
|
|
11
|
+
fieldName: PropTypes.Requireable<string>;
|
|
12
|
+
value: PropTypes.Requireable<any>;
|
|
13
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
14
|
+
dataTypeDefinition: PropTypes.Requireable<object>;
|
|
15
|
+
};
|
|
16
|
+
displayName: string;
|
|
17
|
+
}>;
|
|
18
|
+
export default _default;
|
|
18
19
|
import PropTypes from "prop-types";
|
|
@@ -20,6 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
+
import { memo } from 'react';
|
|
23
24
|
import { has, is, mergeDeepLeft } from 'ramda';
|
|
24
25
|
import EditorsFactory from '../EditorsFactory';
|
|
25
26
|
import PropTypes from 'prop-types';
|
|
@@ -44,4 +45,5 @@ DataTypeValueEditor.propTypes = {
|
|
|
44
45
|
onChange: PropTypes.func,
|
|
45
46
|
dataTypeDefinition: PropTypes.object
|
|
46
47
|
};
|
|
47
|
-
|
|
48
|
+
DataTypeValueEditor.displayName = 'DataTypeValueEditor';
|
|
49
|
+
export default memo(DataTypeValueEditor);
|
|
@@ -0,0 +1,13 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
};
|
package/esm/contexts/index.d.ts
CHANGED
|
@@ -22,3 +22,4 @@ export { SnackbarContext } from './SnackbarContext';
|
|
|
22
22
|
export { HighlightedValuesContext } from './HighlightedValuesContext';
|
|
23
23
|
export { InterceptHandlersContext } from './InterceptHandlersContext';
|
|
24
24
|
export { SearchValueContext } from './SearchValueContext';
|
|
25
|
+
export { ScrollToErrorContext, ScrollToErrorProvider } from './ScrollToErrorContext';
|
package/esm/contexts/index.js
CHANGED
|
@@ -22,3 +22,4 @@ export { SnackbarContext } from './SnackbarContext';
|
|
|
22
22
|
export { HighlightedValuesContext } from './HighlightedValuesContext';
|
|
23
23
|
export { InterceptHandlersContext } from './InterceptHandlersContext';
|
|
24
24
|
export { SearchValueContext } from './SearchValueContext';
|
|
25
|
+
export { ScrollToErrorContext, ScrollToErrorProvider } from './ScrollToErrorContext';
|
package/esm/hooks/index.d.ts
CHANGED
package/esm/hooks/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"highlightError" | "@keyframes highlightAnimation" | "highlightWarning" | "simpleAttribute">;
|
|
@@ -0,0 +1,46 @@
|
|
|
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: '0px',
|
|
18
|
+
width: '5000px',
|
|
19
|
+
height: 'calc(100% - 10px)',
|
|
20
|
+
animationName: '$highlightAnimation',
|
|
21
|
+
animationDuration: '2s',
|
|
22
|
+
animationIterationCount: 1,
|
|
23
|
+
opacity: 0
|
|
24
|
+
};
|
|
25
|
+
var ERROR_COLOR = 'rgba(255, 0, 0, 0.06)';
|
|
26
|
+
var WARNING_COLOR = 'rgba(228, 151, 0, 0.08)';
|
|
27
|
+
export var useStyles = makeStyles(function () { return ({
|
|
28
|
+
'@keyframes highlightAnimation': {
|
|
29
|
+
'0%': { opacity: 0 },
|
|
30
|
+
'50%': { opacity: 1 },
|
|
31
|
+
'100%': { opacity: 0 }
|
|
32
|
+
},
|
|
33
|
+
highlightError: {
|
|
34
|
+
'&::before': __assign(__assign({}, highlightBeforeStyles), { background: ERROR_COLOR })
|
|
35
|
+
},
|
|
36
|
+
highlightWarning: {
|
|
37
|
+
'&::before': __assign(__assign({}, highlightBeforeStyles), { background: WARNING_COLOR })
|
|
38
|
+
},
|
|
39
|
+
simpleAttribute: {
|
|
40
|
+
position: 'relative',
|
|
41
|
+
'&::before': {
|
|
42
|
+
top: '-4px',
|
|
43
|
+
height: 'calc(100% + 8px)'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}); });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ContextType } from 'react';
|
|
2
|
+
import { ScrollToErrorContext } from '../../contexts';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
highlightedError: ContextType<typeof ScrollToErrorContext> | null;
|
|
5
|
+
isSimple?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const useScrollToAttributeError: ({ highlightedError: context, isSimple }: Props) => {
|
|
8
|
+
ref: import("react").MutableRefObject<HTMLDivElement>;
|
|
9
|
+
errorClassName: string;
|
|
10
|
+
} | {
|
|
11
|
+
ref: import("react").MutableRefObject<HTMLDivElement>;
|
|
12
|
+
errorClassName?: undefined;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { propOr } from 'ramda';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { ErrorSeverity } from '@reltio/mdm-sdk';
|
|
5
|
+
import { useStyles } from './styles';
|
|
6
|
+
export var useScrollToAttributeError = function (_a) {
|
|
7
|
+
var _b;
|
|
8
|
+
var context = _a.highlightedError, _c = _a.isSimple, isSimple = _c === void 0 ? false : _c;
|
|
9
|
+
var styles = useStyles();
|
|
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]);
|
|
13
|
+
var errorClassName = classnames((_b = {},
|
|
14
|
+
_b[styles.highlightError] = severity === ErrorSeverity.ERROR,
|
|
15
|
+
_b[styles.highlightWarning] = severity === ErrorSeverity.WARNING,
|
|
16
|
+
_b[styles.simpleAttribute] = isSimple,
|
|
17
|
+
_b));
|
|
18
|
+
useEffect(function () {
|
|
19
|
+
if (context) {
|
|
20
|
+
scrollIntoRef(ref);
|
|
21
|
+
}
|
|
22
|
+
}, [context, scrollIntoRef]);
|
|
23
|
+
return context ? { ref: ref, errorClassName: errorClassName } : { ref: ref };
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1373",
|
|
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.
|
|
11
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
10
|
+
"@reltio/mdm-module": "^1.4.1373",
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1373",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|