orc-shared 5.10.2 → 5.99.0-dev.10

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 (234) 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/Form/Inputs/MultiSelector.js +137 -0
  16. package/dist/components/Form/Inputs/Selector.js +13 -10
  17. package/dist/components/Form/Inputs/index.js +1 -1
  18. package/dist/components/InternetExplorerWarningMessage.js +15 -15
  19. package/dist/components/LoadingIcon.js +38 -17
  20. package/dist/components/MaterialUI/DataDisplay/Modal.js +3 -3
  21. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
  22. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +1 -1
  23. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
  24. package/dist/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
  25. package/dist/components/MaterialUI/DataDisplay/Table.js +2 -1
  26. package/dist/components/MaterialUI/DataDisplay/TableProps.js +3 -1
  27. package/dist/components/MaterialUI/DataDisplay/TransferList.js +1 -1
  28. package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
  29. package/dist/components/MaterialUI/Inputs/DatePicker.js +1 -1
  30. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  31. package/dist/components/MaterialUI/Inputs/Select.js +175 -109
  32. package/dist/components/MaterialUI/Inputs/SelectProps.js +11 -1
  33. package/dist/components/MaterialUI/Inputs/Switch.js +1 -1
  34. package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
  35. package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -1
  36. package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +27 -42
  37. package/dist/components/MaterialUI/Surfaces/Paper.js +1 -1
  38. package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +3 -2
  39. package/dist/components/MaterialUI/muiThemes.js +3 -1
  40. package/dist/components/Provision.js +30 -13
  41. package/dist/components/Routing/SegmentPage.js +117 -56
  42. package/dist/components/Scope/ScopeNode.js +62 -57
  43. package/dist/components/Sidepanel.js +59 -23
  44. package/dist/components/Spritesheet.js +35 -17
  45. package/dist/components/Text.js +1 -60
  46. package/dist/components/ToastList.js +95 -64
  47. package/dist/components/Treeview/Branch.js +82 -20
  48. package/dist/components/Treeview/Label.js +108 -31
  49. package/dist/components/Treeview/Leaf.js +56 -12
  50. package/dist/components/Treeview/Node.js +22 -9
  51. package/dist/components/Treeview/index.js +7 -1
  52. package/dist/components/Treeview/settings.js +17 -6
  53. package/dist/{components/Modal/index.js → hooks/useWindowSize.js} +38 -36
  54. package/dist/sharedMessages.js +8 -0
  55. package/dist/utils/index.js +0 -4
  56. package/dist/utils/testUtils.js +1 -12
  57. package/dist/{components/Modal/Background.js → utils/toastHelper.js} +11 -14
  58. package/package.json +2 -2
  59. package/src/components/AppFrame/About.js +13 -13
  60. package/src/components/AppFrame/Anchor.js +7 -7
  61. package/src/components/AppFrame/AppFrame.js +3 -3
  62. package/src/components/AppFrame/Help.js +4 -4
  63. package/src/components/AppFrame/MenuItem.js +15 -23
  64. package/src/components/AppFrame/Preferences.js +14 -14
  65. package/src/components/AppFrame/Sidebar.js +6 -6
  66. package/src/components/AppFrame/Topbar.js +6 -6
  67. package/src/components/ApplicationModuleLoader.js +2 -2
  68. package/src/components/ApplicationModuleLoader.test.js +15 -28
  69. package/src/components/Authenticate.js +21 -23
  70. package/src/components/Authenticate.test.js +19 -27
  71. package/src/components/DropMenu/Menu.js +9 -9
  72. package/src/components/ErrorPlaceholder.js +4 -21
  73. package/src/components/ErrorPlaceholder.test.js +7 -14
  74. package/src/components/Form/Field.js +4 -4
  75. package/src/components/Form/InputField.test.js +2 -1
  76. package/src/components/Form/Inputs/Button.js +2 -2
  77. package/src/components/Form/Inputs/MultiSelector.js +73 -0
  78. package/src/components/Form/Inputs/MultiSelector.test.js +332 -0
  79. package/src/components/Form/Inputs/Selector.js +12 -4
  80. package/src/components/Form/Inputs/Selector.test.js +27 -12
  81. package/src/components/Form/Inputs/index.js +1 -1
  82. package/src/components/InternetExplorerWarningMessage.js +15 -15
  83. package/src/components/Loader.test.js +50 -59
  84. package/src/components/LoadingIcon.js +27 -14
  85. package/src/components/LoadingIcon.test.js +11 -15
  86. package/src/components/MaterialUI/DataDisplay/Modal.js +3 -3
  87. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +6 -6
  88. package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +1 -1
  89. package/src/components/MaterialUI/DataDisplay/PredefinedElements/TableInfoBar.js +1 -1
  90. package/src/components/MaterialUI/DataDisplay/SelectionList.js +1 -1
  91. package/src/components/MaterialUI/DataDisplay/Table.js +6 -1
  92. package/src/components/MaterialUI/DataDisplay/Table.test.js +21 -1
  93. package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
  94. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +20 -2
  95. package/src/components/MaterialUI/DataDisplay/TransferList.js +1 -1
  96. package/src/components/MaterialUI/Inputs/CheckboxGroup.js +1 -1
  97. package/src/components/MaterialUI/Inputs/DatePicker.js +1 -1
  98. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
  99. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.test.js +1 -1
  100. package/src/components/MaterialUI/Inputs/Select.js +143 -83
  101. package/src/components/MaterialUI/Inputs/Select.test.js +199 -14
  102. package/src/components/MaterialUI/Inputs/SelectProps.js +10 -0
  103. package/src/components/MaterialUI/Inputs/SelectProps.test.js +10 -0
  104. package/src/components/MaterialUI/Inputs/Switch.js +1 -1
  105. package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
  106. package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
  107. package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +1 -2
  108. package/src/components/MaterialUI/ScopeSelector/TreeItem.js +8 -31
  109. package/src/components/MaterialUI/Surfaces/Paper.js +1 -1
  110. package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +2 -1
  111. package/src/components/MaterialUI/muiThemes.js +4 -1
  112. package/src/components/Navigation/Navigation.test.js +0 -5
  113. package/src/components/Navigation/useNavigationState.test.js +79 -222
  114. package/src/components/Provision.js +36 -42
  115. package/src/components/Provision.test.js +10 -26
  116. package/src/components/Routing/SegmentPage.js +68 -52
  117. package/src/components/Routing/SegmentPage.test.js +4 -12
  118. package/src/components/Scope/ScopeNode.js +44 -55
  119. package/src/components/Scope/ScopeNode.test.js +84 -163
  120. package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
  121. package/src/components/Sidepanel.js +38 -32
  122. package/src/components/Sidepanel.test.js +54 -27
  123. package/src/components/Spritesheet.js +23 -21
  124. package/src/components/Spritesheet.test.js +10 -10
  125. package/src/components/Text.js +0 -49
  126. package/src/components/ToastList.js +79 -90
  127. package/src/components/ToastList.test.js +29 -103
  128. package/src/components/Treeview/Branch.js +65 -47
  129. package/src/components/Treeview/Branch.test.js +2 -43
  130. package/src/components/Treeview/Label.js +68 -54
  131. package/src/components/Treeview/Label.test.js +55 -63
  132. package/src/components/Treeview/Leaf.js +41 -22
  133. package/src/components/Treeview/Leaf.test.js +1 -15
  134. package/src/components/Treeview/Node.js +16 -9
  135. package/src/components/Treeview/Node.test.js +269 -200
  136. package/src/components/Treeview/Treeview.test.js +248 -248
  137. package/src/components/Treeview/index.js +6 -0
  138. package/src/components/Treeview/settings.js +10 -6
  139. package/src/hooks/useMultipleFieldEditState.test.js +0 -1
  140. package/src/hooks/useWindowSize.js +39 -0
  141. package/src/hooks/useWindowSize.test.js +68 -0
  142. package/src/sharedMessages.js +8 -0
  143. package/src/translations/en-US.json +2 -0
  144. package/src/translations/fr-CA.json +2 -0
  145. package/src/utils/index.js +0 -4
  146. package/src/utils/testUtils.js +0 -10
  147. package/src/utils/testUtils.test.js +0 -68
  148. package/src/utils/toastHelper.js +8 -0
  149. package/src/utils/toastHelper.test.js +41 -0
  150. package/dist/components/Button.js +0 -70
  151. package/dist/components/CategoryList.js +0 -197
  152. package/dist/components/Checkbox.js +0 -103
  153. package/dist/components/Icon.js +0 -69
  154. package/dist/components/IconButton.js +0 -80
  155. package/dist/components/Input.js +0 -101
  156. package/dist/components/List/DataCell.js +0 -129
  157. package/dist/components/List/HeadCell.js +0 -125
  158. package/dist/components/List/HeadRow.js +0 -73
  159. package/dist/components/List/List.js +0 -274
  160. package/dist/components/List/Row.js +0 -109
  161. package/dist/components/List/enhanceColumnDefs.js +0 -111
  162. package/dist/components/List/index.js +0 -59
  163. package/dist/components/Modal/Dialog.js +0 -75
  164. package/dist/components/Modal/Wrapper.js +0 -69
  165. package/dist/components/MultiSelector.js +0 -187
  166. package/dist/components/Navigation/Bar.js +0 -293
  167. package/dist/components/Navigation/Tab.js +0 -182
  168. package/dist/components/Placeholder.js +0 -114
  169. package/dist/components/Scope/Selector.js +0 -123
  170. package/dist/components/Selector.js +0 -185
  171. package/dist/components/Switch.js +0 -128
  172. package/dist/components/Toolbar.js +0 -227
  173. package/dist/components/Tooltip.js +0 -66
  174. package/dist/getTheme.js +0 -158
  175. package/dist/getThemeOverrides.js +0 -93
  176. package/dist/hocs/withAuthentication.js +0 -72
  177. package/dist/utils/styledPropFuncs.js +0 -88
  178. package/src/components/Button.js +0 -90
  179. package/src/components/Button.test.js +0 -49
  180. package/src/components/CategoryList.js +0 -140
  181. package/src/components/CategoryList.test.js +0 -667
  182. package/src/components/Checkbox.js +0 -63
  183. package/src/components/Checkbox.test.js +0 -122
  184. package/src/components/Icon.js +0 -18
  185. package/src/components/IconButton.js +0 -30
  186. package/src/components/IconButton.test.js +0 -61
  187. package/src/components/Input.js +0 -35
  188. package/src/components/Input.test.js +0 -34
  189. package/src/components/List/DataCell.js +0 -77
  190. package/src/components/List/DataCell.test.js +0 -357
  191. package/src/components/List/HeadCell.js +0 -105
  192. package/src/components/List/HeadCell.test.js +0 -331
  193. package/src/components/List/HeadRow.js +0 -21
  194. package/src/components/List/HeadRow.test.js +0 -27
  195. package/src/components/List/List.js +0 -162
  196. package/src/components/List/List.test.js +0 -705
  197. package/src/components/List/Row.js +0 -72
  198. package/src/components/List/Row.test.js +0 -194
  199. package/src/components/List/enhanceColumnDefs.js +0 -54
  200. package/src/components/List/enhanceColumnDefs.test.js +0 -179
  201. package/src/components/List/index.js +0 -6
  202. package/src/components/Modal/Background.js +0 -10
  203. package/src/components/Modal/Dialog.js +0 -27
  204. package/src/components/Modal/Dialog.test.js +0 -20
  205. package/src/components/Modal/Modal.test.js +0 -52
  206. package/src/components/Modal/Wrapper.js +0 -32
  207. package/src/components/Modal/Wrapper.test.js +0 -55
  208. package/src/components/Modal/index.js +0 -22
  209. package/src/components/MultiSelector.js +0 -104
  210. package/src/components/MultiSelector.test.js +0 -348
  211. package/src/components/Navigation/Bar.js +0 -212
  212. package/src/components/Navigation/Bar.test.js +0 -552
  213. package/src/components/Navigation/Tab.js +0 -156
  214. package/src/components/Navigation/Tab.test.js +0 -404
  215. package/src/components/Placeholder.js +0 -61
  216. package/src/components/Placeholder.test.js +0 -106
  217. package/src/components/Scope/Selector.js +0 -70
  218. package/src/components/Scope/Selector.test.js +0 -138
  219. package/src/components/Selector.js +0 -191
  220. package/src/components/Selector.test.js +0 -157
  221. package/src/components/Switch.js +0 -112
  222. package/src/components/Switch.test.js +0 -130
  223. package/src/components/Text.test.js +0 -132
  224. package/src/components/Toolbar.js +0 -178
  225. package/src/components/Toolbar.test.js +0 -478
  226. package/src/components/Tooltip.js +0 -51
  227. package/src/components/Tooltip.test.js +0 -21
  228. package/src/getTheme.js +0 -103
  229. package/src/getTheme.test.js +0 -92
  230. package/src/getThemeOverrides.js +0 -27
  231. package/src/hocs/withAuthentication.js +0 -18
  232. package/src/hocs/withAuthentication.test.js +0 -120
  233. package/src/utils/styledPropFuncs.js +0 -20
  234. package/src/utils/styledPropFuncs.test.js +0 -166
@@ -1,63 +0,0 @@
1
- import React from "react";
2
- import styled, { css } from "styled-components";
3
- import { getThemeProp, ifFlag } from "../utils";
4
- import { tint } from "polished";
5
- import withId from "../hocs/withId";
6
-
7
- export const Wrapper = styled.label`
8
- padding: 10px 15px;
9
- margin: -10px -15px;
10
- `;
11
-
12
- export const ContainedInput = styled.input.attrs(() => ({ type: "checkbox" }))`
13
- position: absolute;
14
- opacity: 0;
15
- z-index: 10;
16
- margin: 0;
17
- `;
18
-
19
- export const Cover = styled.label`
20
- display: inline-block;
21
- position: relative;
22
- height: 14px;
23
- width: 14px;
24
- border: 1px solid ${getThemeProp(["colors", "borderLight"], "#cccccc")};
25
- border-radius: 3px;
26
-
27
- ${ContainedInput}:active + &,
28
- ${ContainedInput}:focus + & {
29
- box-shadow: 0px 0px 1px 0px ${getThemeProp(["colors", "application", "base"], "#777", color => tint(0.05, color))};
30
- border-color: ${getThemeProp(["colors", "application", "base"], "#777")};
31
- }
32
-
33
- ${ifFlag(
34
- "value",
35
- css`
36
- background-color: ${getThemeProp(["colors", "application", "base"], "#777", color => tint(0.05, color))};
37
- &::after {
38
- content: "✔";
39
- font-size: 12px;
40
- line-height: 1;
41
- position: absolute;
42
- top: 1px;
43
- left: 0;
44
- right: 0;
45
- bottom: 0;
46
- color: white;
47
- text-align: center;
48
- }
49
- `,
50
- css`
51
- background-color: white;
52
- `,
53
- )};
54
- `;
55
-
56
- export const Checkbox = ({ value, className, id, ...otherProps }) => (
57
- <Wrapper className={className} htmlFor={id}>
58
- <ContainedInput value={value} id={id} {...otherProps} />
59
- <Cover value={value} htmlFor={id} />
60
- </Wrapper>
61
- );
62
-
63
- export default withId("checkbox")(Checkbox);
@@ -1,122 +0,0 @@
1
- import React from "react";
2
- import { mount } from "unexpected-reaction";
3
- import { getClassSelector, getStyledClassSelector } from "../utils/testUtils";
4
- import { Checkbox, Wrapper, ContainedInput, Cover } from "./Checkbox";
5
-
6
- describe("Checkbox", () => {
7
- it("renders an input and a label", () =>
8
- expect(
9
- <Checkbox id="foo" value={true} random="stuff" />,
10
- "when mounted",
11
- "to satisfy",
12
- <Wrapper htmlFor="foo">
13
- <ContainedInput id="foo" value={true} random="stuff" />
14
- <Cover htmlFor="foo" value={true} />
15
- </Wrapper>,
16
- ));
17
- });
18
-
19
- describe("ContainedInput", () => {
20
- it("renders an input of type checkbox", () =>
21
- expect(<ContainedInput />, "when mounted", "to satisfy", <input type="checkbox" />));
22
- });
23
-
24
- describe("Cover", () => {
25
- it("sets a highlight when input is focused or active", () => {
26
- const inputSelector = getStyledClassSelector(ContainedInput);
27
- const coverSelector = getClassSelector(<Cover />, 1); // Get the generated class name
28
- mount(<Cover />);
29
- return expect(
30
- coverSelector,
31
- "as a selector to have style rules",
32
- expect.it(
33
- "to contain",
34
- `${inputSelector}:active + ${coverSelector},` +
35
- `${inputSelector}:focus + ${coverSelector}` +
36
- " {box-shadow: 0px 0px 1px 0px #7d7d7d; border-color: #777;}",
37
- ),
38
- );
39
- });
40
-
41
- it("sets a highlight when input is focused or active, when checked", () => {
42
- const inputSelector = getStyledClassSelector(ContainedInput);
43
- const coverSelector = getClassSelector(<Cover value={true} />, 1); // Get the generated class name
44
- mount(<Cover value={true} />);
45
- return expect(
46
- coverSelector,
47
- "as a selector to have style rules",
48
- expect.it(
49
- "to contain",
50
- `${inputSelector}:active + ${coverSelector},` +
51
- `${inputSelector}:focus + ${coverSelector}` +
52
- " {box-shadow: 0px 0px 1px 0px #7d7d7d; border-color: #777;}",
53
- ),
54
- );
55
- });
56
-
57
- it("sets a clear background when not checked", () =>
58
- expect(<Cover />, "when mounted", "to have style rules satisfying", "to contain", "background-color: white;"));
59
-
60
- it("sets a colored background and a checkmark when checked", () =>
61
- expect(
62
- <Cover value />,
63
- "when mounted",
64
- "to have style rules satisfying",
65
- expect.it("to contain", "background-color: #7d7d7d;").and("to contain", '::after {content: "✔";'),
66
- ));
67
-
68
- describe("with highlight color from theme", () => {
69
- let theme;
70
- beforeEach(() => {
71
- theme = { colors: { application: { base: "#cc0000" } } };
72
- });
73
-
74
- it("sets a highlight when input is focused or active", () => {
75
- const inputSelector = getStyledClassSelector(ContainedInput);
76
- const coverSelector = getClassSelector(<Cover theme={theme} />, 1); // Get the generated class name
77
- mount(<Cover theme={theme} />);
78
- return expect(
79
- coverSelector,
80
- "as a selector to have style rules",
81
- expect.it(
82
- "to contain",
83
- `${inputSelector}:active + ${coverSelector},` +
84
- `${inputSelector}:focus + ${coverSelector}` +
85
- " {box-shadow: 0px 0px 1px 0px #ce0c0c; border-color: #cc0000;}",
86
- ),
87
- );
88
- });
89
-
90
- it("sets a highlight when input is focused or active, when checked", () => {
91
- const inputSelector = getStyledClassSelector(ContainedInput);
92
- const coverSelector = getClassSelector(<Cover theme={theme} value={true} />, 1); // Get the generated class name
93
- mount(<Cover theme={theme} value={true} />);
94
- return expect(
95
- coverSelector,
96
- "as a selector to have style rules",
97
- expect.it(
98
- "to contain",
99
- `${inputSelector}:active + ${coverSelector},` +
100
- `${inputSelector}:focus + ${coverSelector}` +
101
- " {box-shadow: 0px 0px 1px 0px #ce0c0c; border-color: #cc0000;}",
102
- ),
103
- );
104
- });
105
-
106
- it("sets a clear background when not checked", () =>
107
- expect(
108
- <Cover theme={theme} />,
109
- "when mounted",
110
- "to have style rules satisfying",
111
- expect.it("to contain", "background-color: white;").and("not to contain", "::after"),
112
- ));
113
-
114
- it("sets a colored background and a checkmark when checked", () =>
115
- expect(
116
- <Cover theme={theme} value />,
117
- "when mounted",
118
- "to have style rules satisfying",
119
- expect.it("to contain", "background-color: #ce0c0c;").and("to contain", '::after {content: "✔";'),
120
- ));
121
- });
122
- });
@@ -1,18 +0,0 @@
1
- import React from "react";
2
- import styled from "styled-components";
3
-
4
- const IconSVG = styled.svg`
5
- height: 1em;
6
- width: 1em;
7
- fill: currentColor;
8
- stroke: currentColor;
9
- `;
10
-
11
- console.warn("Icon has been deprecated. Use Icon from MaterialUI.");
12
- const Icon = ({ id, ...props }) => (
13
- <IconSVG {...props}>
14
- <use href={`#icon-${id}`} />
15
- </IconSVG>
16
- );
17
-
18
- export default Icon;
@@ -1,30 +0,0 @@
1
- import React from "react";
2
- import styled from "styled-components";
3
- import Button from "./Button";
4
- import Icon from "./Icon";
5
- import Text from "./Text";
6
-
7
- export const ButtonIcon = styled(Icon)`
8
- font-size: 1.23em;
9
- margin: -3px -2px;
10
- `;
11
-
12
- export const ButtonText = styled.span`
13
- ${ButtonIcon} + & {
14
- margin-left: 12px;
15
- vertical-align: top;
16
- }
17
- `;
18
-
19
- const IconButton = ({ icon, label, ...props }) => (
20
- <Button {...props}>
21
- {icon ? <ButtonIcon id={icon} /> : null}
22
- {label ? (
23
- <ButtonText>
24
- <Text message={label} />
25
- </ButtonText>
26
- ) : null}
27
- </Button>
28
- );
29
-
30
- export default IconButton;
@@ -1,61 +0,0 @@
1
- import React from "react";
2
- import { Provider } from "react-redux";
3
- import Button from "./Button";
4
- import IconButton, { ButtonIcon, ButtonText } from "./IconButton";
5
-
6
- describe("IconButton", () => {
7
- it("renders a button with an icon", () =>
8
- expect(
9
- <Provider
10
- store={{
11
- subscribe: () => {},
12
- dispatch: () => {},
13
- getState: () => ({}),
14
- }}
15
- >
16
- <IconButton icon="test" otherProp />
17
- </Provider>,
18
- "when mounted",
19
- "to satisfy",
20
- <Button otherProp>
21
- <ButtonIcon id="test" />
22
- </Button>,
23
- ));
24
-
25
- it("renders a button with a label", () =>
26
- expect(
27
- <Provider
28
- store={{
29
- subscribe: () => {},
30
- dispatch: () => {},
31
- getState: () => ({}),
32
- }}
33
- >
34
- <IconButton label="Message" random="foo" />
35
- </Provider>,
36
- "when mounted",
37
- "to satisfy",
38
- <Button random="foo">
39
- <ButtonText>Message</ButtonText>
40
- </Button>,
41
- ));
42
-
43
- it("renders a button with both an icon and a label", () =>
44
- expect(
45
- <Provider
46
- store={{
47
- subscribe: () => {},
48
- dispatch: () => {},
49
- getState: () => ({}),
50
- }}
51
- >
52
- <IconButton icon="test" label="Message" passThru={[1, 2, 3]} />
53
- </Provider>,
54
- "when mounted",
55
- "to satisfy",
56
- <Button passThru={[1, 2, 3]}>
57
- <ButtonIcon id="test" />
58
- <ButtonText>Message</ButtonText>
59
- </Button>,
60
- ));
61
- });
@@ -1,35 +0,0 @@
1
- import React, { useContext } from "react";
2
- import styled from "styled-components";
3
- import { IntlContext } from "react-intl";
4
- import { getThemeProp } from "../utils";
5
-
6
- const defaultFormatMessage = message => {
7
- throw new Error("Attempting to translate message " + message.id + " outside of Intl context");
8
- };
9
- const maybeTranslate = (formatMessage = defaultFormatMessage, message) =>
10
- message && message.id ? formatMessage(message) : message;
11
-
12
- const useIntlSoft = () => useContext(IntlContext) || {};
13
-
14
- export const InputComponent = styled.input`
15
- font-family: ${getThemeProp(["fonts", "base"], "sans-serif")};
16
- box-sizing: border-box;
17
- flex: 0 0 auto;
18
- height: 30px;
19
- padding: 5px 10px;
20
- border: 1px solid ${getThemeProp(["colors", "borderLight"], "#cccccc")};
21
- border-radius: 5px;
22
-
23
- &:focus {
24
- border-color: #4fa1f0;
25
- box-shadow: 0 0 4px #4fa1f0;
26
- outline: none;
27
- }
28
- `;
29
-
30
- const Input = ({ placeholder, ...props }) => {
31
- const { formatMessage } = useIntlSoft();
32
- return <InputComponent {...props} placeholder={maybeTranslate(formatMessage, placeholder)} />;
33
- };
34
-
35
- export default Input;
@@ -1,34 +0,0 @@
1
- import React from "react";
2
- import { IntlProvider } from "react-intl";
3
- import { mount } from "unexpected-reaction";
4
- import { spyOnConsole } from "../utils/testUtils";
5
- import Input, { InputComponent } from "./Input";
6
-
7
- describe("Input", () => {
8
- spyOnConsole(["error"]);
9
-
10
- it("renders a styled input field with a plain text placeholder", () =>
11
- expect(
12
- <Input placeholder="A placeholder" />,
13
- "when mounted",
14
- "to satisfy",
15
- <InputComponent placeholder="A placeholder" />,
16
- ));
17
-
18
- it("renders a styled input field with a translated placeholder", () =>
19
- expect(
20
- <IntlProvider locale="en">
21
- <Input placeholder={{ id: "placeholder", defaultMessage: "A placeholder" }} />
22
- </IntlProvider>,
23
- "when mounted",
24
- "to satisfy",
25
- <InputComponent placeholder="A placeholder" />,
26
- ));
27
-
28
- it("fails on attempt to translate intl message outside an IntlProvider", () =>
29
- expect(
30
- () => mount(<Input placeholder={{ id: "placeholder", defaultMessage: "A placeholder" }} />),
31
- "to throw",
32
- "Attempting to translate message placeholder outside of Intl context",
33
- ));
34
- });
@@ -1,77 +0,0 @@
1
- import React from "react";
2
- import styled from "styled-components";
3
- import { FormattedNumber, FormattedDate, FormattedTime } from "react-intl";
4
- import { safeGet, getThemeProp } from "../../utils";
5
- import Switch from "../Switch";
6
- import Checkbox from "../Checkbox";
7
- import Text from "../Text";
8
-
9
- const arrify = thing => (Array.isArray(thing) ? thing : [thing]);
10
-
11
- const renderByType = (value, def, rowId, selected, row) => {
12
- const transformedValue = def.transform ? def.transform(value) : value;
13
- switch (def.type) {
14
- case "custom": {
15
- const Comp = def.component;
16
- return <Comp {...row} {...def.funcs} />;
17
- }
18
- case "currency": {
19
- let currency = def.currency;
20
- if (Array.isArray(currency)) {
21
- currency = safeGet(row, ...currency);
22
- }
23
- return (
24
- <FormattedNumber
25
- style="currency" // eslint-disable-line react/style-prop-object
26
- currency={currency}
27
- value={transformedValue || "0"}
28
- />
29
- );
30
- }
31
- case "date":
32
- return <FormattedDate value={transformedValue} />;
33
- case "datetime":
34
- return (
35
- <React.Fragment>
36
- <FormattedDate value={transformedValue} /> <FormattedTime value={transformedValue} />
37
- </React.Fragment>
38
- );
39
- case "select":
40
- return <Checkbox id={"select_" + rowId} value={selected} data-row-id={rowId} onChange={def.onChange} />;
41
- case "switch":
42
- return <Switch value={!!transformedValue} {...def.switch} data-row-id={rowId} onChange={def.onChange} />;
43
- default:
44
- return transformedValue ? <Text message={transformedValue} /> : null;
45
- }
46
- };
47
-
48
- export const TableData = styled.td`
49
- border: 0 solid ${getThemeProp(["colors", "borderLight"], "#cccccc")};
50
- border-top-width: 1px;
51
- tr:first-child & {
52
- border-top-width: 0;
53
- }
54
- tr:last-child & {
55
- border-bottom-width: 1px;
56
- }
57
-
58
- height: 20px;
59
- padding: 15px 20px;
60
- white-space: nowrap;
61
- overflow-x: hidden;
62
- text-overflow: ellipsis;
63
- `;
64
-
65
- const DataCell = ({ columnDef, row, rowId, selected }) => (
66
- <TableData>
67
- {renderByType(
68
- safeGet(row, ...arrify(columnDef.fieldName)) || columnDef.defaultValue,
69
- columnDef,
70
- rowId,
71
- selected,
72
- row,
73
- )}
74
- </TableData>
75
- );
76
-
77
- export default DataCell;