@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.
@@ -15,13 +15,28 @@ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }
15
15
  }
16
16
  return (React.createElement(Wrapper, null,
17
17
  React.createElement(List, null, documents.map((document) => {
18
+ /*
18
19
  const _path = pathRoute?.replace(/^\/|\/$/g, '');
20
+
19
21
  const prefix = _path ? `/${_path}/` : '/';
20
- const pathRouteUrl = window.location.pathname === '/'
22
+
23
+ const pathRouteUrl =
24
+ window.location.pathname === '/'
21
25
  ? `${prefix}${document._id}`
22
26
  : `${window.location.pathname}${prefix}${document._id}`;
27
+ */
28
+ /*
29
+ const _pathRoute = pathRoute
30
+ ? pathRoute.startsWith('/')
31
+ ? `${location.pathname}${pathRoute}/${document._id}`
32
+ : `${pathRoute}/${document._id}`
33
+ : undefined;
34
+
35
+ console.log(_pathRoute);
36
+ */
37
+ const _pathRoute = pathRoute ? `${pathRoute}/${document._id}` : undefined;
23
38
  return (React.createElement(Item, { key: document._id },
24
- React.createElement(ProductCard, { id: document._id, onClick: onClickItem, title: document.title, pathRoute: pathRoute, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: resolveImage(document), placeholderImage: placeholderImage, description: document.shortDescription, uspList: [
39
+ React.createElement(ProductCard, { id: document._id, onClick: onClickItem, title: document.title, pathRoute: pathRoute, href: _pathRoute ? _pathRoute : hashRoute ? `#${document._id}` : undefined, image: resolveImage(document), placeholderImage: placeholderImage, description: document.shortDescription, uspList: [
25
40
  {
26
41
  title: document.modelYear,
27
42
  },
@@ -8,9 +8,12 @@ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, desc
8
8
  const { pushState } = usePath();
9
9
  const _onClick = useMemo(() => (onClick ? () => onClick(id) : undefined), [id]);
10
10
  const onHrefClick = useCallback((e) => {
11
- if (!!pathRoute && href) {
12
- e.preventDefault();
13
- pushState(href);
11
+ if (pathRoute && href) {
12
+ const reg = new RegExp('^((http|https)://)|//');
13
+ if (!pathRoute.match(reg) && !pathRoute.startsWith(location.origin)) {
14
+ e.preventDefault();
15
+ pushState(href);
16
+ }
14
17
  }
15
18
  }, [id, pathRoute, href]);
16
19
  return (React.createElement(Wrapper, { onClick: _onClick },
@@ -36,11 +36,11 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
36
36
  React.createElement(OverflowGrid, null,
37
37
  React.createElement(OverflowGridList, null, response?.documentList.documents.map((document) => {
38
38
  const prefix = pathRoute ? `/${pathRoute}` : '/';
39
- const r = regexPathGuid(pathRoute);
39
+ const r = regexPathGuid();
40
40
  const pathRouteUrl = window.location.pathname === '/'
41
41
  ? `${prefix}${document._id}`
42
42
  : r.test(`${pathRoute}${id}`)
43
- ? window.location.pathname.replace(r, `${pathRoute}${document._id}`)
43
+ ? window.location.pathname.replace(r, document._id)
44
44
  : `${window.location.pathname}${prefix}${document._id}`;
45
45
  return (React.createElement(OverflowGridItem, { key: document._id },
46
46
  React.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: document.featuredImage?.files?.[0]?.url, description: document.shortDescription, uspList: [
@@ -2,7 +2,7 @@ export const regexGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a
2
2
  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}$/;
3
3
  export const escapeRegExpString = (s) => s.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
4
4
  export const regexPathGuid = (path) => {
5
- if (!path) {
5
+ if (!path || path) {
6
6
  return regexEndGuid;
7
7
  }
8
8
  const r = new RegExp(`${escapeRegExpString(path)}${regexEndGuid.source}`, 'gi');
package/dist-web/index.js CHANGED
@@ -1956,9 +1956,12 @@ const ProductCard = ({ id, title, href, image, pathRoute, placeholderImage, desc
1956
1956
  const { pushState } = usePath();
1957
1957
  const _onClick = useMemo(() => (onClick ? () => onClick(id) : undefined), [id]);
1958
1958
  const onHrefClick = useCallback((e) => {
1959
- if (!!pathRoute && href) {
1960
- e.preventDefault();
1961
- pushState(href);
1959
+ if (pathRoute && href) {
1960
+ const reg = new RegExp('^((http|https)://)|//');
1961
+ if (!pathRoute.match(reg) && !pathRoute.startsWith(location.origin)) {
1962
+ e.preventDefault();
1963
+ pushState(href);
1964
+ }
1962
1965
  }
1963
1966
  }, [id, pathRoute, href]);
1964
1967
  return (React__default.createElement(Wrapper$8, { onClick: _onClick },
@@ -1997,13 +2000,28 @@ const Grid = ({ documents, placeholderImage, hashRoute, pathRoute, onClickItem }
1997
2000
  }
1998
2001
  return (React__default.createElement(Wrapper$7, null,
1999
2002
  React__default.createElement(List$4, null, documents.map((document) => {
2003
+ /*
2000
2004
  const _path = pathRoute?.replace(/^\/|\/$/g, '');
2005
+
2001
2006
  const prefix = _path ? `/${_path}/` : '/';
2002
- const pathRouteUrl = window.location.pathname === '/'
2007
+
2008
+ const pathRouteUrl =
2009
+ window.location.pathname === '/'
2003
2010
  ? `${prefix}${document._id}`
2004
2011
  : `${window.location.pathname}${prefix}${document._id}`;
2012
+ */
2013
+ /*
2014
+ const _pathRoute = pathRoute
2015
+ ? pathRoute.startsWith('/')
2016
+ ? `${location.pathname}${pathRoute}/${document._id}`
2017
+ : `${pathRoute}/${document._id}`
2018
+ : undefined;
2019
+
2020
+ console.log(_pathRoute);
2021
+ */
2022
+ const _pathRoute = pathRoute ? `${pathRoute}/${document._id}` : undefined;
2005
2023
  return (React__default.createElement(Item$4, { key: document._id },
2006
- React__default.createElement(ProductCard, { id: document._id, onClick: onClickItem, title: document.title, pathRoute: pathRoute, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: resolveImage(document), placeholderImage: placeholderImage, description: document.shortDescription, uspList: [
2024
+ React__default.createElement(ProductCard, { id: document._id, onClick: onClickItem, title: document.title, pathRoute: pathRoute, href: _pathRoute ? _pathRoute : hashRoute ? `#${document._id}` : undefined, image: resolveImage(document), placeholderImage: placeholderImage, description: document.shortDescription, uspList: [
2007
2025
  {
2008
2026
  title: document.modelYear,
2009
2027
  },
@@ -5762,7 +5780,7 @@ const useRelatedSearch = (id) => {
5762
5780
  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}$/;
5763
5781
  const escapeRegExpString = (s) => s.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
5764
5782
  const regexPathGuid = (path) => {
5765
- if (!path) {
5783
+ if (!path || path) {
5766
5784
  return regexEndGuid;
5767
5785
  }
5768
5786
  const r = new RegExp(`${escapeRegExpString(path)}${regexEndGuid.source}`, 'gi');
@@ -5794,11 +5812,11 @@ const Related = ({ id, hashRoute, pathRoute, onClickSearchItem }) => {
5794
5812
  React__default.createElement(OverflowGrid, null,
5795
5813
  React__default.createElement(OverflowGridList, null, response?.documentList.documents.map((document) => {
5796
5814
  const prefix = pathRoute ? `/${pathRoute}` : '/';
5797
- const r = regexPathGuid(pathRoute);
5815
+ const r = regexPathGuid();
5798
5816
  const pathRouteUrl = window.location.pathname === '/'
5799
5817
  ? `${prefix}${document._id}`
5800
5818
  : r.test(`${pathRoute}${id}`)
5801
- ? window.location.pathname.replace(r, `${pathRoute}${document._id}`)
5819
+ ? window.location.pathname.replace(r, document._id)
5802
5820
  : `${window.location.pathname}${prefix}${document._id}`;
5803
5821
  return (React__default.createElement(OverflowGridItem, { key: document._id },
5804
5822
  React__default.createElement(ProductCard, { id: document._id, onClick: onItemClicked, title: document.title, href: pathRoute ? pathRouteUrl : hashRoute ? `#${document._id}` : undefined, image: document.featuredImage?.files?.[0]?.url, description: document.shortDescription, uspList: [