@wayke-se/components-react 5.2.0 → 6.0.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 (145) hide show
  1. package/README.md +260 -140
  2. package/dist/assets/StyreneA-Bold-Web-4CXEYQLA-4CXEYQLA.woff2 +0 -0
  3. package/dist/assets/StyreneA-Bold-Web-AGBUOKS2-AGBUOKS2.woff +0 -0
  4. package/dist/assets/StyreneA-Light-Web-DAMPSUFB-DAMPSUFB.woff +0 -0
  5. package/dist/assets/StyreneA-Light-Web-EE4AJECE-EE4AJECE.woff2 +0 -0
  6. package/dist/assets/StyreneA-Medium-Web-53Q6X35A-53Q6X35A.woff +0 -0
  7. package/dist/assets/StyreneA-Medium-Web-7KYQNCKQ-7KYQNCKQ.woff2 +0 -0
  8. package/dist/assets/StyreneA-Regular-Web-7SAOGHB5-7SAOGHB5.woff2 +0 -0
  9. package/dist/assets/StyreneA-Regular-Web-XFBCXNPA-XFBCXNPA.woff +0 -0
  10. package/dist/chunks/chunk-XBJKSIMP.js +2 -0
  11. package/dist/chunks/chunk-XBJKSIMP.js.map +7 -0
  12. package/dist/chunks/dist-3TYBTGV5.js +1969 -0
  13. package/dist/chunks/dist-3TYBTGV5.js.map +7 -0
  14. package/dist/index.js +1037 -3129
  15. package/dist/index.js.map +4 -4
  16. package/dist/style.css +1 -0
  17. package/dist/types/src/@types/filter.d.ts +7 -1
  18. package/dist/types/src/Gql/ad/legacyWaykeId.d.ts +1 -0
  19. package/dist/types/src/Gql/ad/propertyTree.d.ts +5 -0
  20. package/dist/types/src/Gql/ad/queries.d.ts +9 -0
  21. package/dist/types/src/Gql/ad/types.d.ts +378 -0
  22. package/dist/types/src/Gql/ad/useAd.d.ts +8 -0
  23. package/dist/types/src/Gql/ad/useInsuranceInquiry.d.ts +11 -0
  24. package/dist/types/src/Gql/ad/useLoanCalculation.d.ts +14 -0
  25. package/dist/types/src/Gql/ad/useRelatedAds.d.ts +12 -0
  26. package/dist/types/src/Gql/ad/view.d.ts +94 -0
  27. package/dist/types/src/Gql/client.d.ts +11 -0
  28. package/dist/types/src/Gql/config.d.ts +9 -0
  29. package/dist/types/src/Gql/facets.d.ts +19 -0
  30. package/dist/types/src/Gql/hit.d.ts +5 -0
  31. package/dist/types/src/Gql/legacyParams.d.ts +7 -0
  32. package/dist/types/src/Gql/queries.d.ts +17 -0
  33. package/dist/types/src/Gql/searchParams.d.ts +55 -0
  34. package/dist/types/src/Gql/suggest.d.ts +8 -0
  35. package/dist/types/src/Gql/types.d.ts +131 -0
  36. package/dist/types/src/Gql/useAdsSearch.d.ts +21 -0
  37. package/dist/types/src/State/Ad/AdContext.d.ts +5 -0
  38. package/dist/types/src/State/Router/RouterContext.d.ts +15 -0
  39. package/dist/types/src/State/Router/RouterProvider.d.ts +6 -0
  40. package/dist/types/src/State/Router/useRouter.d.ts +2 -0
  41. package/dist/types/src/State/Search/SearchContext.d.ts +15 -9
  42. package/dist/types/src/State/Search/SearchProvider.d.ts +1 -5
  43. package/dist/types/src/State/Settings/SettingsContext.d.ts +2 -12
  44. package/dist/types/src/State/Settings/settings.d.ts +62 -0
  45. package/dist/types/src/State/Settings/useSettings.d.ts +1 -1
  46. package/dist/types/src/components/ActionList/index.d.ts +3 -10
  47. package/dist/types/src/components/DocumentList/index.d.ts +3 -3
  48. package/dist/types/src/components/Filter/index.d.ts +1 -3
  49. package/dist/types/src/components/FilterPanel/checkListFacet.d.ts +2 -3
  50. package/dist/types/src/components/FilterPanel/colorFacet.d.ts +2 -3
  51. package/dist/types/src/components/FilterPanel/faceSelector.d.ts +2 -3
  52. package/dist/types/src/components/FilterPanel/index.d.ts +8 -15
  53. package/dist/types/src/components/FilterPanel/rangeFacet.d.ts +3 -3
  54. package/dist/types/src/components/FinancialOptions/LoanModal.d.ts +3 -7
  55. package/dist/types/src/components/FinancialOptions/index.d.ts +5 -7
  56. package/dist/types/src/components/FinancialOptions/leasing.d.ts +3 -3
  57. package/dist/types/src/components/FinancialOptions/loan.d.ts +3 -7
  58. package/dist/types/src/components/Gallery/index.d.ts +3 -5
  59. package/dist/types/src/components/Grid/index.d.ts +3 -7
  60. package/dist/types/src/components/InsuranceOptions/Insurance.d.ts +4 -6
  61. package/dist/types/src/components/InsuranceOptions/InsuranceFree.d.ts +5 -7
  62. package/dist/types/src/components/InsuranceOptions/InsuranceFreeModal.d.ts +4 -4
  63. package/dist/types/src/components/InsuranceOptions/InsuranceModal.d.ts +4 -6
  64. package/dist/types/src/components/InsuranceOptions/index.d.ts +5 -6
  65. package/dist/types/src/components/LeadForm/index.d.ts +1 -6
  66. package/dist/types/src/components/Lightbox/index.d.ts +2 -2
  67. package/dist/types/src/components/Map/index.d.ts +4 -2
  68. package/dist/types/src/components/OpeningHours/index.d.ts +2 -2
  69. package/dist/types/src/components/ProductCard/HitCard.d.ts +10 -0
  70. package/dist/types/src/components/ProductCard/index.d.ts +9 -13
  71. package/dist/types/src/components/SearchBar/index.d.ts +4 -1
  72. package/dist/types/src/components/SearchBar/wrapper.d.ts +10 -0
  73. package/dist/types/src/components/SortSelect/index.d.ts +1 -2
  74. package/dist/types/src/hooks/useSubmitLead.d.ts +1 -1
  75. package/dist/types/src/index.d.ts +5 -4
  76. package/dist/types/src/layouts/WaykeComposite.d.ts +3 -8
  77. package/dist/types/src/layouts/WaykeCompositeWithProvider.d.ts +1 -1
  78. package/dist/types/src/layouts/search/index.d.ts +6 -7
  79. package/dist/types/src/layouts/searchItem/Accessories/AccessoryModal.d.ts +2 -2
  80. package/dist/types/src/layouts/searchItem/Accessories/index.d.ts +2 -2
  81. package/dist/types/src/layouts/searchItem/Branch.d.ts +3 -4
  82. package/dist/types/src/layouts/searchItem/CheckList.d.ts +3 -15
  83. package/dist/types/src/layouts/searchItem/Documents.d.ts +2 -2
  84. package/dist/types/src/layouts/searchItem/ManufacturerPackagesOption.d.ts +2 -2
  85. package/dist/types/src/layouts/searchItem/PackageOptions.d.ts +3 -3
  86. package/dist/types/src/layouts/searchItem/Property.d.ts +1 -6
  87. package/dist/types/src/layouts/searchItem/Related.d.ts +5 -6
  88. package/dist/types/src/layouts/searchItem/index.d.ts +8 -6
  89. package/dist/types/src/layouts/searchItem/useEcom.d.ts +7 -3
  90. package/dist/types/src/providers/WaykeProvider.d.ts +7 -21
  91. package/dist/types/src/utils/image.d.ts +14 -0
  92. package/dist/types/src/utils/sortOptions.d.ts +4 -13
  93. package/package.json +26 -22
  94. package/dist/assets/default.css +0 -1
  95. package/dist/assets/fonts/slick.svg +0 -14
  96. package/dist/index.mjs +0 -5511
  97. package/dist/index.mjs.map +0 -7
  98. package/dist/types/src/@types/action.d.ts +0 -3
  99. package/dist/types/src/@types/codegen/types.d.ts +0 -433
  100. package/dist/types/src/@types/queryFilter.d.ts +0 -5
  101. package/dist/types/src/@types/search.d.ts +0 -114
  102. package/dist/types/src/State/CentralStorage/CentralStorageContext.d.ts +0 -5
  103. package/dist/types/src/State/CentralStorage/CentralStorageProvider.d.ts +0 -6
  104. package/dist/types/src/State/CentralStorage/useCentralStorage.d.ts +0 -6
  105. package/dist/types/src/State/Path/PathContext.d.ts +0 -8
  106. package/dist/types/src/State/Path/PathProvider.d.ts +0 -6
  107. package/dist/types/src/State/Path/reducer.d.ts +0 -14
  108. package/dist/types/src/State/Path/usePath.d.ts +0 -3
  109. package/dist/types/src/State/RelatedSearch/RelatedSearchContext.d.ts +0 -9
  110. package/dist/types/src/State/RelatedSearch/RelatedSearchProvider.d.ts +0 -9
  111. package/dist/types/src/State/RelatedSearch/useRelatedSearch.d.ts +0 -2
  112. package/dist/types/src/State/Settings/SettingsProvider.d.ts +0 -11
  113. package/dist/types/src/components/Video/QuickNavVideo.d.ts +0 -7
  114. package/dist/types/src/hooks/apolloTypes.d.ts +0 -6
  115. package/dist/types/src/hooks/useHasBeenVisible.d.ts +0 -2
  116. package/dist/types/src/hooks/useHashGuid.d.ts +0 -2
  117. package/dist/types/src/hooks/useInsurance.d.ts +0 -4
  118. package/dist/types/src/hooks/useLoan.d.ts +0 -4
  119. package/dist/types/src/hooks/useOnScreen.d.ts +0 -2
  120. package/dist/types/src/hooks/usePrevious.d.ts +0 -2
  121. package/dist/types/src/hooks/useSearchItem.d.ts +0 -4
  122. package/dist/types/src/hooks/useSearchItemBranch.d.ts +0 -4
  123. package/dist/types/src/hooks/useSessionStorage.d.ts +0 -7
  124. package/dist/types/src/layouts/searchItem/BranchModal.d.ts +0 -9
  125. package/dist/types/src/providers/WaykeItemProvidet.d.ts +0 -24
  126. package/dist/types/src/providers/graphqlProvider.d.ts +0 -6
  127. package/dist/types/src/queries/INSURANCE_CALCULATION.d.ts +0 -2
  128. package/dist/types/src/queries/LOAN_CALCULATION.d.ts +0 -2
  129. package/dist/types/src/queries/SEARCH_ITEM_BRANCH_QUERY.d.ts +0 -2
  130. package/dist/types/src/queries/SEARCH_ITEM_QUERY.d.ts +0 -2
  131. package/dist/types/src/utils/deep-copy.d.ts +0 -5
  132. package/dist/types/src/utils/regex.d.ts +0 -3
  133. package/dist/types/src/utils/specification.d.ts +0 -28
  134. package/dist/types/src/utils/url.d.ts +0 -1
  135. package/dist/types/src/utils/vehicle-properties/compare-basic-properties.d.ts +0 -3
  136. package/dist/types/src/utils/vehicle-properties/compare-categories.d.ts +0 -3
  137. package/dist/types/src/utils/vehicle-properties/compare-properties.d.ts +0 -3
  138. package/dist/types/src/utils/vehicle-properties/custom-property-adder.d.ts +0 -13
  139. package/dist/types/src/utils/vehicle-properties/property-remover.d.ts +0 -7
  140. package/dist/types/src/utils/vehicle-properties/property-tree-creator.d.ts +0 -31
  141. package/dist/types/src/utils/vehicle-properties/property-tree-sorter.d.ts +0 -3
  142. /package/dist/assets/{ajax-loader.gif → ajax-loader-BOAPMZMT.gif} +0 -0
  143. /package/dist/assets/{fonts/slick.eot → slick-EVLS6IWX.eot} +0 -0
  144. /package/dist/assets/{fonts/slick.woff → slick-MU5EZO5G.woff} +0 -0
  145. /package/dist/assets/{fonts/slick.ttf → slick-NKQ64RRA.ttf} +0 -0
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
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
+ Upgrading from 5.x? See [Migrating from 5.x to 6.0](#migrating-from-5x-to-60).
6
+
5
7
  ## Quick start
6
8
 
7
9
  Add this where the vehicles should be shown, for example in an HTML block in your CMS, such as WordPress:
@@ -9,19 +11,30 @@ Add this where the vehicles should be shown, for example in an HTML block in you
9
11
  ```html
10
12
  <div id="wayke"></div>
11
13
  <script type="module">
12
- import { mount } from 'https://cdn.wayke.se/public-assets/wayke-components-react/5.2.0/index.js';
14
+ import { mount } from 'https://cdn.wayke.se/public-assets/wayke-components-react/6.0.0/index.js';
15
+
16
+ mount('#wayke');
17
+ </script>
18
+ ```
19
+
20
+ <details>
21
+ <summary>The same snippet for Wayke's test environment</summary>
22
+
23
+ For a staging site or `localhost`, registered in Wayke's test environment. It shows test vehicles, and leads and orders go to test. See [Environments](#environments).
24
+
25
+ ```html
26
+ <div id="wayke"></div>
27
+ <script type="module">
28
+ import { mount } from 'https://cdn.wayke.se/public-assets/wayke-components-react/6.0.0/index.js';
13
29
 
14
30
  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
- },
31
+ provider: { environment: 'test' },
21
32
  });
22
33
  </script>
23
34
  ```
24
35
 
36
+ </details>
37
+
25
38
  Two things to know:
26
39
 
27
40
  * **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.
@@ -37,6 +50,7 @@ That is all you need on most sites. The rest of this page covers other ways to a
37
50
  * [Routing](#routing)
38
51
  * [Events](#events)
39
52
  * [Reference](#reference)
53
+ * [Migrating from 5.x to 6.0](#migrating-from-5x-to-60)
40
54
 
41
55
  ## Add to your site
42
56
 
@@ -48,7 +62,7 @@ That is all you need on most sites. The rest of this page covers other ways to a
48
62
 
49
63
  ### CDN
50
64
 
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.
65
+ Every release is published to the Wayke CDN with everything included: React, the styles and the buy online flow. Nothing needs to be installed.
52
66
 
53
67
  ```
54
68
  https://cdn.wayke.se/public-assets/wayke-components-react/<version>/index.js
@@ -64,31 +78,24 @@ There are two ways to load the script. They show the same thing and take the sam
64
78
 
65
79
  ```html
66
80
  <div id="wayke"></div>
67
- <script type="module" src="https://cdn.wayke.se/public-assets/wayke-components-react/5.2.0/index.js"></script>
81
+ <script type="module" src="https://cdn.wayke.se/public-assets/wayke-components-react/6.0.0/index.js"></script>
68
82
  <script>
69
83
  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
- });
84
+ WaykeComponents.mount('#wayke');
78
85
  });
79
86
  </script>
80
87
  ```
81
88
 
82
89
  #### Functions
83
90
 
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)) |
91
+ | Function | Settings | Shows |
92
+ |---------------|--------------------------------|-------------------------------------------|
93
+ | `mount` | `{ provider?, composite? }` | Search, and the vehicle page when a vehicle is opened ([WaykeComposite](#waykecomposite)) |
94
+ | `mountSearch` | `{ provider?, search? }` | Only the search ([WaykeSearch](#waykesearch)) |
95
+ | `mountItem` | `{ provider?, item }` | Only one vehicle page, `item.id` is required ([WaykeSearchItem](#waykesearchitem)) |
89
96
 
90
97
  * The first argument is a CSS selector, such as `'#wayke'`, or an element.
91
- * `provider` is [WaykeProviderSettings](#waykeprovidersettings) (for `mountItem`: [WaykeItemProviderSettings](#waykeitemprovidersettings)).
98
+ * `provider` is [WaykeProviderSettings](#waykeprovidersettings), the same for all three.
92
99
  * Each function returns `{ unmount }`, which removes the components again.
93
100
  * `WaykePubSub` is exported too, and is available as `WaykeComponents.WaykePubSub` in option B. See [Events](#events).
94
101
 
@@ -99,43 +106,37 @@ The script adds its stylesheet, `index.css` in the same folder, to the top of `<
99
106
  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
107
 
101
108
  ```html
102
- <link rel="stylesheet" href="https://cdn.wayke.se/public-assets/wayke-components-react/5.2.0/index.css">
109
+ <link rel="stylesheet" href="https://cdn.wayke.se/public-assets/wayke-components-react/6.0.0/index.css">
103
110
  ```
104
111
 
105
112
  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.
106
113
 
107
114
  ```html
108
- <script type="module" src="https://cdn.wayke.se/public-assets/wayke-components-react/5.2.0/index.js" disablecssinjection></script>
115
+ <script type="module" src="https://cdn.wayke.se/public-assets/wayke-components-react/6.0.0/index.js" disablecssinjection></script>
109
116
  ```
110
117
 
111
118
  ### React
112
119
 
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.
120
+ Install the package and its peer dependencies, and import its stylesheet once. The stylesheet covers everything, buy online included, and the code for buy online is only loaded when a buyer opens it. No bundler setup is needed.
114
121
 
115
122
  ```bash
116
123
  npm install @wayke-se/components-react react react-dom styled-components
117
- npm install @wayke-se/ecom-web
118
124
  ```
119
125
 
120
126
  ```tsx
121
127
  import React from 'react';
122
128
  import WaykeComposite, { type WaykeProviderSettings } from '@wayke-se/components-react';
123
- import '@wayke-se/components-react/dist/assets/default.css';
124
- import '@wayke-se/ecom-web/dist/index.css'; // Only with ecomSettings
129
+ import '@wayke-se/components-react/style.css';
125
130
 
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' },
131
- };
131
+ // All settings are optional, see WaykeProviderSettings.
132
+ const ProviderSettings: WaykeProviderSettings = {};
132
133
 
133
134
  const App = () => <WaykeComposite provider={ProviderSettings} />;
134
135
  ```
135
136
 
136
137
  The React examples further down use this `ProviderSettings`.
137
138
 
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': {} }`.
139
+ The package is ESM only, with `@wayke-se/components-react` and `@wayke-se/components-react/style.css` as its entry points.
139
140
 
140
141
  ### Without React
141
142
 
@@ -143,7 +144,6 @@ The components can be added to any element on any website. React is then bundled
143
144
 
144
145
  ```bash
145
146
  npm install @wayke-se/components-react react react-dom styled-components
146
- npm install @wayke-se/ecom-web # Only with ecomSettings
147
147
  ```
148
148
 
149
149
  ```html
@@ -155,33 +155,27 @@ npm install @wayke-se/ecom-web # Only with ecomSettings
155
155
  import { createElement } from 'react';
156
156
  import { createRoot } from 'react-dom/client';
157
157
  import WaykeComposite from '@wayke-se/components-react';
158
- import '@wayke-se/components-react/dist/assets/default.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
- );
158
+ import '@wayke-se/components-react/style.css';
159
+
160
+ createRoot(document.getElementById('wayke')).render(createElement(WaykeComposite));
171
161
  ```
172
162
 
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).
163
+ `createElement` is used instead of JSX, so no JSX setup is needed.
174
164
 
175
165
  ## Environments
176
166
 
177
- The examples on this page use production. Use test while you develop, to work with test data.
167
+ The components use production by default. Set `environment: 'test'` while you develop, to work with test data:
168
+
169
+ ```javascript
170
+ mount('#wayke', {
171
+ provider: { environment: 'test' },
172
+ });
173
+ ```
178
174
 
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` |
175
+ | `environment` | Vehicles and loans | Leads | Buy online |
176
+ |------------------------|---------------------------------------------|---------------------------------|-----------------------------|
177
+ | `production` (default) | `https://public-api.wayke.com/graphql` | `https://api.wayke.se/lead` | `https://ecom.wayke.se` |
178
+ | `test` | `https://public-test-api.wayke.com/graphql` | `https://api.wayketech.se/lead` | `https://ecom.wayketech.se` |
185
179
 
186
180
  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
181
 
@@ -246,7 +240,7 @@ Only change the values in the color rules. Adding or removing properties there c
246
240
 
247
241
  ### Buy online colors
248
242
 
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.
243
+ 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 `@wayke-se/components-react/style.css`. On the CDN, that is any stylesheet on your page.
250
244
 
251
245
  ```css
252
246
  .waykeecom-root {
@@ -278,9 +272,9 @@ composite: {
278
272
 
279
273
  | type | Button | Default style | Shown when |
280
274
  |---------------|-----------------------|---------------|----------------------------------------------------|
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 |
275
+ | `ecom` | Buy online | primary | The dealer sells the vehicle online, unless `ecom.enabled` is `false` |
276
+ | `leadMessage` | Send message (form) | primary | Always |
277
+ | `leadCallMe` | Get a callback (form) | primary | Always |
284
278
  | `email` | Show email address | secondary | The branch or contact has an email address |
285
279
  | `phone` | Show phone number | secondary | The branch or contact has a phone number |
286
280
 
@@ -308,7 +302,7 @@ Both can be changed, as a text or a function of the vehicle. The vehicle has `id
308
302
 
309
303
  ### Filters
310
304
 
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.
305
+ Choose which filters are shown, in the order they are listed. `displayName` changes the title of a filter. See [SearchFilterTypes](#searchfiltertypes) for all filters. A filter with nothing to pick, such as business leasing on a site without leasing cars, is left out.
312
306
 
313
307
  ```javascript
314
308
  composite: {
@@ -319,7 +313,7 @@ composite: {
319
313
  }
320
314
  ```
321
315
 
322
- To set the filters that are applied when the search loads, use `initialQueryParams`. See [WaykeSearch](#waykesearch) for the available parameters.
316
+ To set the filters that are applied when the search loads, use `initialQueryParams`. It takes the same parameters as the url, see [Search parameters](#search-parameters).
323
317
 
324
318
  ```javascript
325
319
  const initialQueryParams = new URLSearchParams();
@@ -332,16 +326,18 @@ composite: {
332
326
  }
333
327
  ```
334
328
 
329
+ The search field suggests makes and models while the visitor types. Picking one, or typing one exactly, such as "volvo v60", filters on it instead of searching the text.
330
+
335
331
  ### Language
336
332
 
337
- The components are in Swedish by default. For Norwegian, set `marketCode: 'NO'` in `composite`.
333
+ The components are in Swedish by default. For Norwegian, set `marketCode: 'NO'` in `provider`.
338
334
 
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.
335
+ * The mileage filter is in Swedish miles (1 mil = 10 km) in Swedish, and in kilometers in Norwegian.
336
+ * The language is set once, by the first provider that is shown.
341
337
 
342
338
  ### Search or vehicle page only
343
339
 
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.
340
+ 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 `WaykeProvider`. Place the provider close to the root of your app, so that its cache is kept.
345
341
 
346
342
  Search only:
347
343
 
@@ -350,50 +346,79 @@ import React from 'react';
350
346
  import { WaykeProvider, WaykeSearch } from '@wayke-se/components-react';
351
347
 
352
348
  const App = () => (
353
- <WaykeProvider {...ProviderSettings}>
354
- <WaykeSearch onClickSearchItem={(data) => console.log(data.id, data.branchId, data.branchName)} />
349
+ <WaykeProvider {...ProviderSettings} routing={{ mode: 'none' }}>
350
+ <WaykeSearch />
355
351
  </WaykeProvider>
356
352
  );
357
353
  ```
358
354
 
359
- Without `hashRoute` or `pathRoute`, the vehicles in the search are not links. Use `onClickSearchItem` to open the vehicle yourself.
355
+ With `routing.mode: 'none'`, the vehicles in the search are not links. Subscribe to the `ItemClicked` [event](#events) to open the vehicle yourself.
360
356
 
361
357
  Vehicle page only:
362
358
 
363
359
  ```tsx
364
360
  import React from 'react';
365
- import { WaykeItemProvider, WaykeSearchItem } from '@wayke-se/components-react';
361
+ import { WaykeProvider, WaykeSearchItem } from '@wayke-se/components-react';
366
362
 
367
363
  const App = () => (
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>
364
+ <WaykeProvider {...ProviderSettings}>
365
+ <WaykeSearchItem id="019cd398-f71a-7ee6-893f-4684c0104a60" />
366
+ </WaykeProvider>
374
367
  );
375
368
  ```
376
369
 
370
+ Older vehicle ids still work: the vehicle is found and the id in the url is replaced with the current one.
371
+
377
372
  ## Routing
378
373
 
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.
374
+ Routing is set in `provider.routing`.
380
375
 
381
- To use a path instead, such as `/vehicles/01a09074-dfab-7e61-9b78-b816c8233b27`, set `pathRoute`:
376
+ `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#019cd398-f71a-7ee6-893f-4684c0104a60`. 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.
377
+
378
+ To use a path instead, such as `/vehicles/019cd398-f71a-7ee6-893f-4684c0104a60`, set `mode: 'path'` and `basePath`:
382
379
 
383
380
  ```javascript
384
- composite: {
385
- pathRoute: '/vehicles',
381
+ provider: {
382
+ routing: { mode: 'path', basePath: '/vehicles' },
386
383
  }
387
384
  ```
388
385
 
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`:
386
+ 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 `basePath` should not end with a `/`. A relative `basePath` is resolved from the page the components are shown on, and an absolute url is used as it is. With the page at `/search/vehicles`:
387
+
388
+ | `basePath` | Vehicle url |
389
+ |--------------------------------|------------------------------------------------|
390
+ | `/search/vehicles` | `yoursite.com/search/vehicles/<vehicle id>` |
391
+ | `/item` | `yoursite.com/item/<vehicle id>` |
392
+ | `item` | `yoursite.com/search/item/<vehicle id>` |
393
+ | `https://www.example.se/bilar` | `https://www.example.se/bilar/<vehicle id>` |
390
394
 
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>` |
395
+ Links on the same site open without reloading the page. Ctrl- or cmd-click opens them in a new tab.
396
+
397
+ To keep the filters in the url, so that a search can be shared and the back button returns to it, set `syncUrl: true`. The filters in the url then win over `initialQueryParams`, which only add what the url doesn't have.
398
+
399
+ ```javascript
400
+ provider: {
401
+ routing: { syncUrl: true },
402
+ }
403
+ ```
404
+
405
+ ### Search parameters
406
+
407
+ The url, `initialQueryParams` and the `onFilterUpdate` action use the same parameters as wayke.se:
408
+
409
+ | Parameter | Example | Filters on |
410
+ |-----------|---------|------------|
411
+ | `q` | `q=drag` | Free text |
412
+ | `manufacturer`, `model`, `modelSeries`, `fuelType`, `gearboxType`, `branchDisplayName`, `branchCity`, `colorName`, `environmentClass`, `segment`, `bodyStyle`, `trimLevel`, `inventoryStatus`, `drivetrainType`, `engineBaseType` | `manufacturer=Volvo&manufacturer=Audi` | One or more values |
413
+ | `price.min`, `price.max` | `price.max=300000` | Price in kr |
414
+ | `odometer.min`, `odometer.max` | `odometer.max=8000` | Mileage, in mil in Swedish and in km in Norwegian |
415
+ | `modelYear.min`, `modelYear.max` | `modelYear.min=2018` | Model year |
416
+ | `privateLease.min`, `privateLease.max` | `privateLease.max=5000` | Private leasing per month |
417
+ | `businessLease.min`, `businessLease.max` | `businessLease.max=5000` | Business leasing per month |
418
+ | `certifiedPreOwned`, `isDemoVersion`, `deductibleVat`, `ecom`, `leasing`, `businessLeasing` | `ecom=true` | Yes or no |
419
+ | `sort` | `sort=price-asc` | `published-desc` (default), `published-asc`, `price-asc`, `price-desc`, `modelYear-desc`, `modelYear-asc`, `odometer-asc`, `odometer-desc` |
420
+
421
+ The parameters from before 6.0, such as `query`, `color`, `mileage.max` and `sort=mileage-asc`, still work: they are translated, a warning in the console names the new ones, and with `syncUrl` the url is updated to them.
397
422
 
398
423
  ## Events
399
424
 
@@ -403,14 +428,14 @@ On the CDN:
403
428
 
404
429
  ```html
405
430
  <script type="module">
406
- import { mount, WaykePubSub } from 'https://cdn.wayke.se/public-assets/wayke-components-react/5.2.0/index.js';
431
+ import { mount, WaykePubSub } from 'https://cdn.wayke.se/public-assets/wayke-components-react/6.0.0/index.js';
407
432
 
408
433
  WaykePubSub.subscribe({
409
434
  eventName: 'ItemClicked',
410
435
  callback: (data) => console.log('ItemClicked', data),
411
436
  });
412
437
 
413
- mount('#wayke', { provider: { /* ... */ } });
438
+ mount('#wayke');
414
439
  </script>
415
440
  ```
416
441
 
@@ -430,6 +455,12 @@ WaykePubSub.unsubscribe(event); // The same object that was passed to subscribe
430
455
 
431
456
  Use `eventName: 'All'` to get every event, with the callback `(eventName, data) => void`.
432
457
 
458
+ To change the filters from your own code, publish the `onFilterUpdate` action with the [search parameters](#search-parameters):
459
+
460
+ ```javascript
461
+ WaykePubSub.publishAction('onFilterUpdate', 'manufacturer=Volvo&sort=price-asc');
462
+ ```
463
+
433
464
  | Event | When | Data |
434
465
  |-------------------------|----------------------------------------------------------------|----------------------------------------|
435
466
  | `View` | The search or a vehicle page is shown | [ViewData](#viewdata) |
@@ -450,14 +481,14 @@ Use `eventName: 'All'` to get every event, with the callback `(eventName, data)
450
481
  | `InsuranceOpen` | The insurance details are opened | [ItemData](#itemdata) |
451
482
  | `InsuranceClose` | The insurance details are closed | [ItemData](#itemdata) |
452
483
  | `InsuranceInterest` | Insurance prices are requested | [ItemData](#itemdata) |
453
- | `Search` | A search text is submitted | [SearchData](#searchdata) |
484
+ | `Search` | A search text or a suggestion is submitted | [SearchData](#searchdata) |
454
485
  | `SearchInitiated` | A search starts: when the search loads, and after the search text or a filter changes | [SearchData](#searchdata) |
455
486
  | `SearchCompleted` | A search has returned its results | [SearchCompletedData](#searchcompleteddata) |
456
487
  | `SearchClearQuery` | The search text is cleared | [SearchClearQueryData](#searchclearquerydata) |
457
488
  | `SearchClearAllFilters` | All filters are cleared | [SearchData](#searchdata) |
458
489
  | `FilterApply` | A filter is changed | [FilterApplyData](#filterapplydata) |
459
490
 
460
- The data types below describe the payloads. They are not exported from the package.
491
+ The data types below describe the payloads. In TypeScript they are exported with the events, as `CallbackItem`, `CallbackLeadData`, `CallbackSearchCompletedData` and so on. Every `query` uses the [search parameters](#search-parameters).
461
492
 
462
493
  #### ViewData
463
494
  | Property | Type |
@@ -498,7 +529,7 @@ The data types below describe the payloads. They are not exported from the packa
498
529
  | currentStep | EcomStep \| undefined |
499
530
  | data | any \| undefined |
500
531
 
501
- `EcomView`, `EcomEvent` and `EcomStep` are exported from `@wayke-se/ecom-web`.
532
+ `EcomView`, `EcomEvent` and `EcomStep` are string enums from `@wayke-se/ecom-web`, which is installed with the package. Compare with their values, such as `data.view === 'SUMMARY'`, so buy online is not loaded with your own code.
502
533
 
503
534
  #### SearchData
504
535
  | Property | Type |
@@ -521,7 +552,7 @@ The data types below describe the payloads. They are not exported from the packa
521
552
  | Property | Type |
522
553
  |----------|---------------------------------------|
523
554
  | type | `"checkbox" \| "range"` |
524
- | filter | string |
555
+ | filter | string, a [filter name](#searchfiltertypes) |
525
556
  | value | string \| undefined (checkbox only) |
526
557
  | checked | boolean \| undefined (checkbox only) |
527
558
  | min | number \| undefined (range only) |
@@ -533,73 +564,69 @@ The data types below describe the payloads. They are not exported from the packa
533
564
 
534
565
  The search, and the vehicle page when a vehicle is opened. This is what `mount` shows on the CDN.
535
566
 
536
- | Property | Type | Required |
537
- |-----------|-----------------------------------------------|----------|
538
- | provider | [WaykeProviderSettings](#waykeprovidersettings) | Yes |
539
- | composite | WaykeCompositeProps | No |
567
+ | Property | Type | Required |
568
+ |-----------|-------------------------------------------------|----------|
569
+ | provider | [WaykeProviderSettings](#waykeprovidersettings) | No |
570
+ | composite | WaykeCompositeProps | No |
540
571
 
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).
572
+ `WaykeCompositeProps` takes the settings of [WaykeSearch](#waykesearch) and [WaykeSearchItem](#waykesearchitem), except `id`.
542
573
 
543
574
  ### WaykeSearch
544
575
 
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`).
576
+ | Property | Type | Description |
577
+ |---------------------------|-------------------------------------------|-------------|
578
+ | filterList | [SearchFilterTypes](#searchfiltertypes)[] | The filters to show, in this order. By default all filters. |
579
+ | initialQueryParams | URLSearchParams \| string | Filters applied when the search loads, see [Search parameters](#search-parameters). |
580
+ | removeSearchBar | boolean | Hides the search field. |
581
+ | removeFilterOptions | boolean | Hides the filters. |
582
+ | placeholderImage | string | Url to an image for vehicles without images. |
583
+ | modifyDocumentTitleSearch | string | Sets the page title. |
584
+ | displayBranchName | boolean | Shows the branch name on the vehicles. |
560
585
 
561
586
  ### WaykeSearchItem
562
587
 
563
588
  | Property | Type | Description |
564
589
  |--------------------------|----------------------------|-------------|
565
- | id | string | **Required.** The id of the vehicle. |
566
- | marketCode | `'SE' \| 'NO'` | Language, see [Language](#language). Default `'SE'`. |
590
+ | id | string | **Required.** The id of the vehicle. Older ids work too. |
567
591
  | conversionOptions | ConversionOption[] | The buttons on the vehicle page, see [Contact buttons](#contact-buttons). |
568
592
  | modifyDocumentTitleItem | boolean | Sets the page title to the vehicle (registration number, title and short description). |
569
593
  | displayBranchName | boolean | Shows the branch name on related vehicles and where the vehicle is located. |
570
594
  | placeholderImage | string | Url to an image for vehicles without images. |
571
595
  | 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. |
575
596
 
576
597
  ### WaykeProviderSettings
577
598
 
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
591
-
592
- The same as [WaykeProviderSettings](#waykeprovidersettings), without `useQueryParamsFromUrl` and `pathRoute`. Used with `WaykeItemProvider` and `mountItem`.
599
+ All settings are optional.
600
+
601
+ | Property | Type | Description |
602
+ |------------------|---------------------------------------|-------------|
603
+ | environment | `'production' \| 'test'` | Which Wayke environment to use, see [Environments](#environments). Default `'production'`. |
604
+ | marketCode | `'SE' \| 'NO'` | Language and market, see [Language](#language). Default `'SE'`. |
605
+ | routing | [RoutingSettings](#routingsettings) | How vehicles are opened, see [Routing](#routing). |
606
+ | ecom | [EcomSettings](#ecomsettings) | Buy online. On by default for the vehicles the dealer sells online. |
607
+ | apiKey | string | Identifies the site instead of its domain. Sent as `x-api-key`. |
608
+ | branchGroupId | string | Limits the vehicles to a group of branches. By default the domain or `apiKey` decides which vehicles are shown. |
609
+ | 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. |
610
+ | googleMapsMarker | string | Url to a custom marker for the map. |
611
+ | publicApiUrl | string | Replaces the vehicle API of `environment`. |
612
+ | leadUrl | string | Replaces the lead API of `environment`. |
613
+
614
+ ### RoutingSettings
615
+
616
+ | Property | Type | Description |
617
+ |----------|------------------------------|-------------|
618
+ | mode | `'hash' \| 'path' \| 'none'` | `hash` (default) opens a vehicle at `#<id>`, `path` at `<basePath>/<id>`, `none` makes the vehicles plain cards that only publish `ItemClicked`. |
619
+ | basePath | string | **Required for `path`.** Where the vehicle pages are, see [Routing](#routing). |
620
+ | syncUrl | boolean | Reads and writes the search filters in the url. |
593
621
 
594
622
  ### EcomSettings
595
623
 
596
624
  | Property | Type | Description |
597
625
  |--------------------|---------|-------------|
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. |
626
+ | enabled | boolean | `false` hides buy online on your site, for example when you sell online in another way. Default `true`. |
627
+ | url | string | Replaces the ecom API of `environment`. |
628
+ | serviceLogotypeUrl | string | Url to the logo at the top of buy online, as an image file (not a `data:` url). Wayke's logo by default. |
600
629
  | 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. |
603
630
 
604
631
  See [wayke-ecom-web](https://github.com/wayke-se/wayke-ecom-web) for more about buy online.
605
632
 
@@ -607,5 +634,98 @@ See [wayke-ecom-web](https://github.com/wayke-se/wayke-ecom-web) for more about
607
634
 
608
635
  | Property | Type | Description |
609
636
  |-------------|--------|-------------|
610
- | filterName | string | **Required.** One of `manufacturer`, `modelSeries`, `fuelType`, `gearboxType`, `branch`, `color`, `environmentClass`, `properties.segment`, `drivingWheel`, `price`, `mileage`, `odometerValueAsKm`, `modelYear`, `leasingPrice`, `businessLeasingPrice`. |
637
+ | filterName | string | **Required.** One of `manufacturer`, `model`, `modelSeries`, `fuelType`, `gearboxType`, `branchDisplayName`, `branchCity`, `colorName`, `environmentClass`, `segment`, `bodyStyle`, `trimLevel`, `inventoryStatus`, `drivetrainType`, `engineBaseType`, `price`, `odometer`, `modelYear`, `privateLease`, `businessLease`. |
611
638
  | displayName | string | The title of the filter. The translated title by default. |
639
+
640
+ By default the list is `manufacturer`, `modelSeries`, `fuelType`, `gearboxType`, `branchDisplayName`, `colorName`, `environmentClass`, `segment`, `drivetrainType`, `price`, `privateLease`, `businessLease`, `odometer` and `modelYear`.
641
+
642
+ ## Migrating from 5.x to 6.0
643
+
644
+ 6.0 gets the vehicles from Wayke's public API (`public-api.wayke.com`) instead of `api.wayke.se` and `gql.wayke.se`, and has fewer settings: most sites only set what is different from the defaults. Leads and buy online work as before, but buy online is now on by default.
645
+
646
+ The old filter names, url parameters and vehicle ids keep working, with a warning in the console, so a site that only changes its settings keeps its links and saved searches. A removed setting also gives a warning, naming what replaces it.
647
+
648
+ ### 1. Provider settings
649
+
650
+ Remove the API urls and `ecomSettings`. Production is the default; set `environment: 'test'` for test.
651
+
652
+ ```javascript
653
+ // 5.x
654
+ provider: {
655
+ url: 'https://api.wayke.se/vehicles',
656
+ graphQlUrl: 'https://gql.wayke.se/query',
657
+ urlMlt: 'https://api.wayke.se/vehicles-mlt-ext',
658
+ ecomSettings: { url: 'https://ecom.wayke.se' },
659
+ },
660
+
661
+ // 6.0: nothing to set
662
+ ```
663
+
664
+ | 5.x | 6.0 |
665
+ |-----|-----|
666
+ | `url`, `graphQlUrl`, `urlMlt` | Removed. Use `environment` (`publicApiUrl` and `leadUrl` replace single urls if you need to) |
667
+ | `ecomSettings` set: buy online on | `ecom` (optional): buy online is on by default for the vehicles the dealer sells online |
668
+ | No `ecomSettings`: buy online off | `ecom: { enabled: false }` |
669
+ | `ecomSettings.url` | `ecom.url`, optional, follows `environment` |
670
+ | `ecomSettings.serviceLogotypeUrl`, `ecomSettings.bankIdThumbprint` | `ecom.serviceLogotypeUrl`, `ecom.bankIdThumbprint` |
671
+ | `ecomSettings.useBankId`, `ecomSettings.displayBankIdAlert` | Removed, no effect since 3.0.0 |
672
+ | `useQueryParamsFromUrl` | `routing.syncUrl` |
673
+ | `pathRoute` (provider and composite) | `routing: { mode: 'path', basePath }` |
674
+ | `marketCode` (composite, search, item) | `provider.marketCode` |
675
+ | `apiKey` | Unchanged; now also identifies the site to the vehicle API |
676
+ | `WaykeItemProvider`, `WaykeItemProviderSettings` | `WaykeProvider`, `WaykeProviderSettings` |
677
+
678
+ ### 2. Install and stylesheet (React and bundlers)
679
+
680
+ The CDN needs no change other than the version in the url.
681
+
682
+ | 5.x | 6.0 |
683
+ |-----|-----|
684
+ | `import '@wayke-se/components-react/dist/assets/default.css'` | `import '@wayke-se/components-react/style.css'`, which also covers buy online |
685
+ | `import '@wayke-se/ecom-web/dist/index.css'` | Remove; it is in `style.css` |
686
+ | `npm install @wayke-se/ecom-web` | Not needed; `npm uninstall @wayke-se/ecom-web` unless you use it yourself |
687
+ | `define` for `process.env` in the bundler, for buy online | Not needed |
688
+ | Imports from `@wayke-se/components-react/dist/...` | Only `@wayke-se/components-react` and `@wayke-se/components-react/style.css` can be imported; the package is ESM only |
689
+
690
+ ### 3. Routing and clicks
691
+
692
+ | 5.x | 6.0 |
693
+ |-----|-----|
694
+ | Hash routing (`#<id>`) by default in `mount` and `WaykeComposite` | Unchanged |
695
+ | `hashRoute` | Removed; hash is the default |
696
+ | `WaykeSearch` alone without `hashRoute` or `pathRoute`: plain cards | Set `routing: { mode: 'none' }`; the default is now hash links |
697
+ | `onClickSearchItem` (search and item) | Removed; subscribe to the `ItemClicked` event |
698
+
699
+ ### 4. Filters and parameters
700
+
701
+ `filterList`, `initialQueryParams`, the `onFilterUpdate` action and the url take the names in [Search parameters](#search-parameters). The old names are translated:
702
+
703
+ | 5.x | 6.0 |
704
+ |-----|-----|
705
+ | `query` | `q` |
706
+ | `branch` | `branchDisplayName` |
707
+ | `color` | `colorName` |
708
+ | `properties.segment` | `segment` |
709
+ | `drivingWheel` | `drivetrainType` |
710
+ | `mileage`, `odometerValueAsKm` | `odometer` (mil in Swedish, km in Norwegian) |
711
+ | `leasingPrice` | `privateLease` |
712
+ | `businessLeasingPrice` | `businessLease` |
713
+ | `sort=model-asc`, `model-desc`, `mileage-asc`, `mileage-desc` | `modelYear-asc`, `modelYear-desc`, `odometer-asc`, `odometer-desc` |
714
+ | `hits`, `offset` | Removed; 30 vehicles per page, "Show more" loads the next |
715
+
716
+ The search field now suggests makes and models. A free text that is exactly a make or model, such as "audi", filters on it.
717
+
718
+ ### 5. Events
719
+
720
+ The event names and data are the same. What changes:
721
+
722
+ * `query` in `Search`, `SearchInitiated`, `SearchCompleted`, `SearchClearAllFilters` uses the new parameter names.
723
+ * `filter` in `FilterApply` is the new filter name, for example `colorName` instead of `color`.
724
+ * `id` is the vehicle's id in the public API. New vehicles have new ids; older ones mostly keep theirs.
725
+
726
+ ### 6. Removed
727
+
728
+ * Central storage (switching to another branch on the vehicle page).
729
+ * The campaign filter. Dealer packages are still shown on the vehicle page.
730
+ * Related vehicles are now the latest vehicles of the same make.
731
+ * A vehicle without a cash price, such as a leasing-only car, shows no price instead of 0 kr.