orc-shared 5.10.1-dev.7 → 5.10.1
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/AppFrame/MenuItem.js +12 -3
- package/dist/components/CategoryList.js +197 -0
- package/dist/components/List/DataCell.js +129 -0
- package/dist/components/List/HeadCell.js +125 -0
- package/dist/components/List/HeadRow.js +73 -0
- package/dist/components/List/List.js +274 -0
- package/dist/components/List/Row.js +109 -0
- package/dist/components/List/enhanceColumnDefs.js +111 -0
- package/dist/components/List/index.js +59 -0
- package/dist/components/MaterialUI/DataDisplay/Table.js +1 -2
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +1 -3
- package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +2 -3
- package/dist/components/ToastList.js +64 -95
- package/dist/getTheme.js +5 -0
- package/package.json +1 -1
- package/src/components/AppFrame/MenuItem.js +9 -1
- package/src/components/CategoryList.js +140 -0
- package/src/components/CategoryList.test.js +667 -0
- package/src/components/List/DataCell.js +77 -0
- package/src/components/List/DataCell.test.js +357 -0
- package/src/components/List/HeadCell.js +105 -0
- package/src/components/List/HeadCell.test.js +331 -0
- package/src/components/List/HeadRow.js +21 -0
- package/src/components/List/HeadRow.test.js +27 -0
- package/src/components/List/List.js +162 -0
- package/src/components/List/List.test.js +705 -0
- package/src/components/List/Row.js +72 -0
- package/src/components/List/Row.test.js +194 -0
- package/src/components/List/enhanceColumnDefs.js +54 -0
- package/src/components/List/enhanceColumnDefs.test.js +179 -0
- package/src/components/List/index.js +6 -0
- package/src/components/MaterialUI/DataDisplay/Table.js +1 -6
- package/src/components/MaterialUI/DataDisplay/Table.test.js +0 -20
- package/src/components/MaterialUI/DataDisplay/TableProps.js +0 -2
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -20
- package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +1 -2
- package/src/components/ToastList.js +90 -79
- package/src/components/ToastList.test.js +103 -29
- package/src/getTheme.js +5 -0
- package/dist/utils/toastHelper.js +0 -52
- package/src/utils/toastHelper.js +0 -8
- package/src/utils/toastHelper.test.js +0 -41
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import styled, { css } from "styled-components";
|
|
3
|
+
import { ifFlag } from "../../utils";
|
|
4
|
+
import DataCell from "./DataCell";
|
|
5
|
+
|
|
6
|
+
export const stringifyFieldName = name => {
|
|
7
|
+
if (Array.isArray(name)) {
|
|
8
|
+
return name.join("_");
|
|
9
|
+
} else {
|
|
10
|
+
return name && name.toString();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const TableRow = styled.tr`
|
|
15
|
+
${ifFlag(
|
|
16
|
+
"bgColor",
|
|
17
|
+
props =>
|
|
18
|
+
css`
|
|
19
|
+
background-color: ${props.bgColor};
|
|
20
|
+
`,
|
|
21
|
+
css`
|
|
22
|
+
transition: background-color 0.2s ease-in;
|
|
23
|
+
&:hover {
|
|
24
|
+
background-color: #f3f3f3;
|
|
25
|
+
}
|
|
26
|
+
`,
|
|
27
|
+
)}
|
|
28
|
+
|
|
29
|
+
${ifFlag(
|
|
30
|
+
"onClick",
|
|
31
|
+
css`
|
|
32
|
+
& td {
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
)}
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
// Clicks on these elements will not be handled by the row onClick
|
|
40
|
+
const formTags = ["INPUT", "SELECT", "LABEL"];
|
|
41
|
+
|
|
42
|
+
export const Row = ({ columnDefs, row, rowId, selected, rowOnClick, bgColor }) => {
|
|
43
|
+
const onClick = useCallback(
|
|
44
|
+
event => {
|
|
45
|
+
if (formTags.indexOf(event.target.tagName) === -1) {
|
|
46
|
+
/* istanbul ignore else */
|
|
47
|
+
if (!event.target.dataset["rowId"]) {
|
|
48
|
+
event.target.dataset["rowId"] = rowId;
|
|
49
|
+
}
|
|
50
|
+
rowOnClick(event);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
[rowOnClick, rowId],
|
|
54
|
+
);
|
|
55
|
+
return (
|
|
56
|
+
<TableRow onClick={rowOnClick ? onClick : undefined} bgColor={bgColor}>
|
|
57
|
+
{columnDefs.map(columnDef => (
|
|
58
|
+
<DataCell
|
|
59
|
+
key={stringifyFieldName(columnDef.fieldName)}
|
|
60
|
+
{...{
|
|
61
|
+
rowId,
|
|
62
|
+
row,
|
|
63
|
+
columnDef,
|
|
64
|
+
selected,
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
))}
|
|
68
|
+
</TableRow>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default Row;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Provider } from "react-redux";
|
|
3
|
+
import sinon from "sinon";
|
|
4
|
+
import { Row, TableRow, stringifyFieldName } from "./Row";
|
|
5
|
+
import DataCell from "./DataCell";
|
|
6
|
+
|
|
7
|
+
const TestComp = () => (
|
|
8
|
+
<div>
|
|
9
|
+
<input />
|
|
10
|
+
<select />
|
|
11
|
+
<label />
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
describe("Row", () => {
|
|
16
|
+
let rowOnClick, columnDefs, row;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
rowOnClick = sinon.spy().named("rowOnClick");
|
|
19
|
+
columnDefs = [{ fieldName: "a" }, { fieldName: "b" }, { fieldName: "test", type: "custom", component: TestComp }];
|
|
20
|
+
row = { a: "foo", b: "bar" };
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("it renders a data cell for each column definition", () =>
|
|
24
|
+
expect(
|
|
25
|
+
<Provider
|
|
26
|
+
store={{
|
|
27
|
+
subscribe: () => {},
|
|
28
|
+
dispatch: () => {},
|
|
29
|
+
getState: () => ({}),
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<table>
|
|
33
|
+
<tbody>
|
|
34
|
+
<Row row={row} rowId="rowIdentifier" columnDefs={columnDefs} rowOnClick={rowOnClick} bgColor="#ff0000" />
|
|
35
|
+
</tbody>
|
|
36
|
+
</table>
|
|
37
|
+
</Provider>,
|
|
38
|
+
"when mounted",
|
|
39
|
+
"with event",
|
|
40
|
+
{ type: "click", target: "tr" },
|
|
41
|
+
"to satisfy",
|
|
42
|
+
<Provider
|
|
43
|
+
store={{
|
|
44
|
+
subscribe: () => {},
|
|
45
|
+
dispatch: () => {},
|
|
46
|
+
getState: () => ({}),
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
<table>
|
|
50
|
+
<tbody>
|
|
51
|
+
<TableRow bgColor="#ff0000" onClick={() => {}}>
|
|
52
|
+
<DataCell key="a" rowId="rowIdentifier" row={row} columnDef={columnDefs[0]} />
|
|
53
|
+
<DataCell key="b" rowId="rowIdentifier" row={row} columnDef={columnDefs[1]} />
|
|
54
|
+
<DataCell key="test" rowId="rowIdentifier" row={row} columnDef={columnDefs[2]} />
|
|
55
|
+
</TableRow>
|
|
56
|
+
</tbody>
|
|
57
|
+
</table>
|
|
58
|
+
</Provider>,
|
|
59
|
+
).then(() => expect(rowOnClick, "was called")));
|
|
60
|
+
|
|
61
|
+
it("wraps row onClick handler to add rowId to event target, and not to fire if target is form element", () =>
|
|
62
|
+
expect(
|
|
63
|
+
<Provider
|
|
64
|
+
store={{
|
|
65
|
+
subscribe: () => {},
|
|
66
|
+
dispatch: () => {},
|
|
67
|
+
getState: () => ({}),
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
<table>
|
|
71
|
+
<tbody>
|
|
72
|
+
<Row row={row} rowId="rowIdentifier" columnDefs={columnDefs} rowOnClick={rowOnClick} />
|
|
73
|
+
</tbody>
|
|
74
|
+
</table>
|
|
75
|
+
</Provider>,
|
|
76
|
+
"when mounted",
|
|
77
|
+
"with event",
|
|
78
|
+
"click",
|
|
79
|
+
"with event",
|
|
80
|
+
{
|
|
81
|
+
type: "click",
|
|
82
|
+
target: "input",
|
|
83
|
+
// don't fire
|
|
84
|
+
},
|
|
85
|
+
"with event",
|
|
86
|
+
{
|
|
87
|
+
type: "click",
|
|
88
|
+
target: "select",
|
|
89
|
+
// don't fire
|
|
90
|
+
},
|
|
91
|
+
"with event",
|
|
92
|
+
{
|
|
93
|
+
type: "click",
|
|
94
|
+
target: "label",
|
|
95
|
+
// don't fire
|
|
96
|
+
},
|
|
97
|
+
"with event",
|
|
98
|
+
{
|
|
99
|
+
type: "click",
|
|
100
|
+
target: "tr",
|
|
101
|
+
},
|
|
102
|
+
"to contain",
|
|
103
|
+
<TestComp />,
|
|
104
|
+
).then(() =>
|
|
105
|
+
expect(rowOnClick, "to have calls satisfying", [
|
|
106
|
+
{
|
|
107
|
+
args: [
|
|
108
|
+
{
|
|
109
|
+
target: expect.it("to have attributes", {
|
|
110
|
+
"data-row-id": "rowIdentifier",
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
]),
|
|
116
|
+
));
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe("TableRow", () => {
|
|
120
|
+
it("renders with a hover transition", () =>
|
|
121
|
+
expect(
|
|
122
|
+
<table>
|
|
123
|
+
<tbody>
|
|
124
|
+
<TableRow />
|
|
125
|
+
</tbody>
|
|
126
|
+
</table>,
|
|
127
|
+
"when mounted",
|
|
128
|
+
"queried for first",
|
|
129
|
+
"tr",
|
|
130
|
+
"to have style rules satisfying",
|
|
131
|
+
expect
|
|
132
|
+
.it("to contain", "transition: background-color 0.2s ease-in;")
|
|
133
|
+
.and("to contain", ":hover {background-color: #f3f3f3;}"),
|
|
134
|
+
));
|
|
135
|
+
|
|
136
|
+
it("renders a specific background color when given", () =>
|
|
137
|
+
expect(
|
|
138
|
+
<table>
|
|
139
|
+
<tbody>
|
|
140
|
+
<TableRow bgColor="#ff0000" />
|
|
141
|
+
</tbody>
|
|
142
|
+
</table>,
|
|
143
|
+
"when mounted",
|
|
144
|
+
"queried for first",
|
|
145
|
+
"tr",
|
|
146
|
+
"to have style rules satisfying",
|
|
147
|
+
"to contain",
|
|
148
|
+
"background-color: #ff0000;",
|
|
149
|
+
));
|
|
150
|
+
|
|
151
|
+
it("renders no transition if given a bgColor prop", () =>
|
|
152
|
+
expect(
|
|
153
|
+
<table>
|
|
154
|
+
<tbody>
|
|
155
|
+
<TableRow bgColor="#ff0000" />
|
|
156
|
+
</tbody>
|
|
157
|
+
</table>,
|
|
158
|
+
"when mounted",
|
|
159
|
+
"queried for first",
|
|
160
|
+
"tr",
|
|
161
|
+
"to have style rules satisfying",
|
|
162
|
+
expect
|
|
163
|
+
.it("not to match", /transition: background-color/)
|
|
164
|
+
.and("not to match", /:hover \{[^}]*background-color:[^}]*\}/),
|
|
165
|
+
));
|
|
166
|
+
|
|
167
|
+
it("sets cursor type if given click handler", () =>
|
|
168
|
+
expect(
|
|
169
|
+
<table>
|
|
170
|
+
<tbody>
|
|
171
|
+
<TableRow onClick={() => {}} />
|
|
172
|
+
</tbody>
|
|
173
|
+
</table>,
|
|
174
|
+
"when mounted",
|
|
175
|
+
"queried for first",
|
|
176
|
+
"tr",
|
|
177
|
+
"to have style rules satisfying",
|
|
178
|
+
expect.it("to contain", "td {cursor: pointer;}"),
|
|
179
|
+
));
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe("stringifyFieldName", () => {
|
|
183
|
+
it("does nothing to a string", () =>
|
|
184
|
+
expect(stringifyFieldName, "when called with", ["FieldName"], "to equal", "FieldName"));
|
|
185
|
+
|
|
186
|
+
it("converts an array to a string", () =>
|
|
187
|
+
expect(stringifyFieldName, "when called with", [["fieldA", "foo"]], "to equal", "fieldA_foo"));
|
|
188
|
+
|
|
189
|
+
it("handles arrays with non-string types", () =>
|
|
190
|
+
expect(stringifyFieldName, "when called with", [["fieldA", 0, "foo"]], "to equal", "fieldA_0_foo"));
|
|
191
|
+
|
|
192
|
+
it("returns undefined if given undefined", () =>
|
|
193
|
+
expect(stringifyFieldName, "when called with", [undefined], "to equal", undefined));
|
|
194
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const toggleInArray = (nameList, name) => {
|
|
2
|
+
if (nameList.indexOf(name) !== -1) {
|
|
3
|
+
return nameList.filter(n => n !== name);
|
|
4
|
+
} else {
|
|
5
|
+
return nameList.concat(name);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const enhanceSelectColumn = (selection, updateViewState, def) => {
|
|
10
|
+
return {
|
|
11
|
+
fieldName: "selection",
|
|
12
|
+
...def,
|
|
13
|
+
onChange: eventOrSelection => {
|
|
14
|
+
if (Array.isArray(eventOrSelection)) {
|
|
15
|
+
updateViewState("selection", eventOrSelection);
|
|
16
|
+
} else {
|
|
17
|
+
updateViewState("selection", toggleInArray(selection, eventOrSelection.target.dataset.rowId));
|
|
18
|
+
eventOrSelection.stopPropagation();
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const enhanceSortableColumn = (sorting, updateViewState, def) => {
|
|
25
|
+
const isSortColumn = sorting.column && def.fieldName && sorting.column.toString() === def.fieldName.toString();
|
|
26
|
+
const isAscending = isSortColumn && sorting.direction === "asc";
|
|
27
|
+
const newDef = {
|
|
28
|
+
...def,
|
|
29
|
+
sort: () => {
|
|
30
|
+
updateViewState("sorting", {
|
|
31
|
+
column: def.fieldName,
|
|
32
|
+
direction: isAscending ? "desc" : "asc",
|
|
33
|
+
});
|
|
34
|
+
def.sort(isAscending, def.fieldName, def.type);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
if (isSortColumn) {
|
|
38
|
+
newDef.sortDirection = sorting.direction;
|
|
39
|
+
}
|
|
40
|
+
return newDef;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const enhanceColumnDef = (sorting, selection, updateViewState, columnDefs) =>
|
|
44
|
+
columnDefs.map(def => {
|
|
45
|
+
if (def.type === "select") {
|
|
46
|
+
return enhanceSelectColumn(selection, updateViewState, def);
|
|
47
|
+
}
|
|
48
|
+
if (def.sort) {
|
|
49
|
+
return enhanceSortableColumn(sorting, updateViewState, def);
|
|
50
|
+
}
|
|
51
|
+
return def;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export default enhanceColumnDef;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import sinon from "sinon";
|
|
2
|
+
import enhanceColumnDefs from "./enhanceColumnDefs";
|
|
3
|
+
|
|
4
|
+
describe("enhanceColumnDefs", () => {
|
|
5
|
+
let sorting, selection, updateViewState, columnDefs, mockEvent, stopPropagations;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
sorting = {};
|
|
8
|
+
selection = [];
|
|
9
|
+
updateViewState = sinon.spy().named("updateViewState");
|
|
10
|
+
columnDefs = [{ fieldName: "a" }];
|
|
11
|
+
stopPropagations = {};
|
|
12
|
+
mockEvent = id => {
|
|
13
|
+
stopPropagations[id] = sinon.spy().named("stopPropagation:" + id);
|
|
14
|
+
return {
|
|
15
|
+
target: { dataset: { rowId: id } },
|
|
16
|
+
stopPropagation: stopPropagations[id],
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("does not change column definitions without cause", () =>
|
|
22
|
+
expect(enhanceColumnDefs, "called with", [sorting, selection, updateViewState, columnDefs], "to satisfy", [
|
|
23
|
+
{
|
|
24
|
+
fieldName: "a",
|
|
25
|
+
},
|
|
26
|
+
]));
|
|
27
|
+
|
|
28
|
+
describe("column selection", () => {
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
columnDefs = [{ type: "select" }, { fieldName: "a" }];
|
|
31
|
+
selection = ["selectedRow"];
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("adds field name and onChange to select columns", () =>
|
|
35
|
+
expect(
|
|
36
|
+
enhanceColumnDefs,
|
|
37
|
+
"called with",
|
|
38
|
+
[sorting, selection, updateViewState, columnDefs],
|
|
39
|
+
"to exhaustively satisfy",
|
|
40
|
+
[
|
|
41
|
+
{
|
|
42
|
+
type: "select",
|
|
43
|
+
fieldName: "selection",
|
|
44
|
+
onChange: expect
|
|
45
|
+
.it("to be a function")
|
|
46
|
+
// Add name to selection
|
|
47
|
+
.and("called with", [mockEvent("myRow")])
|
|
48
|
+
// remove name from selection
|
|
49
|
+
.and("called with", [mockEvent("selectedRow")])
|
|
50
|
+
// Replace selection
|
|
51
|
+
.and("called with", [["list", "of", "row", "ids"]]),
|
|
52
|
+
},
|
|
53
|
+
{ fieldName: "a" },
|
|
54
|
+
],
|
|
55
|
+
).then(() => {
|
|
56
|
+
expect(stopPropagations["myRow"], "was called");
|
|
57
|
+
expect(stopPropagations["selectedRow"], "was called");
|
|
58
|
+
expect(updateViewState, "to have calls satisfying", [
|
|
59
|
+
{
|
|
60
|
+
args: [
|
|
61
|
+
// Add name to selection
|
|
62
|
+
"selection",
|
|
63
|
+
["selectedRow", "myRow"],
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
args: [
|
|
68
|
+
// remove name from selection
|
|
69
|
+
"selection",
|
|
70
|
+
[],
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
args: [
|
|
75
|
+
// Replace selection
|
|
76
|
+
"selection",
|
|
77
|
+
["list", "of", "row", "ids"],
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
it("handles missing selection", () =>
|
|
84
|
+
expect(enhanceColumnDefs, "called with", [sorting, [], updateViewState, columnDefs], "to exhaustively satisfy", [
|
|
85
|
+
{
|
|
86
|
+
type: "select",
|
|
87
|
+
fieldName: "selection",
|
|
88
|
+
onChange: expect.it("to be a function"),
|
|
89
|
+
},
|
|
90
|
+
{ fieldName: "a" },
|
|
91
|
+
]));
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("column sorting", () => {
|
|
95
|
+
let sorterSpies;
|
|
96
|
+
beforeEach(() => {
|
|
97
|
+
sorting = { column: "b", direction: "asc" };
|
|
98
|
+
sorterSpies = [sinon.spy().named("sorter-a"), sinon.spy().named("sorter-b"), sinon.spy().named("sorter-c")];
|
|
99
|
+
columnDefs = [
|
|
100
|
+
{
|
|
101
|
+
fieldName: "a",
|
|
102
|
+
sort: sorterSpies[0],
|
|
103
|
+
type: "currency",
|
|
104
|
+
onChange: () => {},
|
|
105
|
+
},
|
|
106
|
+
{ fieldName: "b", sort: sorterSpies[1], type: "date" },
|
|
107
|
+
{ fieldName: "c", sort: sorterSpies[2], type: "switch" },
|
|
108
|
+
];
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("wraps sort functions to set view state", () =>
|
|
112
|
+
expect(
|
|
113
|
+
enhanceColumnDefs,
|
|
114
|
+
"called with",
|
|
115
|
+
[sorting, selection, updateViewState, columnDefs],
|
|
116
|
+
"to exhaustively satisfy",
|
|
117
|
+
[
|
|
118
|
+
{
|
|
119
|
+
fieldName: "a",
|
|
120
|
+
sort: expect.it("to be a function").and("called"),
|
|
121
|
+
type: "currency",
|
|
122
|
+
onChange: expect.it("to be a function"),
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
fieldName: "b",
|
|
126
|
+
sort: expect.it("to be a function"),
|
|
127
|
+
type: "date",
|
|
128
|
+
sortDirection: "asc",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
fieldName: "c",
|
|
132
|
+
sort: expect.it("to be a function"),
|
|
133
|
+
type: "switch",
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
).then(() => {
|
|
137
|
+
expect(sorterSpies, "to have calls satisfying", [{ spy: sorterSpies[0], args: [false, "a", "currency"] }]);
|
|
138
|
+
expect(updateViewState, "to have calls satisfying", [
|
|
139
|
+
{
|
|
140
|
+
args: ["sorting", { column: "a", direction: "asc" }],
|
|
141
|
+
},
|
|
142
|
+
]);
|
|
143
|
+
}));
|
|
144
|
+
|
|
145
|
+
it("wraps sort functions to handle flipping sort direction", () =>
|
|
146
|
+
expect(
|
|
147
|
+
enhanceColumnDefs,
|
|
148
|
+
"called with",
|
|
149
|
+
[sorting, selection, updateViewState, columnDefs],
|
|
150
|
+
"to exhaustively satisfy",
|
|
151
|
+
[
|
|
152
|
+
{
|
|
153
|
+
fieldName: "a",
|
|
154
|
+
sort: expect.it("to be a function"),
|
|
155
|
+
type: "currency",
|
|
156
|
+
onChange: expect.it("to be a function"),
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
fieldName: "b",
|
|
160
|
+
sort: expect.it("to be a function").and("called"),
|
|
161
|
+
type: "date",
|
|
162
|
+
sortDirection: "asc",
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
fieldName: "c",
|
|
166
|
+
sort: expect.it("to be a function"),
|
|
167
|
+
type: "switch",
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
).then(() => {
|
|
171
|
+
expect(sorterSpies, "to have calls satisfying", [{ spy: sorterSpies[1], args: [true, "b", "date"] }]);
|
|
172
|
+
expect(updateViewState, "to have calls satisfying", [
|
|
173
|
+
{
|
|
174
|
+
args: ["sorting", { column: "b", direction: "desc" }],
|
|
175
|
+
},
|
|
176
|
+
]);
|
|
177
|
+
}));
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -352,11 +352,7 @@ const DefaultFullTable = React.forwardRef((props, ref) => {
|
|
|
352
352
|
context={props.context}
|
|
353
353
|
/>
|
|
354
354
|
</TableMui>
|
|
355
|
-
{props.tableRows.length > 0 ? null :
|
|
356
|
-
<div className={classNames(props.classes.placeholder, props.customClasses.placeholderContainer)}>
|
|
357
|
-
{props.placeholder}
|
|
358
|
-
</div>
|
|
359
|
-
)}
|
|
355
|
+
{props.tableRows.length > 0 ? null : <div className={props.classes.placeholder}>{props.placeholder}</div>}
|
|
360
356
|
</div>
|
|
361
357
|
);
|
|
362
358
|
});
|
|
@@ -445,7 +441,6 @@ const Table = React.forwardRef(
|
|
|
445
441
|
customClasses["tableCell"] = tableProps?.getStyle(TableProps.ruleNames.tableCell) || null;
|
|
446
442
|
customClasses["headerCell"] = tableProps?.getStyle(TableProps.ruleNames.headerCell) || null;
|
|
447
443
|
customClasses["tableContainer"] = tableProps?.getStyle(TableProps.ruleNames.tableContainer) || null;
|
|
448
|
-
customClasses["placeholderContainer"] = tableProps?.getStyle(TableProps.ruleNames.placeholderContainer) || null;
|
|
449
444
|
customClasses["container"] = tableProps?.getStyle(TableProps.ruleNames.container) || null;
|
|
450
445
|
customClasses["table"] = tableProps?.getStyle(TableProps.ruleNames.table) || null;
|
|
451
446
|
|
|
@@ -1102,26 +1102,6 @@ describe("Table", () => {
|
|
|
1102
1102
|
expect(placeHolder.length, "to equal", 1);
|
|
1103
1103
|
});
|
|
1104
1104
|
|
|
1105
|
-
it("Renders Table with placeholder and custom class if rows are empty", () => {
|
|
1106
|
-
const { headers, rows } = buildHeaderAndRowFromConfig(config, []);
|
|
1107
|
-
|
|
1108
|
-
const placeholder = <Placeholder />;
|
|
1109
|
-
|
|
1110
|
-
const tableProps = new TableProps();
|
|
1111
|
-
tableProps.setStyle(TableProps.ruleNames.placeholderContainer, "placeholder-container-custom-class");
|
|
1112
|
-
|
|
1113
|
-
const component = <Table rows={rows} headers={headers} placeholder={placeholder} tableProps={tableProps} />;
|
|
1114
|
-
|
|
1115
|
-
const mountedComponent = mount(component);
|
|
1116
|
-
|
|
1117
|
-
const placeHolder = mountedComponent.find(Placeholder);
|
|
1118
|
-
expect(placeHolder.exists(), "to be true");
|
|
1119
|
-
|
|
1120
|
-
const placeholderContainer = placeHolder.parent();
|
|
1121
|
-
expect(placeholderContainer.exists(), "to be true");
|
|
1122
|
-
expect(placeholderContainer.hasClass("placeholder-container-custom-class"), "to be true");
|
|
1123
|
-
});
|
|
1124
|
-
|
|
1125
1105
|
it("Renders Table with tableInfo if provided", () => {
|
|
1126
1106
|
const { headers, rows } = buildHeaderAndRowFromConfig(config, []);
|
|
1127
1107
|
|
|
@@ -24,7 +24,6 @@ class TableProps extends ComponentProps {
|
|
|
24
24
|
tableContainer: "tableContainer",
|
|
25
25
|
container: "container",
|
|
26
26
|
table: "table",
|
|
27
|
-
placeholderContainer: "placeholderContainer",
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
constructor() {
|
|
@@ -48,7 +47,6 @@ class TableProps extends ComponentProps {
|
|
|
48
47
|
this.componentClasses.set(this.constructor.ruleNames.tableCell, null);
|
|
49
48
|
this.componentClasses.set(this.constructor.ruleNames.headerCell, null);
|
|
50
49
|
this.componentClasses.set(this.constructor.ruleNames.tableContainer, null);
|
|
51
|
-
this.componentClasses.set(this.constructor.ruleNames.placeholderContainer, null);
|
|
52
50
|
this.componentClasses.set(this.constructor.ruleNames.container, null);
|
|
53
51
|
this.componentClasses.set(this.constructor.ruleNames.table, null);
|
|
54
52
|
|
|
@@ -12,16 +12,7 @@ describe("TableProps Props", () => {
|
|
|
12
12
|
"constrained",
|
|
13
13
|
];
|
|
14
14
|
|
|
15
|
-
const ruleNames = [
|
|
16
|
-
"tableHeader",
|
|
17
|
-
"tableRow",
|
|
18
|
-
"tableCell",
|
|
19
|
-
"headerCell",
|
|
20
|
-
"tableContainer",
|
|
21
|
-
"placeholderContainer",
|
|
22
|
-
"container",
|
|
23
|
-
"table",
|
|
24
|
-
];
|
|
15
|
+
const ruleNames = ["tableHeader", "tableRow", "tableCell", "headerCell", "tableContainer", "container", "table"];
|
|
25
16
|
|
|
26
17
|
expect(TableProps.propNames, "to have keys", propNames);
|
|
27
18
|
expect(TableProps.ruleNames, "to have keys", ruleNames);
|
|
@@ -43,16 +34,7 @@ describe("TableProps Props", () => {
|
|
|
43
34
|
"saveScrollbarPosition",
|
|
44
35
|
];
|
|
45
36
|
|
|
46
|
-
const ruleNames = [
|
|
47
|
-
"tableHeader",
|
|
48
|
-
"tableRow",
|
|
49
|
-
"tableCell",
|
|
50
|
-
"headerCell",
|
|
51
|
-
"tableContainer",
|
|
52
|
-
"placeholderContainer",
|
|
53
|
-
"container",
|
|
54
|
-
"table",
|
|
55
|
-
];
|
|
37
|
+
const ruleNames = ["tableHeader", "tableRow", "tableCell", "headerCell", "tableContainer", "container", "table"];
|
|
56
38
|
|
|
57
39
|
const tableProps = new TableProps();
|
|
58
40
|
|
|
@@ -69,7 +69,6 @@ const SectionExpansionPanel = ({
|
|
|
69
69
|
expansionPanelId,
|
|
70
70
|
expansionPanelProps,
|
|
71
71
|
expansionPanelActionsProps,
|
|
72
|
-
headerClassName,
|
|
73
72
|
}) => {
|
|
74
73
|
if (isExpansionPanelProps(expansionPanelProps) === false) {
|
|
75
74
|
throw new TypeError("expansionPanelProps property is not of type ExpansionPanelProps");
|
|
@@ -123,7 +122,7 @@ const SectionExpansionPanel = ({
|
|
|
123
122
|
expandIcon={<Icon id="dropdown-chevron-down" />}
|
|
124
123
|
IconButtonProps={defaultSummaryStyles}
|
|
125
124
|
classes={{
|
|
126
|
-
root: classNames(classes.summaryRoot,
|
|
125
|
+
root: classNames(classes.summaryRoot, constrained ? classes.constrainedSummaryRoot : ""),
|
|
127
126
|
expanded: classNames(classes.panelExpanded),
|
|
128
127
|
content: classNames(classes.summaryContent, constrained ? classes.constrainedSummaryContent : ""),
|
|
129
128
|
expandIcon: classNames(classes.summaryExpandIconRoot),
|