orc-shared 5.7.0-dev.16 → 5.7.0-dev.17
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 +12 -9
- package/package.json +1 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +23 -7
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +18 -6
|
@@ -34,13 +34,11 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
34
34
|
return !props.error ? theme.palette.text.hint : theme.palette.error.main;
|
|
35
35
|
},
|
|
36
36
|
fontFamily: theme.typography.fontFamily,
|
|
37
|
-
marginBottom: theme.spacing(1)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
color: theme.palette.error.main
|
|
43
|
-
}
|
|
37
|
+
marginBottom: theme.spacing(1)
|
|
38
|
+
},
|
|
39
|
+
titleRequired: {
|
|
40
|
+
paddingLeft: theme.spacing(0.5),
|
|
41
|
+
color: theme.palette.error.main
|
|
44
42
|
},
|
|
45
43
|
value: {
|
|
46
44
|
fontSize: theme.typography.fontSize,
|
|
@@ -111,11 +109,15 @@ var InformationItemHeader = function InformationItemHeader(_ref2) {
|
|
|
111
109
|
var classes = _ref2.classes,
|
|
112
110
|
label = _ref2.label,
|
|
113
111
|
headerIcon = _ref2.headerIcon,
|
|
114
|
-
headerIconClassName = _ref2.headerIconClassName
|
|
112
|
+
headerIconClassName = _ref2.headerIconClassName,
|
|
113
|
+
required = _ref2.required;
|
|
115
114
|
var formattedLabel = typeof label === "object" ? /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, label) : label;
|
|
116
115
|
var headerText = (_ref3 = formattedLabel && /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
117
116
|
className: classes.title,
|
|
118
|
-
children: formattedLabel
|
|
117
|
+
children: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, formattedLabel, required && /*#__PURE__*/_react.default.createElement("span", {
|
|
118
|
+
"data-qa": "required",
|
|
119
|
+
className: classes.titleRequired
|
|
120
|
+
}, "*"))
|
|
119
121
|
})) != null ? _ref3 : null;
|
|
120
122
|
if (headerIcon) {
|
|
121
123
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -154,6 +156,7 @@ var InformationItem = function InformationItem(_ref4) {
|
|
|
154
156
|
}, /*#__PURE__*/_react.default.createElement(InformationItemHeader, {
|
|
155
157
|
classes: classes,
|
|
156
158
|
label: label,
|
|
159
|
+
required: required,
|
|
157
160
|
headerIcon: headerIcon,
|
|
158
161
|
headerIconClassName: headerIconClassName
|
|
159
162
|
}), /*#__PURE__*/_react.default.createElement(InformationItemChildren, {
|
package/package.json
CHANGED
|
@@ -15,11 +15,10 @@ const useStyles = makeStyles(theme => ({
|
|
|
15
15
|
color: props => (!props.error ? theme.palette.text.hint : theme.palette.error.main),
|
|
16
16
|
fontFamily: theme.typography.fontFamily,
|
|
17
17
|
marginBottom: theme.spacing(1),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
18
|
+
},
|
|
19
|
+
titleRequired: {
|
|
20
|
+
paddingLeft: theme.spacing(0.5),
|
|
21
|
+
color: theme.palette.error.main,
|
|
23
22
|
},
|
|
24
23
|
value: {
|
|
25
24
|
fontSize: theme.typography.fontSize,
|
|
@@ -77,9 +76,25 @@ const InformationItemChildren = ({
|
|
|
77
76
|
return <MultipleLinesText textProps={multipleLinesTextProps} children={value} tooltipClasses={tooltipClasses} />;
|
|
78
77
|
};
|
|
79
78
|
|
|
80
|
-
const InformationItemHeader = ({ classes, label, headerIcon, headerIconClassName }) => {
|
|
79
|
+
const InformationItemHeader = ({ classes, label, headerIcon, headerIconClassName, required }) => {
|
|
81
80
|
const formattedLabel = typeof label === "object" ? <FormattedMessage {...label} /> : label;
|
|
82
|
-
const headerText =
|
|
81
|
+
const headerText =
|
|
82
|
+
(formattedLabel && (
|
|
83
|
+
<Typography
|
|
84
|
+
className={classes.title}
|
|
85
|
+
children={
|
|
86
|
+
<>
|
|
87
|
+
{formattedLabel}
|
|
88
|
+
{required && (
|
|
89
|
+
<span data-qa="required" className={classes.titleRequired}>
|
|
90
|
+
*
|
|
91
|
+
</span>
|
|
92
|
+
)}
|
|
93
|
+
</>
|
|
94
|
+
}
|
|
95
|
+
/>
|
|
96
|
+
)) ??
|
|
97
|
+
null;
|
|
83
98
|
|
|
84
99
|
if (headerIcon) {
|
|
85
100
|
return (
|
|
@@ -113,6 +128,7 @@ const InformationItem = ({
|
|
|
113
128
|
<InformationItemHeader
|
|
114
129
|
classes={classes}
|
|
115
130
|
label={label}
|
|
131
|
+
required={required}
|
|
116
132
|
headerIcon={headerIcon}
|
|
117
133
|
headerIconClassName={headerIconClassName}
|
|
118
134
|
/>
|
|
@@ -237,7 +237,7 @@ describe("Information Item", () => {
|
|
|
237
237
|
|
|
238
238
|
const component = (
|
|
239
239
|
<IntlProvider locale="en" messages={{ label }}>
|
|
240
|
-
<InformationItem label={label} required={
|
|
240
|
+
<InformationItem label={label} required={false}>
|
|
241
241
|
{value}
|
|
242
242
|
</InformationItem>
|
|
243
243
|
</IntlProvider>
|
|
@@ -272,19 +272,31 @@ describe("Information Item", () => {
|
|
|
272
272
|
|
|
273
273
|
it("Renders Information Item with required", () => {
|
|
274
274
|
const label = "label";
|
|
275
|
-
const value =
|
|
275
|
+
const value = <p>Value</p>;
|
|
276
276
|
|
|
277
|
-
const component =
|
|
277
|
+
const component = (
|
|
278
278
|
<IntlProvider locale="en-US">
|
|
279
279
|
<InformationItem label={label} required={true}>
|
|
280
280
|
{value}
|
|
281
281
|
</InformationItem>
|
|
282
|
-
</IntlProvider
|
|
282
|
+
</IntlProvider>
|
|
283
283
|
);
|
|
284
284
|
|
|
285
|
-
const
|
|
285
|
+
const expected = (
|
|
286
|
+
<div>
|
|
287
|
+
<Typography
|
|
288
|
+
children={
|
|
289
|
+
<>
|
|
290
|
+
{label}
|
|
291
|
+
<span data-qa="required">*</span>
|
|
292
|
+
</>
|
|
293
|
+
}
|
|
294
|
+
/>
|
|
295
|
+
{value}
|
|
296
|
+
</div>
|
|
297
|
+
);
|
|
286
298
|
|
|
287
|
-
expect(
|
|
299
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
288
300
|
});
|
|
289
301
|
|
|
290
302
|
it("Renders Information Item properly with a header icon", () => {
|