orc-shared 5.10.2-dev.4 → 5.99.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.
Files changed (226) hide show
  1. package/dist/components/AppFrame/About.js +13 -13
  2. package/dist/components/AppFrame/Anchor.js +7 -7
  3. package/dist/components/AppFrame/AppFrame.js +3 -3
  4. package/dist/components/AppFrame/Help.js +4 -4
  5. package/dist/components/AppFrame/MenuItem.js +17 -26
  6. package/dist/components/AppFrame/Preferences.js +14 -14
  7. package/dist/components/AppFrame/Sidebar.js +6 -6
  8. package/dist/components/AppFrame/Topbar.js +6 -6
  9. package/dist/components/ApplicationModuleLoader.js +3 -2
  10. package/dist/components/Authenticate.js +29 -22
  11. package/dist/components/DropMenu/Menu.js +9 -9
  12. package/dist/components/ErrorPlaceholder.js +8 -24
  13. package/dist/components/Form/Field.js +4 -4
  14. package/dist/components/Form/Inputs/Button.js +2 -2
  15. package/dist/components/{IconButton.js → Form/Inputs/MultiSelector.js} +33 -31
  16. package/dist/components/Form/Inputs/index.js +1 -1
  17. package/dist/components/InternetExplorerWarningMessage.js +15 -15
  18. package/dist/components/LoadingIcon.js +38 -17
  19. package/dist/components/MaterialUI/DataDisplay/Modal.js +3 -3
  20. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
  21. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +4 -4
  22. package/dist/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
  23. package/dist/components/MaterialUI/DataDisplay/Table.js +2 -1
  24. package/dist/components/MaterialUI/DataDisplay/TableProps.js +3 -1
  25. package/dist/components/MaterialUI/DataDisplay/TransferList.js +1 -1
  26. package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
  27. package/dist/components/MaterialUI/Inputs/DatePicker.js +1 -1
  28. package/dist/components/MaterialUI/Inputs/InputBase.js +20 -188
  29. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  30. package/dist/components/MaterialUI/Inputs/Select.js +10 -0
  31. package/dist/components/MaterialUI/Inputs/SelectProps.js +3 -1
  32. package/dist/components/MaterialUI/Inputs/Switch.js +1 -1
  33. package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
  34. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -1
  35. package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +27 -42
  36. package/dist/components/MaterialUI/Surfaces/Paper.js +1 -1
  37. package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +3 -2
  38. package/dist/components/MaterialUI/muiThemes.js +2 -0
  39. package/dist/components/Provision.js +30 -13
  40. package/dist/components/Routing/SegmentPage.js +115 -56
  41. package/dist/components/Scope/ScopeNode.js +62 -57
  42. package/dist/components/Sidepanel.js +59 -23
  43. package/dist/components/Spritesheet.js +35 -17
  44. package/dist/components/Text.js +1 -60
  45. package/dist/components/ToastList.js +95 -64
  46. package/dist/components/Treeview/Branch.js +82 -20
  47. package/dist/components/Treeview/Label.js +108 -31
  48. package/dist/components/Treeview/Leaf.js +56 -12
  49. package/dist/components/Treeview/Node.js +22 -9
  50. package/dist/components/Treeview/index.js +7 -1
  51. package/dist/components/Treeview/settings.js +17 -6
  52. package/dist/utils/index.js +0 -4
  53. package/dist/utils/testUtils.js +1 -12
  54. package/dist/{components/Modal/Background.js → utils/toastHelper.js} +11 -14
  55. package/package.json +2 -2
  56. package/src/components/AppFrame/About.js +13 -13
  57. package/src/components/AppFrame/Anchor.js +7 -7
  58. package/src/components/AppFrame/AppFrame.js +3 -3
  59. package/src/components/AppFrame/Help.js +4 -4
  60. package/src/components/AppFrame/MenuItem.js +15 -23
  61. package/src/components/AppFrame/Preferences.js +14 -14
  62. package/src/components/AppFrame/Sidebar.js +6 -6
  63. package/src/components/AppFrame/Topbar.js +6 -6
  64. package/src/components/ApplicationModuleLoader.js +2 -2
  65. package/src/components/ApplicationModuleLoader.test.js +15 -28
  66. package/src/components/Authenticate.js +21 -23
  67. package/src/components/Authenticate.test.js +19 -27
  68. package/src/components/DropMenu/Menu.js +9 -9
  69. package/src/components/ErrorPlaceholder.js +4 -21
  70. package/src/components/ErrorPlaceholder.test.js +7 -14
  71. package/src/components/Form/Field.js +4 -4
  72. package/src/components/Form/InputField.test.js +2 -1
  73. package/src/components/Form/Inputs/Button.js +2 -2
  74. package/src/components/Form/Inputs/MultiSelector.js +23 -0
  75. package/src/components/Form/Inputs/MultiSelector.test.js +112 -0
  76. package/src/components/Form/Inputs/index.js +1 -1
  77. package/src/components/InternetExplorerWarningMessage.js +15 -15
  78. package/src/components/Loader.test.js +50 -59
  79. package/src/components/LoadingIcon.js +27 -14
  80. package/src/components/LoadingIcon.test.js +11 -15
  81. package/src/components/MaterialUI/DataDisplay/Modal.js +3 -3
  82. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
  83. package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +3 -3
  84. package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +0 -74
  85. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Translations.test.js +6 -18
  86. package/src/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
  87. package/src/components/MaterialUI/DataDisplay/Table.js +6 -1
  88. package/src/components/MaterialUI/DataDisplay/Table.test.js +21 -1
  89. package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
  90. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +20 -2
  91. package/src/components/MaterialUI/DataDisplay/TransferList.js +1 -1
  92. package/src/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
  93. package/src/components/MaterialUI/Inputs/DatePicker.js +1 -1
  94. package/src/components/MaterialUI/Inputs/InputBase.js +31 -214
  95. package/src/components/MaterialUI/Inputs/InputBase.test.js +1 -460
  96. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  97. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +1 -1
  98. package/src/components/MaterialUI/Inputs/Select.js +7 -0
  99. package/src/components/MaterialUI/Inputs/Select.test.js +45 -0
  100. package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
  101. package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
  102. package/src/components/MaterialUI/Inputs/Switch.js +1 -1
  103. package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
  104. package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
  105. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -2
  106. package/src/components/MaterialUI/ScopeSelector/TreeItem.js +8 -31
  107. package/src/components/MaterialUI/Surfaces/Paper.js +1 -1
  108. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +2 -1
  109. package/src/components/MaterialUI/muiThemes.js +3 -0
  110. package/src/components/Navigation/Navigation.test.js +0 -5
  111. package/src/components/Navigation/useNavigationState.test.js +79 -222
  112. package/src/components/Provision.js +36 -42
  113. package/src/components/Provision.test.js +10 -26
  114. package/src/components/Routing/SegmentPage.js +68 -52
  115. package/src/components/Routing/SegmentPage.test.js +4 -12
  116. package/src/components/Scope/ScopeNode.js +44 -55
  117. package/src/components/Scope/ScopeNode.test.js +84 -163
  118. package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
  119. package/src/components/Sidepanel.js +38 -32
  120. package/src/components/Sidepanel.test.js +54 -27
  121. package/src/components/Spritesheet.js +23 -21
  122. package/src/components/Spritesheet.test.js +10 -10
  123. package/src/components/Text.js +0 -49
  124. package/src/components/ToastList.js +79 -90
  125. package/src/components/ToastList.test.js +29 -103
  126. package/src/components/Treeview/Branch.js +65 -47
  127. package/src/components/Treeview/Branch.test.js +2 -43
  128. package/src/components/Treeview/Label.js +68 -54
  129. package/src/components/Treeview/Label.test.js +55 -63
  130. package/src/components/Treeview/Leaf.js +41 -22
  131. package/src/components/Treeview/Leaf.test.js +1 -15
  132. package/src/components/Treeview/Node.js +16 -9
  133. package/src/components/Treeview/Node.test.js +269 -200
  134. package/src/components/Treeview/Treeview.test.js +248 -248
  135. package/src/components/Treeview/index.js +6 -0
  136. package/src/components/Treeview/settings.js +10 -6
  137. package/src/utils/index.js +0 -4
  138. package/src/utils/testUtils.js +0 -10
  139. package/src/utils/testUtils.test.js +0 -68
  140. package/src/utils/toastHelper.js +8 -0
  141. package/src/utils/toastHelper.test.js +41 -0
  142. package/dist/components/Button.js +0 -70
  143. package/dist/components/CategoryList.js +0 -197
  144. package/dist/components/Checkbox.js +0 -103
  145. package/dist/components/Icon.js +0 -69
  146. package/dist/components/Input.js +0 -101
  147. package/dist/components/List/DataCell.js +0 -129
  148. package/dist/components/List/HeadCell.js +0 -125
  149. package/dist/components/List/HeadRow.js +0 -73
  150. package/dist/components/List/List.js +0 -274
  151. package/dist/components/List/Row.js +0 -109
  152. package/dist/components/List/enhanceColumnDefs.js +0 -111
  153. package/dist/components/List/index.js +0 -59
  154. package/dist/components/Modal/Dialog.js +0 -75
  155. package/dist/components/Modal/Wrapper.js +0 -69
  156. package/dist/components/Modal/index.js +0 -86
  157. package/dist/components/MultiSelector.js +0 -187
  158. package/dist/components/Navigation/Bar.js +0 -293
  159. package/dist/components/Navigation/Tab.js +0 -182
  160. package/dist/components/Placeholder.js +0 -114
  161. package/dist/components/Scope/Selector.js +0 -123
  162. package/dist/components/Selector.js +0 -185
  163. package/dist/components/Switch.js +0 -128
  164. package/dist/components/Toolbar.js +0 -227
  165. package/dist/components/Tooltip.js +0 -66
  166. package/dist/getTheme.js +0 -158
  167. package/dist/getThemeOverrides.js +0 -93
  168. package/dist/hocs/withAuthentication.js +0 -72
  169. package/dist/utils/styledPropFuncs.js +0 -88
  170. package/src/components/Button.js +0 -90
  171. package/src/components/Button.test.js +0 -49
  172. package/src/components/CategoryList.js +0 -140
  173. package/src/components/CategoryList.test.js +0 -667
  174. package/src/components/Checkbox.js +0 -63
  175. package/src/components/Checkbox.test.js +0 -122
  176. package/src/components/Icon.js +0 -18
  177. package/src/components/IconButton.js +0 -30
  178. package/src/components/IconButton.test.js +0 -61
  179. package/src/components/Input.js +0 -35
  180. package/src/components/Input.test.js +0 -34
  181. package/src/components/List/DataCell.js +0 -77
  182. package/src/components/List/DataCell.test.js +0 -357
  183. package/src/components/List/HeadCell.js +0 -105
  184. package/src/components/List/HeadCell.test.js +0 -331
  185. package/src/components/List/HeadRow.js +0 -21
  186. package/src/components/List/HeadRow.test.js +0 -27
  187. package/src/components/List/List.js +0 -162
  188. package/src/components/List/List.test.js +0 -705
  189. package/src/components/List/Row.js +0 -72
  190. package/src/components/List/Row.test.js +0 -194
  191. package/src/components/List/enhanceColumnDefs.js +0 -54
  192. package/src/components/List/enhanceColumnDefs.test.js +0 -179
  193. package/src/components/List/index.js +0 -6
  194. package/src/components/Modal/Background.js +0 -10
  195. package/src/components/Modal/Dialog.js +0 -27
  196. package/src/components/Modal/Dialog.test.js +0 -20
  197. package/src/components/Modal/Modal.test.js +0 -52
  198. package/src/components/Modal/Wrapper.js +0 -32
  199. package/src/components/Modal/Wrapper.test.js +0 -55
  200. package/src/components/Modal/index.js +0 -22
  201. package/src/components/MultiSelector.js +0 -104
  202. package/src/components/MultiSelector.test.js +0 -348
  203. package/src/components/Navigation/Bar.js +0 -212
  204. package/src/components/Navigation/Bar.test.js +0 -552
  205. package/src/components/Navigation/Tab.js +0 -156
  206. package/src/components/Navigation/Tab.test.js +0 -404
  207. package/src/components/Placeholder.js +0 -61
  208. package/src/components/Placeholder.test.js +0 -106
  209. package/src/components/Scope/Selector.js +0 -70
  210. package/src/components/Scope/Selector.test.js +0 -138
  211. package/src/components/Selector.js +0 -191
  212. package/src/components/Selector.test.js +0 -157
  213. package/src/components/Switch.js +0 -112
  214. package/src/components/Switch.test.js +0 -130
  215. package/src/components/Text.test.js +0 -132
  216. package/src/components/Toolbar.js +0 -178
  217. package/src/components/Toolbar.test.js +0 -478
  218. package/src/components/Tooltip.js +0 -51
  219. package/src/components/Tooltip.test.js +0 -21
  220. package/src/getTheme.js +0 -103
  221. package/src/getTheme.test.js +0 -92
  222. package/src/getThemeOverrides.js +0 -27
  223. package/src/hocs/withAuthentication.js +0 -18
  224. package/src/hocs/withAuthentication.test.js +0 -120
  225. package/src/utils/styledPropFuncs.js +0 -20
  226. 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());