@shopgate/engage 7.31.0-beta.1 → 7.31.0-beta.3
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/components/ScrollHeader/index.d.ts.map +1 -1
- package/components/ScrollHeader/index.js +9 -2
- package/package.json +7 -7
- package/product/components/ProductGrid/components/Item/components/ItemName/index.js +13 -7
- package/product/components/ProductGrid/components/Item/components/ItemName/spec.js +2 -1
- package/product/components/ProductRatingStars/ProductRatingStars.d.ts +14 -0
- package/product/components/ProductRatingStars/ProductRatingStars.d.ts.map +1 -0
- package/product/components/ProductRatingStars/ProductRatingStars.js +43 -0
- package/product/components/ProductRatingStars/index.d.ts +2 -0
- package/product/components/ProductRatingStars/index.d.ts.map +1 -0
- package/product/components/ProductRatingStars/index.js +1 -0
- package/product/components/Rating/index.js +1 -1
- package/product/components/index.js +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/ScrollHeader/index.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/ScrollHeader/index.jsx"],"names":[],"mappings":";AA6GA;;;;;;;;;;;cA5DW,KAAK,CAAC,SAAS;yCA4DwB;kBA7GK,OAAO"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState, forwardRef, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { makeStyles, responsiveMediaQuery } from '@shopgate/engage/styles';
|
|
4
|
-
import { useScrollDirectionChange } from '@shopgate/engage/core/hooks';
|
|
4
|
+
import { useScrollDirectionChange, useRoute } from '@shopgate/engage/core/hooks';
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
const useStyles = makeStyles()({
|
|
7
7
|
root: {
|
|
@@ -68,8 +68,15 @@ function ScrollHeaderBase({
|
|
|
68
68
|
cx
|
|
69
69
|
} = useStyles();
|
|
70
70
|
const [shouldHideHeader, setShouldHideHeader] = useState(false);
|
|
71
|
+
|
|
72
|
+
// The `viewScroll$` stream is shared across all mounted views. Cached routes (e.g. a product
|
|
73
|
+
// list) stay mounted in the background while another route is active, so without this guard the
|
|
74
|
+
// header would react to scroll events emitted by a different, currently visible view and end up
|
|
75
|
+
// hidden when the user navigates back. `visible` is true only for the active route.
|
|
76
|
+
const route = useRoute();
|
|
77
|
+
const visible = route ? route.visible !== false : true;
|
|
71
78
|
useScrollDirectionChange({
|
|
72
|
-
enabled: hideOnScroll,
|
|
79
|
+
enabled: hideOnScroll && visible,
|
|
73
80
|
offset: scrollOffset,
|
|
74
81
|
onlyFireOnScrollUpAtTop: onlyShowAtTop,
|
|
75
82
|
onlyFireOnScrollUpAtTopOffset: onlyShowAtTopOffset,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "7.31.0-beta.
|
|
3
|
+
"version": "7.31.0-beta.3",
|
|
4
4
|
"description": "Shopgate's ENGAGE library.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@emotion/react": "^11.14.0",
|
|
20
20
|
"@shopgate/native-modules": "1.0.0-beta.25",
|
|
21
|
-
"@shopgate/pwa-common": "7.31.0-beta.
|
|
22
|
-
"@shopgate/pwa-common-commerce": "7.31.0-beta.
|
|
23
|
-
"@shopgate/pwa-core": "7.31.0-beta.
|
|
24
|
-
"@shopgate/pwa-ui-ios": "7.31.0-beta.
|
|
25
|
-
"@shopgate/pwa-ui-material": "7.31.0-beta.
|
|
26
|
-
"@shopgate/pwa-ui-shared": "7.31.0-beta.
|
|
21
|
+
"@shopgate/pwa-common": "7.31.0-beta.3",
|
|
22
|
+
"@shopgate/pwa-common-commerce": "7.31.0-beta.3",
|
|
23
|
+
"@shopgate/pwa-core": "7.31.0-beta.3",
|
|
24
|
+
"@shopgate/pwa-ui-ios": "7.31.0-beta.3",
|
|
25
|
+
"@shopgate/pwa-ui-material": "7.31.0-beta.3",
|
|
26
|
+
"@shopgate/pwa-ui-shared": "7.31.0-beta.3",
|
|
27
27
|
"@stripe/react-stripe-js": "^1.16.5",
|
|
28
28
|
"@stripe/stripe-js": "^1.44.1",
|
|
29
29
|
"@virtuous/conductor": "~2.5.0",
|
|
@@ -2,7 +2,7 @@ import React, { memo, useMemo } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { PRODUCT_ITEM_NAME, PRODUCT_ITEM_NAME_BEFORE, PRODUCT_ITEM_NAME_AFTER } from '@shopgate/engage/category/constants';
|
|
4
4
|
import { Portal } from '@shopgate/engage/components';
|
|
5
|
-
import { ProductName } from '@shopgate/engage/product';
|
|
5
|
+
import { ProductName, ProductRatingStars } from '@shopgate/engage/product';
|
|
6
6
|
import { makeStyles } from '@shopgate/engage/styles';
|
|
7
7
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
const useStyles = makeStyles()({
|
|
@@ -38,18 +38,24 @@ const ItemName = ({
|
|
|
38
38
|
children: [/*#__PURE__*/_jsx(Portal, {
|
|
39
39
|
name: PRODUCT_ITEM_NAME_BEFORE,
|
|
40
40
|
props: portalProps
|
|
41
|
+
}), /*#__PURE__*/_jsx(ProductRatingStars, {
|
|
42
|
+
productId: productId
|
|
41
43
|
}), /*#__PURE__*/_jsx(Portal, {
|
|
42
44
|
name: PRODUCT_ITEM_NAME_AFTER,
|
|
43
45
|
props: portalProps
|
|
44
46
|
})]
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
|
-
return /*#__PURE__*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
50
|
+
children: [/*#__PURE__*/_jsx(ProductRatingStars, {
|
|
51
|
+
productId: productId
|
|
52
|
+
}), /*#__PURE__*/_jsx(ProductName, {
|
|
53
|
+
name: name,
|
|
54
|
+
className: cx(classes.root, 'theme__product-grid__item__item-name'),
|
|
55
|
+
portalName: PRODUCT_ITEM_NAME,
|
|
56
|
+
portalProps: portalProps,
|
|
57
|
+
testId: `Productname: ${name}`
|
|
58
|
+
})]
|
|
53
59
|
});
|
|
54
60
|
};
|
|
55
61
|
ItemName.defaultProps = {
|
|
@@ -3,7 +3,8 @@ import { shallow } from 'enzyme';
|
|
|
3
3
|
import ItemName from "./index";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
jest.mock('@shopgate/engage/product', () => ({
|
|
6
|
-
ProductName: () => null
|
|
6
|
+
ProductName: () => null,
|
|
7
|
+
ProductRatingStars: () => null
|
|
7
8
|
}));
|
|
8
9
|
jest.mock('@shopgate/engage/components');
|
|
9
10
|
const props = {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface RatingProps {
|
|
2
|
+
/**
|
|
3
|
+
* Id of the product to show the rating for.
|
|
4
|
+
*/
|
|
5
|
+
productId: string;
|
|
6
|
+
/**
|
|
7
|
+
* Size of the rating stars.
|
|
8
|
+
* @default 'small'
|
|
9
|
+
*/
|
|
10
|
+
size?: 'big' | 'small' | 'large';
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("react").MemoExoticComponent<({ productId, size, }: RatingProps) => import("react/jsx-runtime").JSX.Element | null>;
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=ProductRatingStars.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductRatingStars.d.ts","sourceRoot":"","sources":["../../../../product/components/ProductRatingStars/ProductRatingStars.tsx"],"names":[],"mappings":"AAiBA,UAAU,WAAW;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,CAAC;CAClC;mFAQE,WAAW;AA4Bd,wBAAwC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { memo, useMemo } from 'react';
|
|
2
|
+
import { useSelector } from 'react-redux';
|
|
3
|
+
import appConfig from '@shopgate/pwa-common/helpers/config';
|
|
4
|
+
import { getProductRating } from '@shopgate/pwa-common-commerce/product/selectors/product';
|
|
5
|
+
import { RatingStars } from '@shopgate/engage/components';
|
|
6
|
+
import { useWidgetSettings } from '@shopgate/engage/core/hooks';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const {
|
|
9
|
+
hasReviews
|
|
10
|
+
} = appConfig;
|
|
11
|
+
/**
|
|
12
|
+
* The product RatingStars component.
|
|
13
|
+
*/
|
|
14
|
+
const ProductRatingStars = ({
|
|
15
|
+
productId,
|
|
16
|
+
size = 'small'
|
|
17
|
+
}) => {
|
|
18
|
+
const rating = useSelector(state =>
|
|
19
|
+
// @ts-expect-error - getProductRating is not typed yet
|
|
20
|
+
getProductRating(state, {
|
|
21
|
+
productId
|
|
22
|
+
}));
|
|
23
|
+
const {
|
|
24
|
+
showEmptyRatingStars = false
|
|
25
|
+
} = useWidgetSettings('@shopgate/engage/rating');
|
|
26
|
+
const showRatings = useMemo(() => {
|
|
27
|
+
if (hasReviews && (rating?.average ?? 0) > 0) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (hasReviews && showEmptyRatingStars && rating) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}, [rating, showEmptyRatingStars]);
|
|
35
|
+
if (!showRatings) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return /*#__PURE__*/_jsx(RatingStars, {
|
|
39
|
+
value: rating?.average ?? 0,
|
|
40
|
+
display: size
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export default /*#__PURE__*/memo(ProductRatingStars);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../product/components/ProductRatingStars/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ProductRatingStars } from "./ProductRatingStars";
|
|
@@ -46,7 +46,7 @@ const Rating = ({
|
|
|
46
46
|
showEmptyRatingStars = false
|
|
47
47
|
} = useWidgetSettings('@shopgate/engage/rating');
|
|
48
48
|
const showRatings = useMemo(() => {
|
|
49
|
-
if (hasReviews && rating?.average > 0) {
|
|
49
|
+
if (hasReviews && (rating?.average ?? 0) > 0) {
|
|
50
50
|
return true;
|
|
51
51
|
}
|
|
52
52
|
if (hasReviews && showEmptyRatingStars && rating) {
|
|
@@ -24,6 +24,7 @@ export { default as ProductSlider } from "./ProductSlider";
|
|
|
24
24
|
export * from "./ProductVariants";
|
|
25
25
|
export { default as QuantityPicker } from "./QuantityPicker";
|
|
26
26
|
export { default as Rating } from "./Rating";
|
|
27
|
+
export { ProductRatingStars } from "./ProductRatingStars";
|
|
27
28
|
export * from "./RelationsSlider";
|
|
28
29
|
export * from "./Swatch";
|
|
29
30
|
export * from "./Swatches";
|