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
@@ -18,6 +18,9 @@ export const Treeview = ({
18
18
  openAll,
19
19
  name,
20
20
  defaultNodeState = {},
21
+ labelClassName,
22
+ leafClassName,
23
+ branchClassName,
21
24
  ...otherProps
22
25
  }) => {
23
26
  const [viewState, updateViewState] = useViewState(name);
@@ -34,6 +37,9 @@ export const Treeview = ({
34
37
  selectedNodeId,
35
38
  nodeState,
36
39
  updateNodeState,
40
+ labelClassName,
41
+ leafClassName,
42
+ branchClassName,
37
43
  otherProps,
38
44
  }}
39
45
  >
@@ -1,6 +1,10 @@
1
- import { getThemeProp } from "../../utils";
2
-
3
- // Functions to easily get the tree settings from theme, or sensible defaults
4
- export const branchIndent = getThemeProp(["treeSettings", "branchIndent"], 14);
5
- export const branchLength = getThemeProp(["treeSettings", "branchLength"], 15);
6
- export const branchHeight = getThemeProp(["treeSettings", "branchHeight"], 18);
1
+ // in px
2
+ // How far from parent left edge to vertical branch under it
3
+ export const branchIndent = 14;
4
+ export const branchIndentSpacing = 1.4;
5
+ // How far from vertical branch to children's left edge
6
+ export const branchLength = 15;
7
+ export const branchLengthSpacing = 1.5;
8
+ // How far up from bottom edge of node should horizontal branch sit
9
+ export const branchHeight = 20;
10
+ export const branchHeightSpacing = 2;
@@ -411,7 +411,6 @@ describe("useMultipleFieldEditState", () => {
411
411
  .returns(useDispatchWithModulesDataSpy);
412
412
 
413
413
  try {
414
- // TODOJOC
415
414
  const mountedComponent = mountComponent();
416
415
 
417
416
  const fieldComponent = mountedComponent.find(`#id1-prop1-update`);
@@ -0,0 +1,39 @@
1
+ import { useEffect, useState } from "react";
2
+
3
+ export const useWindowSize = () => {
4
+ const [windowSize, setWindowSize] = useState({
5
+ innerWidth: window.innerWidth,
6
+ innerHeight: window.innerHeight,
7
+ outerWidth: window.outerWidth,
8
+ outerHeight: window.outerHeight,
9
+ });
10
+
11
+ useEffect(() => {
12
+ const handleResize = () => {
13
+ const haveChanged =
14
+ windowSize.innerWidth !== window.innerWidth ||
15
+ windowSize.innerHeight !== window.innerHeight ||
16
+ windowSize.outerWidth !== window.outerWidth ||
17
+ windowSize.outerHeight !== window.outerHeight;
18
+
19
+ if (haveChanged) {
20
+ setWindowSize({
21
+ innerWidth: window.innerWidth,
22
+ innerHeight: window.innerHeight,
23
+ outerWidth: window.outerWidth,
24
+ outerHeight: window.outerHeight,
25
+ });
26
+ }
27
+ };
28
+
29
+ handleResize();
30
+
31
+ window.addEventListener("resize", handleResize);
32
+
33
+ return () => window.removeEventListener("resize", handleResize);
34
+ }, [windowSize]);
35
+
36
+ return windowSize;
37
+ };
38
+
39
+ export default useWindowSize;
@@ -0,0 +1,68 @@
1
+ import React from "react";
2
+ import useWindowSize from "./useWindowSize";
3
+ import { mount, unmount, act } from "unexpected-reaction";
4
+
5
+ let renderingCount = 0;
6
+
7
+ const TestComp = () => {
8
+ const windowSize = useWindowSize();
9
+
10
+ const allDimensions = `${windowSize.innerWidth},${windowSize.innerHeight},${windowSize.outerWidth},${windowSize.outerHeight},${++renderingCount}`;
11
+
12
+ return <div>{allDimensions}</div>;
13
+ };
14
+
15
+ function setViewport(width, height) {
16
+ Object.defineProperty(window, "innerWidth", { configurable: true, value: width });
17
+ Object.defineProperty(window, "innerHeight", { configurable: true, value: height });
18
+ Object.defineProperty(window, "outerWidth", { configurable: true, value: width + 20 });
19
+ Object.defineProperty(window, "outerHeight", { configurable: true, value: height + 25 });
20
+ }
21
+
22
+ describe("useWindowSize", () => {
23
+ let element = null;
24
+
25
+ beforeEach(() => {
26
+ renderingCount = 0;
27
+ setViewport(1440, 720);
28
+ window.dispatchEvent(new Event("resize"));
29
+ });
30
+
31
+ afterEach(() => {
32
+ if (element !== null) {
33
+ unmount(element);
34
+ }
35
+ });
36
+
37
+ it("display window dimensions properly after first render", () => {
38
+ element = mount(<TestComp />);
39
+
40
+ expect(element, "to satisfy", <div>1440,720,1460,745,1</div>);
41
+ });
42
+
43
+ it("display window dimensions properly after resize event", () => {
44
+ element = mount(<TestComp />);
45
+
46
+ expect(element, "to satisfy", <div>1440,720,1460,745,1</div>);
47
+
48
+ act(() => {
49
+ setViewport(843, 487);
50
+ window.dispatchEvent(new Event("resize"));
51
+ });
52
+
53
+ expect(element, "to satisfy", <div>843,487,863,512,2</div>);
54
+ });
55
+
56
+ it("display window dimensions properly after resize event with unchanged dimensions", () => {
57
+ element = mount(<TestComp />);
58
+
59
+ expect(element, "to satisfy", <div>1440,720,1460,745,1</div>);
60
+
61
+ act(() => {
62
+ setViewport(1440, 720);
63
+ window.dispatchEvent(new Event("resize"));
64
+ });
65
+
66
+ expect(element, "to satisfy", <div>1440,720,1460,745,1</div>);
67
+ });
68
+ });
@@ -483,6 +483,14 @@ const sharedMessages = defineMessages({
483
483
  id: "orc-shared.december",
484
484
  defaultMessage: "December",
485
485
  },
486
+ selectAll: {
487
+ id: "orc-shared.selectAll",
488
+ defaultMessage: "Select All",
489
+ },
490
+ clear: {
491
+ id: "orc-shared.clear",
492
+ defaultMessage: "Clear",
493
+ },
486
494
  });
487
495
 
488
496
  export default sharedMessages;
@@ -14,6 +14,7 @@
14
14
  "orc-shared.ccDescription": "The API-first commerce platform that makes omnichannel retail work.",
15
15
  "orc-shared.ccName": "Orckestra Commerce Cloud",
16
16
  "orc-shared.ccVersion": "Commerce Cloud {version}",
17
+ "orc-shared.clear": "Clear",
17
18
  "orc-shared.close": "Close",
18
19
  "orc-shared.confirmation": "Confirmation",
19
20
  "orc-shared.copyright": "© {year} Orckestra Technologies Inc.",
@@ -90,6 +91,7 @@
90
91
  "orc-shared.scopeChangeWithUnsavedDataTitle": "Confirm scope change without saving data",
91
92
  "orc-shared.scopeFilterPlaceholder": "Type a scope name",
92
93
  "orc-shared.search": "Search",
94
+ "orc-shared.selectAll": "Select All",
93
95
  "orc-shared.september": "September",
94
96
  "orc-shared.septemberShort": "Sep",
95
97
  "orc-shared.shared": "Shared",
@@ -14,6 +14,7 @@
14
14
  "orc-shared.ccDescription": "La plateforme de commerce « API-first » qui rend le commerce de détail omnicanal fluide.",
15
15
  "orc-shared.ccName": "Orckestra Commerce Cloud",
16
16
  "orc-shared.ccVersion": "Commerce Cloud {version}",
17
+ "orc-shared.clear": "Effacer",
17
18
  "orc-shared.close": "Fermer",
18
19
  "orc-shared.confirmation": "Confirmation",
19
20
  "orc-shared.copyright": "© {year} Technologies Orckestra Inc.",
@@ -90,6 +91,7 @@
90
91
  "orc-shared.scopeChangeWithUnsavedDataTitle": "Confirmation du changement de Scope sans sauvegarde",
91
92
  "orc-shared.scopeFilterPlaceholder": "Entrez un nom de Scope",
92
93
  "orc-shared.search": "Recherche",
94
+ "orc-shared.selectAll": "Tout sélectionner",
93
95
  "orc-shared.september": "septembre",
94
96
  "orc-shared.septemberShort": "sept.",
95
97
  "orc-shared.shared": "Partagé",
@@ -1,5 +1,4 @@
1
1
  import safeGet from "./safeGet";
2
- import { getThemeProp, ifFlag, switchEnum } from "./styledPropFuncs";
3
2
  import unwrapImmutable from "./unwrapImmutable";
4
3
  import logPass from "./logPass";
5
4
  import normalizeForSearch from "./normalizeForSearch";
@@ -18,8 +17,6 @@ export {
18
17
  debounce,
19
18
  flatten,
20
19
  flattenObj,
21
- getThemeProp,
22
- ifFlag,
23
20
  insertIcons,
24
21
  loadConfig,
25
22
  logPass,
@@ -30,6 +27,5 @@ export {
30
27
  setTranslationWithFallbackValue,
31
28
  setTranslationWithFallbackField,
32
29
  stripKey,
33
- switchEnum,
34
30
  unwrapImmutable,
35
31
  };
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import { isStyledComponent } from "styled-components";
3
2
  import { mount } from "unexpected-reaction";
4
3
  import { Ignore } from "unexpected-reaction";
5
4
  import createThemes from "./../components/MaterialUI/muiThemes";
@@ -56,15 +55,6 @@ export const getClassSelector = (elm, index, container) => {
56
55
  }
57
56
  };
58
57
 
59
- export const getStyledClassSelector = elm => {
60
- const component = elm.type || elm;
61
- if (!isStyledComponent(component)) {
62
- throw new Error("<" + (component.name || component) + " /> is not a styled component");
63
- }
64
- // Styled component toString() function returns a stable class name
65
- return component.toString();
66
- };
67
-
68
58
  export const firstItemComparator = (a, b) => (a[0] > b[0] ? 1 : a[0] < b[0] ? -1 : 0);
69
59
 
70
60
  export const PropStruct = React.forwardRef((props, ref) => (
@@ -1,10 +1,8 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
3
2
  import { defineMessages } from "react-intl";
4
3
  import {
5
4
  getElmClasses,
6
5
  getClassName,
7
- getStyledClassSelector,
8
6
  getClassSelector,
9
7
  PropStruct,
10
8
  firstItemComparator,
@@ -28,13 +26,6 @@ class TestComp2 extends React.Component {
28
26
  }
29
27
 
30
28
  describe("class name helpers", () => {
31
- const TestStyled = styled.div`
32
- color: red;
33
- `;
34
- const DerivedTestStyled = styled(TestStyled)`
35
- color: blue;
36
- `;
37
-
38
29
  spyOnConsole(["error"]);
39
30
 
40
31
  describe("getElmClasses", () => {
@@ -44,16 +35,6 @@ describe("class name helpers", () => {
44
35
  it("works with svg elements", () =>
45
36
  expect(getElmClasses, "when called with", [<svg className="foo bar" />], "to equal", ["foo", "bar"]));
46
37
 
47
- it("works with styled components", () =>
48
- expect(
49
- getElmClasses,
50
- "when called with",
51
- [<TestStyled />],
52
- "to have an item satisfying",
53
- "to match",
54
- /__TestStyled-/,
55
- ));
56
-
57
38
  it("throws an error if no class found on DOM element", () =>
58
39
  expect(
59
40
  () => expect(getElmClasses, "when called with", [<div />]),
@@ -94,9 +75,6 @@ describe("class name helpers", () => {
94
75
  it("works with svg elements", () =>
95
76
  expect(getClassName, "when called with", [<svg className="foo bar" />], "to equal", "foo"));
96
77
 
97
- it("works with styled components", () =>
98
- expect(getClassName, "when called with", [<TestStyled />], "to match", /__TestStyled-/));
99
-
100
78
  it("can use a custom container element type", () => {
101
79
  expect(getClassName(<td className="foo bar" />, 0, "tr"), "to equal", "foo");
102
80
  expect(console.error, "was not called");
@@ -116,9 +94,6 @@ describe("class name helpers", () => {
116
94
  it("works with svg elements", () =>
117
95
  expect(getClassSelector, "when called with", [<svg className="foo bar" />], "to equal", ".foo"));
118
96
 
119
- it("works with styled components", () =>
120
- expect(getClassSelector, "when called with", [<TestStyled />], "to match", /^\.\S*__TestStyled-/));
121
-
122
97
  it("can make a selector targeting all classes", () =>
123
98
  expect(getClassSelector, "when called with", [<TestComp className="foo bar" />, -1], "to equal", ".foo.bar"));
124
99
 
@@ -127,49 +102,6 @@ describe("class name helpers", () => {
127
102
  expect(console.error, "was not called");
128
103
  });
129
104
  });
130
-
131
- describe("getStyledClassSelector", () => {
132
- it("creates a selector for a styled component", () =>
133
- expect(
134
- getStyledClassSelector,
135
- "when called with",
136
- [<TestStyled />],
137
- "to match",
138
- /.*__TestStyled-sc-[0-9a-zA-Z]{6}-[0-9]/,
139
- ));
140
-
141
- it("can use the component function without rendering", () =>
142
- expect(
143
- getStyledClassSelector,
144
- "when called with",
145
- [TestStyled],
146
- "to match",
147
- /.*__TestStyled-sc-[0-9a-zA-Z]{6}-[0-9]/,
148
- ));
149
-
150
- it("finds the most specific class name", () =>
151
- expect(
152
- getStyledClassSelector,
153
- "when called with",
154
- [<DerivedTestStyled />],
155
- "to match",
156
- /.*__DerivedTestStyled-sc-[0-9a-zA-Z]{6}-[0-9]/,
157
- ));
158
-
159
- it("throws an error if not given a non-styled component", () =>
160
- expect(
161
- () => expect(getStyledClassSelector, "when called with", [<TestComp />]),
162
- "to throw",
163
- "<TestComp /> is not a styled component",
164
- ));
165
-
166
- it("throws an error if not given a DOM primitive", () =>
167
- expect(
168
- () => expect(getStyledClassSelector, "when called with", [<div />]),
169
- "to throw",
170
- "<div /> is not a styled component",
171
- ));
172
- });
173
105
  });
174
106
 
175
107
  describe("PropStruct", () => {
@@ -0,0 +1,8 @@
1
+ export const getToastColor = (theme, alertType) => {
2
+ const toastBorderColors = {
3
+ error: theme.palette.error.main,
4
+ warn: theme.palette.warning.main,
5
+ confirm: theme.palette.success.main,
6
+ };
7
+ return toastBorderColors[alertType] || "red";
8
+ };
@@ -0,0 +1,41 @@
1
+ import { getToastColor } from "./toastHelper";
2
+
3
+ describe("getToastColor", () => {
4
+ const theme = {
5
+ palette: {
6
+ error: {
7
+ main: "#FF0000",
8
+ },
9
+ warning: {
10
+ main: "#FFA500",
11
+ },
12
+ success: {
13
+ main: "#00FF00",
14
+ },
15
+ },
16
+ };
17
+
18
+ it("should return error color", () => {
19
+ const toastColor = getToastColor(theme, "error");
20
+
21
+ return expect(toastColor, "to be", "#FF0000");
22
+ });
23
+
24
+ it("should return warning color", () => {
25
+ const toastColor = getToastColor(theme, "warn");
26
+
27
+ return expect(toastColor, "to be", "#FFA500");
28
+ });
29
+
30
+ it("should return success color", () => {
31
+ const toastColor = getToastColor(theme, "confirm");
32
+
33
+ return expect(toastColor, "to be", "#00FF00");
34
+ });
35
+
36
+ it("should return default color", () => {
37
+ const toastColor = getToastColor(theme, "test");
38
+
39
+ return expect(toastColor, "to be", "red");
40
+ });
41
+ });
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
6
- var _utils = require("../utils");
7
- var _polished = require("polished");
8
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
9
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
- (function () {
11
- var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
12
- enterModule && enterModule(module);
13
- })();
14
- (function () {
15
- var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
16
- enterModule && enterModule(module);
17
- })();
18
- var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
19
- return a;
20
- };
21
- var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
22
- return a;
23
- };
24
- var borderColor = function borderColor(base) {
25
- return (0, _utils.ifFlag)("primary", (0, _utils.getThemeProp)(["colors", "application", "base"], base), base);
26
- };
27
- var background = (0, _utils.ifFlag)("primary", (0, _utils.ifFlag)("active", (0, _styledComponents.css)(["color:#fff;background-image:linear-gradient( ", ",", " );&:enabled:active{background-image:none;background-color:#fff;color:", ";}"], (0, _utils.getThemeProp)(["colors", "application", "base"], "#333", function (color) {
28
- return (0, _polished.tint)(0.05, color);
29
- }), (0, _utils.getThemeProp)(["colors", "application", "base"], "#333"), (0, _utils.getThemeProp)(["colors", "application", "base"], "#333")), (0, _styledComponents.css)(["color:", ";background-image:none;background-color:#fff;&:enabled:active{color:#fff;background-image:linear-gradient( ", ",", " );}"], (0, _utils.getThemeProp)(["colors", "application", "base"], "#333"), (0, _utils.getThemeProp)(["colors", "application", "base"], "#333", function (color) {
30
- return (0, _polished.tint)(0.05, color);
31
- }), (0, _utils.getThemeProp)(["colors", "application", "base"], "#333"))), (0, _utils.ifFlag)("active", (0, _styledComponents.css)(["background-image:none;background-color:", ";&:enabled:active{background-color:#f7f7f7;}"], (0, _utils.getThemeProp)(["colors", "bgLight"], "#efefef")), (0, _styledComponents.css)(["background-image:none;background-color:#f7f7f7;&:enabled:active{background-color:", ";}"], (0, _utils.getThemeProp)(["colors", "bgLight"], "#efefef"))));
32
- var Button = _styledComponents.default.button.withConfig({
33
- displayName: "Button",
34
- componentId: "sc-1rffh1n-0"
35
- })(["display:inline-block;margin:0;font-weight:400;text-align:center;vertical-align:middle;cursor:pointer;white-space:nowrap;padding:6px 10px;font-size:13px;line-height:1.42857;border-radius:4px;user-select:none;height:30px;border:1px solid ", ";outline:none;font-family:", ";text-transform:uppercase;min-width:50px;box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);", ";&:enabled:active,&:enabled:focus,&:enabled:hover{border-color:", ";box-shadow:0 0 4px #4fa1f0;outline:none;}&:disabled{opacity:0.6;cursor:default;}"], borderColor((0, _utils.getThemeProp)(["colors", "borderLight"], "#cccccc")), (0, _utils.getThemeProp)(["fonts", "header"], "sans-serif"), background, borderColor("#4fa1f0"));
36
- var _default = Button;
37
- var _default2 = _default;
38
- var _default3 = exports.default = _default2;
39
- ;
40
- (function () {
41
- var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
42
- if (!reactHotLoader) {
43
- return;
44
- }
45
- reactHotLoader.register(borderColor, "borderColor", "/home/vsts/work/1/s/src/components/Button.js");
46
- reactHotLoader.register(background, "background", "/home/vsts/work/1/s/src/components/Button.js");
47
- reactHotLoader.register(Button, "Button", "/home/vsts/work/1/s/src/components/Button.js");
48
- reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/Button.js");
49
- })();
50
- ;
51
- (function () {
52
- var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
53
- leaveModule && leaveModule(module);
54
- })();
55
- ;
56
- (function () {
57
- var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
58
- if (!reactHotLoader) {
59
- return;
60
- }
61
- reactHotLoader.register(borderColor, "borderColor", "/home/vsts/work/1/s/src/components/Button.js");
62
- reactHotLoader.register(background, "background", "/home/vsts/work/1/s/src/components/Button.js");
63
- reactHotLoader.register(Button, "Button", "/home/vsts/work/1/s/src/components/Button.js");
64
- reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/Button.js");
65
- })();
66
- ;
67
- (function () {
68
- var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
69
- leaveModule && leaveModule(module);
70
- })();