@shopgate/pwa-common 7.30.0-alpha.7 → 7.30.0-alpha.9

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 (306) hide show
  1. package/App.js +48 -6
  2. package/action-creators/app/index.js +75 -12
  3. package/action-creators/app/spec.js +96 -1
  4. package/action-creators/client/index.js +27 -5
  5. package/action-creators/client/spec.js +44 -1
  6. package/action-creators/error/index.js +15 -3
  7. package/action-creators/index.js +9 -1
  8. package/action-creators/menu/index.js +23 -4
  9. package/action-creators/menu/spec.js +37 -1
  10. package/action-creators/modal/index.js +15 -3
  11. package/action-creators/modal/spec.js +26 -1
  12. package/action-creators/page/index.js +24 -4
  13. package/action-creators/page/spec.js +38 -1
  14. package/action-creators/router/index.js +48 -7
  15. package/action-creators/url/index.js +24 -4
  16. package/action-creators/url/spec.js +45 -1
  17. package/action-creators/user/index.js +90 -13
  18. package/action-creators/user/spec.js +186 -2
  19. package/actions/app/handleDeepLink.js +11 -2
  20. package/actions/app/handleLink.js +62 -6
  21. package/actions/app/handlePushNotification.js +32 -4
  22. package/actions/app/handleUniversalLink.js +11 -2
  23. package/actions/app/registerLinkEvents.js +24 -3
  24. package/actions/client/fetchClientInformation.js +26 -2
  25. package/actions/menu/fetchMenu.js +23 -2
  26. package/actions/modal/closeModal.js +18 -2
  27. package/actions/modal/promiseMap.js +3 -1
  28. package/actions/modal/showModal.js +54 -8
  29. package/actions/page/fetchPageConfig.js +69 -2
  30. package/actions/page/getPageConfig.js +6 -2
  31. package/actions/page/index.js +1 -1
  32. package/actions/router/historyPop.js +12 -2
  33. package/actions/router/historyPopToRoute.js +27 -2
  34. package/actions/router/historyPush.js +12 -2
  35. package/actions/router/historyRedirect.js +21 -2
  36. package/actions/router/historyReplace.js +20 -3
  37. package/actions/router/historyReset.js +11 -2
  38. package/actions/router/historyResetTo.js +12 -2
  39. package/actions/router/index.js +17 -1
  40. package/actions/router/routeDidPop.js +11 -2
  41. package/actions/router/routeDidPush.js +13 -2
  42. package/actions/router/routeDidReplace.js +11 -2
  43. package/actions/router/routeDidReset.js +11 -2
  44. package/actions/router/routeDidUpdate.js +10 -2
  45. package/actions/router/routeWillPop.js +11 -2
  46. package/actions/router/routeWillPush.js +13 -2
  47. package/actions/router/routeWillReplace.js +11 -2
  48. package/actions/router/routeWillReset.js +11 -2
  49. package/actions/router/windowOpenOverride.js +10 -2
  50. package/actions/user/fetchRegisterUrl.js +36 -2
  51. package/actions/user/fetchUser.js +29 -3
  52. package/actions/user/getUser.js +6 -2
  53. package/actions/user/index.js +1 -1
  54. package/actions/user/login.js +76 -9
  55. package/actions/user/logout.js +30 -2
  56. package/collections/AuthRoutes.js +73 -14
  57. package/collections/Configuration.js +54 -7
  58. package/collections/EmbeddedMedia.js +84 -11
  59. package/collections/PersistedReducers.js +41 -6
  60. package/collections/Redirects.js +103 -17
  61. package/collections/index.js +5 -1
  62. package/collections/media-providers/MediaProvider.js +151 -26
  63. package/collections/media-providers/Vimeo.js +113 -19
  64. package/collections/media-providers/YouTube.js +74 -14
  65. package/collections/media-providers/index.js +3 -1
  66. package/collections/media-providers/style.js +52 -2
  67. package/components/Backdrop/index.js +95 -6
  68. package/components/Backdrop/spec.js +23 -1
  69. package/components/Backdrop/style.js +11 -2
  70. package/components/Button/index.js +47 -5
  71. package/components/Button/spec.js +36 -1
  72. package/components/Button/style.js +6 -1
  73. package/components/Checkbox/index.js +126 -32
  74. package/components/Checkbox/spec.js +94 -3
  75. package/components/Consume/helpers/buildParams.js +13 -2
  76. package/components/Consume/index.js +14 -2
  77. package/components/CountdownTimer/index.js +115 -17
  78. package/components/CountdownTimer/spec.js +126 -12
  79. package/components/Drawer/index.js +131 -16
  80. package/components/Drawer/spec.js +76 -1
  81. package/components/Drawer/style.js +37 -1
  82. package/components/Dropdown/index.js +65 -6
  83. package/components/Dropdown/style.js +4 -1
  84. package/components/Dropdown/transitions.js +34 -1
  85. package/components/Ellipsis/index.js +16 -2
  86. package/components/Ellipsis/spec.js +13 -1
  87. package/components/EmbeddedMedia/index.js +56 -6
  88. package/components/EmbeddedMedia/spec.js +52 -3
  89. package/components/ErrorBoundary/connector.js +9 -2
  90. package/components/ErrorBoundary/index.js +43 -7
  91. package/components/Grid/components/Item/index.js +40 -4
  92. package/components/Grid/components/Item/spec.js +23 -1
  93. package/components/Grid/components/Item/style.js +17 -3
  94. package/components/Grid/index.js +36 -4
  95. package/components/Grid/spec.js +23 -1
  96. package/components/Grid/style.js +11 -2
  97. package/components/HtmlSanitizer/connector.js +24 -3
  98. package/components/HtmlSanitizer/index.js +104 -12
  99. package/components/HtmlSanitizer/spec.js +214 -7
  100. package/components/I18n/components/FormatDate/index.js +26 -2
  101. package/components/I18n/components/FormatDate/spec.js +46 -1
  102. package/components/I18n/components/FormatNumber/index.js +34 -2
  103. package/components/I18n/components/FormatNumber/spec.js +41 -2
  104. package/components/I18n/components/FormatPrice/index.js +32 -2
  105. package/components/I18n/components/FormatPrice/spec.js +46 -1
  106. package/components/I18n/components/FormatTime/index.js +26 -2
  107. package/components/I18n/components/FormatTime/spec.js +43 -2
  108. package/components/I18n/components/I18nProvider/index.js +52 -9
  109. package/components/I18n/components/I18nProvider/spec.js +39 -1
  110. package/components/I18n/components/Placeholder/index.js +8 -2
  111. package/components/I18n/components/Placeholder/spec.js +30 -1
  112. package/components/I18n/components/Translate/index.js +68 -7
  113. package/components/I18n/components/Translate/spec.js +30 -1
  114. package/components/I18n/index.js +16 -1
  115. package/components/Icon/index.js +25 -2
  116. package/components/Icon/style.js +6 -1
  117. package/components/Image/Image.js +176 -19
  118. package/components/Image/ImageInner.js +48 -2
  119. package/components/Image/index.js +1 -1
  120. package/components/Image/style.js +29 -2
  121. package/components/InfiniteContainer/index.js +381 -49
  122. package/components/InfiniteContainer/spec.js +199 -10
  123. package/components/Input/components/DateInput.js +262 -6
  124. package/components/Input/components/MultiLineInput.js +98 -12
  125. package/components/Input/components/SimpleInput.js +207 -31
  126. package/components/Input/index.js +32 -3
  127. package/components/Input/spec.js +122 -1
  128. package/components/KeyboardConsumer/index.js +48 -7
  129. package/components/Link/connector.js +7 -1
  130. package/components/Link/index.js +96 -11
  131. package/components/Link/spec.js +56 -1
  132. package/components/Link/style.js +10 -1
  133. package/components/List/components/Item/index.js +35 -3
  134. package/components/List/components/Item/style.js +16 -1
  135. package/components/List/index.js +20 -2
  136. package/components/List/spec.js +31 -1
  137. package/components/Loading/index.js +6 -2
  138. package/components/Modal/index.js +38 -3
  139. package/components/Modal/style.js +36 -1
  140. package/components/ModalContainer/connector.js +17 -3
  141. package/components/ModalContainer/index.js +36 -3
  142. package/components/ModalContainer/spec.js +105 -5
  143. package/components/Picker/components/Button/index.js +34 -2
  144. package/components/Picker/components/Button/style.js +19 -1
  145. package/components/Picker/components/List/index.js +33 -2
  146. package/components/Picker/components/List/style.js +17 -1
  147. package/components/Picker/components/Modal/index.js +60 -7
  148. package/components/Picker/components/Modal/style.js +78 -1
  149. package/components/Picker/index.js +167 -21
  150. package/components/Picker/spec.js +83 -2
  151. package/components/Portal/index.js +130 -19
  152. package/components/ProductCharacteristics/connector.js +33 -4
  153. package/components/ProductCharacteristics/context.js +2 -1
  154. package/components/ProductCharacteristics/helpers/index.js +135 -21
  155. package/components/ProductCharacteristics/index.js +266 -31
  156. package/components/RangeSlider/components/Handle/index.js +25 -2
  157. package/components/RangeSlider/components/Handle/style.js +14 -1
  158. package/components/RangeSlider/helper.js +43 -8
  159. package/components/RangeSlider/index.js +228 -38
  160. package/components/RangeSlider/style.js +14 -1
  161. package/components/Route/RouteNotFound.js +46 -3
  162. package/components/Route/index.js +78 -10
  163. package/components/Router/connector.js +9 -2
  164. package/components/Router/index.js +237 -31
  165. package/components/ScannerContainer/connector.js +9 -2
  166. package/components/ScannerContainer/index.js +42 -6
  167. package/components/Select/components/Item/index.js +20 -4
  168. package/components/Select/components/Item/style.js +4 -1
  169. package/components/Select/index.js +149 -28
  170. package/components/Select/spec.js +86 -2
  171. package/components/Select/style.js +17 -1
  172. package/components/SelectBox/components/Item/index.js +47 -5
  173. package/components/SelectBox/components/Item/style.js +7 -1
  174. package/components/SelectBox/index.js +173 -17
  175. package/components/SelectBox/spec.js +59 -3
  176. package/components/SelectBox/style.js +18 -1
  177. package/components/Slider/index.js +6 -2
  178. package/components/SurroundPortals/index.js +26 -2
  179. package/components/Swiper/components/SwiperItem/index.js +28 -4
  180. package/components/Swiper/components/SwiperItem/spec.js +21 -1
  181. package/components/Swiper/components/SwiperItem/styles.js +5 -1
  182. package/components/Swiper/index.js +210 -18
  183. package/components/Swiper/styles.js +75 -7
  184. package/components/Toaster/index.js +10 -2
  185. package/components/Transition/index.js +89 -13
  186. package/components/Widgets/components/Widget/index.js +52 -4
  187. package/components/Widgets/components/Widget/spec.js +68 -3
  188. package/components/Widgets/components/Widget/style.js +21 -3
  189. package/components/Widgets/components/WidgetGrid/index.js +52 -7
  190. package/components/Widgets/components/WidgetGrid/spec.js +46 -2
  191. package/components/Widgets/components/WidgetGrid/style.js +8 -1
  192. package/components/Widgets/helpers/shouldShowWidget.js +44 -7
  193. package/components/Widgets/index.js +127 -15
  194. package/components/Widgets/spec.js +228 -6
  195. package/components/index.js +9 -1
  196. package/constants/ActionTypes.js +97 -19
  197. package/constants/Configuration.js +12 -2
  198. package/constants/Device.js +29 -2
  199. package/constants/DisplayOptions.js +8 -1
  200. package/constants/MenuIDs.js +2 -1
  201. package/constants/ModalTypes.js +1 -1
  202. package/constants/PageIDs.js +1 -1
  203. package/constants/Pipelines.js +7 -1
  204. package/constants/Portals.js +136 -3
  205. package/constants/Registration.js +3 -1
  206. package/constants/RoutePaths.js +13 -2
  207. package/constants/Tracking.js +3 -1
  208. package/constants/client.js +6 -1
  209. package/constants/ui.js +2 -1
  210. package/constants/user.js +6 -2
  211. package/context/index.js +33 -3
  212. package/helpers/config/index.js +139 -21
  213. package/helpers/config/mock.js +200 -8
  214. package/helpers/config/theme.js +50 -4
  215. package/helpers/data/index.js +204 -29
  216. package/helpers/data/spec.js +187 -7
  217. package/helpers/date/index.js +58 -6
  218. package/helpers/date/spec.js +92 -1
  219. package/helpers/dom/index.js +48 -11
  220. package/helpers/environment/index.js +14 -2
  221. package/helpers/html/decodeHTML.js +7 -1
  222. package/helpers/html/handleDOM.js +172 -21
  223. package/helpers/html/parseHTML.js +67 -12
  224. package/helpers/i18n/getDateFormatter.js +23 -4
  225. package/helpers/i18n/getNumberFormatter.js +32 -4
  226. package/helpers/i18n/getPriceFormatter.js +38 -4
  227. package/helpers/i18n/getTimeFormatter.js +23 -4
  228. package/helpers/i18n/getTranslator.js +62 -8
  229. package/helpers/i18n/index.js +5 -1
  230. package/helpers/i18n/mergeTranslations.js +36 -9
  231. package/helpers/i18n/messageCache.js +3 -1
  232. package/helpers/legacy/index.js +47 -9
  233. package/helpers/modal/withShowModal.js +13 -2
  234. package/helpers/portals/portalCollection.js +28 -6
  235. package/helpers/portals/routePortals.js +12 -1
  236. package/helpers/redux/compareObjects.js +7 -2
  237. package/helpers/redux/generateResultHash.js +36 -3
  238. package/helpers/redux/generateSortedHash.js +7 -2
  239. package/helpers/redux/hasExpired.js +10 -2
  240. package/helpers/redux/index.js +7 -1
  241. package/helpers/redux/mutable.js +143 -24
  242. package/helpers/redux/shouldFetchData.js +46 -10
  243. package/helpers/redux/shouldFetchFilters.js +17 -4
  244. package/helpers/router/index.js +49 -5
  245. package/helpers/style/index.js +43 -4
  246. package/helpers/style/spec.js +108 -2
  247. package/helpers/tracking/index.js +52 -9
  248. package/helpers/validation/index.js +39 -12
  249. package/helpers/validation/spec.js +10 -1
  250. package/package.json +3 -4
  251. package/providers/index.js +4 -1
  252. package/providers/loading/context.js +2 -1
  253. package/providers/loading/index.js +137 -22
  254. package/providers/toast/context.js +2 -1
  255. package/providers/toast/index.js +105 -11
  256. package/reducers/client/connectivity.js +22 -2
  257. package/reducers/client/index.js +7 -1
  258. package/reducers/client/info.js +27 -2
  259. package/reducers/index.js +23 -4
  260. package/reducers/menu/index.js +5 -1
  261. package/reducers/menu/menusById.js +41 -2
  262. package/reducers/modal/index.js +14 -2
  263. package/reducers/page/index.js +68 -5
  264. package/reducers/router/index.js +48 -2
  265. package/reducers/url/index.js +42 -3
  266. package/reducers/user/data.js +27 -2
  267. package/reducers/user/index.js +7 -1
  268. package/reducers/user/login.js +65 -2
  269. package/selectors/client.js +138 -21
  270. package/selectors/history.js +49 -11
  271. package/selectors/menu.js +34 -6
  272. package/selectors/modal.js +15 -4
  273. package/selectors/page.js +25 -4
  274. package/selectors/router.js +154 -30
  275. package/selectors/url.js +25 -4
  276. package/selectors/user.js +90 -13
  277. package/store/index.js +60 -6
  278. package/store/middelwares/logger.js +7 -1
  279. package/store/middelwares/streams.js +19 -2
  280. package/streams/app.js +60 -8
  281. package/streams/client.js +8 -2
  282. package/streams/error.js +14 -3
  283. package/streams/index.js +6 -1
  284. package/streams/interval.js +6 -2
  285. package/streams/main.js +27 -2
  286. package/streams/router.js +45 -8
  287. package/streams/user.js +89 -15
  288. package/streams/view.js +97 -25
  289. package/styles/reset/form.js +57 -5
  290. package/styles/reset/index.js +6 -1
  291. package/styles/reset/media.js +22 -1
  292. package/styles/reset/root.js +33 -1
  293. package/styles/reset/table.js +10 -1
  294. package/styles/reset/typography.js +26 -1
  295. package/subscriptions/app.js +148 -17
  296. package/subscriptions/error.js +292 -13
  297. package/subscriptions/helpers/buildRegisterUrl.js +25 -6
  298. package/subscriptions/helpers/clearUpInAppBrowser.js +14 -3
  299. package/subscriptions/helpers/handleLinks.js +267 -25
  300. package/subscriptions/helpers/pipeline.js +12 -1
  301. package/subscriptions/history.js +34 -6
  302. package/subscriptions/index.js +25 -4
  303. package/subscriptions/menu.js +22 -5
  304. package/subscriptions/mock.js +39 -7
  305. package/subscriptions/router.js +336 -23
  306. package/subscriptions/user.js +93 -3
@@ -1 +1,56 @@
1
- import React from'react';import{shallow,mount}from'enzyme';import{Disconnected as Link}from"./index";describe('<Link />',function(){var historyPush=jest.fn();var historyReplace=jest.fn();var pathname='/';var state={x:5};beforeEach(function(){jest.useFakeTimers();jest.clearAllMocks();});afterEach(function(){jest.useRealTimers();});it('renders with children',function(){var wrapper=shallow(React.createElement(Link,{href:pathname,historyPush:historyPush,historyReplace:historyReplace},React.createElement("span",null)));expect(wrapper).toMatchSnapshot();expect(wrapper.find('span').length).toBe(1);});it('handles a push',function(){var wrapper=mount(React.createElement(Link,{href:pathname,state:state,historyPush:historyPush,historyReplace:historyReplace},React.createElement("span",null)));wrapper.find('div').simulate('click');jest.runAllTimers();expect(historyPush).toHaveBeenLastCalledWith({pathname:pathname,state:state});});it('handles a replace',function(){var wrapper=mount(React.createElement(Link,{href:pathname,historyPush:historyPush,historyReplace:historyReplace,state:state,replace:true},React.createElement("span",null)));wrapper.find('div').simulate('click');jest.runAllTimers();expect(historyReplace).toHaveBeenLastCalledWith({pathname:pathname,state:state});});});
1
+ import React from 'react';
2
+ import { shallow, mount } from 'enzyme';
3
+ import { Disconnected as Link } from "./index";
4
+ describe('<Link />', () => {
5
+ const historyPush = jest.fn();
6
+ const historyReplace = jest.fn();
7
+ const pathname = '/';
8
+ const state = {
9
+ x: 5
10
+ };
11
+ beforeEach(() => {
12
+ jest.useFakeTimers();
13
+ jest.clearAllMocks();
14
+ });
15
+ afterEach(() => {
16
+ jest.useRealTimers();
17
+ });
18
+ it('renders with children', () => {
19
+ const wrapper = shallow(/*#__PURE__*/React.createElement(Link, {
20
+ href: pathname,
21
+ historyPush: historyPush,
22
+ historyReplace: historyReplace
23
+ }, /*#__PURE__*/React.createElement("span", null)));
24
+ expect(wrapper).toMatchSnapshot();
25
+ expect(wrapper.find('span').length).toBe(1);
26
+ });
27
+ it('handles a push', () => {
28
+ const wrapper = mount(/*#__PURE__*/React.createElement(Link, {
29
+ href: pathname,
30
+ state: state,
31
+ historyPush: historyPush,
32
+ historyReplace: historyReplace
33
+ }, /*#__PURE__*/React.createElement("span", null)));
34
+ wrapper.find('div').simulate('click');
35
+ jest.runAllTimers();
36
+ expect(historyPush).toHaveBeenLastCalledWith({
37
+ pathname,
38
+ state
39
+ });
40
+ });
41
+ it('handles a replace', () => {
42
+ const wrapper = mount(/*#__PURE__*/React.createElement(Link, {
43
+ href: pathname,
44
+ historyPush: historyPush,
45
+ historyReplace: historyReplace,
46
+ state: state,
47
+ replace: true
48
+ }, /*#__PURE__*/React.createElement("span", null)));
49
+ wrapper.find('div').simulate('click');
50
+ jest.runAllTimers();
51
+ expect(historyReplace).toHaveBeenLastCalledWith({
52
+ pathname,
53
+ state
54
+ });
55
+ });
56
+ });
@@ -1 +1,10 @@
1
- import{css}from'glamor';export default css({padding:0,margin:0,border:'none',textAlign:'left',alignItems:'stretch',width:'100%',cursor:'pointer'}).toString();
1
+ import { css } from 'glamor';
2
+ export default css({
3
+ padding: 0,
4
+ margin: 0,
5
+ border: 'none',
6
+ textAlign: 'left',
7
+ alignItems: 'stretch',
8
+ width: '100%',
9
+ cursor: 'pointer'
10
+ }).toString();
@@ -1,5 +1,37 @@
1
- import React from'react';import PropTypes from'prop-types';import styles from"./style";/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styles from "./style";
4
+
5
+ /**
2
6
  * The ListItem component.
3
7
  * @returns {JSX}
4
- */var ListItem=function ListItem(_ref){var children=_ref.children,className=_ref.className,isSelected=_ref.isSelected,role=_ref.role;if(!React.Children.count(children)){return null;}var classes=styles.item;if(className){classes+=" ".concat(className);}// Add selected or unselected styling.
5
- classes+=" common__list__list-item ".concat(isSelected?styles.selected:styles.unselected);return React.createElement("li",{className:classes,"data-test-id":"listItem",role:role},children);};ListItem.defaultProps={className:null,children:null,isSelected:false,role:null};export default ListItem;
8
+ */
9
+ const ListItem = ({
10
+ children,
11
+ className,
12
+ isSelected,
13
+ role
14
+ }) => {
15
+ if (!React.Children.count(children)) {
16
+ return null;
17
+ }
18
+ let classes = styles.item;
19
+ if (className) {
20
+ classes += ` ${className}`;
21
+ }
22
+
23
+ // Add selected or unselected styling.
24
+ classes += ` common__list__list-item ${isSelected ? styles.selected : styles.unselected}`;
25
+ return /*#__PURE__*/React.createElement("li", {
26
+ className: classes,
27
+ "data-test-id": "listItem",
28
+ role: role
29
+ }, children);
30
+ };
31
+ ListItem.defaultProps = {
32
+ className: null,
33
+ children: null,
34
+ isSelected: false,
35
+ role: null
36
+ };
37
+ export default ListItem;
@@ -1 +1,16 @@
1
- import{css}from'glamor';var item=css({display:'block',position:'relative'}).toString();var unselected=css({zIndex:1}).toString();var selected=css({zIndex:2}).toString();export default{item:item,selected:selected,unselected:unselected};
1
+ import { css } from 'glamor';
2
+ const item = css({
3
+ display: 'block',
4
+ position: 'relative'
5
+ }).toString();
6
+ const unselected = css({
7
+ zIndex: 1
8
+ }).toString();
9
+ const selected = css({
10
+ zIndex: 2
11
+ }).toString();
12
+ export default {
13
+ item,
14
+ selected,
15
+ unselected
16
+ };
@@ -1,5 +1,23 @@
1
- import React from'react';import PropTypes from'prop-types';import ListItem from"./components/Item";/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import ListItem from "./components/Item";
4
+
5
+ /**
2
6
  * The List component.
3
7
  * @param {Object} props The component props.
4
8
  * @returns {JSX}
5
- */var List=function List(_ref){var children=_ref.children,className=_ref.className,role=_ref.role;return React.createElement("ul",{className:"".concat(className," common_list"),role:role},children);};List.Item=ListItem;List.defaultProps={className:'',role:null};export default List;
9
+ */
10
+ const List = ({
11
+ children,
12
+ className,
13
+ role
14
+ }) => /*#__PURE__*/React.createElement("ul", {
15
+ className: `${className} common_list`,
16
+ role: role
17
+ }, children);
18
+ List.Item = ListItem;
19
+ List.defaultProps = {
20
+ className: '',
21
+ role: null
22
+ };
23
+ export default List;
@@ -1 +1,31 @@
1
- /* eslint-disable no-console */import React from'react';import{shallow}from'enzyme';import List from"./index";console.error=jest.fn();describe('<List />',function(){var children=[React.createElement(List.Item,{key:"0"}),React.createElement(List.Item,{key:"1"}),React.createElement(List.Item,{key:"2"})];beforeEach(function(){jest.clearAllMocks();});it('renders with children',function(){var numChildren=children.length;var wrapper=shallow(React.createElement(List,null,children));expect(wrapper).toMatchSnapshot();expect(wrapper.find(List.Item).length).toBe(numChildren);expect(console.error).not.toHaveBeenCalled();});it('renders without children',function(){var wrapper=shallow(React.createElement(List,null));expect(wrapper).toMatchSnapshot();expect(wrapper.find(List.Item).length).toBe(0);expect(console.error).toHaveBeenCalledTimes(1);});});/* eslint-enable no-console */
1
+ /* eslint-disable no-console */
2
+ import React from 'react';
3
+ import { shallow } from 'enzyme';
4
+ import List from "./index";
5
+ console.error = jest.fn();
6
+ describe('<List />', () => {
7
+ const children = [/*#__PURE__*/React.createElement(List.Item, {
8
+ key: "0"
9
+ }), /*#__PURE__*/React.createElement(List.Item, {
10
+ key: "1"
11
+ }), /*#__PURE__*/React.createElement(List.Item, {
12
+ key: "2"
13
+ })];
14
+ beforeEach(() => {
15
+ jest.clearAllMocks();
16
+ });
17
+ it('renders with children', () => {
18
+ const numChildren = children.length;
19
+ const wrapper = shallow(/*#__PURE__*/React.createElement(List, null, children));
20
+ expect(wrapper).toMatchSnapshot();
21
+ expect(wrapper.find(List.Item).length).toBe(numChildren);
22
+ expect(console.error).not.toHaveBeenCalled();
23
+ });
24
+ it('renders without children', () => {
25
+ const wrapper = shallow(/*#__PURE__*/React.createElement(List, null));
26
+ expect(wrapper).toMatchSnapshot();
27
+ expect(wrapper.find(List.Item).length).toBe(0);
28
+ expect(console.error).toHaveBeenCalledTimes(1);
29
+ });
30
+ });
31
+ /* eslint-enable no-console */
@@ -1,3 +1,7 @@
1
- import React,{Fragment}from'react';/**
1
+ import React, { Fragment } from 'react';
2
+
3
+ /**
2
4
  * @return {null}
3
- */var Loading=function Loading(){return React.createElement(Fragment,null,null);};export default Loading;
5
+ */
6
+ const Loading = () => /*#__PURE__*/React.createElement(Fragment, null, null);
7
+ export default Loading;
@@ -1,7 +1,42 @@
1
- var _excluded=["children","classes"];function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import React,{forwardRef}from'react';import PropTypes from'prop-types';import{createPortal}from'react-dom';import{useTrackModalState}from'@shopgate/engage/a11y/hooks';import classNames from'classnames';import styles from"./style";/**
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { forwardRef } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { createPortal } from 'react-dom';
5
+ import { useTrackModalState } from '@shopgate/engage/a11y/hooks';
6
+ import classNames from 'classnames';
7
+ import styles from "./style";
8
+
9
+ /**
2
10
  * The Modal component.
3
11
  * @param {Object} props The component props.
4
12
  * @param {Object} props.classes The component classes.
5
13
  * @returns {JSX.Element}
6
- */var Modal=forwardRef(function(_ref,ref){var children=_ref.children,classes=_ref.classes,props=_objectWithoutProperties(_ref,_excluded);// Track modal visibility for accessibility purposes.
7
- useTrackModalState();return createPortal(React.createElement("div",_extends({className:classNames(styles.container,classes===null||classes===void 0?void 0:classes.container,'common__modal'),role:"alertdialog","aria-modal":true},props,{ref:ref}),React.createElement("div",{className:classNames(styles.layout,classes===null||classes===void 0?void 0:classes.layout)},React.createElement("div",{className:classNames(styles.content,classes===null||classes===void 0?void 0:classes.content)},children))),document.getElementById('portals'));});Modal.defaultProps={children:null,classes:{container:'',layout:'',content:''}};export default Modal;
14
+ */
15
+ const Modal = /*#__PURE__*/forwardRef(({
16
+ children,
17
+ classes,
18
+ ...props
19
+ }, ref) => {
20
+ // Track modal visibility for accessibility purposes.
21
+ useTrackModalState();
22
+ return /*#__PURE__*/createPortal(/*#__PURE__*/React.createElement("div", _extends({
23
+ className: classNames(styles.container, classes?.container, 'common__modal'),
24
+ role: "alertdialog",
25
+ "aria-modal": true
26
+ }, props, {
27
+ ref: ref
28
+ }), /*#__PURE__*/React.createElement("div", {
29
+ className: classNames(styles.layout, classes?.layout)
30
+ }, /*#__PURE__*/React.createElement("div", {
31
+ className: classNames(styles.content, classes?.content)
32
+ }, children))), document.getElementById('portals'));
33
+ });
34
+ Modal.defaultProps = {
35
+ children: null,
36
+ classes: {
37
+ container: '',
38
+ layout: '',
39
+ content: ''
40
+ }
41
+ };
42
+ export default Modal;
@@ -1 +1,36 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{css}from'glamor';import{responsiveMediaQuery}from'@shopgate/engage/styles';var container=css({position:'fixed',top:0,bottom:0,left:0,right:0,overflow:'hidden',zIndex:2000}).toString();var layout=css({display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',height:'100%'}).toString();var content=css(_defineProperty({position:'relative',maxWidth:'100vw',maxHeight:'100vh',paddingTop:'var(--safe-area-inset-top)',paddingBottom:'var(--safe-area-inset-bottom)',overflowY:'scroll'},responsiveMediaQuery('>xs',{webOnly:true}),{overflowY:'initial'})).toString();export default{container:container,layout:layout,content:content};
1
+ import { css } from 'glamor';
2
+ import { responsiveMediaQuery } from '@shopgate/engage/styles';
3
+ const container = css({
4
+ position: 'fixed',
5
+ top: 0,
6
+ bottom: 0,
7
+ left: 0,
8
+ right: 0,
9
+ overflow: 'hidden',
10
+ zIndex: 2000
11
+ }).toString();
12
+ const layout = css({
13
+ display: 'flex',
14
+ flexDirection: 'column',
15
+ alignItems: 'center',
16
+ justifyContent: 'center',
17
+ height: '100%'
18
+ }).toString();
19
+ const content = css({
20
+ position: 'relative',
21
+ maxWidth: '100vw',
22
+ maxHeight: '100vh',
23
+ paddingTop: 'var(--safe-area-inset-top)',
24
+ paddingBottom: 'var(--safe-area-inset-bottom)',
25
+ overflowY: 'scroll',
26
+ [responsiveMediaQuery('>xs', {
27
+ webOnly: true
28
+ })]: {
29
+ overflowY: 'initial'
30
+ }
31
+ }).toString();
32
+ export default {
33
+ container,
34
+ layout,
35
+ content
36
+ };
@@ -1,9 +1,23 @@
1
- import{connect}from'react-redux';import closeModal from"../../actions/modal/closeModal";import{getFirstModal}from"../../selectors/modal";/**
1
+ import { connect } from 'react-redux';
2
+ import closeModal from "../../actions/modal/closeModal";
3
+ import { getFirstModal } from "../../selectors/modal";
4
+
5
+ /**
2
6
  * Maps the contents of the state to the component props.
3
7
  * @param {Object} state The current application state.
4
8
  * @return {Object} The extended component props.
5
- */var mapStateToProps=function mapStateToProps(state){return{modal:getFirstModal(state)};};/**
9
+ */
10
+ const mapStateToProps = state => ({
11
+ modal: getFirstModal(state)
12
+ });
13
+
14
+ /**
6
15
  * Connects the dispatch function to a callable function in the props.
7
16
  * @param {Function} dispatch The redux dispatch function.
8
17
  * @return {Object} The extended component props.
9
- */var mapDispatchToProps=function mapDispatchToProps(dispatch){return{confirm:function confirm(id){return dispatch(closeModal(id,true));},dismiss:function dismiss(id){return dispatch(closeModal(id,false));}};};export default connect(mapStateToProps,mapDispatchToProps);
18
+ */
19
+ const mapDispatchToProps = dispatch => ({
20
+ confirm: id => dispatch(closeModal(id, true)),
21
+ dismiss: id => dispatch(closeModal(id, false))
22
+ });
23
+ export default connect(mapStateToProps, mapDispatchToProps);
@@ -1,7 +1,40 @@
1
- import React from'react';import PropTypes from'prop-types';import connect from"./connector";export var MODAL_EVENTS={SHOW:'Modal.show',HIDE:'Modal.hide'};/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import connect from "./connector";
4
+ export const MODAL_EVENTS = {
5
+ SHOW: 'Modal.show',
6
+ HIDE: 'Modal.hide'
7
+ };
8
+
9
+ /**
2
10
  * The ModalContainer is connected to the modal state
3
11
  * and renders the currently active modal.
4
12
  * @param {Object} props The component props.
5
13
  * @returns {JSX.Element}
6
- */var ModalContainer=function ModalContainer(_ref){var component=_ref.component,confirm=_ref.confirm,dismiss=_ref.dismiss,modal=_ref.modal;if(!modal){return null;}var componentProps={modal:modal,// A11Y focus is handled by the modal container itself.
7
- onConfirm:function onConfirm(){return confirm(modal.id);},onDismiss:function onDismiss(){return dismiss(modal.id);}};if(React.isValidElement(component)){return React.cloneElement(component,componentProps);}return React.createElement(component,componentProps);};ModalContainer.defaultProps={confirm:function confirm(){},dismiss:function dismiss(){},modal:null};export default connect(ModalContainer);
14
+ */
15
+ const ModalContainer = ({
16
+ component,
17
+ confirm,
18
+ dismiss,
19
+ modal
20
+ }) => {
21
+ if (!modal) {
22
+ return null;
23
+ }
24
+ const componentProps = {
25
+ modal,
26
+ // A11Y focus is handled by the modal container itself.
27
+ onConfirm: () => confirm(modal.id),
28
+ onDismiss: () => dismiss(modal.id)
29
+ };
30
+ if (/*#__PURE__*/React.isValidElement(component)) {
31
+ return /*#__PURE__*/React.cloneElement(component, componentProps);
32
+ }
33
+ return /*#__PURE__*/React.createElement(component, componentProps);
34
+ };
35
+ ModalContainer.defaultProps = {
36
+ confirm: () => {},
37
+ dismiss: () => {},
38
+ modal: null
39
+ };
40
+ export default connect(ModalContainer);
@@ -1,11 +1,111 @@
1
- /* eslint-disable no-unused-vars */import React from'react';import{mount}from'enzyme';import{Provider}from'react-redux';import{configureStore}from"../../store";import modalReducer from"../../reducers/modal";import showModal from"../../actions/modal/showModal";import ModalContainer from"./index";// const store = configureStore({ modal: modalReducer });
1
+ /* eslint-disable no-unused-vars */
2
+ import React from 'react';
3
+ import { mount } from 'enzyme';
4
+ import { Provider } from 'react-redux';
5
+ import { configureStore } from "../../store";
6
+ import modalReducer from "../../reducers/modal";
7
+ import showModal from "../../actions/modal/showModal";
8
+ import ModalContainer from "./index";
9
+
10
+ // const store = configureStore({ modal: modalReducer });
2
11
  // Replacement for commented out configureStore()
3
- var store={};jest.mock('redux-logger',function(){return{createLogger:function createLogger(){return function(){return function(next){return function(action){return next(action);};};};}};});global.requestAnimationFrame=function(fn){return fn();};/**
12
+ const store = {};
13
+ jest.mock('redux-logger', () => ({
14
+ createLogger: () => () => next => action => next(action)
15
+ }));
16
+ global.requestAnimationFrame = fn => fn();
17
+
18
+ /**
4
19
  * Some mock modal component.
5
20
  * @param {func} onConfirm Confirm callback
6
21
  * @param {func} onDismiss Dismiss callback
7
22
  * @constructor
8
- */var MockModal=function MockModal(_ref){var onConfirm=_ref.onConfirm,onDismiss=_ref.onDismiss;return React.createElement("div",{className:"modal"},React.createElement("button",{className:"confirmBtn",onClick:onConfirm,type:"button"}),React.createElement("button",{className:"dismissBtn",onClick:onDismiss,type:"button"}));};describe.skip('<ModalContainer />',function(){var renderedElement;var dispatch=store.dispatch,getState=store.getState;/**
23
+ */
24
+ const MockModal = ({
25
+ onConfirm,
26
+ // eslint-disable-line react/prop-types
27
+ onDismiss // eslint-disable-line react/prop-types
28
+ }) => /*#__PURE__*/React.createElement("div", {
29
+ className: "modal"
30
+ }, /*#__PURE__*/React.createElement("button", {
31
+ className: "confirmBtn",
32
+ onClick: onConfirm,
33
+ type: "button"
34
+ }), /*#__PURE__*/React.createElement("button", {
35
+ className: "dismissBtn",
36
+ onClick: onDismiss,
37
+ type: "button"
38
+ }));
39
+ describe.skip('<ModalContainer />', () => {
40
+ let renderedElement;
41
+ const {
42
+ dispatch,
43
+ getState
44
+ } = store;
45
+
46
+ /**
9
47
  * The rendered component.
10
- */var renderComponent=function renderComponent(){renderedElement=mount(React.createElement(Provider,{store:store},React.createElement("div",{id:"container"},React.createElement(ModalContainer,{component:MockModal}))));};beforeEach(function(){// Reset the modals state before each test.
11
- getState().modal=[];renderComponent();});describe('Given the component was mounted to the DOM',function(){it('should match snapshot',function(){expect(renderedElement).toMatchSnapshot();});it('should show no modal',function(){expect(renderedElement.find('.modal').length).toBe(0);});describe('Given a modal gets dispatched',function(){var modalPromise;beforeEach(function(){modalPromise=dispatch(showModal({title:'Title',message:'Message'}));renderedElement.update();});it('should contain a modal item in the state',function(){expect(getState().modal.length).toBe(1);});it('should show the modal',function(){expect(renderedElement.find('.modal').length).toBe(1);});describe('Given the modal gets confirmed',function(){beforeEach(function(){renderedElement.find('.confirmBtn').simulate('click');});it('should resolve the promise as confirmed',function(){modalPromise.then(function(confirmed){return expect(confirmed).toBe(true);});});it('should contain no modal item in the state',function(){expect(getState().modal.length).toBe(0);});it('should not show the modal anymore',function(){expect(renderedElement.find('.modal').length).toBe(0);});});describe('Given the modal gets dismissed',function(){beforeEach(function(){renderedElement.find('.dismissBtn').simulate('click');});it('should resolve the promise as dismissed',function(){modalPromise.then(function(confirmed){return expect(confirmed).toBe(false);});});});});});});/* eslint-enable no-unused-vars */
48
+ */
49
+ const renderComponent = () => {
50
+ renderedElement = mount(/*#__PURE__*/React.createElement(Provider, {
51
+ store: store
52
+ }, /*#__PURE__*/React.createElement("div", {
53
+ id: "container"
54
+ }, /*#__PURE__*/React.createElement(ModalContainer, {
55
+ component: MockModal
56
+ }))));
57
+ };
58
+ beforeEach(() => {
59
+ // Reset the modals state before each test.
60
+ getState().modal = [];
61
+ renderComponent();
62
+ });
63
+ describe('Given the component was mounted to the DOM', () => {
64
+ it('should match snapshot', () => {
65
+ expect(renderedElement).toMatchSnapshot();
66
+ });
67
+ it('should show no modal', () => {
68
+ expect(renderedElement.find('.modal').length).toBe(0);
69
+ });
70
+ describe('Given a modal gets dispatched', () => {
71
+ let modalPromise;
72
+ beforeEach(() => {
73
+ modalPromise = dispatch(showModal({
74
+ title: 'Title',
75
+ message: 'Message'
76
+ }));
77
+ renderedElement.update();
78
+ });
79
+ it('should contain a modal item in the state', () => {
80
+ expect(getState().modal.length).toBe(1);
81
+ });
82
+ it('should show the modal', () => {
83
+ expect(renderedElement.find('.modal').length).toBe(1);
84
+ });
85
+ describe('Given the modal gets confirmed', () => {
86
+ beforeEach(() => {
87
+ renderedElement.find('.confirmBtn').simulate('click');
88
+ });
89
+ it('should resolve the promise as confirmed', () => {
90
+ modalPromise.then(confirmed => expect(confirmed).toBe(true));
91
+ });
92
+ it('should contain no modal item in the state', () => {
93
+ expect(getState().modal.length).toBe(0);
94
+ });
95
+ it('should not show the modal anymore', () => {
96
+ expect(renderedElement.find('.modal').length).toBe(0);
97
+ });
98
+ });
99
+ describe('Given the modal gets dismissed', () => {
100
+ beforeEach(() => {
101
+ renderedElement.find('.dismissBtn').simulate('click');
102
+ });
103
+ it('should resolve the promise as dismissed', () => {
104
+ modalPromise.then(confirmed => expect(confirmed).toBe(false));
105
+ });
106
+ });
107
+ });
108
+ });
109
+ });
110
+
111
+ /* eslint-enable no-unused-vars */
@@ -1,4 +1,36 @@
1
- import React from'react';import PropTypes from'prop-types';import styles from"./style";/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styles from "./style";
4
+
5
+ /**
2
6
  * The default button for the Picker component.
3
7
  * @returns {JSX} The button component.
4
- */var PickerButton=function PickerButton(_ref){var value=_ref.value,label=_ref.label,openList=_ref.openList;if(value!==null){return React.createElement("button",{className:styles.button,onClick:openList,type:"button"},React.createElement("span",{className:styles.label},label),React.createElement("span",{className:styles.value},value));}return React.createElement("button",{className:styles.button,onClick:openList,type:"button"},React.createElement("span",{className:styles.label},label));};PickerButton.defaultProps={value:null};export default PickerButton;
8
+ */
9
+ const PickerButton = ({
10
+ value,
11
+ label,
12
+ openList
13
+ }) => {
14
+ if (value !== null) {
15
+ return /*#__PURE__*/React.createElement("button", {
16
+ className: styles.button,
17
+ onClick: openList,
18
+ type: "button"
19
+ }, /*#__PURE__*/React.createElement("span", {
20
+ className: styles.label
21
+ }, label), /*#__PURE__*/React.createElement("span", {
22
+ className: styles.value
23
+ }, value));
24
+ }
25
+ return /*#__PURE__*/React.createElement("button", {
26
+ className: styles.button,
27
+ onClick: openList,
28
+ type: "button"
29
+ }, /*#__PURE__*/React.createElement("span", {
30
+ className: styles.label
31
+ }, label));
32
+ };
33
+ PickerButton.defaultProps = {
34
+ value: null
35
+ };
36
+ export default PickerButton;
@@ -1 +1,19 @@
1
- import{css}from'glamor';var button=css({display:'block',width:'100%',textAlign:'left',padding:'10px 20px'}).toString();var label=css({display:'block'}).toString();var value=css({display:'block',fontWeight:'bold'}).toString();export default{button:button,label:label,value:value};
1
+ import { css } from 'glamor';
2
+ const button = css({
3
+ display: 'block',
4
+ width: '100%',
5
+ textAlign: 'left',
6
+ padding: '10px 20px'
7
+ }).toString();
8
+ const label = css({
9
+ display: 'block'
10
+ }).toString();
11
+ const value = css({
12
+ display: 'block',
13
+ fontWeight: 'bold'
14
+ }).toString();
15
+ export default {
16
+ button,
17
+ label,
18
+ value
19
+ };
@@ -1,4 +1,35 @@
1
- function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React from'react';import PropTypes from'prop-types';import classNames from'classnames';import styles from"./style";/**
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+ import styles from "./style";
5
+
6
+ /**
2
7
  * The default button for the Picker component.
3
8
  * @returns {JSX} The button component.
4
- */var PickerList=function PickerList(_ref){var items=_ref.items,onClose=_ref.onClose,onSelect=_ref.onSelect,selectedIndex=_ref.selectedIndex;return React.createElement("ul",{className:"common__picker__list"},items.map(function(item,currentIndex){return React.createElement("li",{key:item.value,className:classNames(_defineProperty({},styles.active,currentIndex===selectedIndex))},React.createElement("button",{className:styles.button,disabled:item.disabled,onClick:function onClick(){onSelect(item.value);onClose();},type:"button"},item.label));}));};PickerList.defaultProps={onClose:function onClose(){},selectedIndex:null};export default PickerList;
9
+ */
10
+ const PickerList = ({
11
+ items,
12
+ onClose,
13
+ onSelect,
14
+ selectedIndex
15
+ }) => /*#__PURE__*/React.createElement("ul", {
16
+ className: "common__picker__list"
17
+ }, items.map((item, currentIndex) => /*#__PURE__*/React.createElement("li", {
18
+ key: item.value,
19
+ className: classNames({
20
+ [styles.active]: currentIndex === selectedIndex
21
+ })
22
+ }, /*#__PURE__*/React.createElement("button", {
23
+ className: styles.button,
24
+ disabled: item.disabled,
25
+ onClick: () => {
26
+ onSelect(item.value);
27
+ onClose();
28
+ },
29
+ type: "button"
30
+ }, item.label))));
31
+ PickerList.defaultProps = {
32
+ onClose: () => {},
33
+ selectedIndex: null
34
+ };
35
+ export default PickerList;
@@ -1 +1,17 @@
1
- import{css}from'glamor';var button=css({display:'block',width:'100%',padding:'10px 20px',outline:'none',textAlign:'left'}).toString();var active=css({button:{fontWeight:'bold'}}).toString();export default{button:button,active:active};
1
+ import { css } from 'glamor';
2
+ const button = css({
3
+ display: 'block',
4
+ width: '100%',
5
+ padding: '10px 20px',
6
+ outline: 'none',
7
+ textAlign: 'left'
8
+ }).toString();
9
+ const active = css({
10
+ button: {
11
+ fontWeight: 'bold'
12
+ }
13
+ }).toString();
14
+ export default {
15
+ button,
16
+ active
17
+ };