@wayke-se/components-react 3.0.0 → 3.1.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.
- package/README.md +12 -3
- package/dist-node/index.js +29 -10
- package/dist-node/index.js.map +1 -1
- package/dist-src/components/Grid/index.js +17 -2
- package/dist-src/components/ProductCard/index.js +6 -3
- package/dist-src/layouts/searchItem/Related.js +2 -2
- package/dist-src/utils/regex.js +1 -1
- package/dist-web/index.js +26 -8
- package/dist-web/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,9 +69,18 @@ const ProviderSettings: WaykeProviderSettings = {
|
|
|
69
69
|
|
|
70
70
|
### WaykeComposite uses hash-route, i want to use path-route
|
|
71
71
|
|
|
72
|
-
In this case you need to make sure that you are in control of the routing where same html file is
|
|
72
|
+
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
|
|
73
73
|
served for `/your/path/to/this/component` and `/your/path/to/this/component/00000000-0000-0000-0000-000000000000`.
|
|
74
74
|
|
|
75
|
+
Examples given the application is located in `/search/vehicles`:
|
|
76
|
+
|
|
77
|
+
1) pathRoute is `/search/vehicles` => `//yoursite.com/search/vehicles/00000000-0000-0000-0000-000000000000`
|
|
78
|
+
2) pathRoute is `/item` => `//yoursite.com/item/00000000-0000-0000-0000-000000000000`
|
|
79
|
+
3) pathRoute is `/a/b` => `//yoursite.com/a/b/00000000-0000-0000-0000-000000000000`
|
|
80
|
+
4) pathRoute is `item` => `//yoursite.com/search/item/00000000-0000-0000-0000-000000000000`
|
|
81
|
+
5) pathRoute is `a/b` => `//yoursite.com/search/a/b/00000000-0000-0000-0000-000000000000`
|
|
82
|
+
6) pathRoute is `https://www.wayke.se/objekt` => `https://www.wayke.se/objekt/00000000-0000-0000-0000-000000000000`
|
|
83
|
+
|
|
75
84
|
```javascript
|
|
76
85
|
import React from 'react';
|
|
77
86
|
import { WaykeCompositePath } from '@wayke-se/components-react'
|
|
@@ -160,7 +169,7 @@ const App = ({}) => {
|
|
|
160
169
|
* Required
|
|
161
170
|
* `id` - Guid that represents a vehicle.
|
|
162
171
|
* Optional
|
|
163
|
-
* `pathRoute` - If set
|
|
172
|
+
* `pathRoute` - If set, then if a item is clicked it will use the provided url and append the guid. Supports both relative and absolute.
|
|
164
173
|
* `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).
|
|
165
174
|
* `disableResetScrollOnInit` - Loading the item page resets the scroll, here it's possible to disable it.
|
|
166
175
|
* `placeholderImage` - Provide custom placeholder image when image is missing.
|
|
@@ -181,7 +190,7 @@ const App = ({}) => {
|
|
|
181
190
|
| modifyDocumentTitleSearch | string | |
|
|
182
191
|
|
|
183
192
|
* Optional
|
|
184
|
-
* `pathRoute` - If set
|
|
193
|
+
* `pathRoute` - If set, then if a item is clicked it will use the provided url and append the guid. Supports both relative and absolute.
|
|
185
194
|
* `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).
|
|
186
195
|
* `filterList` - Select what filters that should be visible and in whiched order, drivingWheel, price, mileage, modelYear
|
|
187
196
|
* `initialQueryParams` - Set the default filter that should be applid upon init.
|
package/dist-node/index.js
CHANGED
|
@@ -2475,9 +2475,13 @@ const ProductCard = ({
|
|
|
2475
2475
|
const _onClick = React.useMemo(() => onClick ? () => onClick(id) : undefined, [id]);
|
|
2476
2476
|
|
|
2477
2477
|
const onHrefClick = React.useCallback(e => {
|
|
2478
|
-
if (
|
|
2479
|
-
|
|
2480
|
-
|
|
2478
|
+
if (pathRoute && href) {
|
|
2479
|
+
const reg = new RegExp('^((http|https)://)|//');
|
|
2480
|
+
|
|
2481
|
+
if (!pathRoute.match(reg) && !pathRoute.startsWith(location.origin)) {
|
|
2482
|
+
e.preventDefault();
|
|
2483
|
+
pushState(href);
|
|
2484
|
+
}
|
|
2481
2485
|
}
|
|
2482
2486
|
}, [id, pathRoute, href]);
|
|
2483
2487
|
return React__default.createElement(Wrapper$8, {
|
|
@@ -2528,10 +2532,25 @@ const Grid = ({
|
|
|
2528
2532
|
}
|
|
2529
2533
|
|
|
2530
2534
|
return React__default.createElement(Wrapper$7, null, React__default.createElement(List$4, null, documents.map(document => {
|
|
2531
|
-
|
|
2535
|
+
/*
|
|
2536
|
+
const _path = pathRoute?.replace(/^\/|\/$/g, '');
|
|
2537
|
+
const prefix = _path ? `/${_path}/` : '/';
|
|
2538
|
+
const pathRouteUrl =
|
|
2539
|
+
window.location.pathname === '/'
|
|
2540
|
+
? `${prefix}${document._id}`
|
|
2541
|
+
: `${window.location.pathname}${prefix}${document._id}`;
|
|
2542
|
+
*/
|
|
2543
|
+
|
|
2544
|
+
/*
|
|
2545
|
+
const _pathRoute = pathRoute
|
|
2546
|
+
? pathRoute.startsWith('/')
|
|
2547
|
+
? `${location.pathname}${pathRoute}/${document._id}`
|
|
2548
|
+
: `${pathRoute}/${document._id}`
|
|
2549
|
+
: undefined;
|
|
2550
|
+
console.log(_pathRoute);
|
|
2551
|
+
*/
|
|
2552
|
+
const _pathRoute = pathRoute ? `${pathRoute}/${document._id}` : undefined;
|
|
2532
2553
|
|
|
2533
|
-
const prefix = _path ? `/${_path}/` : '/';
|
|
2534
|
-
const pathRouteUrl = window.location.pathname === '/' ? `${prefix}${document._id}` : `${window.location.pathname}${prefix}${document._id}`;
|
|
2535
2554
|
return React__default.createElement(Item$4, {
|
|
2536
2555
|
key: document._id
|
|
2537
2556
|
}, React__default.createElement(ProductCard, {
|
|
@@ -2539,7 +2558,7 @@ const Grid = ({
|
|
|
2539
2558
|
onClick: onClickItem,
|
|
2540
2559
|
title: document.title,
|
|
2541
2560
|
pathRoute: pathRoute,
|
|
2542
|
-
href:
|
|
2561
|
+
href: _pathRoute ? _pathRoute : hashRoute ? `#${document._id}` : undefined,
|
|
2543
2562
|
image: resolveImage(document),
|
|
2544
2563
|
placeholderImage: placeholderImage,
|
|
2545
2564
|
description: document.shortDescription,
|
|
@@ -6939,7 +6958,7 @@ const useRelatedSearch = id => {
|
|
|
6939
6958
|
const regexEndGuid = /[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
6940
6959
|
const escapeRegExpString = s => s.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
|
6941
6960
|
const regexPathGuid = path => {
|
|
6942
|
-
if (!path) {
|
|
6961
|
+
if (!path || path) {
|
|
6943
6962
|
return regexEndGuid;
|
|
6944
6963
|
}
|
|
6945
6964
|
|
|
@@ -6991,8 +7010,8 @@ const Related = ({
|
|
|
6991
7010
|
var _document$featuredIma, _document$featuredIma2, _document$featuredIma3;
|
|
6992
7011
|
|
|
6993
7012
|
const prefix = pathRoute ? `/${pathRoute}` : '/';
|
|
6994
|
-
const r = regexPathGuid(
|
|
6995
|
-
const pathRouteUrl = window.location.pathname === '/' ? `${prefix}${document._id}` : r.test(`${pathRoute}${id}`) ? window.location.pathname.replace(r,
|
|
7013
|
+
const r = regexPathGuid();
|
|
7014
|
+
const pathRouteUrl = window.location.pathname === '/' ? `${prefix}${document._id}` : r.test(`${pathRoute}${id}`) ? window.location.pathname.replace(r, document._id) : `${window.location.pathname}${prefix}${document._id}`;
|
|
6996
7015
|
return React__default.createElement(OverflowGridItem, {
|
|
6997
7016
|
key: document._id
|
|
6998
7017
|
}, React__default.createElement(ProductCard, {
|