@wayke-se/components-react 5.1.0 → 5.2.0

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 (267) hide show
  1. package/README.md +476 -626
  2. package/dist/index.d.ts +2 -4317
  3. package/dist/index.js +786 -792
  4. package/dist/index.js.map +4 -4
  5. package/dist/index.mjs +783 -789
  6. package/dist/index.mjs.map +4 -4
  7. package/dist/types/src/@types/action.d.ts +3 -0
  8. package/dist/types/src/@types/codegen/types.d.ts +433 -0
  9. package/dist/types/src/@types/conversion.d.ts +45 -0
  10. package/dist/types/src/@types/filter.d.ts +5 -0
  11. package/dist/types/src/@types/market.d.ts +1 -0
  12. package/dist/types/src/@types/queryFilter.d.ts +5 -0
  13. package/dist/types/src/@types/search.d.ts +114 -0
  14. package/dist/types/src/@types/vehicle-properties.d.ts +29 -0
  15. package/dist/types/src/State/CentralStorage/CentralStorageContext.d.ts +5 -0
  16. package/dist/types/src/State/CentralStorage/CentralStorageProvider.d.ts +6 -0
  17. package/dist/types/src/State/CentralStorage/useCentralStorage.d.ts +6 -0
  18. package/dist/types/src/State/Path/PathContext.d.ts +8 -0
  19. package/dist/types/src/State/Path/PathProvider.d.ts +6 -0
  20. package/dist/types/src/State/Path/reducer.d.ts +14 -0
  21. package/dist/types/src/State/Path/usePath.d.ts +3 -0
  22. package/dist/types/src/State/RelatedSearch/RelatedSearchContext.d.ts +9 -0
  23. package/dist/types/src/State/RelatedSearch/RelatedSearchProvider.d.ts +9 -0
  24. package/dist/types/src/State/RelatedSearch/useRelatedSearch.d.ts +2 -0
  25. package/dist/types/src/State/Search/SearchContext.d.ts +14 -0
  26. package/dist/types/src/State/Search/SearchProvider.d.ts +10 -0
  27. package/dist/types/src/State/Search/useSearch.d.ts +2 -0
  28. package/dist/types/src/State/Settings/SettingsContext.d.ts +12 -0
  29. package/dist/types/src/State/Settings/SettingsProvider.d.ts +11 -0
  30. package/dist/types/src/State/Settings/useSettings.d.ts +2 -0
  31. package/dist/types/src/components/AccessoryCard/index.d.ts +16 -0
  32. package/dist/types/src/components/AccessoryCard/wrapper.d.ts +54 -0
  33. package/dist/types/src/components/Accordion/index.d.ts +13 -0
  34. package/dist/types/src/components/Accordion/wrapper.d.ts +42 -0
  35. package/dist/types/src/components/ActionList/index.d.ts +17 -0
  36. package/dist/types/src/components/ActionList/toggle-item.d.ts +13 -0
  37. package/dist/types/src/components/Avatar/index.d.ts +7 -0
  38. package/dist/types/src/components/Avatar/wrapper.d.ts +9 -0
  39. package/dist/types/src/components/Badge/index.d.ts +7 -0
  40. package/dist/types/src/components/Badge/wrapper.d.ts +9 -0
  41. package/dist/types/src/components/Blockquote/index.d.ts +9 -0
  42. package/dist/types/src/components/Blockquote/wrapper.d.ts +23 -0
  43. package/dist/types/src/components/Button/index.d.ts +207 -0
  44. package/dist/types/src/components/CheckMarkList/index.d.ts +7 -0
  45. package/dist/types/src/components/CheckMarkList/wrapper.d.ts +14 -0
  46. package/dist/types/src/components/Checklist/index.d.ts +13 -0
  47. package/dist/types/src/components/Checklist/wrapper.d.ts +28 -0
  48. package/dist/types/src/components/ColorSelect/index.d.ts +14 -0
  49. package/dist/types/src/components/ColorSelect/wrapper.d.ts +29 -0
  50. package/dist/types/src/components/ColumnRow/index.d.ts +6 -0
  51. package/dist/types/src/components/Columns/index.d.ts +20 -0
  52. package/dist/types/src/components/Container/index.d.ts +6 -0
  53. package/dist/types/src/components/Container/wrapper.d.ts +3 -0
  54. package/dist/types/src/components/Content/index.d.ts +6 -0
  55. package/dist/types/src/components/Content/wrapper.d.ts +7 -0
  56. package/dist/types/src/components/ContentLogo/index.d.ts +9 -0
  57. package/dist/types/src/components/CreditorDisclaimer/index.d.ts +2 -0
  58. package/dist/types/src/components/CreditorDisclaimer/wrapper.d.ts +14 -0
  59. package/dist/types/src/components/DataList/index.d.ts +10 -0
  60. package/dist/types/src/components/DataList/wrapper.d.ts +14 -0
  61. package/dist/types/src/components/DetailBox/index.d.ts +8 -0
  62. package/dist/types/src/components/DetailBox/wrapper.d.ts +98 -0
  63. package/dist/types/src/components/DocumentList/index.d.ts +11 -0
  64. package/dist/types/src/components/DocumentList/wrapper.d.ts +25 -0
  65. package/dist/types/src/components/ExtendContent/index.d.ts +8 -0
  66. package/dist/types/src/components/ExtendContent/wrapper.d.ts +13 -0
  67. package/dist/types/src/components/ExtendInfo/index.d.ts +7 -0
  68. package/dist/types/src/components/ExtendInfo/wrapper.d.ts +38 -0
  69. package/dist/types/src/components/Filter/index.d.ts +9 -0
  70. package/dist/types/src/components/Filter/wrapper.d.ts +27 -0
  71. package/dist/types/src/components/FilterPanel/checkListFacet.d.ts +7 -0
  72. package/dist/types/src/components/FilterPanel/colorFacet.d.ts +7 -0
  73. package/dist/types/src/components/FilterPanel/faceSelector.d.ts +7 -0
  74. package/dist/types/src/components/FilterPanel/index.d.ts +20 -0
  75. package/dist/types/src/components/FilterPanel/rangeFacet.d.ts +9 -0
  76. package/dist/types/src/components/FinancialOptions/LoanModal.d.ts +12 -0
  77. package/dist/types/src/components/FinancialOptions/index.d.ts +11 -0
  78. package/dist/types/src/components/FinancialOptions/leasing.d.ts +7 -0
  79. package/dist/types/src/components/FinancialOptions/loan.d.ts +11 -0
  80. package/dist/types/src/components/Gallery/MediaButton.d.ts +7 -0
  81. package/dist/types/src/components/Gallery/index.d.ts +10 -0
  82. package/dist/types/src/components/Gallery/wrapper.d.ts +74 -0
  83. package/dist/types/src/components/Grid/index.d.ts +13 -0
  84. package/dist/types/src/components/Grid/wrapper.d.ts +9 -0
  85. package/dist/types/src/components/Heading/index.d.ts +145 -0
  86. package/dist/types/src/components/Icon/index.d.ts +17 -0
  87. package/dist/types/src/components/Image/index.d.ts +3 -0
  88. package/dist/types/src/components/InputCheckbox/index.d.ts +7 -0
  89. package/dist/types/src/components/InputCheckbox/wrapper.d.ts +31 -0
  90. package/dist/types/src/components/InputError/index.d.ts +7 -0
  91. package/dist/types/src/components/InputError/wrapper.d.ts +3 -0
  92. package/dist/types/src/components/InputGroup/index.d.ts +6 -0
  93. package/dist/types/src/components/InputLabel/index.d.ts +7 -0
  94. package/dist/types/src/components/InputLabel/wrapper.d.ts +5 -0
  95. package/dist/types/src/components/InputSearch/index.d.ts +11 -0
  96. package/dist/types/src/components/InputSearch/wrapper.d.ts +42 -0
  97. package/dist/types/src/components/InputSelect/index.d.ts +14 -0
  98. package/dist/types/src/components/InputSelect/wrapper.d.ts +14 -0
  99. package/dist/types/src/components/InputText/index.d.ts +7 -0
  100. package/dist/types/src/components/InputText/wrapper.d.ts +9 -0
  101. package/dist/types/src/components/InputTextarea/index.d.ts +7 -0
  102. package/dist/types/src/components/InputTextarea/wrapper.d.ts +8 -0
  103. package/dist/types/src/components/InsuranceOptions/Insurance.d.ts +9 -0
  104. package/dist/types/src/components/InsuranceOptions/InsuranceFree.d.ts +9 -0
  105. package/dist/types/src/components/InsuranceOptions/InsuranceFreeModal.d.ts +8 -0
  106. package/dist/types/src/components/InsuranceOptions/InsuranceModal.d.ts +10 -0
  107. package/dist/types/src/components/InsuranceOptions/index.d.ts +9 -0
  108. package/dist/types/src/components/LeadForm/index.d.ts +15 -0
  109. package/dist/types/src/components/LeadForm/wrapper.d.ts +3 -0
  110. package/dist/types/src/components/Lightbox/index.d.ts +9 -0
  111. package/dist/types/src/components/Lightbox/wrapper.d.ts +26 -0
  112. package/dist/types/src/components/Link/index.d.ts +9 -0
  113. package/dist/types/src/components/Loader/index.d.ts +7 -0
  114. package/dist/types/src/components/Loader/wrapper.d.ts +13 -0
  115. package/dist/types/src/components/LogoBox/index.d.ts +9 -0
  116. package/dist/types/src/components/LogoBox/wrapper.d.ts +7 -0
  117. package/dist/types/src/components/Map/index.d.ts +7 -0
  118. package/dist/types/src/components/Map/wrapper.d.ts +12 -0
  119. package/dist/types/src/components/Modal/index.d.ts +9 -0
  120. package/dist/types/src/components/Modal/wrapper.d.ts +51 -0
  121. package/dist/types/src/components/NavButton/index.d.ts +12 -0
  122. package/dist/types/src/components/OpeningHours/index.d.ts +7 -0
  123. package/dist/types/src/components/OptionBox/index.d.ts +9 -0
  124. package/dist/types/src/components/OptionBox/wrapper.d.ts +20 -0
  125. package/dist/types/src/components/OverflowBox/index.d.ts +6 -0
  126. package/dist/types/src/components/OverflowBox/wrapper.d.ts +3 -0
  127. package/dist/types/src/components/OverflowGrid/index.d.ts +12 -0
  128. package/dist/types/src/components/OverflowGrid/wrapper.d.ts +44 -0
  129. package/dist/types/src/components/Page/index.d.ts +12 -0
  130. package/dist/types/src/components/Panel/index.d.ts +10 -0
  131. package/dist/types/src/components/Panel/wrapper.d.ts +50 -0
  132. package/dist/types/src/components/PhoneNumber/index.d.ts +6 -0
  133. package/dist/types/src/components/Portal/index.d.ts +4 -0
  134. package/dist/types/src/components/Portal/portal-element.d.ts +6 -0
  135. package/dist/types/src/components/Portal/portal-namespace.d.ts +1 -0
  136. package/dist/types/src/components/Portal/portal.d.ts +7 -0
  137. package/dist/types/src/components/Price/index.d.ts +8 -0
  138. package/dist/types/src/components/PriceBox/index.d.ts +11 -0
  139. package/dist/types/src/components/PriceBox/wrapper.d.ts +18 -0
  140. package/dist/types/src/components/PriceTable/index.d.ts +7 -0
  141. package/dist/types/src/components/PriceTable/wrapper.d.ts +12 -0
  142. package/dist/types/src/components/ProductCard/index.d.ts +27 -0
  143. package/dist/types/src/components/ProductCard/wrapper.d.ts +62 -0
  144. package/dist/types/src/components/ProductPage/index.d.ts +22 -0
  145. package/dist/types/src/components/ProgressBar/index.d.ts +7 -0
  146. package/dist/types/src/components/ProgressBar/wrapper.d.ts +14 -0
  147. package/dist/types/src/components/RangeSlider/RangeSliderSimple.d.ts +13 -0
  148. package/dist/types/src/components/RangeSlider/SliderWithLabel.d.ts +13 -0
  149. package/dist/types/src/components/RangeSlider/handle.d.ts +9 -0
  150. package/dist/types/src/components/RangeSlider/index.d.ts +13 -0
  151. package/dist/types/src/components/RangeSlider/track.d.ts +9 -0
  152. package/dist/types/src/components/RangeSlider/wrapper.d.ts +22 -0
  153. package/dist/types/src/components/RangeSliderLabel/index.d.ts +8 -0
  154. package/dist/types/src/components/RangeSliderLabel/wrapper.d.ts +17 -0
  155. package/dist/types/src/components/Repeat/index.d.ts +9 -0
  156. package/dist/types/src/components/Result/index.d.ts +6 -0
  157. package/dist/types/src/components/Result/wrapper.d.ts +27 -0
  158. package/dist/types/src/components/Root/index.d.ts +6 -0
  159. package/dist/types/src/components/SearchBar/index.d.ts +8 -0
  160. package/dist/types/src/components/SearchFilter/index.d.ts +3 -0
  161. package/dist/types/src/components/SearchTerm/index.d.ts +8 -0
  162. package/dist/types/src/components/SearchTerm/wrapper.d.ts +20 -0
  163. package/dist/types/src/components/SectionHeader/index.d.ts +8 -0
  164. package/dist/types/src/components/SectionHeader/wrapper.d.ts +9 -0
  165. package/dist/types/src/components/Snackbar/index.d.ts +9 -0
  166. package/dist/types/src/components/Snackbar/wrapper.d.ts +21 -0
  167. package/dist/types/src/components/SortSelect/index.d.ts +14 -0
  168. package/dist/types/src/components/SortSelect/wrapper.d.ts +14 -0
  169. package/dist/types/src/components/Sphere/Sphere.d.ts +6 -0
  170. package/dist/types/src/components/Sphere/SphereLightbox.d.ts +6 -0
  171. package/dist/types/src/components/Sphere/SphereViewer.d.ts +9 -0
  172. package/dist/types/src/components/Sphere/wrapper.d.ts +5 -0
  173. package/dist/types/src/components/SrOnly/index.d.ts +3 -0
  174. package/dist/types/src/components/StateIndicator/index.d.ts +7 -0
  175. package/dist/types/src/components/SwitchBar/index.d.ts +10 -0
  176. package/dist/types/src/components/SwitchBar/wrapper.d.ts +46 -0
  177. package/dist/types/src/components/TableColumn/index.d.ts +9 -0
  178. package/dist/types/src/components/TableList/index.d.ts +18 -0
  179. package/dist/types/src/components/Tabs/index.d.ts +12 -0
  180. package/dist/types/src/components/Tabs/wrapper.d.ts +37 -0
  181. package/dist/types/src/components/ThreeSixty/Rotation.d.ts +6 -0
  182. package/dist/types/src/components/ThreeSixty/ThreeSixtLightbox.d.ts +6 -0
  183. package/dist/types/src/components/ThreeSixty/ThreeSixty.d.ts +9 -0
  184. package/dist/types/src/components/UspList/index.d.ts +11 -0
  185. package/dist/types/src/components/UspList/wrapper.d.ts +37 -0
  186. package/dist/types/src/components/Utility/index.d.ts +16 -0
  187. package/dist/types/src/components/Video/CustomPlayer.d.ts +10 -0
  188. package/dist/types/src/components/Video/EmbeddedVideoLightbox.d.ts +8 -0
  189. package/dist/types/src/components/Video/EmbededVideo.d.ts +8 -0
  190. package/dist/types/src/components/Video/QuickNavEmbeded.d.ts +7 -0
  191. package/dist/types/src/components/Video/QuickNavVideo.d.ts +7 -0
  192. package/dist/types/src/components/Video/Video.d.ts +8 -0
  193. package/dist/types/src/components/Video/VimeoPlayer.d.ts +7 -0
  194. package/dist/types/src/components/Video/YoutubePlayer.d.ts +7 -0
  195. package/dist/types/src/components/Video/useThumbnail.d.ts +2 -0
  196. package/dist/types/src/components/Video/utils.d.ts +9 -0
  197. package/dist/types/src/components/Video/wrapper.d.ts +13 -0
  198. package/dist/types/src/hooks/apolloTypes.d.ts +6 -0
  199. package/dist/types/src/hooks/useFetch.d.ts +7 -0
  200. package/dist/types/src/hooks/useHasBeenVisible.d.ts +2 -0
  201. package/dist/types/src/hooks/useHashGuid.d.ts +2 -0
  202. package/dist/types/src/hooks/useInitializeTranslation.d.ts +3 -0
  203. package/dist/types/src/hooks/useInsurance.d.ts +4 -0
  204. package/dist/types/src/hooks/useIsInViewport.d.ts +5 -0
  205. package/dist/types/src/hooks/useLoan.d.ts +4 -0
  206. package/dist/types/src/hooks/useOnScreen.d.ts +2 -0
  207. package/dist/types/src/hooks/useOutsideClick.d.ts +2 -0
  208. package/dist/types/src/hooks/usePrevious.d.ts +2 -0
  209. package/dist/types/src/hooks/useSearchItem.d.ts +4 -0
  210. package/dist/types/src/hooks/useSearchItemBranch.d.ts +4 -0
  211. package/dist/types/src/hooks/useSessionStorage.d.ts +7 -0
  212. package/dist/types/src/hooks/useSubmitLead.d.ts +29 -0
  213. package/dist/types/src/hooks/useVimeoThumbnail.d.ts +2 -0
  214. package/dist/types/src/index.d.ts +13 -0
  215. package/dist/types/src/layout/helpers.d.ts +1 -0
  216. package/dist/types/src/layout/keyframes.d.ts +3 -0
  217. package/dist/types/src/layout/theme.d.ts +49 -0
  218. package/dist/types/src/layouts/WaykeComposite.d.ts +12 -0
  219. package/dist/types/src/layouts/WaykeCompositeWithProvider.d.ts +9 -0
  220. package/dist/types/src/layouts/search/index.d.ts +19 -0
  221. package/dist/types/src/layouts/searchItem/Accessories/AccessoryModal.d.ts +8 -0
  222. package/dist/types/src/layouts/searchItem/Accessories/index.d.ts +7 -0
  223. package/dist/types/src/layouts/searchItem/Branch.d.ts +9 -0
  224. package/dist/types/src/layouts/searchItem/BranchModal.d.ts +9 -0
  225. package/dist/types/src/layouts/searchItem/CheckList.d.ts +21 -0
  226. package/dist/types/src/layouts/searchItem/DemoCarModal.d.ts +6 -0
  227. package/dist/types/src/layouts/searchItem/Documents.d.ts +7 -0
  228. package/dist/types/src/layouts/searchItem/ManufacturerPackagesOption.d.ts +7 -0
  229. package/dist/types/src/layouts/searchItem/MetadataItem.d.ts +10 -0
  230. package/dist/types/src/layouts/searchItem/PackageOptionModal.d.ts +17 -0
  231. package/dist/types/src/layouts/searchItem/PackageOptions.d.ts +7 -0
  232. package/dist/types/src/layouts/searchItem/Page404.d.ts +3 -0
  233. package/dist/types/src/layouts/searchItem/PageLoading.d.ts +3 -0
  234. package/dist/types/src/layouts/searchItem/Property.d.ts +8 -0
  235. package/dist/types/src/layouts/searchItem/Related.d.ts +11 -0
  236. package/dist/types/src/layouts/searchItem/index.d.ts +17 -0
  237. package/dist/types/src/layouts/searchItem/useEcom.d.ts +8 -0
  238. package/dist/types/src/providers/WaykeItemProvidet.d.ts +24 -0
  239. package/dist/types/src/providers/WaykeProvider.d.ts +26 -0
  240. package/dist/types/src/providers/graphqlProvider.d.ts +6 -0
  241. package/dist/types/src/providers/themeProvider.d.ts +6 -0
  242. package/dist/types/src/queries/INSURANCE_CALCULATION.d.ts +2 -0
  243. package/dist/types/src/queries/LOAN_CALCULATION.d.ts +2 -0
  244. package/dist/types/src/queries/SEARCH_ITEM_BRANCH_QUERY.d.ts +2 -0
  245. package/dist/types/src/queries/SEARCH_ITEM_QUERY.d.ts +2 -0
  246. package/dist/types/src/utils/I18n.d.ts +4 -0
  247. package/dist/types/src/utils/constants.d.ts +67 -0
  248. package/dist/types/src/utils/converters.d.ts +1 -0
  249. package/dist/types/src/utils/deep-copy.d.ts +5 -0
  250. package/dist/types/src/utils/formats.d.ts +8 -0
  251. package/dist/types/src/utils/phonenumbers.d.ts +1 -0
  252. package/dist/types/src/utils/pubsub/Actions.d.ts +16 -0
  253. package/dist/types/src/utils/pubsub/Events.d.ts +147 -0
  254. package/dist/types/src/utils/pubsub/pubsub.d.ts +44 -0
  255. package/dist/types/src/utils/regex.d.ts +3 -0
  256. package/dist/types/src/utils/sortOptions.d.ts +13 -0
  257. package/dist/types/src/utils/specification.d.ts +28 -0
  258. package/dist/types/src/utils/ssn.d.ts +1 -0
  259. package/dist/types/src/utils/url.d.ts +1 -0
  260. package/dist/types/src/utils/vehicle-properties/compare-basic-properties.d.ts +3 -0
  261. package/dist/types/src/utils/vehicle-properties/compare-categories.d.ts +3 -0
  262. package/dist/types/src/utils/vehicle-properties/compare-properties.d.ts +3 -0
  263. package/dist/types/src/utils/vehicle-properties/custom-property-adder.d.ts +13 -0
  264. package/dist/types/src/utils/vehicle-properties/property-remover.d.ts +7 -0
  265. package/dist/types/src/utils/vehicle-properties/property-tree-creator.d.ts +31 -0
  266. package/dist/types/src/utils/vehicle-properties/property-tree-sorter.d.ts +3 -0
  267. package/package.json +29 -26
package/README.md CHANGED
@@ -1,761 +1,611 @@
1
- # Components React
1
+ # Wayke Components React
2
2
 
3
- > This repository contains components for search and items to use on external websites.
3
+ Vehicle search and vehicle pages from Wayke, ready to add to a dealer or partner website. Visitors can search and filter the vehicles, open a vehicle, contact the dealer and buy the vehicle online.
4
4
 
5
- ## Notes
5
+ ## Quick start
6
6
 
7
- * Starting from version `2.0.0` and above will require import of `@wayke-se/components-react/dist/assets/default.css` in order to apply basic styling to the gallery.
7
+ Add this where the vehicles should be shown, for example in an HTML block in your CMS, such as WordPress:
8
8
 
9
- ## Usage
10
-
11
- Install
12
- ```bash
13
- npm install @wayke-se/components-react
9
+ ```html
10
+ <div id="wayke"></div>
11
+ <script type="module">
12
+ import { mount } from 'https://cdn.wayke.se/public-assets/wayke-components-react/5.2.0/index.js';
13
+
14
+ mount('#wayke', {
15
+ provider: {
16
+ graphQlUrl: 'https://gql.wayke.se/query',
17
+ url: 'https://api.wayke.se/vehicles',
18
+ urlMlt: 'https://api.wayke.se/vehicles-mlt-ext',
19
+ ecomSettings: { url: 'https://ecom.wayke.se' },
20
+ },
21
+ });
22
+ </script>
14
23
  ```
15
24
 
16
- Install peer dependencies
17
- ```bash
18
- npm install react react-dom styled-components
19
- ```
25
+ Two things to know:
20
26
 
21
- Install the ecom stylesheet (optional, only if you use `ecomSettings`, see [Ecom theme](#ecom-theme))
22
- ```bash
23
- npm install @wayke-se/ecom-web
24
- ```
27
+ * **Your domain has to be registered with Wayke.** Wayke shows the vehicles that belong to your site, and recognizes the site by its domain. Until the domain is registered, the search loads but shows no vehicles. Ask your contact at Wayke to register it, and see [Environments](#environments) for development.
28
+ * **Set the colors and font** to match your site, see [Colors and fonts](#colors-and-fonts).
25
29
 
26
- ```javascript
27
- import React from 'react';
28
- import WaykeComposite, { WaykeProviderSettings } from '@wayke-se/components-react'
29
- import '@wayke-se/components-react/dist/assets/default.css';
30
- // Optional, only if you use ecomSettings
31
- import '@wayke-se/ecom-web/dist/index.css';
30
+ That is all you need on most sites. The rest of this page covers other ways to add the components, the settings and the details.
32
31
 
33
- const ProviderSettings: WaykeProviderSettings = {
34
- graphQlUrl: "https://gql.wayketech.se/query",
35
- url: "https://api.wayketech.se/vehicles",
36
- urlMlt: "https://api.wayketech.se/vehicles-mlt-ext",
37
- ecomSettings: {
38
- url: "OPTIONAL_ECOM_URL",
39
- },
40
- googleMapsApiKey: "OPTIONAL_GOOGLE_MAPS_STATIC_API_KEY",
41
- }
32
+ ## Contents
42
33
 
43
- const App = () => (
44
- <WaykeComposite
45
- provider={ProviderSettings}
46
- />
47
- );
48
- ```
34
+ * [Add to your site](#add-to-your-site): [CDN](#cdn), [React](#react), [Without React](#without-react)
35
+ * [Environments](#environments)
36
+ * [Customize](#customize): [colors and fonts](#colors-and-fonts), [buy online colors](#buy-online-colors), [contact buttons](#contact-buttons), [filters](#filters), [language](#language), [search or vehicle page only](#search-or-vehicle-page-only)
37
+ * [Routing](#routing)
38
+ * [Events](#events)
39
+ * [Reference](#reference)
49
40
 
50
- ### Environments for test
51
- ```javascript
52
- const ProviderSettings: WaykeProviderSettings = {
53
- graphQlUrl: "https://gql.wayketech.se/query",
54
- url: "https://api.wayketech.se/vehicles",
55
- urlMlt: "https://api.wayketech.se/vehicles-mlt-ext",
56
- ecomSettings: {
57
- url: "https://ecom.wayketech.se",
58
- },
59
- }
60
- ```
41
+ ## Add to your site
61
42
 
62
- ### Environments for production
63
- ```javascript
64
- const ProviderSettings: WaykeProviderSettings = {
65
- graphQlUrl: "https://gql.wayke.se/query",
66
- url: "https://api.wayke.se/vehicles",
67
- urlMlt: "https://api.wayke.se/vehicles-mlt-ext",
68
- ecomSettings: {
69
- url: "https://ecom.wayke.se",
70
- },
71
- }
72
- ```
43
+ | Your site | Use |
44
+ |-----------|-----|
45
+ | Any website, without a build step, such as a CMS or static HTML | [CDN](#cdn) |
46
+ | A React app | [React](#react) |
47
+ | A website with its own bundler (webpack, Vite, ...) but no React | [Without React](#without-react) |
73
48
 
49
+ ### CDN
74
50
 
75
- ### WaykeComposite uses hash-route, i want to use path-route
51
+ Every release from `5.2.0` is published to the Wayke CDN with everything included: React, the styles and the buy online flow. Nothing needs to be installed.
76
52
 
77
- In this case you need to make sure that you are in control of the routing, if the user reloads the page, where same html file is
78
- served for `/your/path/to/this/component` and `/your/path/to/this/component/00000000-0000-0000-0000-000000000000`.
53
+ ```
54
+ https://cdn.wayke.se/public-assets/wayke-components-react/<version>/index.js
55
+ ```
79
56
 
80
- Examples given the application is located in `/search/vehicles`:
57
+ Use an exact version. The files of a version never change, so your site only changes when you update the version in the snippet. The latest version is shown on [npm](https://www.npmjs.com/package/@wayke-se/components-react).
81
58
 
82
- 1) pathRoute is `/search/vehicles` => `//yoursite.com/search/vehicles/00000000-0000-0000-0000-000000000000`
83
- 2) pathRoute is `/item` => `//yoursite.com/item/00000000-0000-0000-0000-000000000000`
84
- 3) pathRoute is `/a/b` => `//yoursite.com/a/b/00000000-0000-0000-0000-000000000000`
85
- 4) pathRoute is `item` => `//yoursite.com/search/item/00000000-0000-0000-0000-000000000000`
86
- 5) pathRoute is `a/b` => `//yoursite.com/search/a/b/00000000-0000-0000-0000-000000000000`
87
- 6) pathRoute is `https://www.wayke.se/objekt` => `https://www.wayke.se/objekt/00000000-0000-0000-0000-000000000000`
59
+ There are two ways to load the script. They show the same thing and take the same settings.
88
60
 
89
- The id is appended with a `/`, so `pathRoute` should not end with a slash.
61
+ **Option A: import** (recommended) is the snippet in [Quick start](#quick-start).
90
62
 
91
- ```javascript
92
- import React from 'react';
93
- import WaykeComposite from '@wayke-se/components-react'
94
- import '@wayke-se/components-react/dist/assets/default.css';
95
- // Optional, only if you use ecomSettings
96
- import '@wayke-se/ecom-web/dist/index.css';
63
+ **Option B: script tag.** The script sets `window.WaykeComponents` when it has loaded. Module scripts run after the page has been read, so wait for `DOMContentLoaded` before you use it. If the snippet is added after the page has loaded, for example by a tag manager, `DOMContentLoaded` has already happened, so use option A.
97
64
 
98
- const App = () => (
99
- <WaykeComposite
100
- composite={{
101
- // ...other composite props
102
- pathRoute: "/your/path/to/this/component"
103
- }}
104
- provider={ProviderSettings}
105
- />
106
- );
65
+ ```html
66
+ <div id="wayke"></div>
67
+ <script type="module" src="https://cdn.wayke.se/public-assets/wayke-components-react/5.2.0/index.js"></script>
68
+ <script>
69
+ window.addEventListener('DOMContentLoaded', () => {
70
+ WaykeComponents.mount('#wayke', {
71
+ provider: {
72
+ graphQlUrl: 'https://gql.wayke.se/query',
73
+ url: 'https://api.wayke.se/vehicles',
74
+ urlMlt: 'https://api.wayke.se/vehicles-mlt-ext',
75
+ ecomSettings: { url: 'https://ecom.wayke.se' },
76
+ },
77
+ });
78
+ });
79
+ </script>
107
80
  ```
108
81
 
109
- ### I only want to use the search component
82
+ #### Functions
110
83
 
111
- It's recomended to place WaykeProvider close to app-root in order to keep the cache
84
+ | Function | Settings | Shows |
85
+ |---------------|-------------------------------------------|-------------------------------------------|
86
+ | `mount` | `{ provider, composite? }` | Search, and the vehicle page when a vehicle is opened ([WaykeComposite](#waykecomposite)) |
87
+ | `mountSearch` | `{ provider, search? }` | Only the search ([WaykeSearch](#waykesearch)) |
88
+ | `mountItem` | `{ provider, item }` | Only one vehicle page, `item.id` is required ([WaykeSearchItem](#waykesearchitem)) |
112
89
 
113
- ```javascript
114
- import React, { useCallback } from 'react';
115
- import { WaykeProvider, WaykeSearch } from '@wayke-se/components-react'
116
-
117
- const App = () => {
118
- const onClickSearchItem = useCallback((data) => {
119
- console.log(data.id, data.branchId, data.branchName);
120
- }, []);
121
-
122
- return (
123
- <WaykeProvider {...ProviderSettings}>
124
- <WaykeSearch onClickSearchItem={onClickSearchItem} />
125
- </WaykeProvider>
126
- );
127
- };
90
+ * The first argument is a CSS selector, such as `'#wayke'`, or an element.
91
+ * `provider` is [WaykeProviderSettings](#waykeprovidersettings) (for `mountItem`: [WaykeItemProviderSettings](#waykeitemprovidersettings)).
92
+ * Each function returns `{ unmount }`, which removes the components again.
93
+ * `WaykePubSub` is exported too, and is available as `WaykeComponents.WaykePubSub` in option B. See [Events](#events).
94
+
95
+ #### Stylesheet
96
+
97
+ The script adds its stylesheet, `index.css` in the same folder, to the top of `<head>`, and shows the components when it has loaded. Since it is added first, the styles of your site override it.
98
+
99
+ To load the stylesheet yourself, add a `<link>` to it with the same URL. The script finds it and does not add it again. This works with both options.
100
+
101
+ ```html
102
+ <link rel="stylesheet" href="https://cdn.wayke.se/public-assets/wayke-components-react/5.2.0/index.css">
128
103
  ```
129
104
 
130
- If neither `hashRoute` nor `pathRoute` is set, the vehicle cards are not links. Use `onClickSearchItem` to handle navigation to the vehicle yourself.
105
+ To not load the stylesheet at all, add `disablecssinjection` to the script tag in option B. The image carousel, the 360 viewer and buy online are then unstyled.
131
106
 
132
- ### I only want to use the Search Item component
107
+ ```html
108
+ <script type="module" src="https://cdn.wayke.se/public-assets/wayke-components-react/5.2.0/index.js" disablecssinjection></script>
109
+ ```
133
110
 
134
- It's recomended to place WaykeItemProvider close to app-root in order to keep the cache
111
+ ### React
135
112
 
136
- ```javascript
137
- import React, { useCallback } from 'react';
138
- import { WaykeItemProvider, WaykeSearchItem } from '@wayke-se/components-react'
113
+ Install the package and its peer dependencies. Install `@wayke-se/ecom-web` too if you use buy online (`ecomSettings`), since the package does not include its stylesheet.
114
+
115
+ ```bash
116
+ npm install @wayke-se/components-react react react-dom styled-components
117
+ npm install @wayke-se/ecom-web
118
+ ```
119
+
120
+ ```tsx
121
+ import React from 'react';
122
+ import WaykeComposite, { type WaykeProviderSettings } from '@wayke-se/components-react';
139
123
  import '@wayke-se/components-react/dist/assets/default.css';
140
- // Optional, only if you use ecomSettings
141
- import '@wayke-se/ecom-web/dist/index.css';
142
-
143
- const App = ({}) => {
144
- const id = 'd01f79a3-7552-49c4-9d4d-deb3aa581c31';
145
-
146
- // Optional, triggered when a related vehicle is clicked
147
- const onClickSearchItem = useCallback((id: string) => {
148
- console.log(id);
149
- }, []);
150
-
151
- return (
152
- <WaykeItemProvider {...ProviderSettings}>
153
- <WaykeSearchItem id={id} onClickSearchItem={onClickSearchItem} />
154
- </WaykeItemProvider>
155
- );
124
+ import '@wayke-se/ecom-web/dist/index.css'; // Only with ecomSettings
125
+
126
+ const ProviderSettings: WaykeProviderSettings = {
127
+ graphQlUrl: 'https://gql.wayke.se/query',
128
+ url: 'https://api.wayke.se/vehicles',
129
+ urlMlt: 'https://api.wayke.se/vehicles-mlt-ext',
130
+ ecomSettings: { url: 'https://ecom.wayke.se' },
156
131
  };
132
+
133
+ const App = () => <WaykeComposite provider={ProviderSettings} />;
157
134
  ```
158
135
 
159
- ### I want to use the components on a site that doesn't use React
136
+ The React examples further down use this `ProviderSettings`.
137
+
138
+ With `ecomSettings`, your bundler has to replace `process.env`, since the bundled buy online code reads `process.env.WAYKE_ECOM_API_ADDRESS`. With esbuild: `--define:process.env='{"NODE_ENV":"production"}'`. With Vite: `define: { 'process.env': {} }`.
160
139
 
161
- The components are built with React, but they can be mounted into any element on any website. React is then bundled with your JavaScript, which adds to the loading time of the site.
140
+ ### Without React
162
141
 
163
- You need a bundler (for example webpack, esbuild, Rollup or Vite) that can bundle the JavaScript and the imported CSS files.
142
+ The components can be added to any element on any website. React is then bundled with your JavaScript. If you don't already use a bundler, the [CDN](#cdn) is easier.
164
143
 
165
- Install the package and its peer dependencies
166
144
  ```bash
167
145
  npm install @wayke-se/components-react react react-dom styled-components
168
- # Optional, only if you use ecomSettings
169
- npm install @wayke-se/ecom-web
146
+ npm install @wayke-se/ecom-web # Only with ecomSettings
170
147
  ```
171
148
 
172
- Add an element where the components should be rendered
173
149
  ```html
174
- <div id="wayke-components"></div>
150
+ <div id="wayke"></div>
175
151
  <script src="your-bundle.js"></script>
176
152
  ```
177
153
 
178
- Mount the component into the element. `createElement` is used instead of JSX, so no JSX transform is needed.
179
154
  ```javascript
180
155
  import { createElement } from 'react';
181
156
  import { createRoot } from 'react-dom/client';
182
157
  import WaykeComposite from '@wayke-se/components-react';
183
158
  import '@wayke-se/components-react/dist/assets/default.css';
184
- // Optional, only if you use ecomSettings
185
- import '@wayke-se/ecom-web/dist/index.css';
159
+ import '@wayke-se/ecom-web/dist/index.css'; // Only with ecomSettings
160
+
161
+ createRoot(document.getElementById('wayke')).render(
162
+ createElement(WaykeComposite, {
163
+ provider: {
164
+ graphQlUrl: 'https://gql.wayke.se/query',
165
+ url: 'https://api.wayke.se/vehicles',
166
+ urlMlt: 'https://api.wayke.se/vehicles-mlt-ext',
167
+ ecomSettings: { url: 'https://ecom.wayke.se' },
168
+ },
169
+ })
170
+ );
171
+ ```
172
+
173
+ `createElement` is used instead of JSX, so no JSX setup is needed. With `ecomSettings`, set up `process.env` in your bundler as described under [React](#react).
174
+
175
+ ## Environments
186
176
 
187
- const settings = {
188
- provider: ProviderSettings,
177
+ The examples on this page use production. Use test while you develop, to work with test data.
178
+
179
+ | Setting | Test | Production |
180
+ |--------------------|---------------------------------------------|-----------------------------------------|
181
+ | `graphQlUrl` | `https://gql.wayketech.se/query` | `https://gql.wayke.se/query` |
182
+ | `url` | `https://api.wayketech.se/vehicles` | `https://api.wayke.se/vehicles` |
183
+ | `urlMlt` | `https://api.wayketech.se/vehicles-mlt-ext` | `https://api.wayke.se/vehicles-mlt-ext` |
184
+ | `ecomSettings.url` | `https://ecom.wayketech.se` | `https://ecom.wayke.se` |
185
+
186
+ Each environment shows the vehicles of the domain the request comes from, so the domain has to be registered in that environment. To develop on `localhost` or a staging domain, have it registered in test. Instead of the domain, a site can be identified with `apiKey`, see [WaykeProviderSettings](#waykeprovidersettings).
187
+
188
+ ## Customize
189
+
190
+ Most settings go in `composite`, next to `provider`. They work the same way with `mount` on the CDN and with `<WaykeComposite composite={...}>` in React:
191
+
192
+ ```javascript
193
+ mount('#wayke', {
194
+ provider: { /* ... */ },
189
195
  composite: {
190
196
  modifyDocumentTitleItem: true,
197
+ displayBranchName: true,
191
198
  },
192
- };
199
+ });
200
+ ```
201
+
202
+ All settings are listed in the [Reference](#reference).
203
+
204
+ ### Colors and fonts
205
+
206
+ The components have no font of their own and inherit the font of your page. Copy this CSS to your site and change the values:
193
207
 
194
- const container = document.getElementById('wayke-components');
195
- createRoot(container).render(createElement(WaykeComposite, settings));
208
+ ```css
209
+ /* Primary color, on buttons and other highlighted elements. Set a text color that is readable on it. */
210
+ .wayke__theme.wayke__color--primary-bg {
211
+ background-color: #ff5a1c;
212
+ color: #fff;
213
+ }
214
+
215
+ /* Primary color on text. Use the same color as above. */
216
+ .wayke__theme.wayke__color--primary-text {
217
+ color: #ff5a1c;
218
+ }
219
+
220
+ /* Secondary background, with the text color used on it. */
221
+ .wayke__theme.wayke__color--secondary-bg {
222
+ background-color: #ebebeb;
223
+ color: #ff5a1c;
224
+ }
225
+
226
+ /* Accent background, with the text color used on it. */
227
+ .wayke__theme.wayke__color--accent-bg {
228
+ background-color: #f8f8f8;
229
+ color: #000;
230
+ }
231
+
232
+ /* Regular text. A light (300) or regular (400) weight is recommended. */
233
+ .wayke__theme.wayke__font--regular {
234
+ font-family: sans-serif;
235
+ font-weight: 300;
236
+ }
237
+
238
+ /* Headings and other bold text. Without a font-weight here, headings are not bold. */
239
+ .wayke__theme.wayke__font--bold {
240
+ font-family: sans-serif;
241
+ font-weight: 700;
242
+ }
196
243
  ```
197
244
 
198
- `WaykeComposite` uses hash routing by default, so it works on a single page without any server configuration. See [path-route](#waykecomposite-uses-hash-route-i-want-to-use-path-route) if you want to use path routing instead.
245
+ Only change the values in the color rules. Adding or removing properties there can break the layout. The font rules can take more properties, such as `letter-spacing`, but check the result before you go live.
199
246
 
200
- ## Components
247
+ ### Buy online colors
201
248
 
202
- ### WaykeComposite
203
- | Property | Type | Required |
204
- |-------------------|------------------------|----------|
205
- | provider | WaykeProviderSettings | true |
206
- | composite | WaykeCompositeProps | false |
249
+ Buy online (ecom) has its own styles, scoped under `.waykeecom-root` and built on CSS custom properties. To change its colors, override them in a stylesheet that is loaded after the ecom stylesheet. On the CDN, that is any stylesheet on your page.
250
+
251
+ ```css
252
+ .waykeecom-root {
253
+ --waykeecom--color-primary-main: #ff5a1c;
254
+ --waykeecom--color-primary-alt: #ffe6dc;
255
+ --waykeecom--color-link-main: #ff5a1c;
256
+ --waykeecom--color-action-main: #ff5a1c;
257
+ --waykeecom--color-action-alt: #ffe6dc;
258
+ }
259
+ ```
207
260
 
208
- `WaykeComposite` shows `WaykeSearch` and switches to `WaykeSearchItem` when a vehicle id is found in the url. It uses hash routing unless `composite.pathRoute` is set.
261
+ See `@wayke-se/ecom-web/dist/index.css` for all custom properties.
209
262
 
210
- ### WaykeSearchItem
211
- | Property | Type | Required | Value |
212
- |--------------------------|------------|----------|----------------------|
213
- | id | string | true | |
214
- | marketCode | MarketCode | false | SE \| NO |
215
- | pathRoute | string | false | |
216
- | hashRoute | boolean | false | |
217
- | disableResetScrollOnInit | boolean | false | |
218
- | placeholderImage | string | false | |
219
- | onClickSearchItem | function | false | (id: string) => void |
220
- | modifyDocumentTitleItem | boolean | false | |
221
- | displayBranchName | boolean | false | |
222
- | conversionOptions | ConversionOption[] | false | See [Conversion options](#conversion-options) |
223
-
224
- * Required
225
- * `id` - Guid that represents a vehicle.
226
- * Optional
227
- * `marketCode` - Set the language, available options are SE and NO, default to SE.
228
- * `pathRoute` - If set, then if a item is clicked it will use the provided url and append the guid. Supports both relative and absolute.
229
- * `hashRoute` - If set to true, then if a item is clicked it will append #guid to the url (is not used if `pathRoute` is set).
230
- * `disableResetScrollOnInit` - Loading the item page resets the scroll, here it's possible to disable it.
231
- * `placeholderImage` - Provide custom placeholder image when image is missing.
232
- * `onClickSearchItem` - Function that will be triggered when a related vehicle is clicked.
233
- * `modifyDocumentTitleItem` - Update document title with vehicle data (registration number, title and short description).
234
- * `displayBranchName` - Displays branch name on related product cards and using branch name in presentation of where the vehicle exist
235
- * `conversionOptions` - Which call-to-action buttons to render on the item page, and in which order. See [Conversion options](#conversion-options).
263
+ ### Contact buttons
236
264
 
237
- ### WaykeSearch
238
- | Property | Type | Values |
239
- |---------------------------|---------------------------|---------------------------|
240
- | marketCode | MarketCode | SE \| NO |
241
- | pathRoute | string | |
242
- | hashRoute | boolean | |
243
- | filterList | SearchFilterTypes[] | |
244
- | initialQueryParams | URLSearchParams or string | query, manufacturer, modelSeries, fuelType, gearboxType, branch, color, environmentClass, properties.segment, drivingWheel, price.min, price.max, mileage.min, mileage.max, odometerValueAsKm.min, odometerValueAsKm.max, modelYear.min, modelYear.max, leasingPrice.min, leasingPrice.max, businessLeasingPrice.min, businessLeasingPrice.max, sort, hits |
245
- | removeSearchBar | boolean | |
246
- | removeFilterOptions | boolean | |
247
- | placeholderImage | string | |
248
- | onClickSearchItem | function | (data: { id: string, branchId?: string, branchName?: string }) => void |
249
- | modifyDocumentTitleSearch | string | |
250
- | displayBranchName | boolean | |
251
-
252
- * Optional
253
- * `marketCode` - Set the language, available options are SE and NO, default to SE.
254
- * `pathRoute` - If set, then if a item is clicked it will use the provided url and append the guid. Supports both relative and absolute.
255
- * `hashRoute` - If set to true, then if a item is clicked it will append #guid to the url (is not used if `pathRoute` is set).
256
- * `filterList` - Select which filters should be visible and in which order. See [SearchFilterTypes](#searchfiltertypes) for available filters. If not set, all filters are shown (see [Notes on MarketCode](#notes-on-marketcode)).
257
- * `initialQueryParams` - Set the default filter that should be applied upon init. The parameters are passed on to the search API. `hits` defaults to `30` and `sort` to `published-desc`.
258
- * `removeSearchBar` - Removes search bar.
259
- * `removeFilterOptions` - Removes filter options.
260
- * `placeholderImage` - Provide custom placeholder image when image is missing.
261
- * `onClickSearchItem` - Function that will be triggered when a vehicle is clicked.
262
- * `modifyDocumentTitleSearch` - Set custom document title
263
- * `displayBranchName` - Displays branch name on product cards
264
-
265
- ### Conversion options
266
- The buttons in the item page sidebar ("Buy online", "Show email address", ...) are controlled by `conversionOptions`.
267
- Options are rendered in array order. An option is skipped when the vehicle lacks what it needs (no e-commerce, no email, no phone number, no branch).
265
+ The buttons on the vehicle page are set with `conversionOptions`, in the order they are listed. A button is left out when the vehicle doesn't have what it needs.
268
266
 
269
267
  ```javascript
270
- <WaykeComposite
271
- composite={{
272
- conversionOptions: [
273
- { type: 'leadMessage' },
274
- { type: 'leadCallMe' },
275
- { type: 'ecom' },
276
- { type: 'phone' },
277
- // Omit 'email' to hide "Show email address" entirely
278
- ],
279
- }}
280
- provider={ProviderSettings}
281
- />
268
+ composite: {
269
+ conversionOptions: [
270
+ { type: 'leadMessage' },
271
+ { type: 'leadCallMe' },
272
+ { type: 'ecom' },
273
+ { type: 'phone' },
274
+ // 'email' is left out, so "Show email address" is hidden
275
+ ],
276
+ }
282
277
  ```
283
278
 
284
- | type | Button | Default style | Requires |
285
- |---------------|--------------------------|---------------|---------------------------------------|
286
- | `ecom` | Buy online | primary | Vehicle with e-commerce enabled |
287
- | `leadMessage` | Send message (form) | primary | Vehicle connected to a branch |
288
- | `leadCallMe` | Get a callback (form) | primary | Vehicle connected to a branch |
289
- | `email` | Show email address | secondary | Branch or contact with email |
290
- | `phone` | Show phone number | secondary | Branch or contact with phone number |
279
+ | type | Button | Default style | Shown when |
280
+ |---------------|-----------------------|---------------|----------------------------------------------------|
281
+ | `ecom` | Buy online | primary | `ecomSettings` is set and the vehicle can be bought online |
282
+ | `leadMessage` | Send message (form) | primary | The vehicle belongs to a branch |
283
+ | `leadCallMe` | Get a callback (form) | primary | The vehicle belongs to a branch |
284
+ | `email` | Show email address | secondary | The branch or contact has an email address |
285
+ | `phone` | Show phone number | secondary | The branch or contact has a phone number |
291
286
 
292
- Default when `conversionOptions` is not set: `[{ type: 'ecom' }, { type: 'email' }, { type: 'phone' }]`.
287
+ Without `conversionOptions`, the buttons are `ecom`, `email` and `phone`.
293
288
 
294
- Every option accepts:
295
- * `name` - Custom button label. Defaults to the translated label for the type.
296
- * `primary` - `true` renders a primary button, `false` a secondary one.
289
+ Every button takes:
290
+ * `name` - Button text. Defaults to the translated text for the type.
291
+ * `primary` - `true` for a primary button, `false` for a secondary one.
297
292
 
298
- `leadMessage` and `leadCallMe` open a form and post the lead to Wayke (`/lead` on the same host as the provider `url`), where it ends up in Wayke Dealer for the branch that owns the vehicle. The lead is tagged with the hostname of the page it was sent from (`source`), the button used (`sourceMechanism`: `cta.email` or `cta.callme`) and this package (`client`: `components-react`, `clientVersion`).
293
+ `leadMessage` and `leadCallMe` open a form and send the lead to Wayke Dealer, to the branch that owns the vehicle. The lead is tagged with the domain of the page it was sent from (`source`), the button used (`sourceMechanism`: `cta.email` or `cta.callme`) and this package (`client`: `components-react`, and `clientVersion`).
299
294
 
300
- `email` opens the visitor's mail client with a pre-populated subject and body so the dealer can tell where the request came from. The texts are translated by `marketCode`, for example with `SE`:
301
- * Subject: `<hostname> – Jag är intresserad av <reg no>, <make> <model>`
295
+ `email` opens the visitor's mail program with a subject and body filled in, so that the dealer can see where the request came from. The texts follow the language, for example in Swedish:
296
+ * Subject: `<domain> – Jag är intresserad av <reg no>, <make> <model>`
302
297
  * Body: `Länk till bilen: <url of the current page>`
303
298
 
304
- Both can be customized, as a string or a function of the vehicle:
299
+ Both can be changed, as a text or a function of the vehicle. The vehicle has `id`, `title`, `registrationNumber`, `manufacturer` and `modelSeries`.
300
+
305
301
  ```javascript
306
302
  {
307
303
  type: 'email',
308
304
  subject: (vehicle) => `Inquiry from example.com – ${vehicle.registrationNumber}`,
309
- body: false, // omit body
305
+ body: false, // No body
310
306
  }
311
307
  ```
312
308
 
313
- Events published along the way: `MailVisible`, `MailClick`, `PhonenumberVisible`, `PhonenumberCall`, `LeadOpen`, `LeadSent`. See [Subscribe to events](#subscribe-to-events).
309
+ ### Filters
314
310
 
315
- ### Notes on MarketCode
316
- `marketCode` defines what language that will be used, `SE` - Swedish (default) or `NO` - Norwegian. Other things that `marketCode` will affect:
317
- - If no `filterList` is set, `SE` will exclude the filter `odometerValueAsKm` and instead use `mileage`, while `NO` will do the opposite. The difference between the two filters is the unit used. For `odometerValueAsKm` the unit is kilometer, while `mileage` is kilometer/10 (Scandinavian miles).
318
- - The language is set once, by the first component that is rendered.
311
+ Choose which filters are shown, in the order they are listed. `displayName` changes the title of a filter. See [SearchFilterTypes](#searchfiltertypes) for all filters.
319
312
 
313
+ ```javascript
314
+ composite: {
315
+ filterList: [
316
+ { filterName: 'price' },
317
+ { filterName: 'modelSeries', displayName: 'Modell' },
318
+ ],
319
+ }
320
+ ```
320
321
 
321
- ## Types
322
+ To set the filters that are applied when the search loads, use `initialQueryParams`. See [WaykeSearch](#waykesearch) for the available parameters.
322
323
 
323
- ### WaykeCompositeProps
324
- WaykeSearchItem & WaykeSearch combined without `id`. `hashRoute` and `onClickSearchItem` are deprecated and have no effect, since `WaykeComposite` handles routing itself. Subscribe to the `ItemClicked` event with [WaykePubSub](#subscribe-to-events) to know when a vehicle is clicked.
324
+ ```javascript
325
+ const initialQueryParams = new URLSearchParams();
326
+ initialQueryParams.set('modelYear.min', '2018');
327
+ initialQueryParams.append('modelSeries', 'A5');
325
328
 
326
- ### WaykeProviderSettings
327
- | Property | Type | Required |
328
- |-----------------------|--------------|----------|
329
- | url | string | true |
330
- | urlMlt | string | false |
331
- | graphQlUrl | string | true |
332
- | apiKey | string | false |
333
- | googleMapsApiKey | string | false |
334
- | googleMapsMarker | string | false |
335
- | ecomSettings | EcomSettings | false |
336
- | useQueryParamsFromUrl | boolean | false |
337
- | pathRoute | string | false |
338
-
339
- * Required
340
- * `url` - Url to Wayke ext-api.
341
- * `graphQlUrl` - Url to the GraphQl endpoint.
342
- * Optional
343
- * `urlMlt` - Url to Wayke ext-api for related vehicles. Used when displaying related vehicles for a given vehicle. If not provided `url` will be used, but then the latest added vehicles are shown instead of related vehicles.
344
- * `apiKey` - Sent as `x-api-key` to Wayke ext-api. If no api key is provided, then the origin of the request is used as api key.
345
- * `googleMapsApiKey` - Provide a Google Maps Static API key. The vehicle page shows a button for the map. With a `googleMapsApiKey` the button shows a static map, otherwise it opens Google Maps in another tab.
346
- * `googleMapsMarker` - Url to a custom map marker for the static map.
347
- * `ecomSettings` - Enables ecom.
348
- * `useQueryParamsFromUrl` - Reading/writing query strings from/to the url. If true and `initialQueryParams` also exist, then each value in `initialQueryParams` is added unless the url already contains the same key with the same value.
349
- * `pathRoute` - Used with `useQueryParamsFromUrl`. When the search query is written to the url, the part of the path from `pathRoute` and onwards is removed. `WaykeComposite` does not pass `composite.pathRoute` on, so set it here as well.
329
+ // ...
330
+ composite: {
331
+ initialQueryParams,
332
+ }
333
+ ```
350
334
 
351
- ### EcomSettings
352
- | Property | Type | Required |
353
- |--------------------|--------------|----------|
354
- | url | string | true |
355
- | useBankId | boolean | false |
356
- | displayBankIdAlert | boolean | false |
357
- | serviceLogotypeUrl | string | false |
358
- | bankIdThumbprint | string | false |
359
-
360
- * Required
361
- * `url` - Wayke ecom url.
362
- * Optional
363
- * `useBankId`: Deprecated, not used since 3.0.0.
364
- * `displayBankIdAlert`: Deprecated, not used since 3.0.0.
365
- * `serviceLogotypeUrl`: Url to the logo shown in ecom. By default the manufacturers logo will be used. Use a url to an image file, a `data:` url is not supported.
366
- * `bankIdThumbprint`: Custom BankID certificate thumbprint.
367
-
368
- > For more information about ecom see https://github.com/wayke-se/wayke-ecom-web.
335
+ ### Language
369
336
 
370
- ### WaykeItemProviderSettings
371
- | Property | Type | Required |
372
- |-----------------------|--------------|----------|
373
- | url | string | true |
374
- | urlMlt | string | false |
375
- | graphQlUrl | string | true |
376
- | apiKey | string | false |
377
- | googleMapsApiKey | string | false |
378
- | googleMapsMarker | string | false |
379
- | ecomSettings | EcomSettings | false |
380
-
381
- * Required
382
- * `url` - Url to Wayke ext-api.
383
- * `graphQlUrl` - Url to the GraphQl endpoint.
384
- * Optional
385
- * `urlMlt` - Url to Wayke ext-api for related vehicles. Used when displaying related vehicles for a given vehicle. If not provided `url` will be used, but then the latest added vehicles are shown instead of related vehicles.
386
- * `apiKey` - Sent as `x-api-key` to Wayke ext-api. If no api key is provided, then the origin of the request is used as api key.
387
- * `googleMapsApiKey` - Provide a Google Maps Static API key. The vehicle page shows a button for the map. With a `googleMapsApiKey` the button shows a static map, otherwise it opens Google Maps in another tab.
388
- * `googleMapsMarker` - Url to a custom map marker for the static map.
389
- * `ecomSettings` - Enables ecom.
337
+ The components are in Swedish by default. For Norwegian, set `marketCode: 'NO'` in `composite`.
390
338
 
391
- ### SearchFilterTypes
392
- | Property | Type | Required | Values |
393
- |-------------|-----------------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------|
394
- | filterName | SearchFilterNameTypes | true | manufacturer, modelSeries, fuelType, gearboxType, branch, color, environmentClass, properties.segment, drivingWheel, price, mileage, odometerValueAsKm, modelYear, leasingPrice, businessLeasingPrice |
395
- | displayName | string | false | |
339
+ * The mileage filter is shown in Swedish miles (`mileage`, 1 mil = 10 km) in Swedish, and in kilometers (`odometerValueAsKm`) in Norwegian, unless `filterList` is set.
340
+ * The language is set once, by the first component that is shown.
396
341
 
397
- * `displayName` - Override the default translation of the filter title.
342
+ ### Search or vehicle page only
398
343
 
399
- ### Set initial query filter
400
- ```javascript
401
- import WaykeComposite from '@wayke-se/components-react'
344
+ To show only the search or only one vehicle page, use `mountSearch` or `mountItem` on the CDN, see [Functions](#functions). In React, use the component with its provider. Place the provider close to the root of your app, so that its cache is kept.
402
345
 
403
- const initialQueryParams = new URLSearchParams();
404
- initialQueryParams.set('modelYear.min', '2018');
405
- initialQueryParams.append('modelSeries', 'A5');
346
+ Search only:
347
+
348
+ ```tsx
349
+ import React from 'react';
350
+ import { WaykeProvider, WaykeSearch } from '@wayke-se/components-react';
406
351
 
407
352
  const App = () => (
408
- <WaykeComposite
409
- provider={ProviderSettings}
410
- composite={{
411
- initialQueryParams,
412
- }}
413
- />
414
- )
353
+ <WaykeProvider {...ProviderSettings}>
354
+ <WaykeSearch onClickSearchItem={(data) => console.log(data.id, data.branchId, data.branchName)} />
355
+ </WaykeProvider>
356
+ );
415
357
  ```
416
358
 
417
- ## Custom usage examples
359
+ Without `hashRoute` or `pathRoute`, the vehicles in the search are not links. Use `onClickSearchItem` to open the vehicle yourself.
418
360
 
419
- ### Select only some of the filters
420
- Order will have effect
421
-
422
- ```javascript
423
- import WaykeComposite, { SearchFilterTypes } from '@wayke-se/components-react'
361
+ Vehicle page only:
424
362
 
425
- const filterList: SearchFilterTypes[] = [
426
- {
427
- filterName: 'price',
428
- },
429
- {
430
- filterName: 'modelSeries',
431
- displayName: 'MODEL SERIES',
432
- },
433
- ];
363
+ ```tsx
364
+ import React from 'react';
365
+ import { WaykeItemProvider, WaykeSearchItem } from '@wayke-se/components-react';
434
366
 
435
367
  const App = () => (
436
- <WaykeComposite
437
- provider={ProviderSettings}
438
- composite={{
439
- filterList,
440
- }}
441
- />
442
- )
368
+ <WaykeItemProvider {...ProviderSettings}>
369
+ <WaykeSearchItem
370
+ id="d01f79a3-7552-49c4-9d4d-deb3aa581c31"
371
+ onClickSearchItem={(id) => console.log(id)} // A related vehicle is clicked
372
+ />
373
+ </WaykeItemProvider>
374
+ );
443
375
  ```
444
376
 
445
- ## Subscribe to events
377
+ ## Routing
446
378
 
447
- ```javascript
448
- import { WaykePubSub } from '@wayke-se/components-react';
379
+ `mount` and `WaykeComposite` show the search, and switch to the vehicle page when a vehicle is opened. By default the vehicle is added to the url after a `#`, such as `/vehicles#01a09074-dfab-7e61-9b78-b816c8233b27`. This works on any page, without any server setup, and the url can be shared. Other hashes, such as `#content`, are ignored and show the search.
449
380
 
450
- const event = {
451
- eventName: 'ItemClicked',
452
- callback: (data) => console.log('subscribed ItemClicked:', data),
453
- };
381
+ To use a path instead, such as `/vehicles/01a09074-dfab-7e61-9b78-b816c8233b27`, set `pathRoute`:
454
382
 
455
- WaykePubSub.subscribe(event);
456
- WaykePubSub.unsubscribe(event);
383
+ ```javascript
384
+ composite: {
385
+ pathRoute: '/vehicles',
386
+ }
457
387
  ```
458
388
 
459
- | Method | Arguments |
460
- |--------------|----------------------------------------------------------------|
461
- | subscribe | event: EventType |
462
- | unsubscribe | event: EventType (the same object that was passed to `subscribe`) |
463
- | publish | eventName: EventNames, data |
464
-
465
- ### EventType
466
- | eventName | callback | Data |
467
- |-----------------------|---------------------------|---------------------------------------------------------------------------------------------------------------------------------|
468
- | View | (data) => void | CallbackViewData |
469
- | HashRouteChange | (data) => void | CallbackHashRouteChangeData |
470
- | ItemClicked | (data) => void | CallbackItemData |
471
- | Ecom | (data) => void | CallbackEcomData |
472
- | ImagesClick | (data) => void | CallbackItemData |
473
- | OptionsClick | (data) => void | CallbackItemData |
474
- | PhonenumberVisible | (data) => void | CallbackItemData |
475
- | PhonenumberCall | (data) => void | CallbackItemData |
476
- | MailVisible | (data) => void | CallbackItemData |
477
- | MailClick | (data) => void | CallbackItemData |
478
- | LeadOpen | (data) => void | CallbackLeadData |
479
- | LeadSent | (data) => void | CallbackLeadData |
480
- | InsuranceInterest | (data) => void | CallbackItemData |
481
- | InsuranceOpen | (data) => void | CallbackItemData |
482
- | InsuranceClose | (data) => void | CallbackItemData |
483
- | FinanceInterest | (data) => void | CallbackItemData |
484
- | FinanceOpen | (data) => void | CallbackItemData |
485
- | FinanceClose | (data) => void | CallbackItemData |
486
- | SearchClearQuery | (data) => void | CallbackSearchClearQueryData |
487
- | SearchClearAllFilters | (data) => void | CallbackSearchClearAllFiltersQueryData |
488
- | SearchInitiated | (data) => void | CallbackSearchInitiatedData |
489
- | SearchCompleted | (data) => void | CallbackSearchCompletedData |
490
- | Search | (data) => void | CallbackSearchData |
491
- | FilterApply | (data) => void | CallbackFilterApplyData |
492
- | All | (eventName, data) => void | CallbackViewData \| CallbackHashRouteChangeData \| CallbackItemData \| CallbackLeadData \| CallbackEcomData \| CallbackSearchClearQueryData \| CallbackSearchClearAllFiltersQueryData \| CallbackSearchInitiatedData \| CallbackSearchCompletedData \| CallbackSearchData \| CallbackFilterApplyData |
493
- * `All` - Subscribes to all events.
494
-
495
- > The `Callback*Data` names below describe the payloads. They are not exported from the package.
496
-
497
- #### CallbackViewData
498
- Published once when the search page or an item page is shown. Either of:
499
-
500
- | Property | Type |
501
- |-----------|---------------------|
502
- | type | "search" \| "item" |
503
- | id | string (item only) |
504
-
505
- #### CallbackHashRouteChangeData
506
- | Property | Type |
507
- |-----------|-----------------------|
508
- | id | string \| undefined |
509
-
510
- `id` is `undefined` when the hash is removed.
511
-
512
- #### CallbackItemData
513
- | Property | Type |
514
- |---------------|-----------------------|
515
- | id | string |
516
- | branchName | string \| undefined |
517
- | branchId | string \| undefined |
518
-
519
- #### CallbackLeadData
520
- | Property | Type |
521
- |---------------|-----------------------|
522
- | id | string |
523
- | branchName | string \| undefined |
524
- | branchId | string \| undefined |
525
- | communication | "email" \| "callme" |
526
-
527
- #### CallbackEcomData
528
- | Property | Type |
529
- |---------------|-----------------------|
530
- | id | string |
531
- | branchName | string \| undefined |
532
- | branchId | string \| undefined |
533
- | view | EcomView |
534
- | event | EcomEvent |
535
- | currentStep | EcomStep \| undefined |
536
- | data | any \| undefined |
389
+ Your server then has to show the same page for `/vehicles` and `/vehicles/<vehicle id>`, so that a vehicle page still works when it is reloaded or shared. The vehicle id is added after a `/`, so `pathRoute` should not end with a `/`. A relative `pathRoute` is resolved from the current page, and an absolute url is used as it is. With the page at `/search/vehicles`:
537
390
 
538
- `EcomView`, `EcomEvent` and `EcomStep` are exported from `@wayke-se/ecom-web`.
391
+ | `pathRoute` | Vehicle url |
392
+ |-------------------------------|------------------------------------------------|
393
+ | `/search/vehicles` | `yoursite.com/search/vehicles/<vehicle id>` |
394
+ | `/item` | `yoursite.com/item/<vehicle id>` |
395
+ | `item` | `yoursite.com/search/item/<vehicle id>` |
396
+ | `https://www.example.se/bilar` | `https://www.example.se/bilar/<vehicle id>` |
539
397
 
540
- #### CallbackSearchClearQueryData
541
- | Property | Type |
542
- |-----------|------------------|
543
- | query | string \| null |
544
-
545
- #### CallbackSearchClearAllFiltersQueryData
546
- | Property | Type |
547
- |-----------|-----------|
548
- | query | string |
549
-
550
- #### CallbackSearchInitiatedData
551
- | Property | Type |
552
- |-----------|-----------|
553
- | query | string |
554
-
555
- #### CallbackSearchCompletedData
556
- | Property | Type |
557
- |-----------|-----------|
558
- | query | string |
559
- | hits | number |
560
- | totalHits | number |
561
-
562
- #### CallbackSearchData
563
- | Property | Type |
564
- |-----------|-----------|
565
- | query | string |
566
-
567
- #### CallbackFilterApplyData
568
- | Property | Type |
569
- |-----------|-----------------------|
570
- | type | "checkbox" \| "range" |
571
- | filter | string |
572
- | value | string \| undefined (checkbox only) |
573
- | checked | boolean \| undefined (checkbox only) |
574
- | min | number \| undefined (range only) |
575
- | max | number \| undefined (range only) |
576
-
577
- ## Theme
578
- It is possible to apply a custom theme using *CSS*. The things that can be styled are:
579
- - Primary brand color
580
- - Secondary brand color
581
- - Accent color
582
- - Font (regular)
583
- - Font (bold)
584
-
585
- To style the components, copy the following snippet into your *CSS* file and modify it to your needs.
398
+ ## Events
586
399
 
587
- ```css
588
- /* === Color === */
400
+ The components publish events when visitors use them, for example to send to your analytics. Subscribe with `WaykePubSub`, before you show the components, so that you also get the events that happen when they load, such as `View`.
589
401
 
590
- /*
591
- Primary (background-color)
592
- Used to add primary background-color to elements. Should also include
593
- a color for text placed on top of the primary color.
594
- */
595
- .wayke__theme.wayke__color--primary-bg {
596
- background-color: #ff5a1c;
597
- color: #fff;
598
- }
402
+ On the CDN:
599
403
 
600
- /*
601
- Primary (text color)
602
- Used to add primary color to text. Make sure to add the same color as
603
- in the background-color selector above.
604
- */
605
- .wayke__theme.wayke__color--primary-text {
606
- color: #ff5a1c;
607
- }
404
+ ```html
405
+ <script type="module">
406
+ import { mount, WaykePubSub } from 'https://cdn.wayke.se/public-assets/wayke-components-react/5.2.0/index.js';
608
407
 
609
- /*
610
- Secondary (background-color)
611
- Used to add secondary background-color to elements. Should also include
612
- a color for text placed on top of the primary color.
613
- */
614
- .wayke__theme.wayke__color--secondary-bg {
615
- background-color: #ebebeb;
616
- color: #ff5a1c;
617
- }
408
+ WaykePubSub.subscribe({
409
+ eventName: 'ItemClicked',
410
+ callback: (data) => console.log('ItemClicked', data),
411
+ });
618
412
 
619
- /*
620
- Accent (background-color)
621
- Used to add accent background-color to elements. Should also include
622
- a color for text placed on top of the primary color.
623
- */
624
- .wayke__theme.wayke__color--accent-bg {
625
- background-color: #f8f8f8;
626
- color: #000;
627
- }
413
+ mount('#wayke', { provider: { /* ... */ } });
414
+ </script>
415
+ ```
628
416
 
629
- /* === Font === */
417
+ With npm:
630
418
 
631
- /*
632
- Regular
633
- This is the regular font used on most text elements. It is recommended
634
- to use a light (300) or regular (400) font for this type.
635
- */
636
- .wayke__theme.wayke__font--regular {
637
- font-family: sans-serif;
638
- font-weight: 300;
639
- font-style: normal;
640
- font-stretch: normal;
641
- letter-spacing: 0.02em;
642
- }
419
+ ```javascript
420
+ import { WaykePubSub } from '@wayke-se/components-react';
643
421
 
644
- /*
645
- Bold
646
- This font will be applied to headings and some other elements using
647
- the same styling.
648
- */
649
- .wayke__theme.wayke__font--bold {
650
- font-family: sans-serif;
651
- font-weight: 700;
652
- font-style: normal;
653
- font-stretch: normal;
654
- letter-spacing: 0.02em;
655
- }
656
- ```
422
+ const event = {
423
+ eventName: 'ItemClicked',
424
+ callback: (data) => console.log('ItemClicked', data),
425
+ };
657
426
 
658
- ...or if you want to use it as Sass (.scss):
659
-
660
- ```scss
661
- .wayke__theme {
662
- $c-primary: #ff5a1c;
663
- $c-primaryText: #fff; // Text placed on top of $c-primary
664
-
665
- &.wayke__color {
666
- &--primary-bg {
667
- background-color: $c-primary;
668
- color: $c-primaryText;
669
- }
670
-
671
- &--primary-text {
672
- color: $c-primary;
673
- }
674
- }
675
-
676
- &.wayke__font {
677
- &--regular {
678
- font-family: sans-serif;
679
- font-weight: 300;
680
- }
681
-
682
- &--bold {
683
- font-family: sans-serif;
684
- font-weight: 700;
685
- }
686
- }
687
- }
427
+ WaykePubSub.subscribe(event);
428
+ WaykePubSub.unsubscribe(event); // The same object that was passed to subscribe
688
429
  ```
689
430
 
690
- > **It is highly recommended to *NOT* add or remove any properties defined above in the color selectors**. However, since fonts usually requires more configuration we encourage you to add the necessary font styling required to match your current profile. If you add new properties to the font selectors, please be careful and ensure everything looks as intended before going into production.
431
+ Use `eventName: 'All'` to get every event, with the callback `(eventName, data) => void`.
432
+
433
+ | Event | When | Data |
434
+ |-------------------------|----------------------------------------------------------------|----------------------------------------|
435
+ | `View` | The search or a vehicle page is shown | [ViewData](#viewdata) |
436
+ | `HashRouteChange` | The page loads, and a vehicle is opened or closed (hash routing) | [HashRouteChangeData](#hashroutechangedata) |
437
+ | `ItemClicked` | A vehicle is clicked in the search, or a related vehicle on a vehicle page | [ItemData](#itemdata) |
438
+ | `ImagesClick` | The images on a vehicle page are clicked | [ItemData](#itemdata) |
439
+ | `OptionsClick` | "Show more" is clicked in the equipment list | [ItemData](#itemdata) |
440
+ | `MailVisible` | "Show email address" is clicked | [ItemData](#itemdata) |
441
+ | `MailClick` | The email address is clicked | [ItemData](#itemdata) |
442
+ | `PhonenumberVisible` | "Show phone number" is clicked | [ItemData](#itemdata) |
443
+ | `PhonenumberCall` | The phone number is clicked | [ItemData](#itemdata) |
444
+ | `LeadOpen` | A contact form is opened | [LeadData](#leaddata) |
445
+ | `LeadSent` | A contact form is sent | [LeadData](#leaddata) |
446
+ | `Ecom` | Something happens in buy online, such as a step being completed | [EcomData](#ecomdata) |
447
+ | `FinanceOpen` | The financing details are opened | [ItemData](#itemdata) |
448
+ | `FinanceClose` | The financing details are closed | [ItemData](#itemdata) |
449
+ | `FinanceInterest` | The financing calculation is expanded or changed | [ItemData](#itemdata) |
450
+ | `InsuranceOpen` | The insurance details are opened | [ItemData](#itemdata) |
451
+ | `InsuranceClose` | The insurance details are closed | [ItemData](#itemdata) |
452
+ | `InsuranceInterest` | Insurance prices are requested | [ItemData](#itemdata) |
453
+ | `Search` | A search text is submitted | [SearchData](#searchdata) |
454
+ | `SearchInitiated` | A search starts: when the search loads, and after the search text or a filter changes | [SearchData](#searchdata) |
455
+ | `SearchCompleted` | A search has returned its results | [SearchCompletedData](#searchcompleteddata) |
456
+ | `SearchClearQuery` | The search text is cleared | [SearchClearQueryData](#searchclearquerydata) |
457
+ | `SearchClearAllFilters` | All filters are cleared | [SearchData](#searchdata) |
458
+ | `FilterApply` | A filter is changed | [FilterApplyData](#filterapplydata) |
459
+
460
+ The data types below describe the payloads. They are not exported from the package.
461
+
462
+ #### ViewData
463
+ | Property | Type |
464
+ |----------|----------------------|
465
+ | type | `"search" \| "item"` |
466
+ | id | string (item only) |
467
+
468
+ #### HashRouteChangeData
469
+ | Property | Type |
470
+ |----------|-----------------------|
471
+ | id | string \| undefined |
472
+
473
+ `id` is `undefined` when no vehicle is open.
474
+
475
+ #### ItemData
476
+ | Property | Type |
477
+ |------------|---------------------|
478
+ | id | string |
479
+ | branchName | string \| undefined |
480
+ | branchId | string \| undefined |
481
+
482
+ #### LeadData
483
+ | Property | Type |
484
+ |---------------|-------------------------|
485
+ | id | string |
486
+ | branchName | string \| undefined |
487
+ | branchId | string \| undefined |
488
+ | communication | `"email" \| "callme"` |
489
+
490
+ #### EcomData
491
+ | Property | Type |
492
+ |-------------|-----------------------|
493
+ | id | string |
494
+ | branchName | string \| undefined |
495
+ | branchId | string \| undefined |
496
+ | view | EcomView |
497
+ | event | EcomEvent |
498
+ | currentStep | EcomStep \| undefined |
499
+ | data | any \| undefined |
691
500
 
692
- ### Ecom theme
693
- The ecom JavaScript is bundled with this package, but its stylesheet is not. If you use `ecomSettings`, install `@wayke-se/ecom-web` and import its stylesheet:
501
+ `EcomView`, `EcomEvent` and `EcomStep` are exported from `@wayke-se/ecom-web`.
694
502
 
695
- ```bash
696
- npm install @wayke-se/ecom-web
697
- ```
503
+ #### SearchData
504
+ | Property | Type |
505
+ |----------|--------|
506
+ | query | string |
507
+
508
+ #### SearchCompletedData
509
+ | Property | Type |
510
+ |-----------|--------|
511
+ | query | string |
512
+ | hits | number |
513
+ | totalHits | number |
514
+
515
+ #### SearchClearQueryData
516
+ | Property | Type |
517
+ |----------|----------------|
518
+ | query | string \| null |
519
+
520
+ #### FilterApplyData
521
+ | Property | Type |
522
+ |----------|---------------------------------------|
523
+ | type | `"checkbox" \| "range"` |
524
+ | filter | string |
525
+ | value | string \| undefined (checkbox only) |
526
+ | checked | boolean \| undefined (checkbox only) |
527
+ | min | number \| undefined (range only) |
528
+ | max | number \| undefined (range only) |
529
+
530
+ ## Reference
698
531
 
699
- ```javascript
700
- import '@wayke-se/ecom-web/dist/index.css';
701
- ```
532
+ ### WaykeComposite
702
533
 
703
- The ecom styles are scoped under `.waykeecom-root` and are built on CSS custom properties prefixed with `--waykeecom-`. To change the ecom colors, override the custom properties in a stylesheet loaded after the ecom stylesheet:
534
+ The search, and the vehicle page when a vehicle is opened. This is what `mount` shows on the CDN.
704
535
 
705
- ```css
706
- .waykeecom-root {
707
- --waykeecom--color-primary-main: #ff5a1c;
708
- --waykeecom--color-primary-alt: #ffe6dc;
709
- --waykeecom--color-link-main: #ff5a1c;
710
- --waykeecom--color-action-main: #ff5a1c;
711
- --waykeecom--color-action-alt: #ffe6dc;
712
- }
713
- ```
536
+ | Property | Type | Required |
537
+ |-----------|-----------------------------------------------|----------|
538
+ | provider | [WaykeProviderSettings](#waykeprovidersettings) | Yes |
539
+ | composite | WaykeCompositeProps | No |
714
540
 
715
- See `@wayke-se/ecom-web/dist/index.css` for the full list of custom properties.
541
+ `WaykeCompositeProps` takes the settings of [WaykeSearch](#waykesearch) and [WaykeSearchItem](#waykesearchitem), except `id`. `hashRoute` and `onClickSearchItem` have no effect here, since `WaykeComposite` handles the routing itself. To know when a vehicle is clicked, subscribe to the `ItemClicked` [event](#events).
716
542
 
717
- ## Run example from repo
718
- This repository contains an example app in `example/` that uses the components straight from `src/`.
543
+ ### WaykeSearch
719
544
 
720
- Create an `.env` file in the repository root:
721
- ```
722
- WAYKE_SEARCH_URL=https://api.wayketech.se/vehicles
723
- WAYKE_SEARCH_MLT_URL=https://api.wayketech.se/vehicles-mlt-ext
724
- WAYKE_GRAPH_QL_URL=https://gql.wayketech.se/query
725
- WAYKE_ECOM_URL=https://ecom.wayketech.se
726
- GOOGLE_MAPS_API_KEY=YOUR_GOOGLE_MAPS_STATIC_API_KEY
727
- ```
545
+ | Property | Type | Description |
546
+ |---------------------------|-----------------------------------------|-------------|
547
+ | marketCode | `'SE' \| 'NO'` | Language, see [Language](#language). Default `'SE'`. |
548
+ | filterList | [SearchFilterTypes](#searchfiltertypes)[] | The filters to show, in this order. By default all filters, with the mileage filter depending on [Language](#language). |
549
+ | initialQueryParams | URLSearchParams \| string | Filters applied when the search loads, see below. |
550
+ | removeSearchBar | boolean | Hides the search field. |
551
+ | removeFilterOptions | boolean | Hides the filters. |
552
+ | placeholderImage | string | Url to an image for vehicles without images. |
553
+ | pathRoute | string | Makes the vehicles links to `pathRoute/<vehicle id>`, see [Routing](#routing). |
554
+ | hashRoute | boolean | Makes the vehicles links to `#<vehicle id>`. Not used if `pathRoute` is set. |
555
+ | onClickSearchItem | `(data: { id, branchId?, branchName? }) => void` | Called when a vehicle is clicked. |
556
+ | modifyDocumentTitleSearch | string | Sets the page title. |
557
+ | displayBranchName | boolean | Shows the branch name on the vehicles. |
558
+
559
+ `initialQueryParams` is passed on to the search API. The parameters are `query`, `manufacturer`, `modelSeries`, `fuelType`, `gearboxType`, `branch`, `color`, `environmentClass`, `properties.segment`, `drivingWheel`, `price.min`, `price.max`, `mileage.min`, `mileage.max`, `odometerValueAsKm.min`, `odometerValueAsKm.max`, `modelYear.min`, `modelYear.max`, `leasingPrice.min`, `leasingPrice.max`, `businessLeasingPrice.min`, `businessLeasingPrice.max`, `sort` (default `published-desc`) and `hits` (default `30`).
728
560
 
729
- * `WAYKE_SEARCH_MLT_URL` - *Optional*. Fetches vehicles related to the current vehicle. If not provided, `WAYKE_SEARCH_URL` is used instead and the latest vehicles are shown.
730
- * `GOOGLE_MAPS_API_KEY` - *Optional*. See `googleMapsApiKey`.
561
+ ### WaykeSearchItem
731
562
 
732
- Then run the following from the repository root:
733
- ```bash
734
- npm install
735
- npm start
736
- ```
563
+ | Property | Type | Description |
564
+ |--------------------------|----------------------------|-------------|
565
+ | id | string | **Required.** The id of the vehicle. |
566
+ | marketCode | `'SE' \| 'NO'` | Language, see [Language](#language). Default `'SE'`. |
567
+ | conversionOptions | ConversionOption[] | The buttons on the vehicle page, see [Contact buttons](#contact-buttons). |
568
+ | modifyDocumentTitleItem | boolean | Sets the page title to the vehicle (registration number, title and short description). |
569
+ | displayBranchName | boolean | Shows the branch name on related vehicles and where the vehicle is located. |
570
+ | placeholderImage | string | Url to an image for vehicles without images. |
571
+ | disableResetScrollOnInit | boolean | Keeps the scroll position when the vehicle page opens. By default it scrolls to the top. |
572
+ | pathRoute | string | Makes related vehicles links to `pathRoute/<vehicle id>`, see [Routing](#routing). |
573
+ | hashRoute | boolean | Makes related vehicles links to `#<vehicle id>`. Not used if `pathRoute` is set. |
574
+ | onClickSearchItem | `(id: string) => void` | Called when a related vehicle is clicked. |
737
575
 
738
- The example is served on port `5000`. Set `PORT` to use another port, for example `PORT=5010 npm start`.
576
+ ### WaykeProviderSettings
739
577
 
740
- The example does not set an `apiKey`, so the origin of the request is used as API key. To use the API key of a specific site, add a host such as `test.com.localhost` to your hosts file:
741
- ```
742
- 127.0.0.1 test.com.localhost
743
- ```
744
- Then open `test.com.localhost:5000`. This changes the origin while still pointing to localhost.
578
+ | Property | Type | Description |
579
+ |-----------------------|-------------------------------|-------------|
580
+ | url | string | **Required.** The vehicle search API, see [Environments](#environments). |
581
+ | graphQlUrl | string | **Required.** The GraphQL API, see [Environments](#environments). |
582
+ | urlMlt | string | The API for related vehicles. Without it, the latest vehicles are shown as related vehicles. |
583
+ | ecomSettings | [EcomSettings](#ecomsettings) | Turns on buy online. |
584
+ | apiKey | string | Identifies the site instead of its domain. Sent as `x-api-key`. |
585
+ | googleMapsApiKey | string | A Google Maps Static API key. With it, the map button on the vehicle page shows a map. Without it, the button opens Google Maps. |
586
+ | googleMapsMarker | string | Url to a custom marker for the map. |
587
+ | useQueryParamsFromUrl | boolean | Reads and writes the search filters in the url. Values in `initialQueryParams` are added unless the url already has them. |
588
+ | pathRoute | string | Used with `useQueryParamsFromUrl`: the part of the path from `pathRoute` is removed when the filters are written to the url. `composite.pathRoute` is not passed on, so set it here as well. |
589
+
590
+ ### WaykeItemProviderSettings
745
591
 
746
- ### Available Routes (Independent)
592
+ The same as [WaykeProviderSettings](#waykeprovidersettings), without `useQueryParamsFromUrl` and `pathRoute`. Used with `WaykeItemProvider` and `mountItem`.
747
593
 
748
- #### WaykeComposite
749
- [http://localhost:5000](http://localhost:5000)
594
+ ### EcomSettings
750
595
 
751
- #### WaykeComposite with hash route
752
- [http://localhost:5000/hash](http://localhost:5000/hash)
596
+ | Property | Type | Description |
597
+ |--------------------|---------|-------------|
598
+ | url | string | **Required.** The ecom API, see [Environments](#environments). |
599
+ | serviceLogotypeUrl | string | Url to the logo shown in buy online, as an image file (not a `data:` url). The logo of the make is used by default. |
600
+ | bankIdThumbprint | string | A custom BankID certificate thumbprint. |
601
+ | useBankId | boolean | Deprecated, has no effect since 3.0.0. |
602
+ | displayBankIdAlert | boolean | Deprecated, has no effect since 3.0.0. |
753
603
 
754
- #### WaykeComposite with path route
755
- [http://localhost:5000/a/b](http://localhost:5000/a/b)
604
+ See [wayke-ecom-web](https://github.com/wayke-se/wayke-ecom-web) for more about buy online.
756
605
 
757
- #### WaykeSearch With WaykeProvider
758
- [http://localhost:5000/search](http://localhost:5000/search)
606
+ ### SearchFilterTypes
759
607
 
760
- #### WaykeSearchItem With WaykeProvider
761
- [http://localhost:5000/search-item/d01f79a3-7552-49c4-9d4d-deb3aa581c31](http://localhost:5000/search-item/d01f79a3-7552-49c4-9d4d-deb3aa581c31)
608
+ | Property | Type | Description |
609
+ |-------------|--------|-------------|
610
+ | filterName | string | **Required.** One of `manufacturer`, `modelSeries`, `fuelType`, `gearboxType`, `branch`, `color`, `environmentClass`, `properties.segment`, `drivingWheel`, `price`, `mileage`, `odometerValueAsKm`, `modelYear`, `leasingPrice`, `businessLeasingPrice`. |
611
+ | displayName | string | The title of the filter. The translated title by default. |