orc-shared 5.10.2-dev.1 → 5.99.0-dev.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.
Files changed (177) hide show
  1. package/dist/components/AppFrame/MenuItem.js +3 -12
  2. package/dist/components/ApplicationModuleLoader.js +3 -2
  3. package/dist/components/Authenticate.js +29 -22
  4. package/dist/components/ErrorPlaceholder.js +8 -24
  5. package/dist/components/{IconButton.js → Form/Inputs/MultiSelector.js} +33 -31
  6. package/dist/components/Form/Inputs/index.js +1 -1
  7. package/dist/components/LoadingIcon.js +38 -17
  8. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +3 -3
  9. package/dist/components/MaterialUI/DataDisplay/Table.js +2 -1
  10. package/dist/components/MaterialUI/DataDisplay/TableProps.js +3 -1
  11. package/dist/components/MaterialUI/Inputs/Select.js +10 -0
  12. package/dist/components/MaterialUI/Inputs/SelectProps.js +3 -1
  13. package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
  14. package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +3 -2
  15. package/dist/components/MaterialUI/muiThemes.js +2 -0
  16. package/dist/components/Provision.js +30 -13
  17. package/dist/components/Routing/SegmentPage.js +115 -56
  18. package/dist/components/Scope/ScopeNode.js +64 -57
  19. package/dist/components/Sidepanel.js +57 -23
  20. package/dist/components/Spritesheet.js +33 -17
  21. package/dist/components/Text.js +1 -60
  22. package/dist/components/ToastList.js +95 -64
  23. package/dist/components/Treeview/Branch.js +82 -20
  24. package/dist/components/Treeview/Label.js +108 -31
  25. package/dist/components/Treeview/Leaf.js +56 -12
  26. package/dist/components/Treeview/Node.js +22 -9
  27. package/dist/components/Treeview/index.js +7 -1
  28. package/dist/components/Treeview/settings.js +7 -5
  29. package/dist/utils/index.js +0 -4
  30. package/dist/utils/testUtils.js +1 -12
  31. package/dist/{components/Modal/Background.js → utils/toastHelper.js} +11 -14
  32. package/package.json +2 -2
  33. package/src/components/AppFrame/MenuItem.js +1 -9
  34. package/src/components/ApplicationModuleLoader.js +2 -2
  35. package/src/components/ApplicationModuleLoader.test.js +15 -28
  36. package/src/components/Authenticate.js +21 -23
  37. package/src/components/Authenticate.test.js +19 -27
  38. package/src/components/ErrorPlaceholder.js +4 -21
  39. package/src/components/ErrorPlaceholder.test.js +7 -14
  40. package/src/components/Form/InputField.test.js +2 -1
  41. package/src/components/Form/Inputs/MultiSelector.js +23 -0
  42. package/src/components/Form/Inputs/MultiSelector.test.js +112 -0
  43. package/src/components/Form/Inputs/index.js +1 -1
  44. package/src/components/Loader.test.js +50 -59
  45. package/src/components/LoadingIcon.js +27 -14
  46. package/src/components/LoadingIcon.test.js +11 -15
  47. package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +2 -2
  48. package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +0 -74
  49. package/src/components/MaterialUI/DataDisplay/Table.js +6 -1
  50. package/src/components/MaterialUI/DataDisplay/Table.test.js +21 -1
  51. package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
  52. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +20 -2
  53. package/src/components/MaterialUI/Inputs/Select.js +7 -0
  54. package/src/components/MaterialUI/Inputs/Select.test.js +45 -0
  55. package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
  56. package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
  57. package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
  58. package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
  59. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +2 -1
  60. package/src/components/MaterialUI/muiThemes.js +3 -0
  61. package/src/components/Navigation/Navigation.test.js +0 -5
  62. package/src/components/Navigation/useNavigationState.test.js +79 -222
  63. package/src/components/Provision.js +36 -42
  64. package/src/components/Provision.test.js +10 -26
  65. package/src/components/Routing/SegmentPage.js +68 -52
  66. package/src/components/Routing/SegmentPage.test.js +4 -12
  67. package/src/components/Scope/ScopeNode.js +45 -55
  68. package/src/components/Scope/ScopeNode.test.js +84 -163
  69. package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
  70. package/src/components/Sidepanel.js +38 -32
  71. package/src/components/Sidepanel.test.js +49 -27
  72. package/src/components/Spritesheet.js +23 -21
  73. package/src/components/Spritesheet.test.js +10 -10
  74. package/src/components/Text.js +0 -49
  75. package/src/components/ToastList.js +79 -90
  76. package/src/components/ToastList.test.js +29 -103
  77. package/src/components/Treeview/Branch.js +63 -45
  78. package/src/components/Treeview/Branch.test.js +21 -24
  79. package/src/components/Treeview/Label.js +66 -52
  80. package/src/components/Treeview/Label.test.js +42 -60
  81. package/src/components/Treeview/Leaf.js +41 -22
  82. package/src/components/Treeview/Leaf.test.js +15 -10
  83. package/src/components/Treeview/Node.js +16 -9
  84. package/src/components/Treeview/Node.test.js +269 -200
  85. package/src/components/Treeview/Treeview.test.js +248 -248
  86. package/src/components/Treeview/index.js +6 -0
  87. package/src/components/Treeview/settings.js +7 -6
  88. package/src/utils/index.js +0 -4
  89. package/src/utils/testUtils.js +0 -10
  90. package/src/utils/testUtils.test.js +0 -68
  91. package/src/utils/toastHelper.js +8 -0
  92. package/src/utils/toastHelper.test.js +41 -0
  93. package/dist/components/Button.js +0 -70
  94. package/dist/components/CategoryList.js +0 -197
  95. package/dist/components/Checkbox.js +0 -103
  96. package/dist/components/Icon.js +0 -69
  97. package/dist/components/Input.js +0 -101
  98. package/dist/components/List/DataCell.js +0 -129
  99. package/dist/components/List/HeadCell.js +0 -125
  100. package/dist/components/List/HeadRow.js +0 -73
  101. package/dist/components/List/List.js +0 -274
  102. package/dist/components/List/Row.js +0 -109
  103. package/dist/components/List/enhanceColumnDefs.js +0 -111
  104. package/dist/components/List/index.js +0 -59
  105. package/dist/components/Modal/Dialog.js +0 -75
  106. package/dist/components/Modal/Wrapper.js +0 -69
  107. package/dist/components/Modal/index.js +0 -86
  108. package/dist/components/MultiSelector.js +0 -187
  109. package/dist/components/Navigation/Bar.js +0 -293
  110. package/dist/components/Navigation/Tab.js +0 -182
  111. package/dist/components/Placeholder.js +0 -114
  112. package/dist/components/Scope/Selector.js +0 -123
  113. package/dist/components/Selector.js +0 -185
  114. package/dist/components/Switch.js +0 -128
  115. package/dist/components/Toolbar.js +0 -227
  116. package/dist/components/Tooltip.js +0 -66
  117. package/dist/getTheme.js +0 -158
  118. package/dist/getThemeOverrides.js +0 -93
  119. package/dist/hocs/withAuthentication.js +0 -72
  120. package/dist/utils/styledPropFuncs.js +0 -88
  121. package/src/components/Button.js +0 -90
  122. package/src/components/Button.test.js +0 -49
  123. package/src/components/CategoryList.js +0 -140
  124. package/src/components/CategoryList.test.js +0 -667
  125. package/src/components/Checkbox.js +0 -63
  126. package/src/components/Checkbox.test.js +0 -122
  127. package/src/components/Icon.js +0 -18
  128. package/src/components/IconButton.js +0 -30
  129. package/src/components/IconButton.test.js +0 -61
  130. package/src/components/Input.js +0 -35
  131. package/src/components/Input.test.js +0 -34
  132. package/src/components/List/DataCell.js +0 -77
  133. package/src/components/List/DataCell.test.js +0 -357
  134. package/src/components/List/HeadCell.js +0 -105
  135. package/src/components/List/HeadCell.test.js +0 -331
  136. package/src/components/List/HeadRow.js +0 -21
  137. package/src/components/List/HeadRow.test.js +0 -27
  138. package/src/components/List/List.js +0 -162
  139. package/src/components/List/List.test.js +0 -705
  140. package/src/components/List/Row.js +0 -72
  141. package/src/components/List/Row.test.js +0 -194
  142. package/src/components/List/enhanceColumnDefs.js +0 -54
  143. package/src/components/List/enhanceColumnDefs.test.js +0 -179
  144. package/src/components/List/index.js +0 -6
  145. package/src/components/Modal/Background.js +0 -10
  146. package/src/components/Modal/Dialog.js +0 -27
  147. package/src/components/Modal/Dialog.test.js +0 -20
  148. package/src/components/Modal/Modal.test.js +0 -52
  149. package/src/components/Modal/Wrapper.js +0 -32
  150. package/src/components/Modal/Wrapper.test.js +0 -55
  151. package/src/components/Modal/index.js +0 -22
  152. package/src/components/MultiSelector.js +0 -104
  153. package/src/components/MultiSelector.test.js +0 -348
  154. package/src/components/Navigation/Bar.js +0 -212
  155. package/src/components/Navigation/Bar.test.js +0 -552
  156. package/src/components/Navigation/Tab.js +0 -156
  157. package/src/components/Navigation/Tab.test.js +0 -404
  158. package/src/components/Placeholder.js +0 -61
  159. package/src/components/Placeholder.test.js +0 -106
  160. package/src/components/Scope/Selector.js +0 -70
  161. package/src/components/Scope/Selector.test.js +0 -138
  162. package/src/components/Selector.js +0 -191
  163. package/src/components/Selector.test.js +0 -157
  164. package/src/components/Switch.js +0 -112
  165. package/src/components/Switch.test.js +0 -130
  166. package/src/components/Text.test.js +0 -132
  167. package/src/components/Toolbar.js +0 -178
  168. package/src/components/Toolbar.test.js +0 -478
  169. package/src/components/Tooltip.js +0 -51
  170. package/src/components/Tooltip.test.js +0 -21
  171. package/src/getTheme.js +0 -103
  172. package/src/getTheme.test.js +0 -92
  173. package/src/getThemeOverrides.js +0 -27
  174. package/src/hocs/withAuthentication.js +0 -18
  175. package/src/hocs/withAuthentication.test.js +0 -120
  176. package/src/utils/styledPropFuncs.js +0 -20
  177. package/src/utils/styledPropFuncs.test.js +0 -166
@@ -1,72 +0,0 @@
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;
@@ -1,194 +0,0 @@
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
- });
@@ -1,54 +0,0 @@
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;
@@ -1,179 +0,0 @@
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
- });
@@ -1,6 +0,0 @@
1
- import Loader from "../Loader";
2
-
3
- /* istanbul ignore next */
4
- const LoadableList = Loader(() => import("./List"));
5
-
6
- export default LoadableList;
@@ -1,10 +0,0 @@
1
- import styled from "styled-components";
2
-
3
- const Background = styled.div`
4
- position: absolute;
5
- background-color: rgba(127, 127, 127, 0.5);
6
- height: 100%;
7
- width: 100%;
8
- `;
9
-
10
- export default Background;
@@ -1,27 +0,0 @@
1
- import styled, { css } from "styled-components";
2
- import { getThemeProp } from "../../utils";
3
- import withClickOutside from "../../hocs/withClickOutside";
4
-
5
- const darkDialogStyle = css`
6
- background-color: ${getThemeProp(["colors", "bgDark"], "#333333")};
7
- border-radius: 15px;
8
- `;
9
-
10
- const dialogLook = {
11
- default: css`
12
- background-color: white;
13
- `,
14
- dark: darkDialogStyle,
15
- };
16
-
17
- // TODO: Add light dialog style for other dialogs, switching mechanism
18
- export const Dialog = styled.div`
19
- flex: 0 0 auto;
20
- margin: auto;
21
- align-self: center;
22
- z-index: 10000;
23
- ${props => dialogLook[props.look]};
24
- `;
25
- Dialog.defaultProps = { look: "default" };
26
-
27
- export default withClickOutside(Dialog);
@@ -1,20 +0,0 @@
1
- import React from "react";
2
- import { Dialog } from "./Dialog";
3
-
4
- describe("Dialog", () => {
5
- it("renders a dialog with a default look", () =>
6
- expect(
7
- <Dialog />,
8
- "when mounted",
9
- "to have style rules satisfying",
10
- expect.it("to contain", "background-color: white;"),
11
- ));
12
-
13
- it("renders a dialog with dark look", () =>
14
- expect(
15
- <Dialog look="dark" />,
16
- "when mounted",
17
- "to have style rules satisfying",
18
- expect.it("to contain", "background-color: #333333;").and("to contain", "border-radius: 15px;"),
19
- ));
20
- });
@@ -1,52 +0,0 @@
1
- import React, { Fragment } from "react";
2
- import ReactDOM from "react-dom";
3
- import { Modal } from "./index";
4
- import Wrapper from "./Wrapper";
5
- import Background from "./Background";
6
- import Dialog from "./Dialog";
7
-
8
- const TestComp1 = () => <div />;
9
- const TestComp2 = () => <div />;
10
-
11
- describe("Modal", () => {
12
- let appRoot, modalRoot, toggle;
13
- beforeEach(() => {
14
- appRoot = document.createElement("div");
15
- appRoot.id = "app";
16
- document.body.appendChild(appRoot);
17
- modalRoot = document.createElement("div");
18
- modalRoot.id = "modal";
19
- document.body.appendChild(modalRoot);
20
- toggle = () => {};
21
- });
22
- afterEach(() => {
23
- try {
24
- ReactDOM.unmountComponentAtNode(appRoot);
25
- } catch {
26
- // don't do anything
27
- }
28
- document.body.removeChild(appRoot);
29
- document.body.removeChild(modalRoot);
30
- });
31
-
32
- it("renders the structure of a modal dialog", () =>
33
- expect(
34
- <Modal
35
- initShow={true}
36
- anchor={toggle => <TestComp1 toggle={toggle} />}
37
- content={toggle => <TestComp2 toggle={toggle} />}
38
- look="dark"
39
- />,
40
- "when mounted",
41
- "to satisfy",
42
- <Fragment>
43
- <TestComp1 toggle={toggle} />
44
- <Wrapper timeout={300}>
45
- <Background />
46
- <Dialog look="dark" onClickOutside={toggle}>
47
- <TestComp2 toggle={toggle} />
48
- </Dialog>
49
- </Wrapper>
50
- </Fragment>,
51
- ));
52
- });
@@ -1,32 +0,0 @@
1
- import React from "react";
2
- import ReactDOM from "react-dom";
3
- import transition from "styled-transition-group";
4
-
5
- const getModalRoot = () => document.getElementById("modal");
6
-
7
- export const Wrapper = transition.div`
8
- z-index: 9999;
9
- display: flex;
10
- position: absolute;
11
- top: 0;
12
- left: 0;
13
- bottom: 0;
14
- right: 0;
15
- transition: opacity ${props => props.timeout}ms ease-out;
16
-
17
- &:enter {
18
- opacity: 0.01;
19
- }
20
- &:enter-active {
21
- opacity: 1;
22
- }
23
- &:exit {
24
- opacity: 1;
25
- }
26
- &:exit-active {
27
- opacity: 0.01;
28
- }
29
- `;
30
- Wrapper.defaultProps = { timeout: 300, unmountOnExit: true };
31
-
32
- export default props => ReactDOM.createPortal(<Wrapper {...props} />, getModalRoot());