orc-shared 1.4.0-dev.1 → 1.4.0-dev.2
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 +8 -4
- package/dist/components/MaterialUI/Inputs/InputBase.js +5 -1
- package/dist/components/MaterialUI/Inputs/InputBaseProps.js +4 -1
- package/package.json +1 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +9 -3
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +121 -0
- package/src/components/MaterialUI/Inputs/InputBase.js +6 -1
- package/src/components/MaterialUI/Inputs/InputBase.test.js +39 -0
- package/src/components/MaterialUI/Inputs/InputBaseProps.js +2 -0
- package/src/components/MaterialUI/Inputs/InputBaseProps.test.js +2 -0
- package/src/utils/timezoneHelper.test.js +4 -4
|
@@ -94,7 +94,9 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
94
94
|
var InformationItemChildren = function InformationItemChildren(_ref) {
|
|
95
95
|
var classes = _ref.classes,
|
|
96
96
|
children = _ref.children,
|
|
97
|
-
showNotAvailable = _ref.showNotAvailable
|
|
97
|
+
showNotAvailable = _ref.showNotAvailable,
|
|
98
|
+
_ref$isMaxLineCountEn = _ref.isMaxLineCountEnabled,
|
|
99
|
+
isMaxLineCountEnabled = _ref$isMaxLineCountEn === void 0 ? true : _ref$isMaxLineCountEn;
|
|
98
100
|
|
|
99
101
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
100
102
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -104,7 +106,7 @@ var InformationItemChildren = function InformationItemChildren(_ref) {
|
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
var multipleLinesTextProps = new _textProps.default();
|
|
107
|
-
multipleLinesTextProps.set(_textProps.default.propNames.lineCount, 2);
|
|
109
|
+
if (isMaxLineCountEnabled) multipleLinesTextProps.set(_textProps.default.propNames.lineCount, 2);
|
|
108
110
|
multipleLinesTextProps.set(_textProps.default.propNames.classes, classes.value);
|
|
109
111
|
var value = children != null ? children : showNotAvailable ? formatMessage(_sharedMessages.default.notAvailable) : "";
|
|
110
112
|
return /*#__PURE__*/_react.default.createElement(_MultipleLinesText.default, {
|
|
@@ -156,7 +158,8 @@ var InformationItem = function InformationItem(_ref4) {
|
|
|
156
158
|
_ref4$showNotAvailabl = _ref4.showNotAvailable,
|
|
157
159
|
showNotAvailable = _ref4$showNotAvailabl === void 0 ? false : _ref4$showNotAvailabl,
|
|
158
160
|
_ref4$marginTop = _ref4.marginTop,
|
|
159
|
-
marginTop = _ref4$marginTop === void 0 ? 0 : _ref4$marginTop
|
|
161
|
+
marginTop = _ref4$marginTop === void 0 ? 0 : _ref4$marginTop,
|
|
162
|
+
isMaxLineCountEnabled = _ref4.isMaxLineCountEnabled;
|
|
160
163
|
var classes = useStyles({
|
|
161
164
|
required: required,
|
|
162
165
|
error: error,
|
|
@@ -171,7 +174,8 @@ var InformationItem = function InformationItem(_ref4) {
|
|
|
171
174
|
}), /*#__PURE__*/_react.default.createElement(InformationItemChildren, {
|
|
172
175
|
classes: classes,
|
|
173
176
|
children: children,
|
|
174
|
-
showNotAvailable: showNotAvailable
|
|
177
|
+
showNotAvailable: showNotAvailable,
|
|
178
|
+
isMaxLineCountEnabled: isMaxLineCountEnabled
|
|
175
179
|
}));
|
|
176
180
|
};
|
|
177
181
|
|
|
@@ -157,6 +157,10 @@ var InputBase = function InputBase(_ref) {
|
|
|
157
157
|
var metadata = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.metadata);
|
|
158
158
|
var autoComplete = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.autoComplete);
|
|
159
159
|
var timeoutDelay = (inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.timeoutDelay)) || 100;
|
|
160
|
+
var rowsProps = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.rows);
|
|
161
|
+
var defaultRows = 4;
|
|
162
|
+
var rows = rowsProps;
|
|
163
|
+
if (rows === null || rows === undefined) rows = defaultRows;
|
|
160
164
|
var tooltipText = type === "text" ? value : "";
|
|
161
165
|
|
|
162
166
|
var onClick = function onClick(item) {
|
|
@@ -233,7 +237,7 @@ var InputBase = function InputBase(_ref) {
|
|
|
233
237
|
multiline: multiline,
|
|
234
238
|
startAdornment: startAdornment,
|
|
235
239
|
endAdornment: endAdornment,
|
|
236
|
-
rows:
|
|
240
|
+
rows: rows,
|
|
237
241
|
title: tooltipText,
|
|
238
242
|
autoComplete: autoComplete
|
|
239
243
|
})), error && /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -71,6 +71,8 @@ var InputBaseProps = /*#__PURE__*/function (_ComponentProps) {
|
|
|
71
71
|
|
|
72
72
|
_this.componentProps.set(_this.constructor.propNames.timeoutDelay, null);
|
|
73
73
|
|
|
74
|
+
_this.componentProps.set(_this.constructor.propNames.rows, null);
|
|
75
|
+
|
|
74
76
|
_this.componentClasses.set(_this.constructor.ruleNames.input, null);
|
|
75
77
|
|
|
76
78
|
_this.componentClasses.set(_this.constructor.ruleNames.errorText, null);
|
|
@@ -106,7 +108,8 @@ _defineProperty(InputBaseProps, "propNames", {
|
|
|
106
108
|
endAdornment: "endAdornment",
|
|
107
109
|
metadata: "metadata",
|
|
108
110
|
autoComplete: "autoComplete",
|
|
109
|
-
timeoutDelay: "timeoutDelay"
|
|
111
|
+
timeoutDelay: "timeoutDelay",
|
|
112
|
+
rows: "rows"
|
|
110
113
|
});
|
|
111
114
|
|
|
112
115
|
_defineProperty(InputBaseProps, "ruleNames", {
|
package/package.json
CHANGED
|
@@ -53,7 +53,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
53
53
|
},
|
|
54
54
|
}));
|
|
55
55
|
|
|
56
|
-
const InformationItemChildren = ({ classes, children, showNotAvailable }) => {
|
|
56
|
+
const InformationItemChildren = ({ classes, children, showNotAvailable, isMaxLineCountEnabled = true }) => {
|
|
57
57
|
const { formatMessage } = useIntl();
|
|
58
58
|
|
|
59
59
|
if (isReactComponent(children)) {
|
|
@@ -61,7 +61,7 @@ const InformationItemChildren = ({ classes, children, showNotAvailable }) => {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const multipleLinesTextProps = new TextProps();
|
|
64
|
-
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
64
|
+
if (isMaxLineCountEnabled) multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
65
65
|
multipleLinesTextProps.set(TextProps.propNames.classes, classes.value);
|
|
66
66
|
|
|
67
67
|
const value = children ?? (showNotAvailable ? formatMessage(sharedMessages.notAvailable) : "");
|
|
@@ -93,13 +93,19 @@ const InformationItem = ({
|
|
|
93
93
|
headerIcon = undefined,
|
|
94
94
|
showNotAvailable = false,
|
|
95
95
|
marginTop = 0,
|
|
96
|
+
isMaxLineCountEnabled,
|
|
96
97
|
}) => {
|
|
97
98
|
const classes = useStyles({ required, error, marginTop });
|
|
98
99
|
|
|
99
100
|
return (
|
|
100
101
|
<div className={classes.container}>
|
|
101
102
|
<InformationItemHeader classes={classes} label={label} headerIcon={headerIcon} />
|
|
102
|
-
<InformationItemChildren
|
|
103
|
+
<InformationItemChildren
|
|
104
|
+
classes={classes}
|
|
105
|
+
children={children}
|
|
106
|
+
showNotAvailable={showNotAvailable}
|
|
107
|
+
isMaxLineCountEnabled={isMaxLineCountEnabled}
|
|
108
|
+
/>
|
|
103
109
|
</div>
|
|
104
110
|
);
|
|
105
111
|
};
|
|
@@ -7,6 +7,7 @@ import MultipleLinesText from "../TooltippedElements/MultipleLinesText";
|
|
|
7
7
|
import { stringifyWithoutQuotes } from "./../../../../utils/parseHelper";
|
|
8
8
|
import sharedMessages from "./../../../../sharedMessages";
|
|
9
9
|
import { extractMessages } from "./../../../../utils/testUtils";
|
|
10
|
+
import TextProps from "../../textProps";
|
|
10
11
|
|
|
11
12
|
const messages = extractMessages(sharedMessages);
|
|
12
13
|
|
|
@@ -51,6 +52,126 @@ describe("Information Item", () => {
|
|
|
51
52
|
expect(component, "when mounted", "to satisfy", expected);
|
|
52
53
|
});
|
|
53
54
|
|
|
55
|
+
it("Renders Information Item with max line count", () => {
|
|
56
|
+
const label = "label";
|
|
57
|
+
const value = "value";
|
|
58
|
+
|
|
59
|
+
const multipleLinesTextProps = new TextProps();
|
|
60
|
+
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
61
|
+
|
|
62
|
+
const component = (
|
|
63
|
+
<IntlProvider locale="en-US">
|
|
64
|
+
<InformationItem label={label} isMaxLineCountEnabled={true}>
|
|
65
|
+
{value}
|
|
66
|
+
</InformationItem>
|
|
67
|
+
</IntlProvider>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const expected = (
|
|
71
|
+
<div>
|
|
72
|
+
<Typography children={label} />
|
|
73
|
+
<MultipleLinesText textProps={multipleLinesTextProps}>{value}</MultipleLinesText>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("Renders Information Item without max line count", () => {
|
|
81
|
+
const label = "label";
|
|
82
|
+
const value = "value";
|
|
83
|
+
|
|
84
|
+
const multipleLinesTextProps = new TextProps();
|
|
85
|
+
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
86
|
+
|
|
87
|
+
const component = (
|
|
88
|
+
<IntlProvider locale="en-US">
|
|
89
|
+
<InformationItem label={label}>{value}</InformationItem>
|
|
90
|
+
</IntlProvider>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const expected = (
|
|
94
|
+
<div>
|
|
95
|
+
<Typography children={label} />
|
|
96
|
+
<MultipleLinesText textProps={multipleLinesTextProps}>{value}</MultipleLinesText>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("Renders Information Item with max line count false", () => {
|
|
104
|
+
const label = "label";
|
|
105
|
+
const value = "value";
|
|
106
|
+
|
|
107
|
+
const component = (
|
|
108
|
+
<IntlProvider locale="en-US">
|
|
109
|
+
<InformationItem label={label} isMaxLineCountEnabled={false}>
|
|
110
|
+
{value}
|
|
111
|
+
</InformationItem>
|
|
112
|
+
</IntlProvider>
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const expected = (
|
|
116
|
+
<div>
|
|
117
|
+
<Typography children={label} />
|
|
118
|
+
<MultipleLinesText>{value}</MultipleLinesText>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("Renders Information Item with null max line count", () => {
|
|
126
|
+
const label = "label";
|
|
127
|
+
const value = "value";
|
|
128
|
+
|
|
129
|
+
const multipleLinesTextProps = new TextProps();
|
|
130
|
+
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
131
|
+
|
|
132
|
+
const component = (
|
|
133
|
+
<IntlProvider locale="en-US">
|
|
134
|
+
<InformationItem label={label} isMaxLineCountEnabled={null}>
|
|
135
|
+
{value}
|
|
136
|
+
</InformationItem>
|
|
137
|
+
</IntlProvider>
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const expected = (
|
|
141
|
+
<div>
|
|
142
|
+
<Typography children={label} />
|
|
143
|
+
<MultipleLinesText textProps={multipleLinesTextProps}>{value}</MultipleLinesText>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("Renders Information Item with undefined max line count", () => {
|
|
151
|
+
const label = "label";
|
|
152
|
+
const value = "value";
|
|
153
|
+
|
|
154
|
+
const multipleLinesTextProps = new TextProps();
|
|
155
|
+
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
156
|
+
|
|
157
|
+
const component = (
|
|
158
|
+
<IntlProvider locale="en-US">
|
|
159
|
+
<InformationItem label={label} isMaxLineCountEnabled={undefined}>
|
|
160
|
+
{value}
|
|
161
|
+
</InformationItem>
|
|
162
|
+
</IntlProvider>
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const expected = (
|
|
166
|
+
<div>
|
|
167
|
+
<Typography children={label} />
|
|
168
|
+
<MultipleLinesText textProps={multipleLinesTextProps}>{value}</MultipleLinesText>
|
|
169
|
+
</div>
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
173
|
+
});
|
|
174
|
+
|
|
54
175
|
it("Renders Information Item with null value and showNotAvailable property is true", () => {
|
|
55
176
|
const label = "label";
|
|
56
177
|
const value = null;
|
|
@@ -100,6 +100,11 @@ const InputBase = ({ inputProps }) => {
|
|
|
100
100
|
const metadata = inputProps?.get(InputBaseProps.propNames.metadata);
|
|
101
101
|
const autoComplete = inputProps?.get(InputBaseProps.propNames.autoComplete);
|
|
102
102
|
const timeoutDelay = inputProps?.get(InputBaseProps.propNames.timeoutDelay) || 100;
|
|
103
|
+
const rowsProps = inputProps?.get(InputBaseProps.propNames.rows);
|
|
104
|
+
|
|
105
|
+
const defaultRows = 4;
|
|
106
|
+
let rows = rowsProps;
|
|
107
|
+
if (rows === null || rows === undefined) rows = defaultRows;
|
|
103
108
|
|
|
104
109
|
const tooltipText = type === "text" ? value : "";
|
|
105
110
|
|
|
@@ -165,7 +170,7 @@ const InputBase = ({ inputProps }) => {
|
|
|
165
170
|
multiline={multiline}
|
|
166
171
|
startAdornment={startAdornment}
|
|
167
172
|
endAdornment={endAdornment}
|
|
168
|
-
rows={
|
|
173
|
+
rows={rows}
|
|
169
174
|
title={tooltipText}
|
|
170
175
|
autoComplete={autoComplete}
|
|
171
176
|
/>
|
|
@@ -57,6 +57,45 @@ describe("InputBase Component", () => {
|
|
|
57
57
|
expect(mountedComponent.prop("inputProps").get(InputBaseProps.propNames.value), "to equal", aValue + aValue);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
it("Renders multiline InputBase component with default number of rows", () => {
|
|
61
|
+
const inputProps = new InputBaseProps();
|
|
62
|
+
const aLabel = "aLabel";
|
|
63
|
+
const aValue = "value";
|
|
64
|
+
const defaultRows = 4;
|
|
65
|
+
|
|
66
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
67
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
68
|
+
inputProps.set(InputBaseProps.propNames.type, "text");
|
|
69
|
+
inputProps.set(InputBaseProps.propNames.multiline, true);
|
|
70
|
+
|
|
71
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
72
|
+
|
|
73
|
+
const mountedComponent = mount(component);
|
|
74
|
+
const expected = <InputBaseMUI value={aValue} title={aValue} rows={defaultRows} />;
|
|
75
|
+
|
|
76
|
+
expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("Renders multiline InputBase component with desired number of rows", () => {
|
|
80
|
+
const inputProps = new InputBaseProps();
|
|
81
|
+
const aLabel = "aLabel";
|
|
82
|
+
const aValue = "value";
|
|
83
|
+
const desiredNumberOfRows = 20;
|
|
84
|
+
|
|
85
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
86
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
87
|
+
inputProps.set(InputBaseProps.propNames.type, "text");
|
|
88
|
+
inputProps.set(InputBaseProps.propNames.multiline, true);
|
|
89
|
+
inputProps.set(InputBaseProps.propNames.rows, desiredNumberOfRows);
|
|
90
|
+
|
|
91
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
92
|
+
|
|
93
|
+
const mountedComponent = mount(component);
|
|
94
|
+
const expected = <InputBaseMUI value={aValue} title={aValue} rows={desiredNumberOfRows} />;
|
|
95
|
+
|
|
96
|
+
expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
|
|
97
|
+
});
|
|
98
|
+
|
|
60
99
|
it("Renders InputBase component with title attribute for input of type text", () => {
|
|
61
100
|
const inputProps = new InputBaseProps();
|
|
62
101
|
const aLabel = "aLabel";
|
|
@@ -18,6 +18,7 @@ class InputBaseProps extends ComponentProps {
|
|
|
18
18
|
metadata: "metadata",
|
|
19
19
|
autoComplete: "autoComplete",
|
|
20
20
|
timeoutDelay: "timeoutDelay",
|
|
21
|
+
rows: "rows",
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
static ruleNames = {
|
|
@@ -43,6 +44,7 @@ class InputBaseProps extends ComponentProps {
|
|
|
43
44
|
this.componentProps.set(this.constructor.propNames.metadata, null);
|
|
44
45
|
this.componentProps.set(this.constructor.propNames.autoComplete, null);
|
|
45
46
|
this.componentProps.set(this.constructor.propNames.timeoutDelay, null);
|
|
47
|
+
this.componentProps.set(this.constructor.propNames.rows, null);
|
|
46
48
|
|
|
47
49
|
this.componentClasses.set(this.constructor.ruleNames.input, null);
|
|
48
50
|
this.componentClasses.set(this.constructor.ruleNames.errorText, null);
|
|
@@ -19,6 +19,7 @@ describe("InputBase Props", () => {
|
|
|
19
19
|
"metadata",
|
|
20
20
|
"autoComplete",
|
|
21
21
|
"timeoutDelay",
|
|
22
|
+
"rows",
|
|
22
23
|
];
|
|
23
24
|
|
|
24
25
|
expect(InputBaseProps.propNames, "to have keys", propNames);
|
|
@@ -42,6 +43,7 @@ describe("InputBase Props", () => {
|
|
|
42
43
|
"metadata",
|
|
43
44
|
"autoComplete",
|
|
44
45
|
"timeoutDelay",
|
|
46
|
+
"rows",
|
|
45
47
|
];
|
|
46
48
|
|
|
47
49
|
const ruleNames = ["input", "errorText"];
|
|
@@ -39,15 +39,15 @@ describe("Timezone Helper", () => {
|
|
|
39
39
|
|
|
40
40
|
it("Retrieves user local timezone date", () => {
|
|
41
41
|
const timezoneName = "America/New_York";
|
|
42
|
-
const date = "Mon Apr 04 2022 13:00:00
|
|
43
|
-
const expectedDate = new Date("2022-04-04T09:00:
|
|
42
|
+
const date = "Mon Apr 04 2022 13:00:00.000Z";
|
|
43
|
+
const expectedDate = new Date("2022-04-04T09:00:00.000Z");
|
|
44
44
|
expect(convertTimeToLocalTimeZone, "called with", [date, timezoneName], "to satisfy", expectedDate);
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
it("Retrieves user other timezone date", () => {
|
|
48
48
|
const timezoneName = "America/New_York";
|
|
49
|
-
const date = "Mon Apr 04 2022
|
|
50
|
-
const expectedDate = new Date("2022-04-
|
|
49
|
+
const date = "Mon Apr 04 2022 06:00:00.000Z";
|
|
50
|
+
const expectedDate = new Date("2022-04-04T10:00:00.000Z");
|
|
51
51
|
expect(convertTimeToOtherTimeZone, "called with", [date, timezoneName], "to satisfy", expectedDate);
|
|
52
52
|
});
|
|
53
53
|
});
|