@shopgate/pwa-common 7.31.6 → 7.32.0-beta.10
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/collections/media-providers/style.js +4 -9
- package/components/Backdrop/index.js +1 -1
- package/components/Button/index.js +6 -0
- package/components/Icon/index.d.ts +1 -1
- package/components/Icon/index.d.ts.map +1 -1
- package/components/Image/Image.d.ts +78 -0
- package/components/Image/Image.d.ts.map +1 -0
- package/components/Image/Image.js +123 -95
- package/components/Image/ImageInner.d.ts +45 -0
- package/components/Image/ImageInner.d.ts.map +1 -0
- package/components/Image/ImageInner.js +23 -29
- package/components/Image/index.d.ts +3 -0
- package/components/Image/index.d.ts.map +1 -0
- package/components/Modal/index.js +4 -4
- package/components/SurroundPortals/index.d.ts +1 -1
- package/components/SurroundPortals/index.d.ts.map +1 -1
- package/components/Swiper/index.js +9 -10
- package/constants/Configuration.js +7 -0
- package/helpers/config/index.d.ts +1 -40
- package/helpers/config/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/providers/toast/index.js +18 -11
- package/subscriptions/router.js +2 -2
- package/styles/reset/form.js +0 -58
- package/styles/reset/index.js +0 -8
- package/styles/reset/media.js +0 -26
- package/styles/reset/root.js +0 -37
- package/styles/reset/table.js +0 -14
- package/styles/reset/typography.js +0 -30
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { css } from '@shopgate/engage/styles';
|
|
2
|
-
import { themeConfig } from '@shopgate/pwa-common/helpers/config';
|
|
3
|
-
const {
|
|
4
|
-
colors
|
|
5
|
-
} = themeConfig;
|
|
6
2
|
const responsiveContainer = css({
|
|
7
3
|
position: 'relative',
|
|
8
4
|
height: 0,
|
|
@@ -29,19 +25,18 @@ const consentContainer = css({
|
|
|
29
25
|
justifyContent: 'center',
|
|
30
26
|
textAlign: 'center',
|
|
31
27
|
gap: 16,
|
|
32
|
-
background:
|
|
33
|
-
border:
|
|
34
|
-
// Add a tiny little border radius to make the message container look nice with padding
|
|
28
|
+
background: 'var(--sg-palette-grey-light)',
|
|
29
|
+
border: '1px solid var(--sg-components-border-medium)',
|
|
35
30
|
borderRadius: 4,
|
|
36
31
|
top: 0
|
|
37
32
|
});
|
|
38
33
|
const consentLink = css({
|
|
39
34
|
textAlign: 'center',
|
|
40
|
-
color:
|
|
35
|
+
color: 'var(--sg-palette-primary-main)',
|
|
41
36
|
fontWeight: 500
|
|
42
37
|
}).toString();
|
|
43
38
|
const consentIcon = css({
|
|
44
|
-
fill:
|
|
39
|
+
fill: 'var(--sg-palette-grey-medium)',
|
|
45
40
|
height: 40
|
|
46
41
|
});
|
|
47
42
|
export default {
|
|
@@ -49,4 +49,10 @@ Button.defaultProps = {
|
|
|
49
49
|
onClick: null,
|
|
50
50
|
testId: 'Button'
|
|
51
51
|
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated Use `ButtonBase` from `@shopgate/engage/components/v2` instead — it renders the same
|
|
55
|
+
* unstyled click target, adds a ripple, and accepts `component` / `href` to change the element.
|
|
56
|
+
* For a styled button use `Button` from the same module.
|
|
57
|
+
*/
|
|
52
58
|
export default /*#__PURE__*/memo(Button);
|
|
@@ -31,6 +31,6 @@ export interface IconProps {
|
|
|
31
31
|
* Provides basic styling via `currentColor` and supports size and color
|
|
32
32
|
* overrides through props while allowing external class-based overrides.
|
|
33
33
|
*/
|
|
34
|
-
declare const Icon: ({ content, className, color, viewBox, size, }: IconProps) => import("react
|
|
34
|
+
declare const Icon: ({ content, className, color, viewBox, size, }: IconProps) => import("react").JSX.Element;
|
|
35
35
|
export default Icon;
|
|
36
36
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Icon/index.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,IAAI,GAAI,+CAMX,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Icon/index.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,IAAI,GAAI,+CAMX,SAAS,gCAgBX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ReactElement, SyntheticEvent } from 'react';
|
|
2
|
+
import type { ImageResolution } from '@shopgate/engage/settings/types/appSettings';
|
|
3
|
+
export interface ImageProps {
|
|
4
|
+
/**
|
|
5
|
+
* Optional alt text for the image. Without one the image is marked decorative.
|
|
6
|
+
*/
|
|
7
|
+
alt?: string | null;
|
|
8
|
+
/**
|
|
9
|
+
* The background color of the image container.
|
|
10
|
+
*/
|
|
11
|
+
backgroundColor?: string;
|
|
12
|
+
/**
|
|
13
|
+
* External class name for the image container.
|
|
14
|
+
*/
|
|
15
|
+
className?: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* External class name for the image itself.
|
|
18
|
+
*/
|
|
19
|
+
classNameImg?: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Shows the `placeholder` even when the image could be loaded. For a parent that decides on
|
|
22
|
+
* grounds this component cannot see, e.g. a product that is not orderable.
|
|
23
|
+
*/
|
|
24
|
+
forcePlaceholder?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Callback that is invoked when the image with the highest resolution has been loaded.
|
|
27
|
+
*/
|
|
28
|
+
highestResolutionLoaded?: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Microdata property name, e.g. "image" for a schema.org Product. Emitted as the itemprop
|
|
31
|
+
* attribute so crawlers can pick the image out of the surrounding item.
|
|
32
|
+
*/
|
|
33
|
+
itemProp?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the image is loaded only once it comes near the viewport. Turn it off for images that
|
|
36
|
+
* are visible immediately, e.g. the first tile of a list.
|
|
37
|
+
*/
|
|
38
|
+
lazy?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Callback that is invoked when image loading failed. Handling the failure is not required - a
|
|
41
|
+
* `placeholder` covers that - so this is for callers that need to react beyond the image itself.
|
|
42
|
+
*/
|
|
43
|
+
onError?: (event: SyntheticEvent<HTMLImageElement>) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Callback that is invoked when the image has been loaded.
|
|
46
|
+
*/
|
|
47
|
+
onLoad?: (event: SyntheticEvent<HTMLImageElement>) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Rendered in place of the image when there is no `src`, when `forcePlaceholder` is set, or when
|
|
50
|
+
* the image failed to load. It renders inside the container, so it inherits the reserved aspect
|
|
51
|
+
* ratio box and needs no sizing of its own.
|
|
52
|
+
*/
|
|
53
|
+
placeholder?: ReactElement | null;
|
|
54
|
+
/**
|
|
55
|
+
* Width and height parts of the rendered aspect ratio, e.g. [16, 9]. Without one the ratio is
|
|
56
|
+
* calculated from the highest resolution.
|
|
57
|
+
*/
|
|
58
|
+
ratio?: number[] | null;
|
|
59
|
+
/**
|
|
60
|
+
* The resolutions to request, ordered ascending. The last is displayed; the second to last is
|
|
61
|
+
* loaded first as a preview, so something appears as soon as possible.
|
|
62
|
+
*/
|
|
63
|
+
resolutions?: ImageResolution[];
|
|
64
|
+
/**
|
|
65
|
+
* Image source. A url the image service serves is rewritten to carry the requested dimensions and
|
|
66
|
+
* the app wide quality and fill settings. Any other url is used as it is, so `resolutions` and
|
|
67
|
+
* `ratio` then only affect the layout, not what is downloaded.
|
|
68
|
+
*/
|
|
69
|
+
src?: string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Renders a plain img tag without the container, for callers that position the image themselves.
|
|
72
|
+
* Nothing reserves its space while it loads, and `backgroundColor` has nothing to apply to.
|
|
73
|
+
*/
|
|
74
|
+
unwrapped?: boolean;
|
|
75
|
+
}
|
|
76
|
+
declare const _default: import("react").MemoExoticComponent<(props: ImageProps) => import("react").JSX.Element | null>;
|
|
77
|
+
export default _default;
|
|
78
|
+
//# sourceMappingURL=Image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../components/Image/Image.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAiB,YAAY,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAKzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAGnF,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,IAAI,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC3D;;;;OAIG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB;;;OAGG;IACH,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;IAChC;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;oEA8EqB,UAAU;AAoMhC,wBAA2B"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import { useMemo, useState, useEffect, useRef, useCallback, memo } from 'react';
|
|
3
2
|
import noop from 'lodash/noop';
|
|
4
|
-
import { themeConfig } from '@shopgate/engage';
|
|
5
3
|
import { makeStyles } from '@shopgate/engage/styles';
|
|
6
4
|
import { getFullImageSource } from '@shopgate/engage/core/helpers';
|
|
5
|
+
import { useImageServiceSettings } from '@shopgate/engage/settings/hooks';
|
|
7
6
|
import ImageInner from "./ImageInner";
|
|
8
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
const {
|
|
10
|
-
colors: themeColors
|
|
11
|
-
} = themeConfig;
|
|
12
8
|
const useStyles = makeStyles()((_theme, {
|
|
13
9
|
background,
|
|
14
10
|
paddingTop
|
|
@@ -27,57 +23,112 @@ const useStyles = makeStyles()((_theme, {
|
|
|
27
23
|
}));
|
|
28
24
|
|
|
29
25
|
/**
|
|
30
|
-
* Calculates the Greatest Common Divisor
|
|
31
|
-
*
|
|
32
|
-
* @param
|
|
33
|
-
* @
|
|
34
|
-
* @returns {number} The greatest common divisor of `a` and `b`.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* gcd(1920, 1080); // Returns 120
|
|
38
|
-
* gcd(10, 15); // Returns 5
|
|
39
|
-
* gcd(100, 25); // Returns 25
|
|
26
|
+
* Calculates the Greatest Common Divisor of two numbers using the Euclidean algorithm.
|
|
27
|
+
* @param a The first number.
|
|
28
|
+
* @param b The second number.
|
|
29
|
+
* @returns The greatest common divisor, or 1 when the pair cannot be reduced.
|
|
40
30
|
*/
|
|
41
|
-
const gcd = (a, b) =>
|
|
31
|
+
const gcd = (a, b) => {
|
|
32
|
+
// Anything but a pair of positive whole numbers is left unreduced. The values can originate from
|
|
33
|
+
// an admin field a merchant is still typing into, and NaN or Infinity would otherwise recurse
|
|
34
|
+
// until the stack overflows, while a fraction would reduce to a near-zero divisor.
|
|
35
|
+
if (!Number.isInteger(a) || !Number.isInteger(b) || a <= 0 || b <= 0) {
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
let dividend = a;
|
|
39
|
+
let remainder = b;
|
|
40
|
+
while (remainder !== 0) {
|
|
41
|
+
const next = dividend % remainder;
|
|
42
|
+
dividend = remainder;
|
|
43
|
+
remainder = next;
|
|
44
|
+
}
|
|
45
|
+
return dividend;
|
|
46
|
+
};
|
|
42
47
|
|
|
43
48
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @param
|
|
46
|
-
* @returns
|
|
49
|
+
* Whether a value can be used as one side of an aspect ratio.
|
|
50
|
+
* @param value The value to check.
|
|
51
|
+
* @returns Whether it is a usable length.
|
|
52
|
+
*/
|
|
53
|
+
const isUsableLength = value => Number.isFinite(value) && value > 0;
|
|
54
|
+
const defaultResolutions = [{
|
|
55
|
+
width: 440,
|
|
56
|
+
height: 440
|
|
57
|
+
}];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Renders an image at the configured resolutions, inside a container that reserves its aspect ratio
|
|
61
|
+
* so the layout does not shift while it loads.
|
|
62
|
+
*
|
|
63
|
+
* What a caller should know:
|
|
64
|
+
*
|
|
65
|
+
* - **Nothing is rendered until there is something to render.** Without a `src`, the container is
|
|
66
|
+
* still there and keeps its space, but it stays empty unless a `placeholder` is given.
|
|
67
|
+
* - **A failed image is remembered per source, not per component.** Once a `placeholder` is given,
|
|
68
|
+
* it takes over on failure, and the image returns by itself as soon as the requested url changes -
|
|
69
|
+
* a new `src`, different `resolutions`, or an app wide image setting edited in the admin. Callers
|
|
70
|
+
* that pass no `placeholder` keep the failed image, and `onError` keeps reporting every attempt.
|
|
71
|
+
* - **`onLoad` and `onError` are always forwarded**, whether or not a placeholder is involved.
|
|
72
|
+
* - **`unwrapped` gives up the container**, and with it the reserved aspect ratio box and the
|
|
73
|
+
* background color. The caller has to provide the space itself.
|
|
74
|
+
* @param props The components props.
|
|
75
|
+
* @returns The rendered component.
|
|
47
76
|
*/
|
|
48
|
-
const Image =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
77
|
+
const Image = props => {
|
|
78
|
+
const {
|
|
79
|
+
alt = null,
|
|
80
|
+
backgroundColor = 'var(--sg-palette-background-emphasized)',
|
|
81
|
+
className = '',
|
|
82
|
+
classNameImg = '',
|
|
83
|
+
forcePlaceholder: parentRendersPlaceholder = false,
|
|
84
|
+
highestResolutionLoaded = noop,
|
|
85
|
+
itemProp,
|
|
86
|
+
onError = noop,
|
|
87
|
+
onLoad = noop,
|
|
88
|
+
placeholder = null,
|
|
89
|
+
ratio = null,
|
|
90
|
+
resolutions = defaultResolutions,
|
|
91
|
+
src = null,
|
|
92
|
+
lazy = true,
|
|
93
|
+
unwrapped = false
|
|
94
|
+
} = props;
|
|
95
|
+
|
|
96
|
+
// Quality and fill color are configured app wide, so they are resolved here rather than passed
|
|
97
|
+
// in by every caller. The returned object is reference stable, so it does not defeat the memo.
|
|
98
|
+
const imageServiceSettings = useImageServiceSettings();
|
|
99
|
+
|
|
63
100
|
// Prepare two image sources - a small preview image and a large main image. The idea is to
|
|
64
101
|
// display an image as soon as possible. Small images might be also available in the cache from
|
|
65
102
|
// the previous page.
|
|
66
103
|
const sources = useMemo(() => {
|
|
67
104
|
// Create a preview source when resolutions array has more than one element
|
|
68
|
-
const preview = resolutions.length > 1 ? getFullImageSource(src, resolutions[resolutions.length - 2]) : null;
|
|
105
|
+
const preview = resolutions.length > 1 ? getFullImageSource(src, resolutions[resolutions.length - 2], imageServiceSettings) : null;
|
|
69
106
|
|
|
70
107
|
// Create a main source when resolutions array has at least one element (highest resolution)
|
|
71
|
-
const main = resolutions.length > 0 ? getFullImageSource(src, resolutions[resolutions.length - 1]) : null;
|
|
108
|
+
const main = resolutions.length > 0 ? getFullImageSource(src, resolutions[resolutions.length - 1], imageServiceSettings) : null;
|
|
72
109
|
return {
|
|
73
110
|
// Only assign preview source if it is different from the main source. Image swap logic
|
|
74
111
|
// will not run when no preview source is available.
|
|
75
112
|
preview: preview !== main ? preview : null,
|
|
76
113
|
main
|
|
77
114
|
};
|
|
78
|
-
}, [resolutions, src]);
|
|
115
|
+
}, [resolutions, src, imageServiceSettings]);
|
|
79
116
|
const imgRef = useRef(null);
|
|
80
117
|
const [isInView, setIsInView] = useState(!lazy);
|
|
118
|
+
const [failedSource, setFailedSource] = useState(null);
|
|
119
|
+
|
|
120
|
+
// A failure counts against the source that produced it, not against the component. Anything that
|
|
121
|
+
// rebuilds the url - a new src, a reconfigured ratio, a different fill color - is by itself the
|
|
122
|
+
// decision to try again, so the placeholder gives way without anyone having to reset a flag.
|
|
123
|
+
//
|
|
124
|
+
// Only callers that provide a placeholder have the image taken away from them. Without one there
|
|
125
|
+
// is nothing to swap to, so a failed image stays mounted and keeps reporting through onError,
|
|
126
|
+
// exactly as it behaved before this prop existed.
|
|
127
|
+
//
|
|
128
|
+
// The null check matters: an empty resolutions array leaves no source to request, and would
|
|
129
|
+
// otherwise match the initial state and report a failure that never happened.
|
|
130
|
+
const hasFailed = sources.main !== null && failedSource === sources.main;
|
|
131
|
+
const showPlaceholder = !src || parentRendersPlaceholder || !!placeholder && hasFailed;
|
|
81
132
|
|
|
82
133
|
// Effect to create an Intersection Observer to enable lazy loading of preview images
|
|
83
134
|
useEffect(() => {
|
|
@@ -107,40 +158,41 @@ const Image = ({
|
|
|
107
158
|
|
|
108
159
|
/**
|
|
109
160
|
* Handles the onLoad event of the image.
|
|
161
|
+
* @param event The load event.
|
|
110
162
|
*/
|
|
111
|
-
const handleOnLoad = useCallback(
|
|
163
|
+
const handleOnLoad = useCallback(event => {
|
|
112
164
|
highestResolutionLoaded();
|
|
113
|
-
onLoad(
|
|
165
|
+
onLoad(event);
|
|
114
166
|
}, [highestResolutionLoaded, onLoad]);
|
|
115
167
|
|
|
116
168
|
/**
|
|
117
169
|
* Handles the onError event of the image.
|
|
170
|
+
* @param event The error event.
|
|
118
171
|
*/
|
|
119
|
-
const handleOnError = useCallback(
|
|
120
|
-
|
|
121
|
-
|
|
172
|
+
const handleOnError = useCallback(event => {
|
|
173
|
+
setFailedSource(sources.main);
|
|
174
|
+
onError(event);
|
|
175
|
+
}, [onError, sources.main]);
|
|
122
176
|
|
|
123
177
|
/**
|
|
124
178
|
* Memoized calculation of aspect ratio and CSS padding-hack ratio for responsive elements.
|
|
125
179
|
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* - `paddingHackRatio` {string} - The CSS padding-hack ratio as a percentage for older browsers
|
|
129
|
-
* (e.g., `56.250%` for a 16:9 ratio).
|
|
180
|
+
* aspectRatio is the ratio in the format `width / height` (e.g. `16 / 9`), paddingHackRatio the
|
|
181
|
+
* same as a percentage for older browsers (e.g. `56.250%` for a 16:9 ratio).
|
|
130
182
|
*/
|
|
131
183
|
const {
|
|
132
184
|
aspectRatio,
|
|
133
185
|
paddingHackRatio
|
|
134
186
|
} = useMemo(() => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
187
|
+
const [width, height] = ratio ?? [resolutions[resolutions.length - 1]?.width, resolutions[resolutions.length - 1]?.height];
|
|
188
|
+
|
|
189
|
+
// Fall back to a square rather than emitting "NaN / NaN" or dividing by zero. Reached when the
|
|
190
|
+
// resolutions are empty, or when a ratio arrives half typed from the admin.
|
|
191
|
+
if (!isUsableLength(width) || !isUsableLength(height)) {
|
|
192
|
+
return {
|
|
193
|
+
aspectRatio: '1 / 1',
|
|
194
|
+
paddingHackRatio: '100.000%'
|
|
195
|
+
};
|
|
144
196
|
}
|
|
145
197
|
const divisor = gcd(width, height);
|
|
146
198
|
return {
|
|
@@ -155,22 +207,24 @@ const Image = ({
|
|
|
155
207
|
background: backgroundColor,
|
|
156
208
|
paddingTop: paddingHackRatio
|
|
157
209
|
});
|
|
210
|
+
const innerStyle = {
|
|
211
|
+
aspectRatio,
|
|
212
|
+
...(isInView && sources.preview && {
|
|
213
|
+
backgroundImage: `url(${sources.preview})`,
|
|
214
|
+
backgroundSize: 'contain',
|
|
215
|
+
backgroundRepeat: 'no-repeat',
|
|
216
|
+
backgroundPosition: 'center'
|
|
217
|
+
})
|
|
218
|
+
};
|
|
158
219
|
if (unwrapped) {
|
|
159
|
-
if (
|
|
220
|
+
if (showPlaceholder) return placeholder;
|
|
160
221
|
return /*#__PURE__*/_jsx(ImageInner, {
|
|
161
222
|
ref: imgRef,
|
|
162
223
|
src: sources.main,
|
|
163
224
|
className: cx(classNameImg),
|
|
164
|
-
style:
|
|
165
|
-
aspectRatio,
|
|
166
|
-
...(isInView && sources.preview && {
|
|
167
|
-
backgroundImage: `url(${sources.preview})`,
|
|
168
|
-
backgroundSize: 'contain',
|
|
169
|
-
backgroundRepeat: 'no-repeat',
|
|
170
|
-
backgroundPosition: 'center'
|
|
171
|
-
})
|
|
172
|
-
},
|
|
225
|
+
style: innerStyle,
|
|
173
226
|
alt: alt,
|
|
227
|
+
itemProp: itemProp,
|
|
174
228
|
lazy: lazy,
|
|
175
229
|
onLoad: handleOnLoad,
|
|
176
230
|
onError: handleOnError
|
|
@@ -178,43 +232,17 @@ const Image = ({
|
|
|
178
232
|
}
|
|
179
233
|
return /*#__PURE__*/_jsx("div", {
|
|
180
234
|
className: cx(classes.container, className, 'common__image__container'),
|
|
181
|
-
children:
|
|
235
|
+
children: showPlaceholder ? placeholder : /*#__PURE__*/_jsx(ImageInner, {
|
|
182
236
|
ref: imgRef,
|
|
183
237
|
src: sources.main,
|
|
184
238
|
className: cx(classNameImg),
|
|
185
|
-
style:
|
|
186
|
-
aspectRatio,
|
|
187
|
-
...(isInView && sources.preview && {
|
|
188
|
-
backgroundImage: `url(${sources.preview})`,
|
|
189
|
-
backgroundSize: 'contain',
|
|
190
|
-
backgroundRepeat: 'no-repeat',
|
|
191
|
-
backgroundPosition: 'center'
|
|
192
|
-
})
|
|
193
|
-
},
|
|
239
|
+
style: innerStyle,
|
|
194
240
|
alt: alt,
|
|
241
|
+
itemProp: itemProp,
|
|
195
242
|
lazy: lazy,
|
|
196
243
|
onLoad: handleOnLoad,
|
|
197
244
|
onError: handleOnError
|
|
198
245
|
})
|
|
199
246
|
});
|
|
200
247
|
};
|
|
201
|
-
const defaultResolutions = [{
|
|
202
|
-
width: 440,
|
|
203
|
-
height: 440
|
|
204
|
-
}];
|
|
205
|
-
Image.defaultProps = {
|
|
206
|
-
alt: null,
|
|
207
|
-
backgroundColor: themeColors.placeholder,
|
|
208
|
-
className: '',
|
|
209
|
-
classNameImg: '',
|
|
210
|
-
forcePlaceholder: false,
|
|
211
|
-
highestResolutionLoaded: noop,
|
|
212
|
-
onError: noop,
|
|
213
|
-
onLoad: noop,
|
|
214
|
-
ratio: null,
|
|
215
|
-
resolutions: defaultResolutions,
|
|
216
|
-
src: null,
|
|
217
|
-
unwrapped: false,
|
|
218
|
-
lazy: true
|
|
219
|
-
};
|
|
220
248
|
export default /*#__PURE__*/memo(Image);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CSSProperties, SyntheticEvent } from 'react';
|
|
2
|
+
export interface ImageInnerProps {
|
|
3
|
+
/**
|
|
4
|
+
* Alt text. Without one the image is marked decorative.
|
|
5
|
+
*/
|
|
6
|
+
alt?: string | null;
|
|
7
|
+
/**
|
|
8
|
+
* External class name for the img element.
|
|
9
|
+
*/
|
|
10
|
+
className?: string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Microdata property name, e.g. "image" for a schema.org Product. Emitted as the itemprop
|
|
13
|
+
* attribute so crawlers can pick the image out of the surrounding item.
|
|
14
|
+
*/
|
|
15
|
+
itemProp?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the browser defers loading until the image is near the viewport.
|
|
18
|
+
*/
|
|
19
|
+
lazy?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback that is invoked when image loading failed.
|
|
22
|
+
*/
|
|
23
|
+
onError?: (event: SyntheticEvent<HTMLImageElement>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback that is invoked when the image has been loaded.
|
|
26
|
+
*/
|
|
27
|
+
onLoad?: (event: SyntheticEvent<HTMLImageElement>) => void;
|
|
28
|
+
/**
|
|
29
|
+
* The resolved image url.
|
|
30
|
+
*/
|
|
31
|
+
src?: string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Inline styles, used to pin the aspect ratio and paint the preview behind the image.
|
|
34
|
+
*/
|
|
35
|
+
style?: CSSProperties | null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The ImageInner component renders the actual image of the Image component.
|
|
39
|
+
* @param props The component props.
|
|
40
|
+
* @param ref The component reference.
|
|
41
|
+
* @returns The rendered component.
|
|
42
|
+
*/
|
|
43
|
+
declare const ImageInner: import("react").ForwardRefExoticComponent<ImageInnerProps & import("react").RefAttributes<HTMLImageElement>>;
|
|
44
|
+
export default ImageInner;
|
|
45
|
+
//# sourceMappingURL=ImageInner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageInner.d.ts","sourceRoot":"","sources":["../../../components/Image/ImageInner.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAI3D,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC3D;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;CAC9B;AAeD;;;;;GAKG;AACH,QAAA,MAAM,UAAU,8GAkCd,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import { forwardRef } from 'react';
|
|
3
2
|
import noop from 'lodash/noop';
|
|
4
3
|
import { makeStyles } from '@shopgate/engage/styles';
|
|
5
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -11,25 +10,28 @@ const useStyles = makeStyles()({
|
|
|
11
10
|
width: '100%',
|
|
12
11
|
maxHeight: '100%',
|
|
13
12
|
WebkitTouchCallout: 'none',
|
|
14
|
-
fontSize: 0
|
|
13
|
+
fontSize: 0,
|
|
14
|
+
objectFit: 'contain'
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* The ImageInner component renders
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @returns
|
|
19
|
+
* The ImageInner component renders the actual image of the Image component.
|
|
20
|
+
* @param props The component props.
|
|
21
|
+
* @param ref The component reference.
|
|
22
|
+
* @returns The rendered component.
|
|
23
23
|
*/
|
|
24
|
-
const ImageInner = /*#__PURE__*/forwardRef(({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
const ImageInner = /*#__PURE__*/forwardRef((props, ref) => {
|
|
25
|
+
const {
|
|
26
|
+
src = null,
|
|
27
|
+
className = null,
|
|
28
|
+
alt = null,
|
|
29
|
+
itemProp,
|
|
30
|
+
lazy = false,
|
|
31
|
+
onLoad = noop,
|
|
32
|
+
onError = noop,
|
|
33
|
+
style = null
|
|
34
|
+
} = props;
|
|
33
35
|
const {
|
|
34
36
|
classes,
|
|
35
37
|
cx
|
|
@@ -37,24 +39,16 @@ const ImageInner = /*#__PURE__*/forwardRef(({
|
|
|
37
39
|
return /*#__PURE__*/_jsx("img", {
|
|
38
40
|
ref: ref,
|
|
39
41
|
loading: lazy ? 'lazy' : 'eager',
|
|
40
|
-
src: src,
|
|
42
|
+
src: src ?? undefined,
|
|
41
43
|
className: cx(classes.image, 'common__image', className),
|
|
42
|
-
alt: alt,
|
|
43
|
-
"aria-label": alt,
|
|
44
|
+
alt: alt ?? undefined,
|
|
45
|
+
"aria-label": alt ?? undefined,
|
|
44
46
|
"aria-hidden": !alt,
|
|
45
47
|
"data-test-id": "image",
|
|
48
|
+
itemProp: itemProp,
|
|
46
49
|
onLoad: onLoad,
|
|
47
50
|
onError: onError,
|
|
48
|
-
style: style
|
|
51
|
+
style: style ?? undefined
|
|
49
52
|
});
|
|
50
53
|
});
|
|
51
|
-
ImageInner.defaultProps = {
|
|
52
|
-
src: null,
|
|
53
|
-
alt: null,
|
|
54
|
-
className: null,
|
|
55
|
-
lazy: false,
|
|
56
|
-
style: null,
|
|
57
|
-
onError: noop,
|
|
58
|
-
onLoad: noop
|
|
59
|
-
};
|
|
60
54
|
export default ImageInner;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Image/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { createPortal } from 'react-dom';
|
|
|
4
4
|
import { useTrackModalState } from '@shopgate/engage/a11y/hooks';
|
|
5
5
|
import { makeStyles, responsiveMediaQuery } from '@shopgate/engage/styles';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
const useStyles = makeStyles()({
|
|
7
|
+
const useStyles = makeStyles()(theme => ({
|
|
8
8
|
container: {
|
|
9
9
|
position: 'fixed',
|
|
10
10
|
top: 0,
|
|
@@ -25,8 +25,8 @@ const useStyles = makeStyles()({
|
|
|
25
25
|
position: 'relative',
|
|
26
26
|
maxWidth: '100vw',
|
|
27
27
|
maxHeight: '100vh',
|
|
28
|
-
paddingTop:
|
|
29
|
-
paddingBottom:
|
|
28
|
+
paddingTop: theme.layout.safeArea.top,
|
|
29
|
+
paddingBottom: theme.layout.safeArea.bottom,
|
|
30
30
|
overflowY: 'scroll',
|
|
31
31
|
[responsiveMediaQuery('>xs', {
|
|
32
32
|
webOnly: true
|
|
@@ -34,7 +34,7 @@ const useStyles = makeStyles()({
|
|
|
34
34
|
overflowY: 'initial'
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
});
|
|
37
|
+
}));
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* The Modal component.
|
|
@@ -19,6 +19,6 @@ export interface SurroundPortalsProps {
|
|
|
19
19
|
*
|
|
20
20
|
* @returns The SurroundPortals component.
|
|
21
21
|
*/
|
|
22
|
-
declare const SurroundPortals: ({ portalName, portalProps, children, }: SurroundPortalsProps) =>
|
|
22
|
+
declare const SurroundPortals: ({ portalName, portalProps, children, }: SurroundPortalsProps) => React.JSX.Element;
|
|
23
23
|
export default SurroundPortals;
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/SurroundPortals/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,eAAe,GAAI,wCAItB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/SurroundPortals/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,eAAe,GAAI,wCAItB,oBAAoB,sBAQtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -9,10 +9,9 @@ import 'swiper/css/navigation';
|
|
|
9
9
|
import 'swiper/css/zoom';
|
|
10
10
|
import { useReduceMotion } from '@shopgate/engage/a11y/hooks';
|
|
11
11
|
import { makeStyles } from '@shopgate/engage/styles';
|
|
12
|
-
import { themeColors } from '@shopgate/pwa-common/helpers/config';
|
|
13
12
|
import SwiperItem from "./components/SwiperItem";
|
|
14
13
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
const useStyles = makeStyles()(
|
|
14
|
+
const useStyles = makeStyles()(theme => ({
|
|
16
15
|
container: {
|
|
17
16
|
position: 'relative',
|
|
18
17
|
maxHeight: '100%',
|
|
@@ -27,7 +26,7 @@ const useStyles = makeStyles()(() => ({
|
|
|
27
26
|
},
|
|
28
27
|
innerContainer: {
|
|
29
28
|
overflow: 'hidden',
|
|
30
|
-
'--swiper-navigation-color':
|
|
29
|
+
'--swiper-navigation-color': theme.components.swiper.paginationBulletColor,
|
|
31
30
|
'& .swiper-wrapper': {
|
|
32
31
|
alignItems: 'stretch'
|
|
33
32
|
},
|
|
@@ -36,11 +35,10 @@ const useStyles = makeStyles()(() => ({
|
|
|
36
35
|
},
|
|
37
36
|
'& .swiper-pagination': {
|
|
38
37
|
'& .swiper-pagination-bullet': {
|
|
39
|
-
background:
|
|
38
|
+
background: theme.components.swiper.paginationBulletActiveColor,
|
|
40
39
|
opacity: '.5',
|
|
41
40
|
margin: '0 4px',
|
|
42
|
-
transition: 'opacity 300ms cubic-bezier(0.25, 0.1, 0.25, 1)'
|
|
43
|
-
border: `1px solid ${themeColors.dark}`
|
|
41
|
+
transition: 'opacity 300ms cubic-bezier(0.25, 0.1, 0.25, 1)'
|
|
44
42
|
},
|
|
45
43
|
'& .swiper-pagination-bullet-active.swiper-pagination-bullet-active-main': {
|
|
46
44
|
opacity: 1
|
|
@@ -51,8 +49,9 @@ const useStyles = makeStyles()(() => ({
|
|
|
51
49
|
left: 'auto',
|
|
52
50
|
right: 0,
|
|
53
51
|
bottom: 'auto',
|
|
54
|
-
fontSize:
|
|
55
|
-
background:
|
|
52
|
+
fontSize: theme.typography.caption.fontSize,
|
|
53
|
+
background: theme.components.swiper.paginationFractionBackground,
|
|
54
|
+
color: theme.contrastColor(theme.components.swiper.paginationFractionBackground),
|
|
56
55
|
borderRadius: '50px',
|
|
57
56
|
width: 'fit-content',
|
|
58
57
|
padding: '4px 8px',
|
|
@@ -60,9 +59,9 @@ const useStyles = makeStyles()(() => ({
|
|
|
60
59
|
transition: 'opacity 300ms cubic-bezier(0.25, 0.1, 0.25, 1)'
|
|
61
60
|
},
|
|
62
61
|
'& .swiper-pagination-progressbar': {
|
|
63
|
-
background:
|
|
62
|
+
background: theme.components.swiper.paginationProgressbarBackground,
|
|
64
63
|
'& .swiper-pagination-progressbar-fill': {
|
|
65
|
-
background:
|
|
64
|
+
background: theme.components.swiper.paginationProgressbarActiveColor
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
},
|
|
@@ -34,4 +34,11 @@ export const IS_CONNECT_EXTENSION_ATTACHED = 'IS_CONNECT_EXTENSION_ATTACHED';
|
|
|
34
34
|
*/
|
|
35
35
|
export const CONFIGURATION_COLLECTION_CREATE_EXTERNAL_IMAGE_URL = 'CONFIGURATION_COLLECTION_CREATE_EXTERNAL_IMAGE_URL';
|
|
36
36
|
export const CONFIGURATION_COLLECTION_KEY_THEME_TYPOGRAPHY = 'CONFIGURATION_COLLECTION_KEY_THEME_TYPOGRAPHY';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Capability flag the PWA sets to signal that base typography is applied on the root (`<html>`)
|
|
40
|
+
* element rather than the legacy `<body>` element. Consumers can read it to adjust behavior
|
|
41
|
+
* accordingly. Absent on older PWAs.
|
|
42
|
+
*/
|
|
43
|
+
export const CONFIGURATION_COLLECTION_KEY_HAS_ROOT_TYPOGRAPHY = 'CONFIGURATION_COLLECTION_KEY_HAS_ROOT_TYPOGRAPHY';
|
|
37
44
|
export const CONFIGURATION_COLLECTION_KEY_UNIVERSAL_LINK_HANDLER = 'universalLinkHandler';
|
|
@@ -51,44 +51,5 @@ export default appConfig;
|
|
|
51
51
|
* Be careful when changing existing properties on the fly, reassignments should never be done!
|
|
52
52
|
* @mixes AppConfig
|
|
53
53
|
*/
|
|
54
|
-
declare const appConfig:
|
|
55
|
-
appId: string;
|
|
56
|
-
browserConnector: boolean;
|
|
57
|
-
colors: {};
|
|
58
|
-
forgotPasswordUrl: null;
|
|
59
|
-
hasFavorites: boolean;
|
|
60
|
-
hasReviews: boolean;
|
|
61
|
-
showWriteReview: boolean;
|
|
62
|
-
language: string;
|
|
63
|
-
logo: string;
|
|
64
|
-
marketId: string;
|
|
65
|
-
publicPath: string;
|
|
66
|
-
shopName: string;
|
|
67
|
-
webCheckoutShopify: null;
|
|
68
|
-
hasNoScanner: boolean;
|
|
69
|
-
apiUrl: string;
|
|
70
|
-
shopCNAME: null;
|
|
71
|
-
currency: string;
|
|
72
|
-
showGmdMenuSubHeaders: boolean;
|
|
73
|
-
benchmark: boolean;
|
|
74
|
-
sentry: {};
|
|
75
|
-
theme: {};
|
|
76
|
-
cartShippingHideAnonymousLegacy: null;
|
|
77
|
-
cartShippingTextAnonymousLegacy: null;
|
|
78
|
-
variantSelectionMode: null;
|
|
79
|
-
product: {
|
|
80
|
-
variantPreselect: boolean;
|
|
81
|
-
};
|
|
82
|
-
cart: {};
|
|
83
|
-
scanner: {};
|
|
84
|
-
favorites: {};
|
|
85
|
-
tracking: {
|
|
86
|
-
hasWebTrackingEngage: boolean;
|
|
87
|
-
useSkuAsProductId: boolean;
|
|
88
|
-
};
|
|
89
|
-
webTrackingEngage: {
|
|
90
|
-
android: string;
|
|
91
|
-
ios: string;
|
|
92
|
-
};
|
|
93
|
-
} | undefined;
|
|
54
|
+
declare const appConfig: any;
|
|
94
55
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../helpers/config/index.js"],"names":[],"mappings":"AAyJA;;;;GAIG;AACH,yCAHW,MAAM,oBACN,mBAAmB,GAAC,IAAI,QAKlC;AA/GD;;GAEG;AACH,yBAFU,MAAM,CAEsB;AAWtC;;;GAGG;AACH,+BAFU,MAAM,CAKd;AASF;;;GAGG;AACH,wBAFU,MAAM,CAEsC;AAEtD;;;GAGG;AACH,0BAFU,WAAW,CAEkC;AAEvD,yBAAyB;AACzB,8BAA8C;AAC9C,0BAA0B;AAC1B,+BAAgD;AAChD,4BAA4B;AAC5B,iCAAoD;AACpD,wBAAwB;AACxB,6BAA4C;AAK5C;;;;;;;;;;GAUG;AACH,2CANU,mBAAmB,CA8B3B;AAWK,gDAPI,MAAM,SACN,GAAC,SACD,GAAC,aACD,MAAM,aACN,MAAM,GACJ,OAAO,CAGK;AAiBzB,6BAAkE;;AA/FlE;;;;GAIG;AACH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../helpers/config/index.js"],"names":[],"mappings":"AAyJA;;;;GAIG;AACH,yCAHW,MAAM,oBACN,mBAAmB,GAAC,IAAI,QAKlC;AA/GD;;GAEG;AACH,yBAFU,MAAM,CAEsB;AAWtC;;;GAGG;AACH,+BAFU,MAAM,CAKd;AASF;;;GAGG;AACH,wBAFU,MAAM,CAEsC;AAEtD;;;GAGG;AACH,0BAFU,WAAW,CAEkC;AAEvD,yBAAyB;AACzB,8BAA8C;AAC9C,0BAA0B;AAC1B,+BAAgD;AAChD,4BAA4B;AAC5B,iCAAoD;AACpD,wBAAwB;AACxB,6BAA4C;AAK5C;;;;;;;;;;GAUG;AACH,2CANU,mBAAmB,CA8B3B;AAWK,gDAPI,MAAM,SACN,GAAC,SACD,GAAC,aACD,MAAM,aACN,MAAM,GACJ,OAAO,CAGK;AAiBzB,6BAAkE;;AA/FlE;;;;GAIG;AACH,6BAA8F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-common",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.32.0-beta.10",
|
|
4
4
|
"description": "Common library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@redux-devtools/extension": "^3.3.0",
|
|
19
19
|
"@sentry/browser": "6.0.1",
|
|
20
|
-
"@shopgate/pwa-benchmark": "7.
|
|
20
|
+
"@shopgate/pwa-benchmark": "7.32.0-beta.10",
|
|
21
21
|
"@virtuous/conductor": "~2.5.0",
|
|
22
22
|
"@virtuous/react-conductor": "~2.5.0",
|
|
23
23
|
"@virtuous/redux-persister": "1.1.0-beta.7",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"glamor": "^2.20.40",
|
|
27
27
|
"gsap": "^3.14.2",
|
|
28
28
|
"history": "^4.9.0",
|
|
29
|
-
"intl-messageformat": "^11.
|
|
29
|
+
"intl-messageformat": "^11.2.9",
|
|
30
30
|
"path-match": "^1.2.4",
|
|
31
31
|
"react-dotdotdot": "~1.3.1",
|
|
32
32
|
"react-helmet": "^6.1.0",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"redux-thunk": "^3.1.0",
|
|
38
38
|
"reselect": "^4.1.8",
|
|
39
39
|
"rxjs": "~5.5.12",
|
|
40
|
-
"swiper": "12.
|
|
40
|
+
"swiper": "12.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@shopgate/pwa-core": "7.
|
|
43
|
+
"@shopgate/pwa-core": "7.32.0-beta.10",
|
|
44
44
|
"@types/lodash": "^4.17.24",
|
|
45
45
|
"@types/react-portal": "^3.0.9",
|
|
46
46
|
"lodash": "^4.17.23",
|
package/providers/toast/index.js
CHANGED
|
@@ -3,20 +3,20 @@ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
|
3
3
|
import React, { Component } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { UIEvents } from '@shopgate/pwa-core';
|
|
6
|
-
import {
|
|
6
|
+
import { withTheme } from '@shopgate/engage/styles/theme/hocs/withTheme';
|
|
7
7
|
import ToastContext from "./context";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = {}
|
|
15
|
-
} = themeConfig;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} ToastProviderProps
|
|
11
|
+
* @property {import('react').ReactNode} children
|
|
12
|
+
* @property {import('@shopgate/engage/styles').Theme} theme
|
|
13
|
+
*/
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
16
|
* The ToastProvider component
|
|
17
|
+
* @augments {Component<ToastProviderProps>}
|
|
19
18
|
*/
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
20
|
let ToastProvider = /*#__PURE__*/function (_Component) {
|
|
21
21
|
/**
|
|
22
22
|
* @param {Object} props The component props.
|
|
@@ -39,7 +39,7 @@ let ToastProvider = /*#__PURE__*/function (_Component) {
|
|
|
39
39
|
onLongPress: toast.onLongPress,
|
|
40
40
|
message: toast.message,
|
|
41
41
|
messageParams: toast.messageParams,
|
|
42
|
-
duration: toast.duration || duration
|
|
42
|
+
duration: toast.duration || _this.props.theme.transitions.duration.toast
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
// Update the queue immutably: consumers rely on the array reference changing to re-render
|
|
@@ -124,4 +124,11 @@ let ToastProvider = /*#__PURE__*/function (_Component) {
|
|
|
124
124
|
}(Component);
|
|
125
125
|
ToastProvider.ADD = 'toast_add';
|
|
126
126
|
ToastProvider.FLUSH = 'toast_flush';
|
|
127
|
-
|
|
127
|
+
const ThemedToastProvider = withTheme(ToastProvider);
|
|
128
|
+
|
|
129
|
+
// The HOC returns a new component which doesn't carry over the statics of the wrapped class. They
|
|
130
|
+
// are part of the public API of this module (consumers emit UIEvents on ToastProvider.ADD), so they
|
|
131
|
+
// are re-attached explicitly.
|
|
132
|
+
ThemedToastProvider.ADD = ToastProvider.ADD;
|
|
133
|
+
ThemedToastProvider.FLUSH = ToastProvider.FLUSH;
|
|
134
|
+
export default ThemedToastProvider;
|
package/subscriptions/router.js
CHANGED
|
@@ -9,7 +9,7 @@ import Route from '@virtuous/conductor/Route';
|
|
|
9
9
|
import { Linking } from '@shopgate/native-modules';
|
|
10
10
|
import { HISTORY_RESET_TO } from '@shopgate/pwa-common/constants/ActionTypes';
|
|
11
11
|
import { logger } from '@shopgate/pwa-core';
|
|
12
|
-
import {
|
|
12
|
+
import { isNavigationBlocked } from '@shopgate/engage/admin-preview/helpers';
|
|
13
13
|
import addCouponsToCart from '@shopgate/pwa-common-commerce/cart/actions/addCouponsToCart';
|
|
14
14
|
import { getCurrentRoute, getRouterStackIndex } from "../selectors/router";
|
|
15
15
|
import { LoadingProvider } from "../providers";
|
|
@@ -31,7 +31,7 @@ import ToastProvider from "../providers/toast";
|
|
|
31
31
|
*/
|
|
32
32
|
export default function routerSubscriptions(subscribe) {
|
|
33
33
|
subscribe(navigate$, async params => {
|
|
34
|
-
if (
|
|
34
|
+
if (isNavigationBlocked()) {
|
|
35
35
|
// No navigation is allowed in page preview mode.
|
|
36
36
|
return;
|
|
37
37
|
}
|
package/styles/reset/form.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { injectGlobal } from '@shopgate/engage/styles';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 1. Correct the inability to style clickable types in iOS and Safari.
|
|
9
|
-
* since iOS 15 button has a default color of blue rgb(0, 122, 255);
|
|
10
|
-
*
|
|
11
|
-
* 1. Change font properties to `inherit` in Safari.
|
|
12
|
-
* 2. Correct the inability to style clickable types in iOS and Safari.
|
|
13
|
-
*
|
|
14
|
-
* Remove the inner padding and cancel buttons in Chrome and Safari for OS X.
|
|
15
|
-
*/
|
|
16
|
-
injectGlobal({
|
|
17
|
-
'button, html [type="button"], [type="reset"], [type="submit"]': {
|
|
18
|
-
WebkitAppearance: 'button'
|
|
19
|
-
},
|
|
20
|
-
button: {
|
|
21
|
-
color: 'inherit',
|
|
22
|
-
borderRadius: 0
|
|
23
|
-
},
|
|
24
|
-
'::-webkit-file-upload-button': {
|
|
25
|
-
font: 'inherit',
|
|
26
|
-
WebkitAppearance: 'button'
|
|
27
|
-
},
|
|
28
|
-
'::-webkit-search-cancel-button, ::-webkit-search-decoration': {
|
|
29
|
-
WebkitAppearance: 'none'
|
|
30
|
-
},
|
|
31
|
-
'button, input, select, textarea': {
|
|
32
|
-
background: 'transparent',
|
|
33
|
-
border: 0,
|
|
34
|
-
fontSize: '1em',
|
|
35
|
-
margin: 0
|
|
36
|
-
},
|
|
37
|
-
'input, select, textarea': {
|
|
38
|
-
fontFamily: 'inherit'
|
|
39
|
-
},
|
|
40
|
-
'button, textarea': {
|
|
41
|
-
fontFamily: 'inherit',
|
|
42
|
-
lineHeight: 'inherit'
|
|
43
|
-
},
|
|
44
|
-
'button, label, [type="checkbox"], [type="radio"]': {
|
|
45
|
-
cursor: 'pointer'
|
|
46
|
-
},
|
|
47
|
-
label: {
|
|
48
|
-
display: 'inline-block'
|
|
49
|
-
},
|
|
50
|
-
textarea: {
|
|
51
|
-
minHeight: '5em',
|
|
52
|
-
maxWidth: '100%',
|
|
53
|
-
resize: 'none'
|
|
54
|
-
},
|
|
55
|
-
'[type="search"]': {
|
|
56
|
-
WebkitAppearance: 'textfield'
|
|
57
|
-
}
|
|
58
|
-
});
|
package/styles/reset/index.js
DELETED
package/styles/reset/media.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated used @shopgate/engage/styles/reset instead
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { injectGlobal } from '@shopgate/engage/styles';
|
|
6
|
-
injectGlobal({
|
|
7
|
-
'audio:not([controls])': {
|
|
8
|
-
display: 'none',
|
|
9
|
-
height: 0
|
|
10
|
-
},
|
|
11
|
-
figure: {
|
|
12
|
-
margin: 0
|
|
13
|
-
},
|
|
14
|
-
iframe: {
|
|
15
|
-
border: 0,
|
|
16
|
-
display: 'block',
|
|
17
|
-
width: '100%'
|
|
18
|
-
},
|
|
19
|
-
'img, svg': {
|
|
20
|
-
display: 'block',
|
|
21
|
-
maxWidth: '100%'
|
|
22
|
-
},
|
|
23
|
-
progress: {
|
|
24
|
-
verticalAlign: 'baseline'
|
|
25
|
-
}
|
|
26
|
-
});
|
package/styles/reset/root.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { injectGlobal } from '@shopgate/engage/styles';
|
|
6
|
-
import { themeConfig } from "../../helpers/config";
|
|
7
|
-
const {
|
|
8
|
-
typography
|
|
9
|
-
} = themeConfig;
|
|
10
|
-
injectGlobal({
|
|
11
|
-
'*, *:before, *:after': {
|
|
12
|
-
boxSizing: 'border-box'
|
|
13
|
-
},
|
|
14
|
-
'html, body': {
|
|
15
|
-
WebkitTapHighlightColor: 'transparent',
|
|
16
|
-
width: '100%',
|
|
17
|
-
height: '100%'
|
|
18
|
-
},
|
|
19
|
-
html: {
|
|
20
|
-
overflow: 'hidden',
|
|
21
|
-
MozOsxFontSmoothing: 'grayscale',
|
|
22
|
-
WebkitFontSmoothing: 'antialiased',
|
|
23
|
-
MsTextSizeAdjust: '100%',
|
|
24
|
-
WebkitTextSizeAdjust: '100%',
|
|
25
|
-
minHeight: '100%'
|
|
26
|
-
},
|
|
27
|
-
body: {
|
|
28
|
-
font: `${typography.rootSize}px/${typography.lineHeight} ${typography.family}`,
|
|
29
|
-
overflow: 'auto',
|
|
30
|
-
margin: 0,
|
|
31
|
-
WebkitOverflowScrolling: 'touch',
|
|
32
|
-
WebkitUserSelect: 'none'
|
|
33
|
-
},
|
|
34
|
-
'[data-pattern]': {
|
|
35
|
-
height: '100% !important'
|
|
36
|
-
}
|
|
37
|
-
});
|
package/styles/reset/table.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { injectGlobal } from '@shopgate/engage/styles';
|
|
6
|
-
injectGlobal({
|
|
7
|
-
table: {
|
|
8
|
-
borderCollapse: 'collapse',
|
|
9
|
-
minWidth: '100%'
|
|
10
|
-
},
|
|
11
|
-
'td, th': {
|
|
12
|
-
verticalAlign: 'top'
|
|
13
|
-
}
|
|
14
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { injectGlobal } from '@shopgate/engage/styles';
|
|
6
|
-
import { rem } from "../../helpers/style";
|
|
7
|
-
injectGlobal({
|
|
8
|
-
a: {
|
|
9
|
-
color: 'inherit',
|
|
10
|
-
textDecoration: 'none',
|
|
11
|
-
WebkitTextDecorationSkip: 'objects'
|
|
12
|
-
},
|
|
13
|
-
'a:hover, a:focus, a:active, [tabindex]': {
|
|
14
|
-
outline: 0
|
|
15
|
-
},
|
|
16
|
-
'ol, ul': {
|
|
17
|
-
listStyle: 'none',
|
|
18
|
-
margin: 0,
|
|
19
|
-
paddingLeft: 0
|
|
20
|
-
},
|
|
21
|
-
'b, strong': {
|
|
22
|
-
fontWeight: 700
|
|
23
|
-
},
|
|
24
|
-
small: {
|
|
25
|
-
fontSize: rem(13)
|
|
26
|
-
},
|
|
27
|
-
'sub, sup': {
|
|
28
|
-
lineHeight: 0
|
|
29
|
-
}
|
|
30
|
-
});
|