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,55 +0,0 @@
1
- import React from "react";
2
- import ReactDOM from "react-dom";
3
- import PortalWrapper, { Wrapper } from "./Wrapper";
4
-
5
- class RenderWrapper extends React.Component {
6
- render() {
7
- return (
8
- <div id="outer">
9
- <PortalWrapper {...this.props} />
10
- </div>
11
- );
12
- }
13
- }
14
-
15
- describe("Wrapper", () => {
16
- it("sets transition time according to its timeout", () =>
17
- expect(
18
- <Wrapper in timeout={500} />,
19
- "when mounted",
20
- "to have style rules satisfying",
21
- "to contain",
22
- "transition: opacity 500ms ease-out;",
23
- ));
24
-
25
- describe("rendered in portal", () => {
26
- let appRoot, modalRoot;
27
- beforeEach(() => {
28
- appRoot = document.createElement("div");
29
- appRoot.id = "app";
30
- document.body.appendChild(appRoot);
31
- modalRoot = document.createElement("div");
32
- modalRoot.id = "modal";
33
- document.body.appendChild(modalRoot);
34
- });
35
- afterEach(() => {
36
- try {
37
- ReactDOM.unmountComponentAtNode(appRoot);
38
- } catch {
39
- // don't do anything
40
- }
41
- document.body.removeChild(appRoot);
42
- document.body.removeChild(modalRoot);
43
- });
44
-
45
- it("renders a Wrapper in a portal", () => {
46
- ReactDOM.render(
47
- <RenderWrapper in>
48
- <div id="inner">Foo</div>
49
- </RenderWrapper>,
50
- appRoot,
51
- );
52
- return expect(modalRoot, "queried for first", "#inner", "to satisfy", <div>Foo</div>);
53
- });
54
- });
55
- });
@@ -1,22 +0,0 @@
1
- import React, { Fragment } from "react";
2
- import Wrapper from "./Wrapper";
3
- import Background from "./Background";
4
- import Dialog from "./Dialog";
5
- import useToggle from "../../hooks/useToggle";
6
-
7
- export const Modal = ({ initShow, anchor, content, look }) => {
8
- const [show, toggle] = useToggle(initShow);
9
- return (
10
- <Fragment>
11
- {anchor(toggle)}
12
- <Wrapper in={show} timeout={300}>
13
- <Background />
14
- <Dialog look={look} onClickOutside={toggle}>
15
- {content(toggle)}
16
- </Dialog>
17
- </Wrapper>
18
- </Fragment>
19
- );
20
- };
21
-
22
- export default Modal;
@@ -1,104 +0,0 @@
1
- import React, { useCallback, useState } from "react";
2
- import styled from "styled-components";
3
- import { memoize } from "../utils";
4
- import withId from "../hocs/withId";
5
- import Text from "./Text";
6
- import ClickAwayListener from "@material-ui/core/ClickAwayListener";
7
- import { InnerSelect, Wrapper, SelectBox, Dropdown, Option, Placeholder } from "./Selector";
8
-
9
- export const SelectedValue = styled.span`
10
- display: inline-block;
11
- width: calc(100% - 20px);
12
- white-space: pre;
13
- overflow: hidden;
14
- `;
15
-
16
- const arrayToggle = (arr, item) => {
17
- const output = arr.filter(val => val !== item);
18
- if (output.length < arr.length) {
19
- return output;
20
- }
21
- output.push(item);
22
- return output;
23
- };
24
-
25
- const labelFromOptions = options => options.map(option => option.label).join(", ");
26
-
27
- export const MultiSelector = ({
28
- id,
29
- value = [],
30
- options,
31
- update,
32
- selectAllMessage = "[Select all]",
33
- clearMessage = "[Clear]",
34
- placeholder = "",
35
- required,
36
- ...props
37
- }) => {
38
- const selectAll = useCallback(() => update(options.map(opt => opt.value)), [update, options]);
39
- const clearValue = useCallback(() => update([]), [update]);
40
- // eslint-disable-next-line react-hooks/exhaustive-deps
41
- const clickOption = useCallback(
42
- memoize(clickValue => () => update(arrayToggle(value, clickValue))),
43
- [update, value],
44
- );
45
- const onChange = useCallback(e => update(arrayToggle(value, e.target.value)), [update, value]);
46
- const [isVisible, setIsVisible] = useState(false);
47
- /* istanbul ignore next */
48
- const toggleVisibility = () => {
49
- setIsVisible(!isVisible);
50
- };
51
-
52
- /* istanbul ignore next */
53
- const handlerClickAway = () => {
54
- setIsVisible(false);
55
- };
56
-
57
- /* istanbul ignore next */
58
- return (
59
- <ClickAwayListener onClickAway={() => handlerClickAway()}>
60
- <Wrapper>
61
- <InnerSelect id={id} onChange={onChange} value={value} multiple required={required} {...props}>
62
- {options.map(option => (
63
- <option key={option.value} value={option.value}>
64
- {option.label}
65
- </option>
66
- ))}
67
- </InnerSelect>
68
- <SelectBox htmlFor={id} onClick={() => toggleVisibility()}>
69
- {value.length ? (
70
- <SelectedValue>
71
- {labelFromOptions(options.filter(option => value.indexOf(option.value) !== -1))}
72
- </SelectedValue>
73
- ) : (
74
- <Placeholder>{placeholder}</Placeholder>
75
- )}
76
- </SelectBox>
77
- <Dropdown isVisible={isVisible}>
78
- {value.length ? (
79
- <Option key="multiselect_clear" onClick={clearValue} data-test-id="multiselect_clear">
80
- <Text message={clearMessage} />
81
- </Option>
82
- ) : null}
83
- {value.length === options.length ? null : (
84
- <Option key="multiselect_selectAll" onClick={selectAll} data-test-id="multiselect_selectAll">
85
- <Text message={selectAllMessage} />
86
- </Option>
87
- )}
88
- {options.map(option => (
89
- <Option
90
- key={option.value}
91
- active={value.indexOf(option.value) !== -1}
92
- onClick={clickOption(option.value)}
93
- data-test-id={option.value}
94
- >
95
- {option.label}
96
- </Option>
97
- ))}
98
- </Dropdown>
99
- </Wrapper>
100
- </ClickAwayListener>
101
- );
102
- };
103
-
104
- export default withId("selector")(MultiSelector);
@@ -1,348 +0,0 @@
1
- import React from "react";
2
- import { Provider } from "react-redux";
3
- import sinon from "sinon";
4
- import { getStyledClassSelector } from "../utils/testUtils";
5
- import { InnerSelect, Wrapper, SelectBox, Dropdown, Option, Placeholder } from "./Selector";
6
- import MultiSelector, { SelectedValue } from "./MultiSelector";
7
-
8
- describe("MultiSelector", () => {
9
- let updater;
10
- beforeEach(() => {
11
- updater = sinon.spy().named("updater");
12
- });
13
-
14
- it("renders a wrapped, hidden multiple select element, and visual cover elements", () =>
15
- expect(
16
- <Provider
17
- store={{
18
- subscribe: () => {},
19
- dispatch: () => {},
20
- getState: () => ({}),
21
- }}
22
- >
23
- <MultiSelector
24
- id="test"
25
- update={updater}
26
- options={[
27
- { value: "1", label: "Opt 1" },
28
- { value: "2", label: "Opt 2" },
29
- { value: "3", label: "Opt 3" },
30
- { value: "4", label: "Opt 4" },
31
- ]}
32
- value={["1", "3"]}
33
- />
34
- </Provider>,
35
- "when mounted",
36
- "to satisfy",
37
- <Wrapper>
38
- <InnerSelect id="test" multiple>
39
- <option key={1} value={1}>
40
- Opt 1
41
- </option>
42
- <option key={2} value={2}>
43
- Opt 2
44
- </option>
45
- <option key={3} value={3}>
46
- Opt 3
47
- </option>
48
- <option key={4} value={4}>
49
- Opt 4
50
- </option>
51
- </InnerSelect>
52
- <SelectBox htmlFor="test">
53
- <SelectedValue>Opt 1, Opt 3</SelectedValue>
54
- </SelectBox>
55
- <Dropdown>
56
- <Option key="multiselect_clear">[Clear]</Option>
57
- <Option key="multiselect_selectAll">[Select all]</Option>
58
- <Option key={1} active>
59
- Opt 1
60
- </Option>
61
- <Option key={2}>Opt 2</Option>
62
- <Option key={3} active>
63
- Opt 3
64
- </Option>
65
- <Option key={4}>Opt 4</Option>
66
- </Dropdown>
67
- </Wrapper>,
68
- ));
69
-
70
- it("only renders 'Clear' if value not empty", () =>
71
- expect(
72
- <Provider
73
- store={{
74
- subscribe: () => {},
75
- dispatch: () => {},
76
- getState: () => ({}),
77
- }}
78
- >
79
- <MultiSelector
80
- id="test"
81
- update={updater}
82
- options={[
83
- { value: "1", label: "Opt 1" },
84
- { value: "2", label: "Opt 2" },
85
- { value: "3", label: "Opt 3" },
86
- { value: "4", label: "Opt 4" },
87
- ]}
88
- value={[]}
89
- />
90
- </Provider>,
91
- "when mounted",
92
- "not to contain",
93
- <Option key="multiselect_clear">[Clear]</Option>,
94
- ));
95
-
96
- it("only renders 'Select all' if value not full", () =>
97
- expect(
98
- <Provider
99
- store={{
100
- subscribe: () => {},
101
- dispatch: () => {},
102
- getState: () => ({}),
103
- }}
104
- >
105
- <MultiSelector
106
- id="test"
107
- update={updater}
108
- options={[
109
- { value: "1", label: "Opt 1" },
110
- { value: "2", label: "Opt 2" },
111
- { value: "3", label: "Opt 3" },
112
- { value: "4", label: "Opt 4" },
113
- ]}
114
- value={["1", "2", "3", "4"]}
115
- />
116
- </Provider>,
117
- "when mounted",
118
- "not to contain",
119
- <Option key="multiselect_selectAll">[Select all]</Option>,
120
- ));
121
-
122
- it("renders a placeholder if no value set", () =>
123
- expect(
124
- <Provider
125
- store={{
126
- subscribe: () => {},
127
- dispatch: () => {},
128
- getState: () => ({}),
129
- }}
130
- >
131
- <MultiSelector
132
- id="test"
133
- placeholder="This space for rent"
134
- update={updater}
135
- required
136
- options={[
137
- { value: "1", label: "Opt 1" },
138
- { value: "2", label: "Opt 2" },
139
- { value: "3", label: "Opt 3" },
140
- { value: "4", label: "Opt 4" },
141
- ]}
142
- />
143
- </Provider>,
144
- "when mounted",
145
- "queried for first",
146
- getStyledClassSelector(Placeholder),
147
- "to satisfy",
148
- <Placeholder>This space for rent</Placeholder>,
149
- ));
150
-
151
- it("can add value when inner selector changes", () =>
152
- expect(
153
- <Provider
154
- store={{
155
- subscribe: () => {},
156
- dispatch: () => {},
157
- getState: () => ({}),
158
- }}
159
- >
160
- <MultiSelector
161
- update={updater}
162
- options={[
163
- { value: "1", label: "Opt 1" },
164
- { value: "2", label: "Opt 2" },
165
- { value: "3", label: "Opt 3" },
166
- { value: "4", label: "Opt 4" },
167
- ]}
168
- value={["3"]}
169
- />
170
- </Provider>,
171
- "when mounted",
172
- "with event",
173
- { type: "change", value: "2", target: "select" },
174
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["3", "2"]] }])));
175
-
176
- it("can remove value when inner selector changes", () =>
177
- expect(
178
- <Provider
179
- store={{
180
- subscribe: () => {},
181
- dispatch: () => {},
182
- getState: () => ({}),
183
- }}
184
- >
185
- <MultiSelector
186
- update={updater}
187
- options={[
188
- { value: "1", label: "Opt 1" },
189
- { value: "2", label: "Opt 2" },
190
- { value: "3", label: "Opt 3" },
191
- { value: "4", label: "Opt 4" },
192
- ]}
193
- value={["2", "3"]}
194
- />
195
- </Provider>,
196
- "when mounted",
197
- "with event",
198
- { type: "change", value: "3", target: "select" },
199
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["2"]] }])));
200
-
201
- it("can add value when clicking a visual option", () =>
202
- expect(
203
- <Provider
204
- store={{
205
- subscribe: () => {},
206
- dispatch: () => {},
207
- getState: () => ({}),
208
- }}
209
- >
210
- <MultiSelector
211
- update={updater}
212
- options={[
213
- { value: "1", label: "Opt 1" },
214
- { value: "2", label: "Opt 2" },
215
- { value: "3", label: "Opt 3" },
216
- { value: "4", label: "Opt 4" },
217
- ]}
218
- value={["3"]}
219
- />
220
- </Provider>,
221
- "when mounted",
222
- "with event",
223
- { type: "click", target: '[data-test-id="4"]' },
224
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["3", "4"]] }])));
225
-
226
- it("can remove value when clicking a visual option", () =>
227
- expect(
228
- <Provider
229
- store={{
230
- subscribe: () => {},
231
- dispatch: () => {},
232
- getState: () => ({}),
233
- }}
234
- >
235
- <MultiSelector
236
- update={updater}
237
- options={[
238
- { value: "1", label: "Opt 1" },
239
- { value: "2", label: "Opt 2" },
240
- { value: "3", label: "Opt 3" },
241
- { value: "4", label: "Opt 4" },
242
- ]}
243
- value={["4", "3"]}
244
- />
245
- </Provider>,
246
- "when mounted",
247
- "with event",
248
- { type: "click", target: '[data-test-id="4"]' },
249
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["3"]] }])));
250
-
251
- it("sets empty value when cleared", () =>
252
- expect(
253
- <Provider
254
- store={{
255
- subscribe: () => {},
256
- dispatch: () => {},
257
- getState: () => ({}),
258
- }}
259
- >
260
- <MultiSelector
261
- update={updater}
262
- options={[
263
- { value: "1", label: "Opt 1" },
264
- { value: "2", label: "Opt 2" },
265
- { value: "3", label: "Opt 3" },
266
- { value: "4", label: "Opt 4" },
267
- ]}
268
- value={["4", "3"]}
269
- />
270
- </Provider>,
271
- "when mounted",
272
- "with event",
273
- { type: "click", target: '[data-test-id="multiselect_clear"]' },
274
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [[]] }])));
275
-
276
- it("sets full value when select all chosen", () =>
277
- expect(
278
- <Provider
279
- store={{
280
- subscribe: () => {},
281
- dispatch: () => {},
282
- getState: () => ({}),
283
- }}
284
- >
285
- <MultiSelector
286
- update={updater}
287
- options={[
288
- { value: "1", label: "Opt 1" },
289
- { value: "2", label: "Opt 2" },
290
- { value: "3", label: "Opt 3" },
291
- { value: "4", label: "Opt 4" },
292
- ]}
293
- value={[4, 3]}
294
- />
295
- </Provider>,
296
- "when mounted",
297
- "with event",
298
- { type: "click", target: '[data-test-id="multiselect_selectAll"]' },
299
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["1", "2", "3", "4"]] }])));
300
-
301
- it("deals with an empty value prop change", () =>
302
- expect(
303
- <Provider
304
- store={{
305
- subscribe: () => {},
306
- dispatch: () => {},
307
- getState: () => ({}),
308
- }}
309
- >
310
- <MultiSelector
311
- update={updater}
312
- options={[
313
- { value: "1", label: "Opt 1" },
314
- { value: "2", label: "Opt 2" },
315
- { value: "3", label: "Opt 3" },
316
- { value: "4", label: "Opt 4" },
317
- ]}
318
- />
319
- </Provider>,
320
- "when mounted",
321
- "with event",
322
- { type: "change", value: "2", target: "select" },
323
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["2"]] }])));
324
-
325
- it("deals with an empty value prop click", () =>
326
- expect(
327
- <Provider
328
- store={{
329
- subscribe: () => {},
330
- dispatch: () => {},
331
- getState: () => ({}),
332
- }}
333
- >
334
- <MultiSelector
335
- update={updater}
336
- options={[
337
- { value: "1", label: "Opt 1" },
338
- { value: "2", label: "Opt 2" },
339
- { value: "3", label: "Opt 3" },
340
- { value: "4", label: "Opt 4" },
341
- ]}
342
- />
343
- </Provider>,
344
- "when mounted",
345
- "with event",
346
- { type: "click", target: '[data-test-id="2"]' },
347
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["2"]] }])));
348
- });