orc-shared 1.5.0-dev.14 → 1.5.0-dev.16
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/dist/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +13 -5
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -2
- package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +3 -1
- package/package.json +1 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +15 -3
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +2 -1
- package/src/components/MaterialUI/hocs/withDeferredTooltip.js +2 -1
- package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +52 -0
|
@@ -10,6 +10,7 @@ var _MultipleLinesText = _interopRequireDefault(require("../TooltippedElements/M
|
|
|
10
10
|
var _textProps = _interopRequireDefault(require("../../textProps"));
|
|
11
11
|
var _propertyValidator = require("../../../../utils/propertyValidator");
|
|
12
12
|
var _sharedMessages = _interopRequireDefault(require("../../../../sharedMessages"));
|
|
13
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
(function () {
|
|
15
16
|
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
@@ -81,7 +82,9 @@ var InformationItemChildren = function InformationItemChildren(_ref) {
|
|
|
81
82
|
children = _ref.children,
|
|
82
83
|
showNotAvailable = _ref.showNotAvailable,
|
|
83
84
|
_ref$isMaxLineCountEn = _ref.isMaxLineCountEnabled,
|
|
84
|
-
isMaxLineCountEnabled = _ref$isMaxLineCountEn === void 0 ? true : _ref$isMaxLineCountEn
|
|
85
|
+
isMaxLineCountEnabled = _ref$isMaxLineCountEn === void 0 ? true : _ref$isMaxLineCountEn,
|
|
86
|
+
tooltipClasses = _ref.tooltipClasses,
|
|
87
|
+
valueClasses = _ref.valueClasses;
|
|
85
88
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
86
89
|
formatMessage = _useIntl.formatMessage;
|
|
87
90
|
if ((0, _propertyValidator.isReactComponent)(children)) {
|
|
@@ -89,11 +92,12 @@ var InformationItemChildren = function InformationItemChildren(_ref) {
|
|
|
89
92
|
}
|
|
90
93
|
var multipleLinesTextProps = new _textProps.default();
|
|
91
94
|
if (isMaxLineCountEnabled) multipleLinesTextProps.set(_textProps.default.propNames.lineCount, 2);
|
|
92
|
-
multipleLinesTextProps.set(_textProps.default.propNames.classes, classes.value);
|
|
95
|
+
multipleLinesTextProps.set(_textProps.default.propNames.classes, (0, _classnames.default)(classes.value, valueClasses));
|
|
93
96
|
var value = children != null ? children : showNotAvailable ? formatMessage(_sharedMessages.default.notAvailable) : "";
|
|
94
97
|
return /*#__PURE__*/_react.default.createElement(_MultipleLinesText.default, {
|
|
95
98
|
textProps: multipleLinesTextProps,
|
|
96
|
-
children: value
|
|
99
|
+
children: value,
|
|
100
|
+
tooltipClasses: tooltipClasses
|
|
97
101
|
});
|
|
98
102
|
};
|
|
99
103
|
__signature__(InformationItemChildren, "useIntl{{ formatMessage }}", function () {
|
|
@@ -134,7 +138,9 @@ var InformationItem = function InformationItem(_ref4) {
|
|
|
134
138
|
showNotAvailable = _ref4$showNotAvailabl === void 0 ? false : _ref4$showNotAvailabl,
|
|
135
139
|
_ref4$marginTop = _ref4.marginTop,
|
|
136
140
|
marginTop = _ref4$marginTop === void 0 ? 0 : _ref4$marginTop,
|
|
137
|
-
isMaxLineCountEnabled = _ref4.isMaxLineCountEnabled
|
|
141
|
+
isMaxLineCountEnabled = _ref4.isMaxLineCountEnabled,
|
|
142
|
+
tooltipClasses = _ref4.tooltipClasses,
|
|
143
|
+
valueClasses = _ref4.valueClasses;
|
|
138
144
|
var classes = useStyles({
|
|
139
145
|
required: required,
|
|
140
146
|
error: error,
|
|
@@ -150,7 +156,9 @@ var InformationItem = function InformationItem(_ref4) {
|
|
|
150
156
|
classes: classes,
|
|
151
157
|
children: children,
|
|
152
158
|
showNotAvailable: showNotAvailable,
|
|
153
|
-
isMaxLineCountEnabled: isMaxLineCountEnabled
|
|
159
|
+
isMaxLineCountEnabled: isMaxLineCountEnabled,
|
|
160
|
+
tooltipClasses: tooltipClasses,
|
|
161
|
+
valueClasses: valueClasses
|
|
154
162
|
}));
|
|
155
163
|
};
|
|
156
164
|
__signature__(InformationItem, "useStyles{classes}", function () {
|
|
@@ -42,7 +42,8 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
42
42
|
var MultipleLinesText = function MultipleLinesText(_ref) {
|
|
43
43
|
var children = _ref.children,
|
|
44
44
|
titleValue = _ref.titleValue,
|
|
45
|
-
textProps = _ref.textProps
|
|
45
|
+
textProps = _ref.textProps,
|
|
46
|
+
tooltipClasses = _ref.tooltipClasses;
|
|
46
47
|
var classes = useStyles();
|
|
47
48
|
var _useState = (0, _react.useState)(false),
|
|
48
49
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -73,7 +74,8 @@ var MultipleLinesText = function MultipleLinesText(_ref) {
|
|
|
73
74
|
alwaysDisplay: isClamped,
|
|
74
75
|
onClampStart: function onClampStart(event) {
|
|
75
76
|
return clampHandler(event);
|
|
76
|
-
}
|
|
77
|
+
},
|
|
78
|
+
tooltipClasses: tooltipClasses
|
|
77
79
|
});
|
|
78
80
|
};
|
|
79
81
|
__signature__(MultipleLinesText, "useStyles{classes}\nuseState{[isClamped, setIsClamped](false)}\nuseCallback{clampHandler}", function () {
|
|
@@ -5,7 +5,7 @@ exports.default = void 0;
|
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
7
7
|
var _propertyValidator = require("../../../utils/propertyValidator");
|
|
8
|
-
var _excluded = ["titleValue", "alwaysDisplay"];
|
|
8
|
+
var _excluded = ["titleValue", "alwaysDisplay", "tooltipClasses"];
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -39,6 +39,7 @@ var withDeferredTooltip = function withDeferredTooltip(Comp) {
|
|
|
39
39
|
return __signature__(__signature__(function (_ref) {
|
|
40
40
|
var titleValue = _ref.titleValue,
|
|
41
41
|
alwaysDisplay = _ref.alwaysDisplay,
|
|
42
|
+
tooltipClasses = _ref.tooltipClasses,
|
|
42
43
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
43
44
|
var _useState = (0, _react.useState)(false),
|
|
44
45
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -62,6 +63,7 @@ var withDeferredTooltip = function withDeferredTooltip(Comp) {
|
|
|
62
63
|
if (shouldBeTooltipped === false) return defaultComponent;
|
|
63
64
|
return /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
|
|
64
65
|
arrow: true,
|
|
66
|
+
classes: tooltipClasses != null ? tooltipClasses : null,
|
|
65
67
|
title: titleValue,
|
|
66
68
|
disableHoverListener: false,
|
|
67
69
|
disableFocusListener: true,
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import TextProps from "../../textProps";
|
|
|
7
7
|
import { isReactComponent } from "../../../../utils/propertyValidator";
|
|
8
8
|
import sharedMessages from "../../../../sharedMessages";
|
|
9
9
|
import { useIntl } from "react-intl";
|
|
10
|
+
import classNames from "classnames";
|
|
10
11
|
|
|
11
12
|
const useStyles = makeStyles(theme => ({
|
|
12
13
|
title: {
|
|
@@ -53,7 +54,14 @@ const useStyles = makeStyles(theme => ({
|
|
|
53
54
|
},
|
|
54
55
|
}));
|
|
55
56
|
|
|
56
|
-
const InformationItemChildren = ({
|
|
57
|
+
const InformationItemChildren = ({
|
|
58
|
+
classes,
|
|
59
|
+
children,
|
|
60
|
+
showNotAvailable,
|
|
61
|
+
isMaxLineCountEnabled = true,
|
|
62
|
+
tooltipClasses,
|
|
63
|
+
valueClasses,
|
|
64
|
+
}) => {
|
|
57
65
|
const { formatMessage } = useIntl();
|
|
58
66
|
|
|
59
67
|
if (isReactComponent(children)) {
|
|
@@ -62,11 +70,11 @@ const InformationItemChildren = ({ classes, children, showNotAvailable, isMaxLin
|
|
|
62
70
|
|
|
63
71
|
const multipleLinesTextProps = new TextProps();
|
|
64
72
|
if (isMaxLineCountEnabled) multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
65
|
-
multipleLinesTextProps.set(TextProps.propNames.classes, classes.value);
|
|
73
|
+
multipleLinesTextProps.set(TextProps.propNames.classes, classNames(classes.value, valueClasses));
|
|
66
74
|
|
|
67
75
|
const value = children ?? (showNotAvailable ? formatMessage(sharedMessages.notAvailable) : "");
|
|
68
76
|
|
|
69
|
-
return <MultipleLinesText textProps={multipleLinesTextProps} children={value} />;
|
|
77
|
+
return <MultipleLinesText textProps={multipleLinesTextProps} children={value} tooltipClasses={tooltipClasses} />;
|
|
70
78
|
};
|
|
71
79
|
|
|
72
80
|
const InformationItemHeader = ({ classes, label, headerIcon }) => {
|
|
@@ -94,6 +102,8 @@ const InformationItem = ({
|
|
|
94
102
|
showNotAvailable = false,
|
|
95
103
|
marginTop = 0,
|
|
96
104
|
isMaxLineCountEnabled,
|
|
105
|
+
tooltipClasses,
|
|
106
|
+
valueClasses,
|
|
97
107
|
}) => {
|
|
98
108
|
const classes = useStyles({ required, error, marginTop });
|
|
99
109
|
|
|
@@ -105,6 +115,8 @@ const InformationItem = ({
|
|
|
105
115
|
children={children}
|
|
106
116
|
showNotAvailable={showNotAvailable}
|
|
107
117
|
isMaxLineCountEnabled={isMaxLineCountEnabled}
|
|
118
|
+
tooltipClasses={tooltipClasses}
|
|
119
|
+
valueClasses={valueClasses}
|
|
108
120
|
/>
|
|
109
121
|
</div>
|
|
110
122
|
);
|
|
@@ -11,7 +11,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
11
11
|
},
|
|
12
12
|
}));
|
|
13
13
|
|
|
14
|
-
const MultipleLinesText = ({ children, titleValue, textProps }) => {
|
|
14
|
+
const MultipleLinesText = ({ children, titleValue, textProps, tooltipClasses }) => {
|
|
15
15
|
const classes = useStyles();
|
|
16
16
|
|
|
17
17
|
const [isClamped, setIsClamped] = useState(false);
|
|
@@ -48,6 +48,7 @@ const MultipleLinesText = ({ children, titleValue, textProps }) => {
|
|
|
48
48
|
titleValue={title}
|
|
49
49
|
alwaysDisplay={isClamped}
|
|
50
50
|
onClampStart={event => clampHandler(event)}
|
|
51
|
+
tooltipClasses={tooltipClasses}
|
|
51
52
|
/>
|
|
52
53
|
);
|
|
53
54
|
};
|
|
@@ -8,7 +8,7 @@ import { isString, isObject, isStringNullOrWhitespace, isReactComponent } from "
|
|
|
8
8
|
|
|
9
9
|
const withDeferredTooltip =
|
|
10
10
|
Comp =>
|
|
11
|
-
({ titleValue, alwaysDisplay, ...props }) => {
|
|
11
|
+
({ titleValue, alwaysDisplay, tooltipClasses, ...props }) => {
|
|
12
12
|
const [shouldBeTooltipped, setShouldBeTooltipped] = useState(false);
|
|
13
13
|
|
|
14
14
|
const defaultComponent = <Comp onMouseEnter={event => makeComponentTooltipped(event)} {...props} />;
|
|
@@ -32,6 +32,7 @@ const withDeferredTooltip =
|
|
|
32
32
|
return (
|
|
33
33
|
<MuiTooltip
|
|
34
34
|
arrow
|
|
35
|
+
classes={tooltipClasses ?? null}
|
|
35
36
|
title={titleValue}
|
|
36
37
|
disableHoverListener={false}
|
|
37
38
|
disableFocusListener={true}
|
|
@@ -155,4 +155,56 @@ describe("withDeferredTooltip", () => {
|
|
|
155
155
|
|
|
156
156
|
expect(wrapper.prop("onMouseEnter"), "to be", undefined);
|
|
157
157
|
});
|
|
158
|
+
|
|
159
|
+
it("Always displays passed title in tooltip with tooltip classes when specified", () => {
|
|
160
|
+
const Wrapper = props => <ComponentToBeTooltipped {...props} />;
|
|
161
|
+
|
|
162
|
+
const TooltippedCompponent = withDeferredTooltip(Wrapper);
|
|
163
|
+
|
|
164
|
+
const mountedTooltippedComponent = shallow(
|
|
165
|
+
<TooltippedCompponent alwaysDisplay titleValue="test" tooltipClasses={{ classTest: "testMyMojo" }} />,
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
const event = {
|
|
169
|
+
target: {
|
|
170
|
+
offsetWidth: 100,
|
|
171
|
+
scrollWidth: 100,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
mountedTooltippedComponent.find(Wrapper).invoke("onMouseEnter")(event);
|
|
176
|
+
|
|
177
|
+
let expected = (
|
|
178
|
+
<MuiTooltip title="test" classes={{ classTest: "testMyMojo" }}>
|
|
179
|
+
<Wrapper />
|
|
180
|
+
</MuiTooltip>
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
expect(mountedTooltippedComponent.containsMatchingElement(expected), "to be true");
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("Always displays passed title in tooltip without tooltip classes when not specified", () => {
|
|
187
|
+
const Wrapper = props => <ComponentToBeTooltipped {...props} />;
|
|
188
|
+
|
|
189
|
+
const TooltippedCompponent = withDeferredTooltip(Wrapper);
|
|
190
|
+
|
|
191
|
+
const mountedTooltippedComponent = shallow(<TooltippedCompponent alwaysDisplay titleValue="test" />);
|
|
192
|
+
|
|
193
|
+
const event = {
|
|
194
|
+
target: {
|
|
195
|
+
offsetWidth: 100,
|
|
196
|
+
scrollWidth: 100,
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
mountedTooltippedComponent.find(Wrapper).invoke("onMouseEnter")(event);
|
|
201
|
+
|
|
202
|
+
let expected = (
|
|
203
|
+
<MuiTooltip title="test" classes={null}>
|
|
204
|
+
<Wrapper />
|
|
205
|
+
</MuiTooltip>
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
expect(mountedTooltippedComponent.containsMatchingElement(expected), "to be true");
|
|
209
|
+
});
|
|
158
210
|
});
|