@shopgate/engage 7.12.3 → 7.20.0-beta.1

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 (419) hide show
  1. package/a11y/components/Section/index.js +2 -2
  2. package/a11y/components/VisuallyHidden/index.js +8 -0
  3. package/a11y/components/index.js +1 -0
  4. package/a11y/constants/index.js +1 -0
  5. package/a11y/helpers/index.js +1 -0
  6. package/a11y/index.js +1 -4
  7. package/account/actions/addContacts.js +1 -1
  8. package/account/actions/deleteContact.js +1 -1
  9. package/account/actions/deleteCustomer.js +1 -1
  10. package/account/actions/fetchContacts.js +1 -1
  11. package/account/actions/fetchCustomer.js +1 -1
  12. package/account/actions/updateContact.js +1 -1
  13. package/account/actions/updateCustomer.js +1 -1
  14. package/account/components/Account/Account.style.js +1 -1
  15. package/account/components/Profile/Profile.provider.js +3 -3
  16. package/account/components/ProfileContact/ProfileContact.js +1 -1
  17. package/app-rating/action-creators/appStart.js +3 -3
  18. package/app-rating/action-creators/ordersPlaced.js +3 -3
  19. package/app-rating/action-creators/popup.js +4 -4
  20. package/app-rating/action-creators/timer.js +3 -3
  21. package/app-rating/actions/showModal.js +6 -6
  22. package/app-rating/constants/index.js +2 -2
  23. package/app-rating/reducers/index.js +2 -2
  24. package/app-rating/subscriptions/index.js +4 -4
  25. package/back-in-stock/actions/index.js +14 -0
  26. package/back-in-stock/components/BackInStockButton/connector.js +1 -0
  27. package/back-in-stock/components/BackInStockButton/index.js +14 -0
  28. package/back-in-stock/components/BackInStockButton/style.js +1 -0
  29. package/back-in-stock/components/CharacteristicsButton/connector.js +3 -0
  30. package/back-in-stock/components/CharacteristicsButton/index.js +8 -0
  31. package/back-in-stock/components/ProductInfoBackInStockButton/connector.js +3 -0
  32. package/back-in-stock/components/ProductInfoBackInStockButton/index.js +10 -0
  33. package/back-in-stock/components/Subscriptions/components/List/index.js +4 -0
  34. package/back-in-stock/components/Subscriptions/components/Subscription/index.js +7 -0
  35. package/back-in-stock/components/Subscriptions/index.js +4 -0
  36. package/back-in-stock/components/index.js +1 -0
  37. package/back-in-stock/constants/Actions.js +1 -0
  38. package/back-in-stock/constants/Common.js +1 -0
  39. package/back-in-stock/constants/Pipelines.js +1 -0
  40. package/back-in-stock/constants/Portals.js +9 -0
  41. package/back-in-stock/constants/index.js +1 -0
  42. package/back-in-stock/hooks/index.js +4 -0
  43. package/back-in-stock/providers/BackInStockSubscriptionsProvider.connector.js +7 -0
  44. package/back-in-stock/providers/BackInStockSubscriptionsProvider.context.js +1 -0
  45. package/back-in-stock/providers/BackInStockSubscriptionsProvider.js +5 -0
  46. package/back-in-stock/providers/index.js +1 -0
  47. package/back-in-stock/reducers/index.js +5 -0
  48. package/back-in-stock/selectors/index.js +43 -0
  49. package/back-in-stock/streams/index.js +1 -0
  50. package/back-in-stock/subscriptions/index.js +11 -0
  51. package/cart/cart.helpers.js +2 -2
  52. package/cart/components/CartItem/CartItemCoupon.js +10 -6
  53. package/cart/components/CartItem/CartItemCouponCode.js +2 -2
  54. package/cart/components/CartItem/CartItemCouponDelete.js +1 -1
  55. package/cart/components/CartItem/CartItemCouponFreeShipping.js +1 -1
  56. package/cart/components/CartItem/CartItemCouponIcon.js +2 -2
  57. package/cart/components/CartItem/CartItemCouponLayout.style.js +5 -1
  58. package/cart/components/CartItem/CartItemCouponTitle.js +2 -2
  59. package/cart/components/CartItem/CartItemProductLayout.js +3 -2
  60. package/cart/components/CartItem/CartItemProductLayoutWide.style.js +1 -1
  61. package/cart/components/CartItem/CartItemProductTitle.js +2 -2
  62. package/cart/components/CartItem/CartItemQuantityPicker.js +26 -14
  63. package/cart/components/CartItem/CartItemSubstitution.js +1 -1
  64. package/cart/components/CartItems/CartItemCardReservation.js +1 -1
  65. package/cart/components/CartItems/CartItemGroupReservation.js +1 -1
  66. package/cart/components/CartSummaryWide/CartSummaryWideCheckoutButton.style.js +1 -1
  67. package/cart/components/PaymentBar/PaymentBar.js +1 -1
  68. package/cart/components/PaymentBar/PaymentBarCheckoutButton.style.js +1 -1
  69. package/cart/components/PaymentBar/PaymentBarPromotionCouponMessages.js +1 -1
  70. package/cart/index.js +1 -1
  71. package/category/actions/index.js +1 -0
  72. package/category/components/CategoryList/index.js +7 -0
  73. package/category/components/CategoryList/style.js +1 -0
  74. package/category/components/index.js +1 -1
  75. package/category/constants/index.js +1 -0
  76. package/category/helpers/index.js +1 -0
  77. package/category/index.js +1 -6
  78. package/category/selectors/index.js +2 -0
  79. package/category/streams/index.js +1 -1
  80. package/checkout/actions/errorCheckout.js +1 -1
  81. package/checkout/actions/fetchCheckoutOrder.js +1 -1
  82. package/checkout/actions/fetchPaymentMethods.js +1 -1
  83. package/checkout/actions/initializeCheckout.js +1 -1
  84. package/checkout/actions/prepareCheckout.js +2 -2
  85. package/checkout/actions/submitCheckoutOrder.js +1 -1
  86. package/checkout/actions/updateCheckoutOrder.js +1 -1
  87. package/checkout/components/Checkout/CheckoutSectionMessages.js +1 -1
  88. package/checkout/components/CheckoutConfirmation/CheckoutConfirmation.js +1 -1
  89. package/checkout/components/CheckoutConfirmation/CheckoutConfirmationBilledTo.js +1 -1
  90. package/checkout/components/PaymentMethodButton/PaymentMethodButton.js +1 -1
  91. package/checkout/components/ShippingMethods/ShippingMethods.js +4 -4
  92. package/checkout/paymentMethods/index.js +2 -2
  93. package/checkout/paymentMethods/paypal/PaypalButtonApp.js +1 -1
  94. package/checkout/paymentMethods/paypal/PaypalButtonWeb.js +1 -1
  95. package/checkout/paymentMethods/paypal/PaypalPayButton.js +1 -1
  96. package/checkout/paymentMethods/paypal/PaypalProvider.js +1 -1
  97. package/checkout/paymentMethods/stripe/StripeButton.js +2 -2
  98. package/checkout/paymentMethods/stripe/StripeCreditCard.js +3 -3
  99. package/checkout/paymentMethods/stripe/StripeProvider.js +8 -8
  100. package/checkout/paymentMethods/stripe/sdk.js +1 -1
  101. package/checkout/providers/AddressBookProvider.js +1 -1
  102. package/checkout/providers/CheckoutProvider.js +8 -8
  103. package/components/ChipLayout/index.js +38 -0
  104. package/components/ChipLayout/spec.js +5 -0
  105. package/components/ChipLayout/style.js +5 -0
  106. package/components/Footer/Footer.js +7 -7
  107. package/components/Form/Builder/Builder.js +50 -29
  108. package/components/Form/Builder/ElementCheckbox.js +1 -1
  109. package/components/Form/Builder/ElementMultiSelect.js +1 -1
  110. package/components/Form/Builder/ElementPhoneNumber.js +3 -3
  111. package/components/Form/Builder/ElementRadio.js +1 -1
  112. package/components/Form/Builder/ElementSelect.js +1 -1
  113. package/components/Form/Builder/ElementText.js +3 -3
  114. package/components/Form/Builder/classes/ActionListener.constants.js +2 -2
  115. package/components/Form/Builder/classes/ActionListener.js +73 -16
  116. package/components/Form/Builder/helpers/buildFormElements.js +2 -2
  117. package/components/Form/Form.js +8 -5
  118. package/components/IntersectionVisibility/index.js +14 -7
  119. package/components/Logo/connector.js +4 -0
  120. package/components/Logo/index.js +4 -0
  121. package/components/Logo/spec.js +1 -0
  122. package/components/Logo/style.js +1 -0
  123. package/components/Menu/components/Position/index.js +5 -5
  124. package/components/Menu/index.js +9 -9
  125. package/components/MessageBar/MessageBar.js +1 -1
  126. package/components/MessageBar/index.js +1 -1
  127. package/components/NavigationHandler/index.js +4 -4
  128. package/components/NavigationHandler/spec.js +1 -1
  129. package/components/Picker/components/Button/index.js +1 -1
  130. package/components/Picker/components/List/index.js +2 -2
  131. package/components/Picker/components/Modal/index.js +7 -7
  132. package/components/Picker/index.js +18 -9
  133. package/components/PickerUtilize/components/Button/index.js +5 -0
  134. package/components/PickerUtilize/components/Button/style.js +1 -0
  135. package/components/PickerUtilize/index.js +17 -0
  136. package/components/PickerUtilize/spec.js +1 -0
  137. package/components/PickerUtilize/style.js +1 -0
  138. package/components/QuantityInput/QuantityInput.js +2 -2
  139. package/components/Radio/Radio.js +1 -1
  140. package/components/RadioCard/RadioCard.js +1 -1
  141. package/components/RangeSlider/components/Handle/index.js +1 -1
  142. package/components/RangeSlider/index.js +36 -24
  143. package/components/SheetList/components/Item/index.js +5 -5
  144. package/components/SheetList/index.js +4 -4
  145. package/components/SideNavigation/SideNavigationCategories.connector.js +2 -2
  146. package/components/SnackBarContainer/index.js +5 -0
  147. package/components/Switch/index.js +12 -0
  148. package/components/Switch/style.js +1 -0
  149. package/components/Tabs/components/TabIndicator.js +2 -2
  150. package/components/Tabs/components/Tabs.js +1 -1
  151. package/components/TimeBoundary/index.js +8 -6
  152. package/components/VideoPlayer/index.js +9 -6
  153. package/components/View/components/Above/index.js +1 -1
  154. package/components/View/components/Below/index.js +1 -1
  155. package/components/View/components/Content/index.js +18 -11
  156. package/components/View/index.js +1 -1
  157. package/components/View/provider.js +22 -5
  158. package/components/index.js +2 -2
  159. package/core/action-creators/app.js +5 -0
  160. package/core/action-creators/appPermissions.js +9 -0
  161. package/core/action-creators/index.js +1 -1
  162. package/core/actions/getGeolocation.js +2 -2
  163. package/core/actions/grantAppTrackingTransparencyPermission.js +6 -0
  164. package/core/actions/grantCameraPermissions.js +1 -1
  165. package/core/actions/grantGeolocationPermissions.js +1 -1
  166. package/core/actions/grantPermissions.js +13 -6
  167. package/core/actions/grantPushPermissions.js +22 -0
  168. package/core/actions/index.js +7 -0
  169. package/core/actions/requestAppPermission.js +12 -0
  170. package/core/actions/requestAppPermissionStatus.js +12 -0
  171. package/core/classes/GeolocationRequest.js +2 -3
  172. package/core/classes/GeolocationRequestApp.js +6 -6
  173. package/core/classes/GeolocationRequestBrowser.js +2 -2
  174. package/core/classes/index.js +1 -0
  175. package/core/collections/AppInitialization.js +49 -0
  176. package/core/collections/index.js +1 -0
  177. package/core/commands/analyticsSetConsent.js +11 -0
  178. package/core/commands/index.js +1 -0
  179. package/core/config/ThemeConfigResolver.js +2 -2
  180. package/core/config/config.action-creators.js +1 -1
  181. package/core/config/config.actions.js +1 -1
  182. package/core/config/config.reducers.js +1 -1
  183. package/core/config/config.subscriptions.js +2 -2
  184. package/core/config/index.js +1 -1
  185. package/core/constants/actionTypes.js +1 -0
  186. package/core/constants/appFeatures.js +1 -0
  187. package/core/constants/index.js +6 -1
  188. package/core/contexts/index.js +1 -0
  189. package/core/helpers/appFeatures.js +14 -0
  190. package/core/helpers/appPermissions.js +43 -6
  191. package/core/helpers/baseUrl.js +14 -0
  192. package/core/helpers/environment.js +4 -0
  193. package/core/helpers/getFullImageSource.js +1 -1
  194. package/core/helpers/i18n.js +5 -3
  195. package/core/helpers/index.js +7 -0
  196. package/core/hocs/index.js +1 -0
  197. package/core/hocs/withCurrentProduct.js +6 -6
  198. package/core/hocs/withTheme.js +2 -2
  199. package/core/hooks/index.js +1 -0
  200. package/core/hooks/useAsyncMemo.js +1 -1
  201. package/core/hooks/useFormState.js +1 -1
  202. package/core/hooks/useScrollTo.js +1 -1
  203. package/core/hooks/useTheme.js +2 -2
  204. package/core/index.js +5 -52
  205. package/core/initialization/index.js +4 -2
  206. package/core/providers/AppProvider.js +10 -8
  207. package/core/providers/index.js +1 -0
  208. package/core/reducers/app.js +6 -0
  209. package/core/reducers/index.js +1 -1
  210. package/core/reducers/merchantSettings.js +1 -1
  211. package/core/reducers/shopSettings.js +1 -1
  212. package/core/selectors/app.js +9 -0
  213. package/core/selectors/index.js +6 -1
  214. package/core/streams/app.js +8 -0
  215. package/core/streams/appPermissions.js +19 -0
  216. package/core/streams/index.js +4 -0
  217. package/core/subscriptions/app.js +7 -0
  218. package/favorites/components/Item/Item.js +5 -5
  219. package/favorites/components/List/List.js +1 -1
  220. package/favorites/components/Lists/Lists.js +4 -4
  221. package/filter/components/PriceSlider/index.js +9 -9
  222. package/filter/helpers/buildFilterParamsForFetchFiltersRequest.js +9 -0
  223. package/filter/helpers/buildUpdatedFilters.js +1 -1
  224. package/filter/helpers/index.js +1 -0
  225. package/filter/helpers/translateFilterLabel.js +6 -0
  226. package/filter/index.js +1 -1
  227. package/filter/providers/SortProvider.helpers.js +1 -1
  228. package/locations/actions/fetchFulfillmentSlots.js +5 -3
  229. package/locations/actions/fetchInventories.js +5 -4
  230. package/locations/actions/fetchLocations.js +18 -3
  231. package/locations/actions/fetchProductInventories.js +4 -2
  232. package/locations/actions/fetchProductLocations.js +9 -2
  233. package/locations/actions/index.js +1 -1
  234. package/locations/actions/setUserGeolocation.js +1 -1
  235. package/locations/actions/setUserSearchGeolocation.js +1 -1
  236. package/locations/actions/submitReservation.js +2 -2
  237. package/locations/components/Cart/CartContextMenuChangeFulfillmentContent.js +1 -1
  238. package/locations/components/FulfillmentPath/FulfillmentPath.js +1 -1
  239. package/locations/components/FulfillmentPath/FulfillmentPathItem.js +2 -2
  240. package/locations/components/FulfillmentSelector/FulfillmentSelectorAddToCart.js +2 -2
  241. package/locations/components/FulfillmentSelector/FulfillmentSelectorAlternativeLocation.js +1 -1
  242. package/locations/components/FulfillmentSheet/FulfillmentSheet.js +2 -2
  243. package/locations/components/FulfillmentSlotSwitcher/FulfillmentSlotDialog.js +1 -1
  244. package/locations/components/ReserveForm/ReserveForm.js +1 -1
  245. package/locations/components/ReserveForm/ReserveFormPhone.js +1 -1
  246. package/locations/components/StockInfo/StockInfo.defaultSettings.js +1 -1
  247. package/locations/components/StoreFinder/StoreFinderMap.style.js +2 -2
  248. package/locations/components/StoreList/StoreListSearch.js +2 -2
  249. package/locations/locations.streams.js +1 -1
  250. package/locations/providers/FulfillmentProvider.js +4 -4
  251. package/locations/providers/StoreFinderProvider.js +1 -1
  252. package/locations/reducers/storage.js +3 -3
  253. package/locations/selectors/index.js +2 -2
  254. package/locations/subscriptions.js +13 -13
  255. package/login/components/ForgotPassword/ForgotPassword.js +1 -1
  256. package/orders/actions/cancelOrder.js +1 -1
  257. package/orders/actions/fetchOrderDetails.js +1 -1
  258. package/orders/constants/status.js +2 -2
  259. package/orders/providers/OrderDetailsPrivateProvider.js +1 -1
  260. package/orders/providers/OrderDetailsProvider.js +3 -3
  261. package/package.json +8 -8
  262. package/page/actions/index.js +1 -0
  263. package/page/components/index.js +1 -0
  264. package/page/constants/index.js +1 -0
  265. package/page/index.js +2 -4
  266. package/page/selectors/index.js +1 -0
  267. package/product/collections/index.js +1 -0
  268. package/product/components/Availability/Availability.connector.js +4 -5
  269. package/product/components/Availability/Availability.js +3 -3
  270. package/product/components/Characteristics/Characteristic/components/Sheet/index.js +20 -0
  271. package/product/components/Characteristics/Characteristic/components/SheetItem/index.js +10 -0
  272. package/product/components/Characteristics/Characteristic/components/SheetItem/style.js +1 -0
  273. package/product/components/Characteristics/Characteristic/index.js +18 -0
  274. package/product/components/Characteristics/Characteristic/style.js +1 -0
  275. package/product/components/Characteristics/Swatch/index.js +12 -0
  276. package/product/components/Characteristics/Swatch/style.js +1 -0
  277. package/product/components/Characteristics/index.js +12 -0
  278. package/product/components/Characteristics/transition.js +1 -0
  279. package/product/components/Description/index.js +2 -2
  280. package/product/components/EffectivityDates/helpers.js +3 -3
  281. package/product/components/EffectivityDates/index.js +1 -1
  282. package/product/components/Header/PriceStriked/connector.js +9 -0
  283. package/product/components/Header/PriceStriked/index.js +5 -0
  284. package/product/components/Header/PriceStriked/style.js +1 -0
  285. package/product/components/Header/Shipping/components/Label/index.js +6 -0
  286. package/product/components/Header/Shipping/components/Label/style.js +1 -0
  287. package/product/components/Header/Shipping/connector.js +9 -0
  288. package/product/components/Header/Shipping/index.js +5 -0
  289. package/product/components/Header/Shipping/mock.js +1 -0
  290. package/product/components/Header/Shipping/spec.js +5 -0
  291. package/product/components/Header/Shipping/style.js +1 -0
  292. package/product/components/Header/Tiers/components/Tier/index.js +6 -0
  293. package/product/components/Header/Tiers/components/Tier/spec.js +1 -0
  294. package/product/components/Header/Tiers/connector.js +10 -0
  295. package/product/components/Header/Tiers/index.js +5 -0
  296. package/product/components/Header/Tiers/spec.js +1 -0
  297. package/product/components/Header/Tiers/style.js +1 -0
  298. package/product/components/Header/index.js +1 -0
  299. package/product/components/MapPriceHint/index.js +1 -1
  300. package/product/components/Media/FeaturedMedia.js +1 -1
  301. package/product/components/MediaSlider/index.js +1 -1
  302. package/product/components/Options/components/Content/connector.js +10 -0
  303. package/product/components/Options/components/Content/index.js +16 -0
  304. package/product/components/Options/components/Content/spec.js +2 -0
  305. package/product/components/Options/components/Option/index.js +4 -0
  306. package/product/components/Options/components/TextOption/components/OptionInfo/index.js +9 -0
  307. package/product/components/Options/components/TextOption/components/OptionInfo/spec.js +1 -0
  308. package/product/components/Options/components/TextOption/components/OptionInfo/style.js +1 -0
  309. package/product/components/Options/components/TextOption/index.js +22 -0
  310. package/product/components/Options/components/TextOption/style.js +1 -0
  311. package/product/components/Options/index.js +5 -0
  312. package/product/components/OrderQuantityHint/index.js +3 -2
  313. package/product/components/OrderQuantityHint/style.js +1 -1
  314. package/product/components/PriceDifference/index.js +1 -1
  315. package/product/components/ProductCard/index.js +2 -2
  316. package/product/components/ProductCharacteristics/helpers/index.js +1 -1
  317. package/product/components/ProductCharacteristics/index.js +28 -12
  318. package/product/components/ProductDiscountBadge/spec.js +1 -1
  319. package/product/components/ProductGridPrice/index.js +2 -2
  320. package/product/components/ProductImage/index.js +15 -12
  321. package/product/components/ProductList/components/Item/index.js +5 -0
  322. package/product/components/ProductList/components/Item/style.js +2 -0
  323. package/product/components/ProductList/components/Iterator/index.js +5 -0
  324. package/product/components/ProductList/components/Iterator/style.js +1 -0
  325. package/product/components/ProductList/components/Layout/index.js +5 -0
  326. package/product/components/ProductList/components/Layout/style.js +1 -0
  327. package/product/components/ProductList/index.js +5 -0
  328. package/product/components/ProductProperties/Content.js +1 -1
  329. package/product/components/ProductProperties/GroupedProperties.js +1 -1
  330. package/product/components/ProductProperties/ListsHTML.js +1 -1
  331. package/product/components/ProductProperties/ProductProperties.js +1 -1
  332. package/product/components/ProductProperties/RowHTML.js +1 -1
  333. package/product/components/ProductProperties/Wrapper.js +1 -1
  334. package/product/components/ProductProperties/style.js +1 -1
  335. package/product/components/ProductProvider/connector.js +5 -0
  336. package/product/components/ProductProvider/index.js +4 -0
  337. package/product/components/ProductSlider/index.js +4 -0
  338. package/product/components/ProductSlider/spec.js +1 -0
  339. package/product/components/ProductSlider/style.js +1 -0
  340. package/product/components/Rating/connector.js +9 -0
  341. package/product/components/Rating/index.js +7 -0
  342. package/product/components/Rating/mock.js +5 -0
  343. package/product/components/Rating/spec.js +5 -0
  344. package/product/components/Rating/style.js +1 -0
  345. package/product/components/Swatch/SwatchContent.js +1 -1
  346. package/product/components/index.js +1 -0
  347. package/product/constants/index.js +1 -1
  348. package/product/contexts/index.js +1 -0
  349. package/product/helpers/index.js +2 -2
  350. package/product/helpers/redirects.js +1 -1
  351. package/product/hocs/index.js +1 -0
  352. package/product/hocs/withProductListEntryProduct.js +12 -0
  353. package/product/hooks/index.js +1 -0
  354. package/product/index.js +4 -11
  355. package/product/providers/index.js +1 -0
  356. package/product/selectors/product.js +13 -2
  357. package/product/selectors/variants.js +2 -2
  358. package/product/streams/index.js +1 -0
  359. package/push-opt-in/action-creators/index.js +1 -0
  360. package/push-opt-in/action-creators/optInTrigger.js +23 -0
  361. package/push-opt-in/action-creators/pushOptIn.js +7 -0
  362. package/push-opt-in/actions/index.js +1 -0
  363. package/push-opt-in/actions/pushOptInModal.js +8 -0
  364. package/push-opt-in/components/PushOptInModal/connector.js +9 -0
  365. package/push-opt-in/components/PushOptInModal/index.js +10 -0
  366. package/push-opt-in/components/PushOptInModal/push-opt-in.svg +62 -0
  367. package/push-opt-in/components/PushOptInModal/style.js +1 -0
  368. package/push-opt-in/components/index.js +1 -0
  369. package/push-opt-in/constants/index.js +1 -0
  370. package/push-opt-in/constants/optInModal.js +1 -0
  371. package/push-opt-in/constants/optInTrigger.js +1 -0
  372. package/push-opt-in/reducers/index.js +1 -0
  373. package/push-opt-in/reducers/optInModal.js +6 -0
  374. package/push-opt-in/reducers/optInTrigger.js +6 -0
  375. package/push-opt-in/selectors/index.js +1 -0
  376. package/push-opt-in/selectors/optInModal.js +8 -0
  377. package/push-opt-in/selectors/optInTrigger.js +5 -0
  378. package/push-opt-in/subscriptions/index.js +1 -0
  379. package/push-opt-in/subscriptions/optInTrigger.js +14 -0
  380. package/registration/providers/GuestRegistrationProvider.actions.js +2 -2
  381. package/registration/providers/GuestRegistrationProvider.js +3 -3
  382. package/registration/providers/RegistrationProvider.actions.js +3 -3
  383. package/registration/providers/RegistrationProvider.js +2 -2
  384. package/registration/subscriptions/index.js +1 -1
  385. package/reviews/actions/index.js +1 -0
  386. package/reviews/components/Reviews/components/Header/components/ReviewsExcerpt/index.js +1 -1
  387. package/reviews/components/Reviews/components/List/index.js +3 -3
  388. package/reviews/components/Reviews/components/List/spec.js +1 -1
  389. package/reviews/components/Reviews/components/RatingCount/index.js +1 -1
  390. package/reviews/components/Reviews/components/ReviewsInfo/index.js +1 -2
  391. package/reviews/components/Reviews/spec.js +1 -1
  392. package/reviews/components/index.js +1 -0
  393. package/reviews/constants/index.js +1 -0
  394. package/reviews/index.js +1 -7
  395. package/reviews/selectors/index.js +1 -0
  396. package/reviews/streams/index.js +1 -0
  397. package/scanner/action-creators/index.js +1 -0
  398. package/scanner/actions/index.js +1 -0
  399. package/scanner/classes/index.js +1 -0
  400. package/scanner/constants/index.js +1 -0
  401. package/scanner/helpers/index.js +1 -0
  402. package/scanner/index.js +1 -6
  403. package/scanner/streams/index.js +1 -0
  404. package/search/actions/index.js +1 -0
  405. package/search/constants/index.js +1 -0
  406. package/search/helpers/index.js +1 -0
  407. package/search/index.js +1 -6
  408. package/search/selectors/index.js +1 -0
  409. package/search/streams/index.js +1 -0
  410. package/styles/helpers/index.js +1 -0
  411. package/styles/helpers/initCSSCustomProperties.js +3 -3
  412. package/styles/helpers/setPageContentWidth.js +2 -1
  413. package/styles/index.js +1 -1
  414. package/tracking/components/CookieConsent/CookieConsentContent.js +1 -1
  415. package/tracking/constants/index.js +2 -1
  416. package/components/MessageBar/MessageBar.types.js +0 -0
  417. package/components/MessageBar/style.js +0 -1
  418. package/product/components/Availability/Availability.types.js +0 -1
  419. /package/page/{NotFound.js → components/NotFound.js} +0 -0
@@ -0,0 +1,5 @@
1
+ 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);}import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var colors=themeConfig.colors,variables=themeConfig.variables;/**
2
+ * Returns the styling based on the container height.
3
+ * @param {number} height The maximum height for the container.
4
+ * @returns {string}
5
+ */var container=function container(height){return css({position:'relative',maxHeight:height,overflow:'hidden',marginBottom:variables.gap.small}).toString();};var layout=css({display:'flex',alignContent:'flex-start',flexWrap:'wrap',padding:'8px 5px',overflow:'hidden'}).toString();var moreButtonWrapper=css({position:'absolute',right:0,bottom:0,marginLeft:'auto',marginRight:variables.gap.small}).toString();var moreButtonBase={marginLeft:'auto',outline:0,padding:9,fontSize:'0.8rem',fontWeight:500,textTransform:'uppercase'};var moreButton=css(_extends({},moreButtonBase,{color:colors.light})).toString();var moreButtonInverted=css(_extends({},moreButtonBase,{color:colors.accent})).toString();export default{container:container,layout:layout,moreButtonWrapper:moreButtonWrapper,moreButton:moreButton,moreButtonInverted:moreButtonInverted};
@@ -1,24 +1,24 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}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,{PureComponent}from'react';import PropTypes from'prop-types';import Portal from'@shopgate/pwa-common/components/Portal';import UIEvents from'@shopgate/pwa-core/emitters/ui';import{APP_FOOTER_CONTENT_BEFORE,APP_FOOTER_CONTENT_AFTER}from'@shopgate/pwa-common/constants/Portals';import{getAbsoluteHeight,getStyle}from'@shopgate/pwa-common/helpers/dom';import{SHEET_EVENTS}from'@shopgate/pwa-ui-shared/Sheet';import{footer,updateInsetBackgroundColor,updateFooterHeight}from"./Footer.style";var APP_FOOTER_ID='AppFooter';var DATA_IGNORED='data-footer-inset-update-ignore';/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}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,{PureComponent}from'react';import PropTypes from'prop-types';import Portal from'@shopgate/pwa-common/components/Portal';import UIEvents from'@shopgate/pwa-core/emitters/ui';import{APP_FOOTER_CONTENT_BEFORE,APP_FOOTER_CONTENT_AFTER}from'@shopgate/pwa-common/constants/Portals';import{getAbsoluteHeight,getStyle}from'@shopgate/pwa-common/helpers/dom';import{SHEET_EVENTS}from'@shopgate/pwa-ui-shared/Sheet';import{footer,updateInsetBackgroundColor,updateFooterHeight}from"./Footer.style";var APP_FOOTER_ID='AppFooter';var DATA_IGNORED='data-footer-inset-update-ignore';/**
2
2
  * The footer component.
3
- */var Footer=/*#__PURE__*/function(_PureComponent){_inherits(Footer,_PureComponent);function Footer(){var _getPrototypeOf2;var _this;_classCallCheck(this,Footer);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_possibleConstructorReturn(this,(_getPrototypeOf2=_getPrototypeOf(Footer)).call.apply(_getPrototypeOf2,[this].concat(args)));_defineProperty(_assertThisInitialized(_this),"ref",React.createRef());_defineProperty(_assertThisInitialized(_this),"hide",function(){if(_this.ref.current){updateFooterHeight(0);}});_defineProperty(_assertThisInitialized(_this),"show",function(){if(_this.ref.current){updateFooterHeight(getAbsoluteHeight(_this.ref.current));}});return _this;}_createClass(Footer,[{key:"componentDidMount",value:function componentDidMount(){var _this2=this;this.performFooterUpdate();var observer=new MutationObserver(function(mutations){var update=mutations.filter(function(mutation){return mutation.target.getAttribute(DATA_IGNORED)!=='true';}).length>0;if(update){_this2.performFooterUpdate();}});observer.observe(this.ref.current,{attributes:true,childList:true,subtree:true});UIEvents.addListener(SHEET_EVENTS.OPEN,this.hide);UIEvents.addListener(SHEET_EVENTS.CLOSE,this.show);}/** @inheritDoc */},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(SHEET_EVENTS.OPEN,this.hide);UIEvents.removeListener(SHEET_EVENTS.CLOSE,this.show);}},{key:"getInsetBackgroundColor",/**
3
+ */var Footer=/*#__PURE__*/function(_PureComponent){function Footer(){var _this2;_classCallCheck(this,Footer);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,Footer,[].concat(args));_defineProperty(_this2,"ref",React.createRef());/** Perform hide action */_defineProperty(_this2,"hide",function(){if(_this2.ref.current){updateFooterHeight(0);}});/** Perform show action */_defineProperty(_this2,"show",function(){if(_this2.ref.current){updateFooterHeight(getAbsoluteHeight(_this2.ref.current));}});return _this2;}_inherits(Footer,_PureComponent);return _createClass(Footer,[{key:"componentDidMount",value:function componentDidMount(){var _this3=this;this.performFooterUpdate();var observer=new MutationObserver(function(mutations){var update=mutations.filter(function(mutation){return mutation.target.getAttribute(DATA_IGNORED)!=='true';}).length>0;if(update){_this3.performFooterUpdate();}});observer.observe(this.ref.current,{attributes:true,childList:true,subtree:true});UIEvents.addListener(SHEET_EVENTS.OPEN,this.hide);UIEvents.addListener(SHEET_EVENTS.CLOSE,this.show);}/** @inheritDoc */},{key:"componentWillUnmount",value:function componentWillUnmount(){UIEvents.removeListener(SHEET_EVENTS.OPEN,this.hide);UIEvents.removeListener(SHEET_EVENTS.CLOSE,this.show);}},{key:"getInsetBackgroundColor",value:/**
4
4
  * Retrieves the background color for the footer inset.
5
5
  * @param {NodeList} elements The DOM elements to inspect.
6
6
  * @returns {string|null}
7
- */value:function getInsetBackgroundColor(elements){var _this3=this;/**
7
+ */function getInsetBackgroundColor(elements){var _this4=this;/**
8
8
  * The background color of the bottom inset needs to identical to the last entry of the footer.
9
9
  * So we loop backwards to the elements to find the first visible one.
10
10
  */var color=Array.from(elements).reverse().reduce(function(result,element){var ignore=element.getAttribute(DATA_IGNORED)==='true';if(result||ignore){// Nothing to do, since the color was already determined or the element can be ignored.
11
11
  return result;}if(element.id===APP_FOOTER_ID){// Inspect core portal.
12
- return _this3.getInsetBackgroundColor(element.children);}if('clientHeight'in element){// Take the background color of the last visible element from the end of the footer.
12
+ return _this4.getInsetBackgroundColor(element.children);}if('clientHeight'in element){// Take the background color of the last visible element from the end of the footer.
13
13
  return getStyle(element,'backgroundColor');}// Nothing happened within this loop - proceed with the next one.
14
- return result;},null);if(color==='rgba(0, 0, 0, 0)'||color==='transparent'){return null;}return color||null;}/** Perform hide action */},{key:"performFooterUpdate",/**
14
+ return result;},null);if(color==='rgba(0, 0, 0, 0)'||color==='transparent'){return null;}return color||null;}},{key:"performFooterUpdate",value:/**
15
15
  * Performs an update of the footer: background color, height.
16
- */value:function performFooterUpdate(){if(this.ref.current){updateFooterHeight(getAbsoluteHeight(this.ref.current));updateInsetBackgroundColor(this.getInsetBackgroundColor(this.ref.current.children));}}/**
16
+ */function performFooterUpdate(){if(this.ref.current){updateFooterHeight(getAbsoluteHeight(this.ref.current));updateInsetBackgroundColor(this.getInsetBackgroundColor(this.ref.current.children));}}/**
17
17
  * Checks if the footer has visible content.
18
18
  * @returns {boolean}
19
19
  */},{key:"hasVisibleContent",value:function hasVisibleContent(){if(this.ref.current){var elements=this.ref.current.parentElement.querySelectorAll("div.".concat(footer.toString()," > *:not(#").concat(APP_FOOTER_ID,"), #").concat(APP_FOOTER_ID," > *"));return Array.from(elements).filter(function(element){return element.getAttribute(DATA_IGNORED)!=='true'&&element.clientHeight>0;}).length>0;}return false;}/**
20
20
  * @returns {JSX}
21
- */},{key:"render",value:function render(){return React.createElement("div",{className:footer,ref:this.ref},React.createElement(Portal,{name:APP_FOOTER_CONTENT_BEFORE}),React.createElement("div",{id:APP_FOOTER_ID},this.props.children),React.createElement(Portal,{name:APP_FOOTER_CONTENT_AFTER}));}}]);return Footer;}(PureComponent);_defineProperty(Footer,"defaultProps",{children:null/**
21
+ */},{key:"render",value:function render(){return React.createElement("div",{className:"".concat(footer," engage__footer"),ref:this.ref},React.createElement(Portal,{name:APP_FOOTER_CONTENT_BEFORE}),React.createElement("div",{id:APP_FOOTER_ID},this.props.children),React.createElement(Portal,{name:APP_FOOTER_CONTENT_AFTER}));}}]);}(PureComponent);_defineProperty(Footer,"defaultProps",{children:null/**
22
22
  * Sets up the DOM Mutation Observer to take care that the footer inset always has the correct
23
23
  * background color, which matches the background color of the last element within the footer.
24
24
  */});export default Footer;
@@ -1,44 +1,65 @@
1
- import _camelCase from"lodash/camelCase";var _defineProperty2;function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}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;}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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}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,{Component,Fragment}from'react';import PropTypes from'prop-types';import{logger}from'@shopgate/pwa-core/helpers';import Portal from'@shopgate/pwa-common/components/Portal';import{BEFORE,AFTER}from'@shopgate/pwa-common/constants/Portals';import{Form}from'..';import ActionListener from"./classes/ActionListener";import{ELEMENT_TYPE_EMAIL,ELEMENT_TYPE_PASSWORD,ELEMENT_TYPE_TEXT,ELEMENT_TYPE_NUMBER,ELEMENT_TYPE_SELECT,ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE,ELEMENT_TYPE_CHECKBOX,ELEMENT_TYPE_RADIO,ELEMENT_TYPE_DATE,ELEMENT_TYPE_PHONE,ELEMENT_TYPE_PHONE_PICKER,ELEMENT_TYPE_MULTISELECT}from"./Builder.constants";import ElementText from"./ElementText";import ElementSelect from"./ElementSelect";import ElementMultiSelect from"./ElementMultiSelect";import ElementRadio from"./ElementRadio";import ElementCheckbox from"./ElementCheckbox";import ElementPhoneNumber from"./ElementPhoneNumber";import buildFormElements from"./helpers/buildFormElements";import buildFormDefaults from"./helpers/buildFormDefaults";import buildCountryList from"./helpers/buildCountryList";import buildProvinceList from"./helpers/buildProvinceList";import buildValidationErrorList from"./helpers/buildValidationErrorList";import{sanitizePortalName}from"./helpers/common";/**
1
+ import _camelCase from"lodash/camelCase";var _excluded=["validationErrors"];var _Builder,_defineProperty2;function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}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;}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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}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,{Component,Fragment}from'react';import PropTypes from'prop-types';import{logger}from'@shopgate/pwa-core/helpers';import Portal from'@shopgate/pwa-common/components/Portal';import{BEFORE,AFTER}from'@shopgate/pwa-common/constants/Portals';import{Form}from'..';import ActionListener from"./classes/ActionListener";import{ELEMENT_TYPE_EMAIL,ELEMENT_TYPE_PASSWORD,ELEMENT_TYPE_TEXT,ELEMENT_TYPE_NUMBER,ELEMENT_TYPE_SELECT,ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE,ELEMENT_TYPE_CHECKBOX,ELEMENT_TYPE_RADIO,ELEMENT_TYPE_DATE,ELEMENT_TYPE_PHONE,ELEMENT_TYPE_PHONE_PICKER,ELEMENT_TYPE_MULTISELECT}from"./Builder.constants";import ElementText from"./ElementText";import ElementSelect from"./ElementSelect";import ElementMultiSelect from"./ElementMultiSelect";import ElementRadio from"./ElementRadio";import ElementCheckbox from"./ElementCheckbox";import ElementPhoneNumber from"./ElementPhoneNumber";import buildFormElements from"./helpers/buildFormElements";import buildFormDefaults from"./helpers/buildFormDefaults";import buildCountryList from"./helpers/buildCountryList";import buildProvinceList from"./helpers/buildProvinceList";import buildValidationErrorList from"./helpers/buildValidationErrorList";import{sanitizePortalName}from"./helpers/common";/**
2
2
  * Optional select element
3
3
  * @type {Object}
4
4
  */var emptySelectOption={'':''};/**
5
5
  * Takes a form configuration and handles rendering and updates of the form fields.
6
6
  * Note: Only one country and one province element is supported per FormBuilder instance.
7
- */var Builder=/*#__PURE__*/function(_Component){_inherits(Builder,_Component);function Builder(props){var _this;_classCallCheck(this,Builder);_this=_possibleConstructorReturn(this,_getPrototypeOf(Builder).call(this,props));// Prepare internal state
8
- _defineProperty(_assertThisInitialized(_this),"getFormElementComponent",function(type){return _this.props.elements[type]||Builder.defaultElements[type]||null;});_defineProperty(_assertThisInitialized(_this),"elementSortFunc",function(element1,element2){// Keep current sort order when no specific sort order was set for both
7
+ */var Builder=/*#__PURE__*/function(_Component){function Builder(props){var _this2;_classCallCheck(this,Builder);_this2=_callSuper(this,Builder,[props]);// Prepare internal state
8
+ /**
9
+ * Retrieves a form element REACT component by the given type or null if the type is unknown.
10
+ * @param {string} type The type value of the element to return.
11
+ * @returns {*|ElementText|ElementSelect|ElementCheckbox|ElementRadio|null}
12
+ */_defineProperty(_this2,"getFormElementComponent",function(type){return _this2.props.elements[type]||Builder.defaultElements[type]||null;});/**
13
+ * Sorts the elements by "sortOrder" property
14
+ *
15
+ * @typedef {Object} FormElement
16
+ * @property {number} sortOrder
17
+ *
18
+ * @param {FormElement} element1 First element
19
+ * @param {FormElement} element2 Second element
20
+ * @returns {number}
21
+ */_defineProperty(_this2,"elementSortFunc",function(element1,element2){// Keep current sort order when no specific sort order was set for both
9
22
  if(element1.sortOrder===undefined||element2.sortOrder===undefined){return 0;}// Sort in ascending order of sortOrder otherwise
10
- return element1.sortOrder-element2.sortOrder;});_defineProperty(_assertThisInitialized(_this),"elementChangeHandler",function(elementId,value){// "newState" is the state changes before any form actions have been applied
11
- var newState=_extends({},_this.state,{formData:_extends({},_this.state.formData,_defineProperty({},elementId,value))});// Handle context sensitive functionality by via "action" listener and use the "new" state
12
- var updatedNewState=_this.actionListener.notify(elementId,_this.state,newState);// Form actions can append validation errors by adding that field to the new state
23
+ return element1.sortOrder-element2.sortOrder;});/**
24
+ * Element change handler based on it's type. It takes a state change and performs form actions on
25
+ * in to allow customization. The final result is then written to the component state.
26
+ * @param {string} elementId Element to create the handler for
27
+ * @param {string} value Element value
28
+ */_defineProperty(_this2,"elementChangeHandler",function(elementId,value){// "newState" is the state changes before any form actions have been applied
29
+ var newState=_extends({},_this2.state,{formData:_extends({},_this2.state.formData,_defineProperty({},elementId,value))});// Handle context sensitive functionality by via "action" listener and use the "new" state
30
+ var updatedNewState=_this2.actionListener.notify(elementId,_this2.state,newState);// Form actions can append validation errors by adding that field to the new state
13
31
  // Split out validation errors from final state and
14
- var _updatedNewState$vali=updatedNewState.validationErrors,validationErrors=_updatedNewState$vali===void 0?{}:_updatedNewState$vali,finalState=_objectWithoutProperties(updatedNewState,["validationErrors"]);// "hasErrors" is true, when a visible + required field is empty or validation errors appeared!
32
+ var _updatedNewState$vali=updatedNewState.validationErrors,validationErrors=_updatedNewState$vali===void 0?{}:_updatedNewState$vali,finalState=_objectWithoutProperties(updatedNewState,_excluded);// "hasErrors" is true, when a visible + required field is empty or validation errors appeared!
15
33
  var hasErrors=Object.keys(validationErrors).length>0;// Check "required" fields for all visible elements and enable rendering on changes
16
- _this.formElements.forEach(function(formElement){if(!finalState.elementVisibility[formElement.id]||!formElement.required){return;}var tmpVal=finalState.formData[formElement.id];var tmpResult=tmpVal===null||tmpVal===undefined||tmpVal===''||tmpVal===false;hasErrors=hasErrors||tmpResult;});// Handle state internally and send an "onChange" event to parent if this finished
17
- _this.setState(finalState);// Transform to external structure (unavailable ones will be set undefined)
18
- var updateData={};_this.formElements.forEach(function(el){if(el.custom){if(updateData.customAttributes===undefined){updateData.customAttributes={};}updateData.customAttributes[el.id]=finalState.formData[el.id];}else{updateData[el.id]=finalState.formData[el.id];}});// Trigger the given update action of the parent and provide all new validation errors to it
19
- _this.props.handleUpdate(updateData,hasErrors,// Output validation errors in the same structure (array) as the component takes them
20
- hasErrors?Object.keys(validationErrors).map(function(k){return{path:k,message:validationErrors[k]};}):[]);});_defineProperty(_assertThisInitialized(_this),"renderElement",function(formName,element,elementErrorText){var elementName="".concat(_this.props.name,"_").concat(element.id);var elementValue=_this.state.formData[element.id];var elementVisible=_this.state.elementVisibility[element.id]||false;// Take a dynamic REACT element based on its type
21
- var Element=_this.getFormElementComponent(element.type);if(!Element){logger.error("Unknown form element type: ".concat(element.type));return null;}// Country and province elements have their data injected, if not already present
22
- var elementData=element;switch(element.type){case ELEMENT_TYPE_COUNTRY:{elementData.options=element.options||_this.countryList;break;}case ELEMENT_TYPE_PROVINCE:{// Province selection only makes sense with a country being selected, or from custom options
23
- var countryElement=_this.formElements.find(function(el){return el.type===ELEMENT_TYPE_COUNTRY;});elementData.options=countryElement&&_this.state.formData[countryElement.id]?buildProvinceList(_this.state.formData[countryElement.id],// Auto-select with "empty" when not required
24
- element.required?null:emptySelectOption):{};break;}default:break;}return React.createElement(Element,{name:elementName,element:elementData,errorText:elementErrorText,value:elementValue,visible:elementVisible,formName:formName});});_this.state={elementVisibility:{},formData:{}};// Reorganize form elements into a structure that can be easily rendered
25
- var formElements=buildFormElements(props.config,_this.elementChangeHandler);// Compute defaults
34
+ _this2.formElements.forEach(function(formElement){if(!finalState.elementVisibility[formElement.id]||!formElement.required){return;}var tmpVal=finalState.formData[formElement.id];var tmpResult=tmpVal===null||tmpVal===undefined||tmpVal===''||tmpVal===false;hasErrors=hasErrors||tmpResult;});// Handle state internally and send an "onChange" event to parent if this finished
35
+ _this2.setState(finalState);// Transform to external structure (unavailable ones will be set undefined)
36
+ var updateData={};_this2.formElements.forEach(function(el){if(el.custom){if(updateData.customAttributes===undefined){updateData.customAttributes={};}updateData.customAttributes[el.id]=finalState.formData[el.id];}else{updateData[el.id]=finalState.formData[el.id];}});// Trigger the given update action of the parent and provide all new validation errors to it
37
+ _this2.props.handleUpdate(updateData,hasErrors,// Output validation errors in the same structure (array) as the component takes them
38
+ hasErrors?Object.keys(validationErrors).map(function(k){return{path:k,message:validationErrors[k]};}):[]);});/**
39
+ * Takes an element of any type and renders it depending on type.
40
+ * Also puts portals around the element.
41
+ * @param {string} formName Name of the form
42
+ * @param {Object} element The data of the element to be rendered
43
+ * @param {string} elementErrorText The error text to be shown for this specific element
44
+ * @returns {JSX}
45
+ */_defineProperty(_this2,"renderElement",function(formName,element,elementErrorText){var elementName="".concat(_this2.props.name,"_").concat(element.id);var elementValue=_this2.state.formData[element.id];var elementVisible=_this2.state.elementVisibility[element.id]||false;// Take a dynamic REACT element based on its type
46
+ var Element=_this2.getFormElementComponent(element.type);if(!Element){logger.error("Unknown form element type: ".concat(element.type));return null;}// Country and province elements have their data injected, if not already present
47
+ var elementData=element;switch(element.type){case ELEMENT_TYPE_COUNTRY:{elementData.options=element.options||_this2.countryList;break;}case ELEMENT_TYPE_PROVINCE:{// Province selection only makes sense with a country being selected, or from custom options
48
+ var countryElement=_this2.formElements.find(function(el){return el.type===ELEMENT_TYPE_COUNTRY;});elementData.options=countryElement&&_this2.state.formData[countryElement.id]?buildProvinceList(_this2.state.formData[countryElement.id],// Auto-select with "empty" when not required
49
+ element.required?null:emptySelectOption):{};break;}default:break;}return React.createElement(Element,{name:elementName,element:elementData,errorText:elementErrorText,value:elementValue,visible:elementVisible,formName:formName});});_this2.state={elementVisibility:{},formData:{}};// Reorganize form elements into a structure that can be easily rendered
50
+ var formElements=buildFormElements(props.config,_this2.elementChangeHandler);// Compute defaults
26
51
  var formDefaults=buildFormDefaults(formElements,props.defaults);// Assign defaults to state
27
- _this.state.formData=formDefaults;// Handle fixed visibilities
52
+ _this2.state.formData=formDefaults;// Handle fixed visibilities
28
53
  formElements.forEach(function(element){// Assume as visible except it's explicitly set to "false"
29
- _this.state.elementVisibility[element.id]=element.visible!==false;});_this.actionListener=new ActionListener(buildProvinceList,formDefaults);_this.actionListener.attachAll(formElements);// Sort the elements after attaching action listeners to keep action hierarchy same as creation
30
- _this.formElements=formElements.sort(_this.elementSortFunc);// Assemble combined country/province list based on the config element
31
- var _countryElement=_this.formElements.find(function(el){return el.type===ELEMENT_TYPE_COUNTRY;});if(_countryElement){_this.countryList=buildCountryList(_countryElement,emptySelectOption);var provinceElement=_this.formElements.find(function(el){return el.type===ELEMENT_TYPE_PROVINCE;});if(provinceElement&&provinceElement.required&&!!formDefaults[_countryElement.id]&&!formDefaults[provinceElement.id]){// Set default for province field for given country
32
- var _Object$keys=Object.keys(buildProvinceList(formDefaults[_countryElement.id])),_Object$keys2=_slicedToArray(_Object$keys,1),first=_Object$keys2[0];if(first){_this.state.formData[provinceElement.id]=first;}}}// Final form initialization, by triggering actionListeners and enable rendering for elements
33
- var _newState=_this.state;_this.formElements.forEach(function(element){_newState=_this.actionListener.notify(element.id,_this.state,_newState);});_this.state=_newState;return _this;}/**
34
- * Retrieves a form element REACT component by the given type or null if the type is unknown.
35
- * @param {string} type The type value of the element to return.
36
- * @returns {*|ElementText|ElementSelect|ElementCheckbox|ElementRadio|null}
37
- */_createClass(Builder,[{key:"render",/**
54
+ _this2.state.elementVisibility[element.id]=element.visible!==false;});_this2.actionListener=new ActionListener(buildProvinceList,formDefaults);_this2.actionListener.attachAll(formElements);// Sort the elements after attaching action listeners to keep action hierarchy same as creation
55
+ _this2.formElements=formElements.sort(_this2.elementSortFunc);// Assemble combined country/province list based on the config element
56
+ var _countryElement=_this2.formElements.find(function(el){return el.type===ELEMENT_TYPE_COUNTRY;});if(_countryElement){_this2.countryList=buildCountryList(_countryElement,emptySelectOption);var provinceElement=_this2.formElements.find(function(el){return el.type===ELEMENT_TYPE_PROVINCE;});if(provinceElement&&provinceElement.required&&!!formDefaults[_countryElement.id]&&!formDefaults[provinceElement.id]){// Set default for province field for given country
57
+ var _Object$keys3=Object.keys(buildProvinceList(formDefaults[_countryElement.id])),_Object$keys4=_slicedToArray(_Object$keys3,1),first=_Object$keys4[0];if(first){_this2.state.formData[provinceElement.id]=first;}}}// Final form initialization, by triggering actionListeners and enable rendering for elements
58
+ var _newState=_this2.state;_this2.formElements.forEach(function(element){_newState=_this2.actionListener.notify(element.id,_this2.state,_newState);});_this2.state=_newState;return _this2;}_inherits(Builder,_Component);return _createClass(Builder,[{key:"render",value:/**
38
59
  * Renders the component based on the given config
39
60
  * @return {JSX}
40
- */value:function render(){var _this2=this;// Convert validation errors for easier handling
41
- var validationErrors=buildValidationErrorList(this.props.validationErrors);return React.createElement(Form,{className:_camelCase(this.props.name),onSubmit:this.props.onSubmit},React.createElement("div",{className:this.props.className},this.formElements.map(function(element){return React.createElement(Fragment,{key:"".concat(_this2.props.name,"_").concat(element.id)},React.createElement(Portal,{name:"".concat(sanitizePortalName(_this2.props.name),".").concat(sanitizePortalName(element.id),".").concat(BEFORE),props:{formName:_this2.props.name,errorText:validationErrors[element.id]||'',element:element}}),React.createElement(Portal,{name:"".concat(sanitizePortalName(_this2.props.name),".").concat(sanitizePortalName(element.id)),props:{formName:_this2.props.name,errorText:validationErrors[element.id]||'',element:element}},_this2.renderElement(_this2.props.name,element,validationErrors[element.id]||'')),React.createElement(Portal,{name:"".concat(sanitizePortalName(_this2.props.name),".").concat(sanitizePortalName(element.id),".").concat(AFTER),props:{formName:_this2.props.name,errorText:validationErrors[element.id]||'',element:element}}));})));}}]);return Builder;}(Component);_defineProperty(Builder,"defaultElements",(_defineProperty2={},_defineProperty(_defineProperty2,ELEMENT_TYPE_EMAIL,ElementText),_defineProperty(_defineProperty2,ELEMENT_TYPE_PASSWORD,ElementText),_defineProperty(_defineProperty2,ELEMENT_TYPE_TEXT,ElementText),_defineProperty(_defineProperty2,ELEMENT_TYPE_NUMBER,ElementText),_defineProperty(_defineProperty2,ELEMENT_TYPE_SELECT,ElementSelect),_defineProperty(_defineProperty2,ELEMENT_TYPE_MULTISELECT,ElementMultiSelect),_defineProperty(_defineProperty2,ELEMENT_TYPE_COUNTRY,ElementSelect),_defineProperty(_defineProperty2,ELEMENT_TYPE_PROVINCE,ElementSelect),_defineProperty(_defineProperty2,ELEMENT_TYPE_CHECKBOX,ElementCheckbox),_defineProperty(_defineProperty2,ELEMENT_TYPE_RADIO,ElementRadio),_defineProperty(_defineProperty2,ELEMENT_TYPE_DATE,ElementText),_defineProperty(_defineProperty2,ELEMENT_TYPE_PHONE,ElementText),_defineProperty(_defineProperty2,ELEMENT_TYPE_PHONE_PICKER,ElementPhoneNumber),_defineProperty2));_defineProperty(Builder,"defaultProps",{className:null,defaults:{},elements:Builder.defaultElements,onSubmit:function onSubmit(){},validationErrors:[]/**
61
+ */function render(){var _this3=this;// Convert validation errors for easier handling
62
+ var validationErrors=buildValidationErrorList(this.props.validationErrors);return React.createElement(Form,{className:_camelCase(this.props.name),onSubmit:this.props.onSubmit},React.createElement("div",{className:this.props.className},this.formElements.map(function(element){return React.createElement(Fragment,{key:"".concat(_this3.props.name,"_").concat(element.id)},React.createElement(Portal,{name:"".concat(sanitizePortalName(_this3.props.name),".").concat(sanitizePortalName(element.id),".").concat(BEFORE),props:{formName:_this3.props.name,errorText:validationErrors[element.id]||'',element:element}}),React.createElement(Portal,{name:"".concat(sanitizePortalName(_this3.props.name),".").concat(sanitizePortalName(element.id)),props:{formName:_this3.props.name,errorText:validationErrors[element.id]||'',element:element}},_this3.renderElement(_this3.props.name,element,validationErrors[element.id]||'')),React.createElement(Portal,{name:"".concat(sanitizePortalName(_this3.props.name),".").concat(sanitizePortalName(element.id),".").concat(AFTER),props:{formName:_this3.props.name,errorText:validationErrors[element.id]||'',element:element}}));})));}}]);}(Component);_Builder=Builder;_defineProperty(Builder,"defaultElements",(_defineProperty2={},_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty2,ELEMENT_TYPE_EMAIL,ElementText),ELEMENT_TYPE_PASSWORD,ElementText),ELEMENT_TYPE_TEXT,ElementText),ELEMENT_TYPE_NUMBER,ElementText),ELEMENT_TYPE_SELECT,ElementSelect),ELEMENT_TYPE_MULTISELECT,ElementMultiSelect),ELEMENT_TYPE_COUNTRY,ElementSelect),ELEMENT_TYPE_PROVINCE,ElementSelect),ELEMENT_TYPE_CHECKBOX,ElementCheckbox),ELEMENT_TYPE_RADIO,ElementRadio),_defineProperty(_defineProperty(_defineProperty(_defineProperty2,ELEMENT_TYPE_DATE,ElementText),ELEMENT_TYPE_PHONE,ElementText),ELEMENT_TYPE_PHONE_PICKER,ElementPhoneNumber)));_defineProperty(Builder,"defaultProps",{className:null,defaults:{},elements:_Builder.defaultElements,onSubmit:function onSubmit(){},validationErrors:[]/**
42
63
  * Initializes the component.
43
64
  * @param {Object} props The components props.
44
65
  */});export default Builder;
@@ -3,4 +3,4 @@ import _camelCase from"lodash/camelCase";import React,{memo}from'react';import P
3
3
  * @param {Object} props Component props.
4
4
  * @param {Object} props.element The data of the element to be rendered
5
5
  * @returns {JSX}
6
- */var ElementCheckbox=function ElementCheckbox(props){var element=props.element,errorText=props.errorText,value=props.value,name=props.name,visible=props.visible,formName=props.formName;if(!visible){return null;}return React.createElement("div",{className:classNames('container-checkbox',_camelCase(name),'formBuilderField',{validationError:!!errorText})},React.createElement(Checkbox,{name:name,errorText:errorText,checked:!!value,label:element.label,onChange:element.handleChange,translateErrorText:false,showErrorText:false,disabled:element.disabled}),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));};ElementCheckbox.defaultProps={value:false,visible:true};export default memo(ElementCheckbox);
6
+ */var ElementCheckbox=function ElementCheckbox(props){var element=props.element,errorText=props.errorText,value=props.value,name=props.name,visible=props.visible,formName=props.formName;if(!visible){return null;}return React.createElement("div",{className:classNames('container-checkbox',_camelCase(name),'engage__form-checkbox','formBuilderField',{validationError:!!errorText})},React.createElement(Checkbox,{name:name,errorText:errorText,checked:!!value,label:element.label,onChange:element.handleChange,translateErrorText:false,showErrorText:false,disabled:element.disabled}),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));};ElementCheckbox.defaultProps={value:false,visible:true};export default memo(ElementCheckbox);
@@ -3,4 +3,4 @@ import _camelCase from"lodash/camelCase";import React,{memo}from'react';import P
3
3
  * @param {Object} props Component props.
4
4
  * @param {Object} props.element The data of the element to be rendered
5
5
  * @returns {JSX}
6
- */var ElementMultiSelect=function ElementMultiSelect(props){var element=props.element,errorText=props.errorText,name=props.name,value=props.value,visible=props.visible,formName=props.formName;if(!visible){return null;}var values=[].concat(value).filter(Boolean);return React.createElement("div",{className:classNames(_camelCase(name),'formBuilderField',{validationError:!!errorText})},React.createElement(ResponsiveContainer,{appAlways:true,breakpoint:"xs"},React.createElement(Select,{name:name,label:element.label,placeholder:element.placeholder,value:values,options:element.options,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false,showErrorText:false,disabled:element.disabled,multiple:true})),React.createElement(ResponsiveContainer,{webOnly:true,breakpoint:">xs"},React.createElement(SelectContextChoices,{label:element.label,placeholder:element.placeholder,value:values,options:element.options,onChange:element.handleChange,errorText:errorText,showErrorText:false})),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));};ElementMultiSelect.defaultProps={value:'',visible:true};export default memo(ElementMultiSelect);
6
+ */var ElementMultiSelect=function ElementMultiSelect(props){var element=props.element,errorText=props.errorText,name=props.name,value=props.value,visible=props.visible,formName=props.formName;if(!visible){return null;}var values=[].concat(value).filter(Boolean);return React.createElement("div",{className:classNames(_camelCase(name),'engage__form-multi-select','formBuilderField',{validationError:!!errorText})},React.createElement(ResponsiveContainer,{appAlways:true,breakpoint:"xs"},React.createElement(Select,{name:name,label:element.label,placeholder:element.placeholder,value:values,options:element.options,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false,showErrorText:false,disabled:element.disabled,multiple:true})),React.createElement(ResponsiveContainer,{webOnly:true,breakpoint:">xs"},React.createElement(SelectContextChoices,{label:element.label,placeholder:element.placeholder,value:values,options:element.options,onChange:element.handleChange,errorText:errorText,showErrorText:false})),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));};ElementMultiSelect.defaultProps={value:'',visible:true};export default memo(ElementMultiSelect);
@@ -1,8 +1,8 @@
1
- import _isEqual from"lodash/isEqual";import _upperCase from"lodash/upperCase";import _camelCase from"lodash/camelCase";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 _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;}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import*as React from'react';import classnames from'classnames';import{i18n}from'@shopgate/engage/core';import{parsePhoneNumber}from'react-phone-number-input';import PhoneInputCountrySelect from'react-phone-number-input/mobile';import PhoneInput from'react-phone-number-input/input-mobile';import{getCountries}from'react-phone-number-input/input';import en from'react-phone-number-input/locale/en';import de from'react-phone-number-input/locale/de';import es from'react-phone-number-input/locale/es';import fr from'react-phone-number-input/locale/fr';import pt from'react-phone-number-input/locale/pt';import flags from'react-phone-number-input/flags';import{useCountriesNames}from'@shopgate/engage/i18n';import{css}from'glamor';import{themeConfig}from'@shopgate/engage';import Label from'@shopgate/pwa-ui-shared/TextField/components/Label';import FormHelper from"./FormHelper";var variables=themeConfig.variables,colors=themeConfig.colors;var styles={formField:css({width:'100%',marginBottom:'0px !important'}).toString(),phoneField:css({position:'relative',width:'100%',paddingTop:variables.gap.big*0.75,paddingBottom:variables.gap.big*1.25,' input.PhoneInputInput':{outline:'none',fontSize:'1rem',lineHeight:'1.1875rem',borderRadius:0,paddingBottom:variables.gap.xsmall*1.5,borderBottom:"1px solid ".concat(colors.shade12),'&:focus':{borderBottom:"2px solid ".concat(colors.primary),paddingBottom:variables.gap.xsmall*1.5-1}}}),phoneFieldError:css({' input.PhoneInputInput':{borderBottom:"2px solid var(--color-state-alert, ".concat(colors.error,")"),paddingBottom:variables.gap.xsmall*1.5-1}}).toString(),phoneFieldErrorText:css({position:'absolute',width:'100%',bottom:'-10px',fontSize:'0.75rem',lineHeight:0.875,color:"var(--color-state-alert, ".concat(colors.error,")"),overflow:'hidden',whiteSpace:'nowrap',textOverflow:'ellipsis',marginLeft:'38px'})};var builtInCountries=getCountries();var locales={en:en,de:de,es:es,fr:fr,pt:pt};/**
1
+ import _isEqual from"lodash/isEqual";import _upperCase from"lodash/upperCase";import _camelCase from"lodash/camelCase";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 _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;}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import*as React from'react';import PropTypes from'prop-types';import classnames from'classnames';import{i18n}from'@shopgate/engage/core';import{parsePhoneNumber}from'react-phone-number-input';import PhoneInputCountrySelect from'react-phone-number-input/mobile';import PhoneInput from'react-phone-number-input/input-mobile';import{getCountries}from'react-phone-number-input/input';import en from'react-phone-number-input/locale/en';import de from'react-phone-number-input/locale/de';import es from'react-phone-number-input/locale/es';import fr from'react-phone-number-input/locale/fr';import pt from'react-phone-number-input/locale/pt';import flags from'react-phone-number-input/flags';import{useCountriesNames}from'@shopgate/engage/i18n';import{css}from'glamor';import{themeConfig}from'@shopgate/engage';import Label from'@shopgate/pwa-ui-shared/TextField/components/Label';import FormHelper from"./FormHelper";var variables=themeConfig.variables,colors=themeConfig.colors;var styles={formField:css({width:'100%',marginBottom:'0px !important'}).toString(),phoneField:css({position:'relative',width:'100%',paddingTop:variables.gap.big*0.75,paddingBottom:variables.gap.big*1.25,' input.PhoneInputInput':{outline:'none',fontSize:'1rem',lineHeight:'1.1875rem',borderRadius:0,paddingBottom:variables.gap.xsmall*1.5,borderBottom:"1px solid ".concat(colors.shade12),'&:focus':{borderBottom:"2px solid ".concat(colors.primary),paddingBottom:variables.gap.xsmall*1.5-1}}}),phoneFieldError:css({' input.PhoneInputInput':{borderBottom:"2px solid var(--color-state-alert, ".concat(colors.error,")"),paddingBottom:variables.gap.xsmall*1.5-1}}).toString(),phoneFieldErrorText:css({position:'absolute',width:'100%',bottom:'-10px',fontSize:'0.75rem',lineHeight:0.875,color:"var(--color-state-alert, ".concat(colors.error,")"),overflow:'hidden',whiteSpace:'nowrap',textOverflow:'ellipsis',marginLeft:'38px'})};var builtInCountries=getCountries();var locales={en:en,de:de,es:es,fr:fr,pt:pt};/**
2
2
  * Renders the reserve form phone input maybe with country selection.
3
3
  * @param {Object} props The component props.
4
4
  * @returns {JSX.Element}
5
- */var UnwrappedElementPhoneNumber=React.memo(function(props){var _classnames;var element=props.element,name=props.name,errorText=props.errorText,value=props.value,visible=props.visible,formName=props.formName;var label=element.label,handleChange=element.handleChange,_element$disabled=element.disabled,disabled=_element$disabled===void 0?false:_element$disabled,_element$config=element.config;_element$config=_element$config===void 0?{}:_element$config;var _element$config$suppo=_element$config.supportedCountries,supportedCountries=_element$config$suppo===void 0?[]:_element$config$suppo,_element$config$count=_element$config.countrySortOrder,countrySortOrder=_element$config$count===void 0?[]:_element$config$count,_element$config$userL=_element$config.userLocation,userLocation=_element$config$userL===void 0?{}:_element$config$userL;var _React$useState=React.useState(false),_React$useState2=_slicedToArray(_React$useState,2),isFocused=_React$useState2[0],setIsFocused=_React$useState2[1];// Maps available countries to correct format.
5
+ */var UnwrappedElementPhoneNumber=React.memo(function(props){var element=props.element,name=props.name,errorText=props.errorText,value=props.value,visible=props.visible,formName=props.formName;var label=element.label,handleChange=element.handleChange,_element$disabled=element.disabled,disabled=_element$disabled===void 0?false:_element$disabled,_element$config=element.config,_element$config2=_element$config===void 0?{}:_element$config,_element$config2$supp=_element$config2.supportedCountries,supportedCountries=_element$config2$supp===void 0?[]:_element$config2$supp,_element$config2$coun=_element$config2.countrySortOrder,countrySortOrder=_element$config2$coun===void 0?[]:_element$config2$coun,_element$config2$user=_element$config2.userLocation,userLocation=_element$config2$user===void 0?{}:_element$config2$user;var _React$useState=React.useState(false),_React$useState2=_slicedToArray(_React$useState,2),isFocused=_React$useState2[0],setIsFocused=_React$useState2[1];// Maps available countries to correct format.
6
6
  var countries=React.useMemo(function(){if(supportedCountries.length===0){return builtInCountries;}return supportedCountries.map(function(country){var pieces=country.split('_');return _upperCase(pieces[0]);});},[supportedCountries]);var countriesNames=useCountriesNames(countries,locales);// Get labels for supported countries.
7
7
  var labels=React.useMemo(function(){var output={};if(!countries){return output;}countries.forEach(function(key){var pieces=key.split('_');output[pieces[0]]=countriesNames[key];});return output;},[countries,countriesNames]);var defaultCountry=React.useMemo(function(){var country;if(value){// Try to parse the value to determine a country
8
8
  var phoneNumber=parsePhoneNumber(value||'');if(phoneNumber&&phoneNumber.country){country=phoneNumber.country;}}if(!country&&userLocation){// Take the country from the user location if present
@@ -17,4 +17,4 @@ var _countries=_slicedToArray(countries,1);country=_countries[0];}}return countr
17
17
  * When list with supported countries has the same entries as the country sort order, we don't
18
18
  * need to add a separator to the countryOptionsOrder array since the country picker lists
19
19
  * will not show a section with unordered countries.
20
- */return sanitizedCountrySortOrder.length?[].concat(sanitizedCountrySortOrder,countryListsEqual?[]:['|']):[];},[countries,countrySortOrder]);var hasCountrySelect=React.useMemo(function(){return countries.length>1;},[countries.length]);var handleChangeWrapped=React.useCallback(function(phoneValue){handleChange(phoneValue,{target:{name:name}});},[handleChange,name]);var phoneClasses=classnames('textField',(_classnames={simpleInput:!hasCountrySelect},_defineProperty(_classnames,_camelCase(name),true),_defineProperty(_classnames,"phonePicker",true),_defineProperty(_classnames,"phonePickerError",!!errorText),_defineProperty(_classnames,"validationError",!!errorText),_defineProperty(_classnames,"phonePickerFocused",isFocused),_defineProperty(_classnames,styles.phoneField,true),_defineProperty(_classnames,styles.phoneFieldError,!!errorText),_classnames));if(!visible){return null;}var Component=hasCountrySelect?PhoneInputCountrySelect:PhoneInput;return React.createElement("div",{className:"formBuilderField"},React.createElement("div",{className:phoneClasses},React.createElement(Label,{label:label,isFocused:isFocused,isFloating:isFocused||!!value}),React.createElement(Component,_extends({defaultCountry:defaultCountry,name:name,value:value||'',onChange:handleChangeWrapped,onFocus:function onFocus(){return setIsFocused(true);},onBlur:function onBlur(){return setIsFocused(false);},disabled:disabled},hasCountrySelect?{countryOptionsOrder:countryOptionsOrder,addInternationalOption:false,flags:flags,countries:countries,labels:labels}:{className:'PhoneInputInput'}))),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));});export default UnwrappedElementPhoneNumber;
20
+ */return sanitizedCountrySortOrder.length?[].concat(sanitizedCountrySortOrder,countryListsEqual?[]:['|']):[];},[countries,countrySortOrder]);var hasCountrySelect=React.useMemo(function(){return countries.length>1;},[countries.length]);var handleChangeWrapped=React.useCallback(function(phoneValue){handleChange(phoneValue,{target:{name:name}});},[handleChange,name]);var phoneClasses=classnames('textField',_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({simpleInput:!hasCountrySelect},_camelCase(name),true),"phonePicker",true),"phonePickerError",!!errorText),"validationError",!!errorText),"phonePickerFocused",isFocused),styles.phoneField,true),styles.phoneFieldError,!!errorText));if(!visible){return null;}var Component=hasCountrySelect?PhoneInputCountrySelect:PhoneInput;return React.createElement("div",{className:classnames('formBuilderField','engage__form-phone-number')},React.createElement("div",{className:phoneClasses},React.createElement(Label,{label:label,isFocused:isFocused,isFloating:isFocused||!!value}),React.createElement(Component,_extends({defaultCountry:defaultCountry,name:name,value:value||'',onChange:handleChangeWrapped,onFocus:function onFocus(){return setIsFocused(true);},onBlur:function onBlur(){return setIsFocused(false);},disabled:disabled},hasCountrySelect?{countryOptionsOrder:countryOptionsOrder,addInternationalOption:false,flags:flags,countries:countries,labels:labels}:{className:'PhoneInputInput'}))),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));});UnwrappedElementPhoneNumber.defaultProps={value:'',visible:true};export default UnwrappedElementPhoneNumber;
@@ -3,4 +3,4 @@ import _camelCase from"lodash/camelCase";import React,{memo}from'react';import P
3
3
  * @param {Object} props Component props.
4
4
  * @param {Object} props.element The data of the element to be rendered
5
5
  * @returns {JSX}
6
- */var ElementRadio=function ElementRadio(props){var element=props.element,errorText=props.errorText,name=props.name,value=props.value,visible=props.visible,formName=props.formName;if(!visible){return null;}return React.createElement("div",{className:classNames(_camelCase(name),'formBuilderField',{validationError:!!errorText})},React.createElement(RadioGroup,{name:name,label:element.label,value:value,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false,showErrorText:false,disabled:element.disabled},Object.keys(element.options).map(function(itemName){return React.createElement(RadioItem,{key:"".concat(name,"_").concat(itemName),id:"".concat(name,"_").concat(_camelCase(itemName)),name:itemName,label:element.options[itemName]});})),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));};ElementRadio.defaultProps={value:'',visible:true};export default memo(ElementRadio);
6
+ */var ElementRadio=function ElementRadio(props){var element=props.element,errorText=props.errorText,name=props.name,value=props.value,visible=props.visible,formName=props.formName;if(!visible){return null;}return React.createElement("div",{className:classNames(_camelCase(name),'engage__form-radio','formBuilderField',{validationError:!!errorText})},React.createElement(RadioGroup,{name:name,label:element.label,value:value,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false,showErrorText:false,disabled:element.disabled},Object.keys(element.options).map(function(itemName){return React.createElement(RadioItem,{key:"".concat(name,"_").concat(itemName),id:"".concat(name,"_").concat(_camelCase(itemName)),name:itemName,label:element.options[itemName]});})),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));};ElementRadio.defaultProps={value:'',visible:true};export default memo(ElementRadio);
@@ -3,4 +3,4 @@ import _camelCase from"lodash/camelCase";import React,{memo}from'react';import P
3
3
  * @param {Object} props Component props.
4
4
  * @param {Object} props.element The data of the element to be rendered
5
5
  * @returns {JSX}
6
- */var ElementSelect=function ElementSelect(props){var element=props.element,errorText=props.errorText,name=props.name,value=props.value,visible=props.visible,formName=props.formName;if(!visible){return null;}return React.createElement("div",{className:classNames(_camelCase(name),'formBuilderField',{validationError:!!errorText})},React.createElement(Select,{name:name,label:element.label,placeholder:element.placeholder,value:value,options:element.options,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false,showErrorText:false,disabled:element.disabled}),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));};ElementSelect.defaultProps={value:'',visible:true};export default memo(ElementSelect);
6
+ */var ElementSelect=function ElementSelect(props){var element=props.element,errorText=props.errorText,name=props.name,value=props.value,visible=props.visible,formName=props.formName;if(!visible){return null;}return React.createElement("div",{className:classNames(_camelCase(name),'engage__form-select','formBuilderField',{validationError:!!errorText})},React.createElement(Select,{name:name,label:element.label,placeholder:element.placeholder,value:value,options:element.options,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false,showErrorText:false,disabled:element.disabled}),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));};ElementSelect.defaultProps={value:'',visible:true};export default memo(ElementSelect);
@@ -1,7 +1,7 @@
1
- import _camelCase from"lodash/camelCase";var _mapping;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,{memo}from'react';import PropTypes from'prop-types';import classNames from'classnames';import TextField from'@shopgate/pwa-ui-shared/TextField';import FormHelper from"./FormHelper";import{ELEMENT_TYPE_TEXT,ELEMENT_TYPE_NUMBER,ELEMENT_TYPE_EMAIL,ELEMENT_TYPE_PASSWORD,ELEMENT_TYPE_DATE,ELEMENT_TYPE_PHONE}from"./Builder.constants";// Map element type to input type
2
- var mapping=(_mapping={},_defineProperty(_mapping,ELEMENT_TYPE_TEXT,'text'),_defineProperty(_mapping,ELEMENT_TYPE_NUMBER,'number'),_defineProperty(_mapping,ELEMENT_TYPE_EMAIL,'email'),_defineProperty(_mapping,ELEMENT_TYPE_PASSWORD,'password'),_defineProperty(_mapping,ELEMENT_TYPE_DATE,'date'),_defineProperty(_mapping,ELEMENT_TYPE_PHONE,'tel'),_mapping);/**
1
+ import _camelCase from"lodash/camelCase";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,{memo}from'react';import PropTypes from'prop-types';import classNames from'classnames';import TextField from'@shopgate/pwa-ui-shared/TextField';import FormHelper from"./FormHelper";import{ELEMENT_TYPE_TEXT,ELEMENT_TYPE_NUMBER,ELEMENT_TYPE_EMAIL,ELEMENT_TYPE_PASSWORD,ELEMENT_TYPE_DATE,ELEMENT_TYPE_PHONE}from"./Builder.constants";// Map element type to input type
2
+ var mapping=_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},ELEMENT_TYPE_TEXT,'text'),ELEMENT_TYPE_NUMBER,'number'),ELEMENT_TYPE_EMAIL,'email'),ELEMENT_TYPE_PASSWORD,'password'),ELEMENT_TYPE_DATE,'date'),ELEMENT_TYPE_PHONE,'tel');/**
3
3
  * Takes an element and renders it, if the type matches
4
4
  * @param {Object} props Component props.
5
5
  * @param {Object} props.element The data of the element to be rendered
6
6
  * @returns {JSX}
7
- */var ElementText=function ElementText(props){var element=props.element,errorText=props.errorText,name=props.name,value=props.value,visible=props.visible,formName=props.formName;if(!visible){return null;}var type=mapping[element.type];return React.createElement("div",{className:classNames(_camelCase(name),'formBuilderField',{validationError:!!errorText})},React.createElement(TextField,{type:type,name:name,label:element.label,value:value,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false,showErrorText:false,disabled:element.disabled}),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));};ElementText.defaultProps={value:'',visible:true};export default memo(ElementText);
7
+ */var ElementText=function ElementText(props){var element=props.element,errorText=props.errorText,name=props.name,value=props.value,visible=props.visible,formName=props.formName;if(!visible){return null;}var type=mapping[element.type];return React.createElement("div",{className:classNames(_camelCase(name),'engage__form-text','formBuilderField',{validationError:!!errorText})},React.createElement(TextField,{type:type,name:name,label:element.label,value:value,onChange:element.handleChange,errorText:errorText,isControlled:true,translateErrorText:false,showErrorText:false,disabled:element.disabled}),React.createElement(FormHelper,{errorText:errorText,element:element,formName:formName}));};ElementText.defaultProps={value:'',visible:true};export default memo(ElementText);
@@ -1,2 +1,2 @@
1
- var _ACTION_RULE_DATA_TYP;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;}export var ACTION_TYPE_UPDATE_PROVINCE_ELEMENT='updateProvinceElement';export var ACTION_TYPE_SET_VISIBILITY='setVisibility';export var ACTION_TYPE_SET_VALUE='setValue';export var ACTION_TYPE_TRANSFORM='transform';export var ACTION_SET_VALUE_FIXED='fixed';export var ACTION_SET_VALUE_COPY_FROM='copyFrom';export var ACTION_SET_VALUE_LENGTH_OF='lengthOf';export var ACTION_RULE_TYPE_NOT_IN='notIn';export var ACTION_RULE_TYPE_ONE_OF='oneOf';export var ACTION_RULE_TYPE_BOOLEAN='boolean';export var ACTION_RULE_TYPE_REGEX='regex';// Rule data is formatted as array
2
- export var ACTION_RULE_DATA_TYPES=(_ACTION_RULE_DATA_TYP={},_defineProperty(_ACTION_RULE_DATA_TYP,ACTION_RULE_TYPE_NOT_IN,'array'),_defineProperty(_ACTION_RULE_DATA_TYP,ACTION_RULE_TYPE_ONE_OF,'array'),_defineProperty(_ACTION_RULE_DATA_TYP,ACTION_RULE_TYPE_BOOLEAN,'boolean'),_defineProperty(_ACTION_RULE_DATA_TYP,ACTION_RULE_TYPE_REGEX,'string'),_ACTION_RULE_DATA_TYP);export var ACTION_RULES_CONCAT_METHOD_ALL='all';export var ACTION_RULES_CONCAT_METHOD_ANY='any';export var ACTION_RULES_CONCAT_METHOD_NONE='none';
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;}export var ACTION_TYPE_UPDATE_PROVINCE_ELEMENT='updateProvinceElement';export var ACTION_TYPE_SET_VISIBILITY='setVisibility';export var ACTION_TYPE_SET_VALUE='setValue';export var ACTION_TYPE_TRANSFORM='transform';export var ACTION_SET_VALUE_FIXED='fixed';export var ACTION_SET_VALUE_COPY_FROM='copyFrom';export var ACTION_SET_VALUE_LENGTH_OF='lengthOf';export var ACTION_RULE_TYPE_NOT_IN='notIn';export var ACTION_RULE_TYPE_ONE_OF='oneOf';export var ACTION_RULE_TYPE_BOOLEAN='boolean';export var ACTION_RULE_TYPE_REGEX='regex';// Rule data is formatted as array
2
+ export var ACTION_RULE_DATA_TYPES=_defineProperty(_defineProperty(_defineProperty(_defineProperty({},ACTION_RULE_TYPE_NOT_IN,'array'),ACTION_RULE_TYPE_ONE_OF,'array'),ACTION_RULE_TYPE_BOOLEAN,'boolean'),ACTION_RULE_TYPE_REGEX,'string');export var ACTION_RULES_CONCAT_METHOD_ALL='all';export var ACTION_RULES_CONCAT_METHOD_ANY='any';export var ACTION_RULES_CONCAT_METHOD_NONE='none';
@@ -1,10 +1,14 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}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{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_NUMBER,ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE,ELEMENT_TYPE_CHECKBOX}from"../Builder.constants";import{ACTION_TYPE_UPDATE_PROVINCE_ELEMENT,ACTION_TYPE_SET_VISIBILITY,ACTION_TYPE_SET_VALUE,ACTION_TYPE_TRANSFORM,ACTION_SET_VALUE_FIXED,ACTION_SET_VALUE_COPY_FROM,ACTION_SET_VALUE_LENGTH_OF,ACTION_RULE_TYPE_NOT_IN,ACTION_RULE_TYPE_ONE_OF,ACTION_RULE_TYPE_BOOLEAN,ACTION_RULE_TYPE_REGEX,ACTION_RULE_DATA_TYPES,ACTION_RULES_CONCAT_METHOD_ALL,ACTION_RULES_CONCAT_METHOD_ANY,ACTION_RULES_CONCAT_METHOD_NONE}from"./ActionListener.constants";/**
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}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{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_NUMBER,ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE,ELEMENT_TYPE_CHECKBOX}from"../Builder.constants";import{ACTION_TYPE_UPDATE_PROVINCE_ELEMENT,ACTION_TYPE_SET_VISIBILITY,ACTION_TYPE_SET_VALUE,ACTION_TYPE_TRANSFORM,ACTION_SET_VALUE_FIXED,ACTION_SET_VALUE_COPY_FROM,ACTION_SET_VALUE_LENGTH_OF,ACTION_RULE_TYPE_NOT_IN,ACTION_RULE_TYPE_ONE_OF,ACTION_RULE_TYPE_BOOLEAN,ACTION_RULE_TYPE_REGEX,ACTION_RULE_DATA_TYPES,ACTION_RULES_CONCAT_METHOD_ALL,ACTION_RULES_CONCAT_METHOD_ANY,ACTION_RULES_CONCAT_METHOD_NONE}from"./ActionListener.constants";/**
2
2
  * ActionListener and handler for the FormBuilder component
3
- */var ActionListener=/**
3
+ */var ActionListener=/*#__PURE__*/_createClass(/**
4
4
  * Constructor
5
5
  * @param {function(string)} getProvincesList Takes a country code and returns a list of provinces
6
6
  * @param {Object} defaults Form defaults
7
- */function ActionListener(getProvincesList,defaults){var _this=this;_classCallCheck(this,ActionListener);_defineProperty(this,"attachAll",function(elementList){// Attach action listeners for element (context) actions
7
+ */function ActionListener(getProvincesList,defaults){var _this=this;_classCallCheck(this,ActionListener);/**
8
+ * Takes the elements to be rendered by the FormBuilder and attaches available action listeners
9
+ * to the component.
10
+ * @param {FormElement[]} elementList List of all elements
11
+ */_defineProperty(this,"attachAll",function(elementList){// Attach action listeners for element (context) actions
8
12
  elementList.forEach(function(element){var elementActions=element.actions;if(element.type===ELEMENT_TYPE_PROVINCE){elementActions=elementActions||[];// Requires a country element to create a "update provinces" action
9
13
  var countryElement=elementList.find(function(el){return el.type===ELEMENT_TYPE_COUNTRY;});if(countryElement){// Attach new action, which is always triggered, when the (only) country element changes
10
14
  elementActions.push({type:ACTION_TYPE_UPDATE_PROVINCE_ELEMENT,rules:[{context:countryElement.id}]});}}if(elementActions===undefined){return;}// Create listeners for all supported actions
@@ -12,29 +16,82 @@ elementActions.forEach(function(action){var actionRules=action.rules||[];// Alwa
12
16
  if(actionRules.length===0){// Define a basic rule if no rules given
13
17
  actionRules.push({context:element.id});}// Actions do have a fixed structure which needs to be fulfilled
14
18
  var normalizedAction=_extends({},action,{rules:actionRules});// Assign the action listeners to all contexts of the current element
15
- actionRules.forEach(function(rule){_this.attach(element,normalizedAction,rule);});});});});_defineProperty(this,"attach",function(element,action,rule){var actionListener;switch(action.type){case ACTION_TYPE_UPDATE_PROVINCE_ELEMENT:{actionListener=_this.createUpdateProvinceElementHandler(element,action);break;}case ACTION_TYPE_SET_VISIBILITY:{// Visibility is special and uses the result of the evaluation itself
16
- actionListener=_this.createSetVisibilityHandler(element,action);break;}case ACTION_TYPE_SET_VALUE:{actionListener=_this.createEvaluatedHandler(element,action,_this.createSetValueHandler(element,action));break;}case ACTION_TYPE_TRANSFORM:{actionListener=_this.createEvaluatedHandler(element,action,_this.createTransformHandler(element,action));break;}default:return;}_this.register(rule.context,actionListener);});_defineProperty(this,"createEvaluatedHandler",function(element,action,actionListener){return function(prevState,nextState){// Apply rules before accepting any changes
17
- if(!_this.evaluateRules(element,action,nextState)){return nextState;}return actionListener(prevState,nextState);};});_defineProperty(this,"createUpdateProvinceElementHandler",function(provinceEl,action){return function(prevState,nextState){var countryElementId=action.rules[0].context;var countryValue=nextState.formData[countryElementId];var countryDefault=_this.defaults[countryElementId];var newState=_extends({},nextState);// Overwrite province with the form's default, if country matches the default as well
19
+ actionRules.forEach(function(rule){_this.attach(element,normalizedAction,rule);});});});});/**
20
+ * Attaches one or possibly multiple action listeners for the given rule
21
+ * @param {FormElement} element The current element that is modified by the action
22
+ * @param {FormFieldAction} action The action and it's params
23
+ * @param {FormFieldActionRule} rule The rule to check in case the action listener is triggered
24
+ */_defineProperty(this,"attach",function(element,action,rule){var actionListener;switch(action.type){case ACTION_TYPE_UPDATE_PROVINCE_ELEMENT:{actionListener=_this.createUpdateProvinceElementHandler(element,action);break;}case ACTION_TYPE_SET_VISIBILITY:{// Visibility is special and uses the result of the evaluation itself
25
+ actionListener=_this.createSetVisibilityHandler(element,action);break;}case ACTION_TYPE_SET_VALUE:{actionListener=_this.createEvaluatedHandler(element,action,_this.createSetValueHandler(element,action));break;}case ACTION_TYPE_TRANSFORM:{actionListener=_this.createEvaluatedHandler(element,action,_this.createTransformHandler(element,action));break;}default:return;}_this.register(rule.context,actionListener);});/**
26
+ * Action listener creator to check all related rules before calling any further action listeners
27
+ * @param {FormElement} element The element for which the listener should be created for
28
+ * @param {FormFieldAction} action The action to be create a listener for
29
+ * @param {Function} actionListener The action listener to call if the rule applies
30
+ * @returns {Function} Returns a function to modify and return the modified state.
31
+ */_defineProperty(this,"createEvaluatedHandler",function(element,action,actionListener){return function(prevState,nextState){// Apply rules before accepting any changes
32
+ if(!_this.evaluateRules(element,action,nextState)){return nextState;}return actionListener(prevState,nextState);};});/**
33
+ * Action listener creator to handle "updateCountryChange" action
34
+ * @param {FormElement} provinceEl The element for which the listener should be created for
35
+ * @param {FormFieldAction} action The action to be create a listener for
36
+ * @returns {Function} Returns a function to modify and return the modified state.
37
+ */_defineProperty(this,"createUpdateProvinceElementHandler",function(provinceEl,action){return function(prevState,nextState){var countryElementId=action.rules[0].context;var countryValue=nextState.formData[countryElementId];var countryDefault=_this.defaults[countryElementId];var newState=_extends({},nextState);// Overwrite province with the form's default, if country matches the default as well
18
38
  if(countryValue===countryDefault){newState.formData[provinceEl.id]=_this.defaults[provinceEl.id];}else{// Update province to first or no selection, based on "required" attribute
19
- newState.formData[provinceEl.id]=!provinceEl.required?'':Object.keys(_this.getProvincesList(countryValue))[0];}return newState;};});_defineProperty(this,"createSetVisibilityHandler",function(element,action){return function(prevState,nextState){var newState=_extends({},nextState,{elementVisibility:_extends({},nextState.elementVisibility,_defineProperty({},element.id,_this.evaluateRules(element,action,nextState))),// Copy form data to be able to check changes and all follow up actions
39
+ newState.formData[provinceEl.id]=!provinceEl.required?'':Object.keys(_this.getProvincesList(countryValue))[0];}return newState;};});/**
40
+ * Action listener creator to handle "setVisibility" actions
41
+ * @param {FormElement} element The element for which the listener should be created for
42
+ * @param {FormFieldAction} action The action to be create a listener for
43
+ * @returns {Function} Returns a function to modify and return the modified state.
44
+ */_defineProperty(this,"createSetVisibilityHandler",function(element,action){return function(prevState,nextState){var newState=_extends({},nextState,{elementVisibility:_extends({},nextState.elementVisibility,_defineProperty({},element.id,_this.evaluateRules(element,action,nextState))),// Copy form data to be able to check changes and all follow up actions
20
45
  formData:_extends({},nextState.formData)});if(newState.formData[element.id]===undefined&&newState.elementVisibility[element.id]){newState.formData[element.id]=_this.defaults[element.id];}else if(!newState.elementVisibility[element.id]&&newState.formData[element.id]!==undefined){delete newState.formData[element.id];}// Notify follow up listeners about the current change
21
- if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};});_defineProperty(this,"createSetValueHandler",function(element,action){return function(prevState,nextState){if(_typeof(action.params)!=='object'||Array.isArray(action.params)){logger.error("Error: Invalid or missing form action in element '".concat(element.id,"'. ")+'Params must be in the format: { "type": string, "value": string }');return nextState;}var value=action.params.value;// Check correctness of value data type
46
+ if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};});/**
47
+ * Action listener creator to handle "setValue" actions
48
+ * @param {FormElement} element The element for which the listener should be created for
49
+ * @param {FormFieldAction} action The action to be create a listener for
50
+ * @returns {Function} Returns the modified state.
51
+ */_defineProperty(this,"createSetValueHandler",function(element,action){return function(prevState,nextState){if(_typeof(action.params)!=='object'||Array.isArray(action.params)){logger.error("Error: Invalid or missing form action in element '".concat(element.id,"'. ")+'Params must be in the format: { "type": string, "value": string }');return nextState;}var value=action.params.value;// Check correctness of value data type
22
52
  switch(_typeof(value)){case'boolean':if(element.type!==ELEMENT_TYPE_CHECKBOX){logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Allowed '".concat(ELEMENT_TYPE_CHECKBOX,"' data type for 'params.value' is: 'boolean'"));return nextState;}break;case'number':if(element.type!==ELEMENT_TYPE_NUMBER){logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Allowed '".concat(ELEMENT_TYPE_NUMBER,"' data types for 'params.value' are: ")+"'number' and 'string'");return nextState;}break;case'string':if(element.type===ELEMENT_TYPE_CHECKBOX){logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Allowed '".concat(ELEMENT_TYPE_CHECKBOX,"' data type for 'params.value' is: 'boolean'"));return nextState;}break;default:logger.error("Error: Invalid form action param in element '".concat(element.id,"'. ")+"Can not use '".concat(_typeof(value),"' data for elements of type '").concat(element.type,"'"));return nextState;}// Perform action based on "setValue" type, defined in params
23
53
  switch(action.params.type){case ACTION_SET_VALUE_LENGTH_OF:value="".concat(nextState.formData[action.params.value].length);break;case ACTION_SET_VALUE_COPY_FROM:value=nextState.formData[action.params.value];break;case undefined:case ACTION_SET_VALUE_FIXED:break;default:logger.error("Error: Invalid form action param 'type' in element '".concat(element.id,"'. ")+"Allowed param types are: '".concat(ACTION_SET_VALUE_LENGTH_OF,"', ")+"'".concat(ACTION_SET_VALUE_COPY_FROM,"', '").concat(ACTION_SET_VALUE_FIXED,"'"));return nextState;}var newState=_extends({},nextState,{formData:_extends({},nextState.formData,_defineProperty({},element.id,value))});// Notify follow up listeners about the current change, if there are any changes
24
- if(nextState.formData[element.id]!==value){newState=_this.notify(element.id,prevState,newState);}return newState;};});_defineProperty(this,"createTransformHandler",function(element,action){return function(prevState,nextState){/**
54
+ if(nextState.formData[element.id]!==value){newState=_this.notify(element.id,prevState,newState);}return newState;};});/**
55
+ * Action listener creator to handle "transform" actions
56
+ * @param {FormElement} element The element for which the listener should be created for
57
+ * @param {FormFieldAction} action The action to be create a listener for
58
+ * @returns {Function} Returns a function to modify and return the modified state.
59
+ */_defineProperty(this,"createTransformHandler",function(element,action){return function(prevState,nextState){/**
25
60
  * Takes a string and applies a case function on it
26
61
  * @param {string|boolean|number} subject The subject to be transformed
27
62
  * @returns {string|boolean|number}
28
63
  */var transform=function transform(subject){// Get optional params to be applied in the transformation process
29
64
  var args=action.params.value||[];if(Array.isArray(action.params.value)){args=action.params.value;}switch(_typeof(subject)){case'string':{if(typeof String.prototype[action.params.type]!=='function'&&typeof String[action.params.type]!=='function'){logger.error("Error: Invalid transform function passed to actions 'params.type' "+"attribute in element '".concat(element.id,"'. Must be withing 'String.prototype'!"));return subject;}if(typeof String.prototype[action.params.type]==='function'){return String.prototype[action.params.type].apply(subject,args);}return String[action.params.type](subject);}case'boolean':{if(typeof Boolean.prototype[action.params.type]!=='function'&&typeof Boolean[action.params.type]!=='function'){logger.error("Error: Invalid transform function passed to actions 'params.type' "+"attribute in element '".concat(element.id,"'. Must be withing 'String.prototype'!"));return subject;}if(typeof Boolean.prototype[action.params.type]==='function'){return Boolean.prototype[action.params.type].apply(subject,args);}return Boolean[action.params.type](subject);}case'number':{if(typeof Number.prototype[action.params.type]!=='function'&&typeof Number[action.params.type]!=='function'){logger.error("Error: Invalid transform function passed to actions 'params.type' "+"attribute in element '".concat(element.id,"'. Must be withing 'String.prototype'!"));return subject;}if(typeof Number.prototype[action.params.type]==='function'){return Number.prototype[action.params.type].apply(subject,args);}return Number[action.params.type](subject);}default:logger.error("Error: The given data can not be transformed. Must be of type 'string', "+"'boolean' or 'number'");return subject;}};var newState=_extends({},nextState,{formData:_extends({},nextState.formData,_defineProperty({},element.id,transform(nextState.formData[element.id])))});// Notify follow up listeners about the current change
30
- if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};});_defineProperty(this,"evaluateRules",function(element,action,nextState){var concatRules=_this.createConcatMethod(action.ruleConcatMethod);var resultInitValue=action.ruleConcatMethod!==ACTION_RULES_CONCAT_METHOD_ANY;var result=resultInitValue;action.rules.forEach(function(rule){var tmpResult=resultInitValue;var ruleType=rule.type;var ruleData=rule.data;// Default to rule type "boolean" and data true when type not given
65
+ if(nextState.formData[element.id]!==newState.formData[element.id]){newState=_this.notify(element.id,prevState,newState);}return newState;};});/**
66
+ * Evaluates all action rules of a given element action
67
+ *
68
+ * @param {FormElement} element The element of which the action rules should be evaluated
69
+ * @param {FormFieldAction} action The current action to be evaluate rules for
70
+ * @param {Object} nextState The state at the time before the "action" event finished
71
+ * @returns {boolean}
72
+ */_defineProperty(this,"evaluateRules",function(element,action,nextState){var concatRules=_this.createConcatMethod(action.ruleConcatMethod);var resultInitValue=action.ruleConcatMethod!==ACTION_RULES_CONCAT_METHOD_ANY;var result=resultInitValue;action.rules.forEach(function(rule){var tmpResult=resultInitValue;var ruleType=rule.type;var ruleData=rule.data;// Default to rule type "boolean" and data true when type not given
31
73
  if(ruleType===undefined){ruleType=ACTION_RULE_TYPE_BOOLEAN;ruleData=true;}// Check rule validity
32
74
  if(!ACTION_RULE_DATA_TYPES[ruleType]){logger.error("Error: Unknown action rule type '".concat(ruleType,"'in element '").concat(element.id,"'"));return;}// Check type of ruleData
33
75
  var ruleDataType=ACTION_RULE_DATA_TYPES[ruleType];if(ruleDataType==='array'&&!Array.isArray(ruleData)){logger.error("Error: Invalid FormBuilder action rule in element '".concat(element.id,"': ")+"data must be an 'array' for rule type '".concat(ruleType,"'"));return;}// eslint-disable-next-line valid-typeof
34
76
  if(ruleDataType!=='array'&&_typeof(ruleData)!==ruleDataType){logger.error("Error: Invalid FormBuilder action rule in element '".concat(element.id,"': ")+"data must be '".concat(ruleDataType,"' for rule type '").concat(ruleType,"'"));return;}switch(ruleType){case ACTION_RULE_TYPE_ONE_OF:{tmpResult=ruleData.includes(nextState.formData[rule.context]);break;}case ACTION_RULE_TYPE_NOT_IN:{tmpResult=!ruleData.includes(nextState.formData[rule.context]);break;}case ACTION_RULE_TYPE_BOOLEAN:{tmpResult=ruleData;break;}case ACTION_RULE_TYPE_REGEX:{var regexParts=ruleData.split('/');var regexPattern='';var regexParam='';if(regexParts.length===1){var _regexParts=_slicedToArray(regexParts,1);regexPattern=_regexParts[0];}else if(regexParts.length===3){regexParts.shift();var _regexParts2=_slicedToArray(regexParts,2);regexPattern=_regexParts2[0];var _regexParts2$=_regexParts2[1];regexParam=_regexParts2$===void 0?'':_regexParts2$;}else{logger.error("Error: Invalid regex string in action rule in element ".concat(element.id));break;}var regex=new RegExp(regexPattern,regexParam);tmpResult=regex.test(nextState.formData[rule.context]);break;}default:break;}// Concat rules based on the rule concat method of the action
35
- result=concatRules(result,tmpResult);});return result;});_defineProperty(this,"createConcatMethod",function(method){return function(prev,next){switch(method){case ACTION_RULES_CONCAT_METHOD_NONE:return prev&&!next;case ACTION_RULES_CONCAT_METHOD_ANY:return prev||next;case ACTION_RULES_CONCAT_METHOD_ALL:default:return prev&&next;}};});_defineProperty(this,"register",function(elementId,handler){if(!_this.actionListeners[elementId]){_this.actionListeners[elementId]=[];}_this.actionListeners[elementId].push(handler);});_defineProperty(this,"notify",function(elementId,prevState,nextState){var newState=nextState;if(_this.actionListeners[elementId]){_this.actionListeners[elementId].forEach(function(notifyListener){// Note: The order of state changes is applied in the same order of listener registration
36
- newState=notifyListener(prevState,newState);});}return newState;});this.defaults=defaults;this.getProvincesList=getProvincesList;this.actionListeners={};}/**
37
- * Takes the elements to be rendered by the FormBuilder and attaches available action listeners
38
- * to the component.
39
- * @param {FormElement[]} elementList List of all elements
40
- */;export default ActionListener;
77
+ result=concatRules(result,tmpResult);});return result;});/**
78
+ * Creates a concat function that defines how to concatenate action rule results
79
+ *
80
+ * @param {string} method The method defined by the action
81
+ * @returns {Function}
82
+ */_defineProperty(this,"createConcatMethod",function(method){return function(prev,next){switch(method){case ACTION_RULES_CONCAT_METHOD_NONE:return prev&&!next;case ACTION_RULES_CONCAT_METHOD_ANY:return prev||next;case ACTION_RULES_CONCAT_METHOD_ALL:default:return prev&&next;}};});/**
83
+ * Adds a "action" listener to a given context element
84
+ *
85
+ * @param {string} elementId the element to listen for
86
+ * @param {Function} handler The listener to call when something has changed
87
+ */_defineProperty(this,"register",function(elementId,handler){if(!_this.actionListeners[elementId]){_this.actionListeners[elementId]=[];}_this.actionListeners[elementId].push(handler);});/**
88
+ * Takes an element id, the state to work with and optional data and notifies all "action"
89
+ * listeners about the change. Every listener can manipulate the state.
90
+ * Returns the new state.
91
+ *
92
+ * @param {string} elementId The id of the element that was changed
93
+ * @param {Object} prevState The state before any changes took place
94
+ * @param {Object} nextState The state containing all updates before the listeners are executed
95
+ * @returns {Object} The new state after all handlers have been executed.
96
+ */_defineProperty(this,"notify",function(elementId,prevState,nextState){var newState=nextState;if(_this.actionListeners[elementId]){_this.actionListeners[elementId].forEach(function(notifyListener){// Note: The order of state changes is applied in the same order of listener registration
97
+ newState=notifyListener(prevState,newState);});}return newState;});this.defaults=defaults;this.getProvincesList=getProvincesList;this.actionListeners={};});export default ActionListener;
@@ -1,4 +1,4 @@
1
- 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;}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);}import{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE}from"../Builder.constants";/** Noop function */var noop=function noop(){};/**
1
+ var _excluded=["custom"];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;}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);}import{logger}from'@shopgate/pwa-core/helpers';import{ELEMENT_TYPE_COUNTRY,ELEMENT_TYPE_PROVINCE}from"../Builder.constants";/** Noop function */var noop=function noop(){};/**
2
2
  * @typedef {Object} FormElement
3
3
  * @property {string} id
4
4
  * @property {boolean} custom
@@ -26,6 +26,6 @@ function _objectWithoutProperties(source,excluded){if(source==null)return{};var
26
26
  */var addFormElement=function addFormElement(id,field){var custom=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;// The "custom" field is just a placeholder for more fields
27
27
  if(typeof field.type!=='string'){return;}// Make sure country and province elements are only added once
28
28
  if(field.type===ELEMENT_TYPE_COUNTRY){if(hasCountryElement){logger.error("Error: Can not add multiple elements of type '".concat(field.type,"'"));return;}hasCountryElement=true;}if(field.type===ELEMENT_TYPE_PROVINCE){if(hasProvinceElement){logger.error("Error: Can not add multiple elements of type '".concat(field.type,"'"));return;}hasProvinceElement=true;}elementList.push(_extends({id:id},field,{custom:custom,handleChange:function handleChange(value){return elementChangeHandler(id,value);}}));};// Extract custom fields, do not mix with normal fields
29
- var _formConfig$fields=formConfig.fields,custom=_formConfig$fields.custom,restFields=_objectWithoutProperties(_formConfig$fields,["custom"]);// Add all non-custom attributes and mark them as such
29
+ var _formConfig$fields=formConfig.fields,custom=_formConfig$fields.custom,restFields=_objectWithoutProperties(_formConfig$fields,_excluded);// Add all non-custom attributes and mark them as such
30
30
  Object.keys(restFields).forEach(function(id){addFormElement(id,formConfig.fields[id]);});// Add custom fields to the element list
31
31
  if(custom){Object.keys(custom).forEach(function(id){addFormElement(id,formConfig.fields.custom[id],true);});}return elementList;});
@@ -1,13 +1,16 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}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,{PureComponent}from'react';import PropTypes from'prop-types';import classNames from'classnames';/**
1
+ function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}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,{PureComponent}from'react';import PropTypes from'prop-types';import classNames from'classnames';/**
2
2
  * Form component that handles keyboard submit, next buttons, ...
3
- */var Form=/*#__PURE__*/function(_PureComponent){_inherits(Form,_PureComponent);function Form(props){var _this;_classCallCheck(this,Form);_this=_possibleConstructorReturn(this,_getPrototypeOf(Form).call(this,props));_defineProperty(_assertThisInitialized(_this),"handleSubmit",function(event){event.preventDefault();var inputFocused=[].concat(_this.formElement.current.querySelectorAll('input')).some(function(input){return document.activeElement===input;});if(inputFocused){document.activeElement.blur();}_this.props.onSubmit();});_defineProperty(_assertThisInitialized(_this),"handleKeyPress",function(event){// Enter key and on iOS also the "Done" button.
4
- if(event.which===13){_this.handleSubmit(event);}});_this.formElement=React.createRef();return _this;}/**
3
+ */var Form=/*#__PURE__*/function(_PureComponent){function Form(props){var _this2;_classCallCheck(this,Form);_this2=_callSuper(this,Form,[props]);/**
5
4
  * Handles the form submit.
6
5
  * @param {Object} event The event that caused the submit.
7
- */_createClass(Form,[{key:"render",/**
6
+ */_defineProperty(_this2,"handleSubmit",function(event){event.preventDefault();var inputFocused=[].concat(_this2.formElement.current.querySelectorAll('input')).some(function(input){return document.activeElement===input;});if(inputFocused){document.activeElement.blur();}_this2.props.onSubmit();});/**
7
+ * Handles form submits by key.
8
+ * @param {Object} event The event that caused the keypress.
9
+ */_defineProperty(_this2,"handleKeyPress",function(event){// Enter key and on iOS also the "Done" button.
10
+ if(event.which===13){_this2.handleSubmit(event);}});_this2.formElement=React.createRef();return _this2;}_inherits(Form,_PureComponent);return _createClass(Form,[{key:"render",value:/**
8
11
  * Renders the component.
9
12
  * @returns {JSX}
10
- */value:function render(){/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */return React.createElement("form",{action:"#",className:classNames(this.props.className,'form'),onSubmit:this.handleSubmit,onKeyPress:this.handleKeyPress,ref:this.formElement},this.props.children);/* eslint-enable jsx-a11y/no-noninteractive-element-interactions */}}]);return Form;}(PureComponent);_defineProperty(Form,"defaultProps",{className:null,onSubmit:function onSubmit(){}/**
13
+ */function render(){/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */return React.createElement("form",{action:"#",className:classNames(this.props.className,'form','engage__form'),onSubmit:this.handleSubmit,onKeyPress:this.handleKeyPress,ref:this.formElement},this.props.children);/* eslint-enable jsx-a11y/no-noninteractive-element-interactions */}}]);}(PureComponent);_defineProperty(Form,"defaultProps",{className:null,onSubmit:function onSubmit(){}/**
11
14
  * Initializes the form component.
12
15
  * @param {Object} props The components props.
13
16
  */});export default Form;