@shopgate/pwa-ui-shared 7.32.2-alpha.1 → 7.32.2-alpha.2

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.
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ export interface AddToCartButtonProps {
3
+ /**
4
+ * Whether the button is disabled.
5
+ */
6
+ isDisabled: boolean;
7
+ /**
8
+ * Shows a spinner instead of the icons and ignores clicks.
9
+ */
10
+ isLoading: boolean;
11
+ /**
12
+ * Called on click. `false` skips the checkmark animation, a promise delays it until it
13
+ * resolves.
14
+ */
15
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => unknown;
16
+ /**
17
+ * Hides the button from assistive technology.
18
+ */
19
+ 'aria-hidden'?: boolean;
20
+ /**
21
+ * Accessible label of the button.
22
+ */
23
+ 'aria-label'?: string;
24
+ /**
25
+ * Size of the button in pixels.
26
+ * @default 40
27
+ */
28
+ buttonSize?: number;
29
+ /**
30
+ * Custom class name for the button.
31
+ */
32
+ className?: string;
33
+ /**
34
+ * Ref of the button element, set by `withForwardedRef`.
35
+ */
36
+ forwardedRef?: React.Ref<HTMLButtonElement>;
37
+ /**
38
+ * Size of the icons in pixels.
39
+ * @default 20
40
+ */
41
+ iconSize?: number;
42
+ /**
43
+ * Called when the checkmark animation has finished.
44
+ */
45
+ onReset?: () => void;
46
+ /**
47
+ * Counts adds that happen outside the click, e.g. in a picker; each increase plays the checkmark.
48
+ * @default 0
49
+ */
50
+ successCount?: number;
51
+ }
52
+ declare const _default: React.ForwardRefExoticComponent<Omit<AddToCartButtonProps, "forwardedRef"> & React.RefAttributes<HTMLButtonElement>>;
53
+ export default _default;
54
+ //# sourceMappingURL=AddToCartButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AddToCartButton.d.ts","sourceRoot":"","sources":["../../AddToCartButton/AddToCartButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAEN,MAAM,OAAO,CAAC;AAiGf,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,OAAO,CAAC;IACjE;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC5C;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;wBAuKmD,KAAK,CAAC,yBAAyB,CACjF,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,CACpF;AAFD,wBAEE"}
@@ -0,0 +1,240 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import spring from 'css-spring';
3
+ import { withForwardedRef } from '@shopgate/engage/core';
4
+ import { keyframes, makeStyles, useTheme } from '@shopgate/engage/styles';
5
+ import CartPlusIcon from "../icons/CartPlusIcon";
6
+ import TickIcon from "../icons/TickIcon";
7
+ import IndicatorCircle from "../IndicatorCircle";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ const DEFAULT_BUTTON_SIZE = 40;
10
+ const DEFAULT_ICON_SIZE = 20;
11
+ const springOptions = {
12
+ stiffness: 381.47,
13
+ damping: 15
14
+ };
15
+ const springFromTopKeyframes = keyframes(spring({
16
+ transform: 'translate3d(0, 300%, 0)'
17
+ }, {
18
+ transform: 'translate3d(0, -50%, 0)'
19
+ }, springOptions));
20
+ const springFromBottomKeyframes = keyframes(spring({
21
+ transform: 'translate3d(0, -300%, 0)'
22
+ }, {
23
+ transform: 'translate3d(0, -50%, 0)'
24
+ }, springOptions));
25
+ const springToTopKeyframes = keyframes(spring({
26
+ transform: 'translate3d(0, -50%, 0)'
27
+ }, {
28
+ transform: 'translate3d(0, 300%, 0)'
29
+ }, springOptions));
30
+ const springToBottomKeyframes = keyframes(spring({
31
+ transform: 'translate3d(0, -50%, 0)'
32
+ }, {
33
+ transform: 'translate3d(0, -300%, 0)'
34
+ }, springOptions));
35
+ const useStyles = makeStyles()(theme => ({
36
+ springFromBottom: {
37
+ animation: `${springFromBottomKeyframes} 600ms`
38
+ },
39
+ springFromTop: {
40
+ animation: `${springFromTopKeyframes} 600ms`
41
+ },
42
+ springToTop: {
43
+ animation: `${springToTopKeyframes} 600ms`
44
+ },
45
+ springToBottom: {
46
+ animation: `${springToBottomKeyframes} 600ms`
47
+ },
48
+ icon: {
49
+ transition: 'opacity 450ms cubic-bezier(0.4, 0.0, 0.2, 1)',
50
+ opacity: 1,
51
+ position: 'absolute',
52
+ display: 'flex',
53
+ left: '50%',
54
+ marginLeft: '-0.5em'
55
+ },
56
+ spinnerIcon: {
57
+ left: '50%',
58
+ top: '50%',
59
+ marginTop: -32 / 2,
60
+ marginLeft: -32 / 2
61
+ },
62
+ buttonReady: {
63
+ background: theme.components.ctaButton.background,
64
+ color: theme.contrastColor(theme.components.ctaButton.background)
65
+ },
66
+ buttonSuccess: {
67
+ background: theme.contrastColor(theme.components.ctaButton.background),
68
+ color: theme.components.ctaButton.background
69
+ },
70
+ buttonDisabled: {
71
+ background: theme.palette.action.disabledBackground,
72
+ color: theme.contrastColor(theme.palette.action.disabledBackground),
73
+ boxShadow: '0 3px 4px rgba(0, 0, 0, 0.13)'
74
+ }
75
+ }));
76
+ const getWrapperStyle = (bSize, iSize) => ({
77
+ transition: 'background 450ms cubic-bezier(0.4, 0.0, 0.2, 1)',
78
+ borderRadius: '50%',
79
+ width: bSize,
80
+ height: bSize,
81
+ position: 'relative',
82
+ fontSize: iSize,
83
+ outline: 0,
84
+ paddingLeft: (bSize - iSize) / 2,
85
+ paddingRight: (bSize - iSize) / 2,
86
+ zIndex: 2,
87
+ overflow: 'hidden',
88
+ flexShrink: 0
89
+ });
90
+ /**
91
+ * The add to cart button with its checkmark animation.
92
+ */
93
+ const AddToCartButton = ({
94
+ 'aria-hidden': ariaHidden = false,
95
+ 'aria-label': ariaLabel,
96
+ buttonSize = DEFAULT_BUTTON_SIZE,
97
+ className,
98
+ forwardedRef,
99
+ iconSize = DEFAULT_ICON_SIZE,
100
+ isDisabled,
101
+ isLoading,
102
+ onClick,
103
+ onReset,
104
+ successCount = 0
105
+ }) => {
106
+ const {
107
+ classes,
108
+ cx
109
+ } = useStyles();
110
+ const theme = useTheme();
111
+ const [showCheckmark, setShowCheckmark] = useState(null);
112
+ const previousSuccessCount = useRef(successCount);
113
+ const isMounted = useRef(true);
114
+ const checkmarkTimeout = useRef();
115
+ useEffect(() => () => {
116
+ isMounted.current = false;
117
+ clearTimeout(checkmarkTimeout.current);
118
+ }, []);
119
+ const handleCompletion = useCallback(() => {
120
+ if (!isMounted.current) {
121
+ return;
122
+ }
123
+ clearTimeout(checkmarkTimeout.current);
124
+ setShowCheckmark(true);
125
+ checkmarkTimeout.current = setTimeout(() => {
126
+ setShowCheckmark(false);
127
+ }, 900);
128
+ }, []);
129
+ useEffect(() => {
130
+ if (successCount > previousSuccessCount.current) {
131
+ handleCompletion();
132
+ }
133
+ previousSuccessCount.current = successCount;
134
+ }, [successCount, handleCompletion]);
135
+ const handleClick = useCallback(event => {
136
+ if (showCheckmark || isLoading || isDisabled) {
137
+ return;
138
+ }
139
+ const result = onClick(event);
140
+ if (result === false) {
141
+ return;
142
+ }
143
+ if (result instanceof Promise) {
144
+ (async () => {
145
+ try {
146
+ await result;
147
+ handleCompletion();
148
+ } catch (error) {
149
+ // ignore error in button.
150
+ }
151
+ })();
152
+ return;
153
+ }
154
+ handleCompletion();
155
+ }, [showCheckmark, isLoading, isDisabled, onClick, handleCompletion]);
156
+ const handleCartAnimationEnd = useCallback(() => {
157
+ if (showCheckmark === false) {
158
+ setShowCheckmark(null);
159
+ }
160
+ onReset?.();
161
+ }, [showCheckmark, onReset]);
162
+ let buttonStateClass = classes.buttonReady;
163
+ let tickIconClass = classes.icon;
164
+ let cartPlusIconClass = classes.icon;
165
+ const iconOpacity = isLoading ? {
166
+ opacity: 0
167
+ } : {
168
+ opacity: 1
169
+ };
170
+ const spinnerInlineStyle = isLoading ? {
171
+ opacity: 1
172
+ } : {
173
+ opacity: 0
174
+ };
175
+ let tickInlineStyle = showCheckmark === null ? {
176
+ transform: 'translate3d(0, 300%, 0)',
177
+ ...iconOpacity
178
+ } : undefined;
179
+ let cartInlineStyle = showCheckmark === null ? {
180
+ transform: 'translate3d(0, -50%, 0)',
181
+ ...iconOpacity
182
+ } : undefined;
183
+ if (isDisabled && !isLoading) {
184
+ buttonStateClass = classes.buttonDisabled;
185
+ } else if (showCheckmark) {
186
+ tickIconClass = cx(classes.icon, classes.springFromBottom);
187
+ cartPlusIconClass = cx(classes.icon, classes.springToTop);
188
+ buttonStateClass = classes.buttonSuccess;
189
+ tickInlineStyle = {
190
+ transform: 'translate3d(0, -50%, 0)',
191
+ ...iconOpacity
192
+ };
193
+ cartInlineStyle = {
194
+ transform: 'translate3d(0, -300%, 0)',
195
+ ...iconOpacity
196
+ };
197
+ } else if (showCheckmark !== null) {
198
+ tickIconClass = cx(classes.icon, classes.springToBottom);
199
+ cartPlusIconClass = cx(classes.icon, classes.springFromTop);
200
+ cartInlineStyle = {
201
+ transform: 'translate3d(0, -50%, 0)',
202
+ ...iconOpacity
203
+ };
204
+ tickInlineStyle = {
205
+ transform: 'translate3d(0, -300%, 0)',
206
+ ...iconOpacity
207
+ };
208
+ }
209
+ const wrapperStyle = getWrapperStyle(buttonSize, iconSize);
210
+ return /*#__PURE__*/_jsxs("button", {
211
+ "data-test-id": "addToCartButton",
212
+ className: cx('ui-shared__add-to-cart-button', buttonStateClass, className),
213
+ style: wrapperStyle,
214
+ onClick: handleClick,
215
+ "aria-hidden": ariaHidden,
216
+ "aria-label": ariaLabel,
217
+ "aria-disabled": isDisabled,
218
+ ref: forwardedRef,
219
+ type: "button",
220
+ children: [isLoading && /*#__PURE__*/_jsx("div", {
221
+ className: cx(classes.icon, classes.spinnerIcon),
222
+ style: spinnerInlineStyle,
223
+ children: /*#__PURE__*/_jsx(IndicatorCircle, {
224
+ color: theme.contrastColor(theme.components.ctaButton.background),
225
+ strokeWidth: 5,
226
+ paused: !isLoading
227
+ })
228
+ }), /*#__PURE__*/_jsx("div", {
229
+ className: tickIconClass,
230
+ style: tickInlineStyle,
231
+ children: /*#__PURE__*/_jsx(TickIcon, {})
232
+ }), /*#__PURE__*/_jsx("div", {
233
+ className: cartPlusIconClass,
234
+ style: cartInlineStyle,
235
+ onAnimationEnd: handleCartAnimationEnd,
236
+ children: /*#__PURE__*/_jsx(CartPlusIcon, {})
237
+ })]
238
+ });
239
+ };
240
+ export default withForwardedRef(AddToCartButton);
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `css-spring` ships no types. It calculates the keyframes of a spring animation between two
3
+ * sets of CSS properties.
4
+ */
5
+ declare module 'css-spring' {
6
+ /**
7
+ * Spring physics of the animation.
8
+ */
9
+ interface SpringOptions {
10
+ stiffness?: number;
11
+ damping?: number;
12
+ precision?: number;
13
+ }
14
+
15
+ export default function spring(
16
+ from: Record<string, string | number>,
17
+ to: Record<string, string | number>,
18
+ options?: SpringOptions
19
+ ): Record<string, Record<string, string | number>>;
20
+ }
@@ -0,0 +1,3 @@
1
+ export { default } from './AddToCartButton';
2
+ export type { AddToCartButtonProps } from './AddToCartButton';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../AddToCartButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,247 +1 @@
1
- import React, { useCallback, useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import spring from 'css-spring';
4
- import { withForwardedRef } from '@shopgate/engage/core';
5
- import { keyframes, makeStyles, useTheme } from '@shopgate/engage/styles';
6
- import CartPlusIcon from "../icons/CartPlusIcon";
7
- import TickIcon from "../icons/TickIcon";
8
- import IndicatorCircle from "../IndicatorCircle";
9
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
- const DEFAULT_BUTTON_SIZE = 40;
11
- const DEFAULT_ICON_SIZE = 20;
12
- const springOptions = {
13
- stiffness: 381.47,
14
- damping: 15
15
- };
16
- const springFromTopKeyframes = keyframes(spring({
17
- transform: 'translate3d(0, 300%, 0)'
18
- }, {
19
- transform: 'translate3d(0, -50%, 0)'
20
- }, springOptions));
21
- const springFromBottomKeyframes = keyframes(spring({
22
- transform: 'translate3d(0, -300%, 0)'
23
- }, {
24
- transform: 'translate3d(0, -50%, 0)'
25
- }, springOptions));
26
- const springToTopKeyframes = keyframes(spring({
27
- transform: 'translate3d(0, -50%, 0)'
28
- }, {
29
- transform: 'translate3d(0, 300%, 0)'
30
- }, springOptions));
31
- const springToBottomKeyframes = keyframes(spring({
32
- transform: 'translate3d(0, -50%, 0)'
33
- }, {
34
- transform: 'translate3d(0, -300%, 0)'
35
- }, springOptions));
36
- const useStyles = makeStyles()(theme => ({
37
- springFromBottom: {
38
- animation: `${springFromBottomKeyframes} 600ms`
39
- },
40
- springFromTop: {
41
- animation: `${springFromTopKeyframes} 600ms`
42
- },
43
- springToTop: {
44
- animation: `${springToTopKeyframes} 600ms`
45
- },
46
- springToBottom: {
47
- animation: `${springToBottomKeyframes} 600ms`
48
- },
49
- icon: {
50
- transition: 'opacity 450ms cubic-bezier(0.4, 0.0, 0.2, 1)',
51
- opacity: 1,
52
- position: 'absolute',
53
- display: 'flex',
54
- left: '50%',
55
- marginLeft: '-0.5em'
56
- },
57
- spinnerIcon: {
58
- left: '50%',
59
- top: '50%',
60
- marginTop: -32 / 2,
61
- marginLeft: -32 / 2
62
- },
63
- buttonReady: {
64
- background: theme.components.ctaButton.background,
65
- color: theme.contrastColor(theme.components.ctaButton.background)
66
- },
67
- buttonSuccess: {
68
- background: theme.contrastColor(theme.components.ctaButton.background),
69
- color: theme.components.ctaButton.background
70
- },
71
- buttonDisabled: {
72
- background: theme.palette.action.disabledBackground,
73
- color: theme.contrastColor(theme.palette.action.disabledBackground),
74
- boxShadow: '0 3px 4px rgba(0, 0, 0, 0.13)'
75
- }
76
- }));
77
-
78
- /**
79
- * @param {number} bSize .
80
- * @param {number} iSize .
81
- * @returns {Object}
82
- */
83
- const getWrapperStyle = (bSize, iSize) => ({
84
- transition: 'background 450ms cubic-bezier(0.4, 0.0, 0.2, 1)',
85
- borderRadius: '50%',
86
- width: bSize,
87
- height: bSize,
88
- position: 'relative',
89
- fontSize: iSize,
90
- outline: 0,
91
- paddingLeft: (bSize - iSize) / 2,
92
- paddingRight: (bSize - iSize) / 2,
93
- zIndex: 2,
94
- overflow: 'hidden',
95
- flexShrink: 0
96
- });
97
-
98
- /**
99
- * AddToCartButton component.
100
- * @param {Object} props Props.
101
- * @returns {JSX.Element}
102
- */
103
- const AddToCartButton = ({
104
- 'aria-hidden': ariaHidden,
105
- 'aria-label': ariaLabel,
106
- buttonSize,
107
- className,
108
- forwardedRef,
109
- iconSize,
110
- isDisabled,
111
- isLoading,
112
- onClick,
113
- onReset
114
- }) => {
115
- const {
116
- classes,
117
- cx
118
- } = useStyles();
119
- const theme = useTheme();
120
- const [showCheckmark, setShowCheckmark] = useState(null);
121
-
122
- /**
123
- * @param {Event} e Click event.
124
- */
125
- const handleClick = useCallback(e => {
126
- if (showCheckmark || isLoading || isDisabled) {
127
- return;
128
- }
129
-
130
- /** Completes the success checkmark animation cycle. */
131
- const handleCompletion = () => {
132
- setShowCheckmark(true);
133
- setTimeout(() => {
134
- setShowCheckmark(false);
135
- }, 900);
136
- };
137
- const result = onClick(e);
138
- if (result === false) {
139
- return;
140
- }
141
- if (result instanceof Promise) {
142
- (async () => {
143
- try {
144
- await result;
145
- handleCompletion();
146
- } catch (error) {
147
- // ignore error in button.
148
- }
149
- })();
150
- return;
151
- }
152
- handleCompletion();
153
- }, [showCheckmark, isLoading, isDisabled, onClick]);
154
- const handleCartAnimationEnd = useCallback(() => {
155
- if (showCheckmark === false) {
156
- setShowCheckmark(null);
157
- }
158
- onReset();
159
- }, [showCheckmark, onReset]);
160
- let buttonStateClass = classes.buttonReady;
161
- let tickIconClass = classes.icon;
162
- let cartPlusIconClass = classes.icon;
163
- const iconOpacity = isLoading ? {
164
- opacity: 0
165
- } : {
166
- opacity: 1
167
- };
168
- const spinnerInlineStyle = isLoading ? {
169
- opacity: 1
170
- } : {
171
- opacity: 0
172
- };
173
- let tickInlineStyle = showCheckmark === null ? {
174
- transform: 'translate3d(0, 300%, 0)',
175
- ...iconOpacity
176
- } : null;
177
- let cartInlineStyle = showCheckmark === null ? {
178
- transform: 'translate3d(0, -50%, 0)',
179
- ...iconOpacity
180
- } : null;
181
- if (isDisabled && !isLoading) {
182
- buttonStateClass = classes.buttonDisabled;
183
- } else if (showCheckmark) {
184
- tickIconClass = cx(classes.icon, classes.springFromBottom);
185
- cartPlusIconClass = cx(classes.icon, classes.springToTop);
186
- buttonStateClass = classes.buttonSuccess;
187
- tickInlineStyle = {
188
- transform: 'translate3d(0, -50%, 0)',
189
- ...iconOpacity
190
- };
191
- cartInlineStyle = {
192
- transform: 'translate3d(0, -300%, 0)',
193
- ...iconOpacity
194
- };
195
- } else if (showCheckmark !== null) {
196
- tickIconClass = cx(classes.icon, classes.springToBottom);
197
- cartPlusIconClass = cx(classes.icon, classes.springFromTop);
198
- cartInlineStyle = {
199
- transform: 'translate3d(0, -50%, 0)',
200
- ...iconOpacity
201
- };
202
- tickInlineStyle = {
203
- transform: 'translate3d(0, -300%, 0)',
204
- ...iconOpacity
205
- };
206
- }
207
- const wrapperStyle = getWrapperStyle(buttonSize, iconSize);
208
- return /*#__PURE__*/_jsxs("button", {
209
- "data-test-id": "addToCartButton",
210
- className: cx('ui-shared__add-to-cart-button', buttonStateClass, className),
211
- style: wrapperStyle,
212
- onClick: handleClick,
213
- "aria-hidden": ariaHidden,
214
- "aria-label": ariaLabel,
215
- "aria-disabled": isDisabled,
216
- ref: forwardedRef,
217
- type: "button",
218
- children: [isLoading && /*#__PURE__*/_jsx("div", {
219
- className: cx(classes.icon, classes.spinnerIcon),
220
- style: spinnerInlineStyle,
221
- children: /*#__PURE__*/_jsx(IndicatorCircle, {
222
- color: theme.contrastColor(theme.components.ctaButton.background),
223
- strokeWidth: 5,
224
- paused: !isLoading
225
- })
226
- }), /*#__PURE__*/_jsx("div", {
227
- className: tickIconClass,
228
- style: tickInlineStyle,
229
- children: /*#__PURE__*/_jsx(TickIcon, {})
230
- }), /*#__PURE__*/_jsx("div", {
231
- className: cartPlusIconClass,
232
- style: cartInlineStyle,
233
- onAnimationEnd: handleCartAnimationEnd,
234
- children: /*#__PURE__*/_jsx(CartPlusIcon, {})
235
- })]
236
- });
237
- };
238
- AddToCartButton.defaultProps = {
239
- 'aria-hidden': false,
240
- 'aria-label': null,
241
- buttonSize: DEFAULT_BUTTON_SIZE,
242
- className: null,
243
- forwardedRef: null,
244
- iconSize: DEFAULT_ICON_SIZE,
245
- onReset: () => {}
246
- };
247
- export default withForwardedRef(AddToCartButton);
1
+ export { default } from "./AddToCartButton";
@@ -1,6 +1,7 @@
1
- import { css } from 'glamor';
2
1
  import spring from 'css-spring';
2
+ import { logger } from '@shopgate/pwa-core/helpers';
3
3
  import { themeConfig } from '@shopgate/pwa-common/helpers/config';
4
+ import { css, keyframes } from '@shopgate/engage/styles';
4
5
 
5
6
  /* eslint-disable max-len */
6
7
  // TODO This file was brought back since some extensions import it (@shopgate-project/tablet-adjustments, @shopgate/grouped-products).
@@ -9,6 +10,7 @@ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
9
10
  // on their own
10
11
  /* eslint-enable max-len */
11
12
 
13
+ logger.warn('DEPRECATED: @shopgate/pwa-ui-shared/AddToCartButton/style is deprecated and will be removed. Style the add to cart button inside the extension instead.');
12
14
  const options = {
13
15
  stiffness: 381.47,
14
16
  damping: 15
@@ -20,38 +22,38 @@ const iconSize = 20;
20
22
  * Keyframe animations to create spring animation.
21
23
  * spring(..) automatically calculates all steps for the keyframe animation.
22
24
  */
23
- const springFromTopKeyframes = css.keyframes(spring({
25
+ const springFromTopKeyframes = keyframes(spring({
24
26
  transform: 'translate3d(0, 300%, 0)'
25
27
  }, {
26
28
  transform: 'translate3d(0, -50%, 0)'
27
29
  }, options));
28
- const springFromBottomKeyframes = css.keyframes(spring({
30
+ const springFromBottomKeyframes = keyframes(spring({
29
31
  transform: 'translate3d(0, -300%, 0)'
30
32
  }, {
31
33
  transform: 'translate3d(0, -50%, 0)'
32
34
  }, options));
33
- const springToTopKeyframes = css.keyframes(spring({
35
+ const springToTopKeyframes = keyframes(spring({
34
36
  transform: 'translate3d(0, -50%, 0)'
35
37
  }, {
36
38
  transform: 'translate3d(0, 300%, 0)'
37
39
  }, options));
38
- const springToBottomKeyframes = css.keyframes(spring({
40
+ const springToBottomKeyframes = keyframes(spring({
39
41
  transform: 'translate3d(0, -50%, 0)'
40
42
  }, {
41
43
  transform: 'translate3d(0, -300%, 0)'
42
44
  }, options));
43
45
  const springFromBottom = css({
44
46
  animation: `${springFromBottomKeyframes} 600ms`
45
- }).toString();
47
+ });
46
48
  const springFromTop = css({
47
49
  animation: `${springFromTopKeyframes} 600ms`
48
- }).toString();
50
+ });
49
51
  const springToTop = css({
50
52
  animation: `${springToTopKeyframes} 600ms`
51
- }).toString();
53
+ });
52
54
  const springToBottom = css({
53
55
  animation: `${springToBottomKeyframes} 600ms`
54
- }).toString();
56
+ });
55
57
 
56
58
  /**
57
59
  * Circular button and container for the icons.
@@ -83,7 +85,7 @@ const buttonWrapperDefault = (bSize, iSize) => ({
83
85
  */
84
86
  const buttonWrapper = (bSize, iSize) => css({
85
87
  ...buttonWrapperDefault(bSize, iSize)
86
- }).toString();
88
+ });
87
89
 
88
90
  /**
89
91
  * Circular button and container for the icons.
@@ -94,7 +96,7 @@ const buttonWrapper = (bSize, iSize) => css({
94
96
  */
95
97
  const buttonWrapperNoShadow = (bSize, iSize) => css({
96
98
  ...buttonWrapperDefault(bSize, iSize)
97
- }).toString();
99
+ });
98
100
 
99
101
  /**
100
102
  * Styling that is applied to the button when cart icon is shown.
@@ -102,7 +104,7 @@ const buttonWrapperNoShadow = (bSize, iSize) => css({
102
104
  const buttonReady = css({
103
105
  background: `var(--color-button-cta, ${themeConfig.colors.cta})`,
104
106
  color: `var(--color-button-cta-contrast, ${themeConfig.colors.ctaContrast})`
105
- }).toString();
107
+ });
106
108
 
107
109
  /**
108
110
  * Styling that is applied to the button when checkmark is shown.
@@ -110,7 +112,7 @@ const buttonReady = css({
110
112
  const buttonSuccess = css({
111
113
  background: `var(--color-button-cta-contrast, ${themeConfig.colors.ctaContrast})`,
112
114
  color: `var(--color-button-cta, ${themeConfig.colors.cta})`
113
- }).toString();
115
+ });
114
116
 
115
117
  /**
116
118
  * Styling that is applied to the button when it is disabled.
@@ -119,7 +121,7 @@ const buttonDisabled = css({
119
121
  background: themeConfig.colors.shade5,
120
122
  color: `var(--color-button-cta-contrast, ${themeConfig.colors.ctaContrast})`,
121
123
  boxShadow: themeConfig.shadows.buttons.disabled
122
- }).toString();
124
+ });
123
125
 
124
126
  /**
125
127
  * Basic icon style that is always applied to all icons.
@@ -128,7 +130,7 @@ const icon = css({
128
130
  transition: 'opacity 450ms cubic-bezier(0.4, 0.0, 0.2, 1)',
129
131
  opacity: 1,
130
132
  position: 'absolute'
131
- }).toString();
133
+ });
132
134
 
133
135
  /**
134
136
  * Icon style that is applied only to the spinner icon.
@@ -138,7 +140,7 @@ const spinnerIcon = css({
138
140
  top: '50%',
139
141
  marginTop: -themeConfig.variables.loadingIndicator.size / 2,
140
142
  marginLeft: -themeConfig.variables.loadingIndicator.size / 2
141
- }).toString();
143
+ });
142
144
  export default {
143
145
  buttonWrapper,
144
146
  buttonWrapperNoShadow,
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  // TODO: Move to ThemeContext
3
2
  import BaseDialogGMD from '@shopgate/pwa-ui-material/BaseDialog';
4
3
  import BaseDialogIOS from '@shopgate/pwa-ui-ios/BaseDialog';
@@ -57,9 +57,9 @@ export type FavoritesButtonProps = FavoritesButtonOwnProps & FavoritesButtonConn
57
57
  declare const FavoritesButtonComponent: import("react-redux").ConnectedComponent<React.MemoExoticComponent<({ active, addFavorites, "aria-hidden": ariaHidden, className, loadWishlistOnAppStartEnabled, once, productId, removeFavorites, removeThrottle, removeWithRelatives, size, wishlistItemQuantityEnabled, }: FavoritesButtonProps) => React.JSX.Element | null>, {
58
58
  className?: string | undefined;
59
59
  size?: IconButtonSize | undefined;
60
+ 'aria-hidden'?: boolean | undefined;
60
61
  active?: boolean | undefined;
61
62
  addFavorites?: ((productId: string) => void) | undefined;
62
- 'aria-hidden'?: boolean | undefined;
63
63
  loadWishlistOnAppStartEnabled?: boolean | undefined;
64
64
  once?: boolean | undefined;
65
65
  productId?: string | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"FavoritesButton.d.ts","sourceRoot":"","sources":["../../FavoritesButton/FavoritesButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAEN,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAiGrE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM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+1,3 @@
1
- import "core-js/modules/es.array.reduce.js";
2
1
  /**
3
2
  * Builds an Object, that contains all validation errors given as array of objects
4
3
  * @param {{path: string, message: string}[]} validationErrors Associated object containing errors
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import { logger } from '@shopgate/pwa-core/helpers';
3
2
  import { ELEMENT_TYPE_NUMBER, ELEMENT_TYPE_COUNTRY, ELEMENT_TYPE_PROVINCE, ELEMENT_TYPE_CHECKBOX } from "../../elementTypes";
4
3
  import { ACTION_TYPE_UPDATE_PROVINCE_ELEMENT, ACTION_TYPE_SET_VISIBILITY, ACTION_TYPE_SET_VALUE, ACTION_TYPE_TRANSFORM, ACTION_SET_VALUE_FIXED, ACTION_SET_VALUE_COPY_FROM, ACTION_SET_VALUE_LENGTH_OF, ACTION_RULE_TYPE_NOT_IN, ACTION_RULE_TYPE_ONE_OF, ACTION_RULE_TYPE_BOOLEAN, ACTION_RULE_TYPE_REGEX, ACTION_RULE_DATA_TYPES, ACTION_RULES_CONCAT_METHOD_ALL, ACTION_RULES_CONCAT_METHOD_ANY, ACTION_RULES_CONCAT_METHOD_NONE } from "./constants";
@@ -1,6 +1,5 @@
1
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
2
  import _isEqual from "lodash/isEqual";
3
- import "core-js/modules/es.string.replace.js";
4
3
  import React, { Component, Fragment } from 'react';
5
4
  import PropTypes from 'prop-types';
6
5
  import { logger } from '@shopgate/pwa-core/helpers';
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import React, { useState, useCallback } from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import pick from 'lodash/pick';
@@ -0,0 +1,36 @@
1
+ export default IndicatorCircle;
2
+ /**
3
+ * The circle indicator component.
4
+ * @param {Object} props The component props.
5
+ * @param {Object} props.size Width and height of the circle.
6
+ * @param {Object} props.color Color of the circle.
7
+ * @param {Object} props.strokeWidth Stroke width of the circle.
8
+ * @param {boolean} props.paused Animation should be paused.
9
+ * @returns {JSX}
10
+ */
11
+ declare function IndicatorCircle({ size, color, strokeWidth, paused, }: {
12
+ size: Object;
13
+ color: Object;
14
+ strokeWidth: Object;
15
+ paused: boolean;
16
+ }): JSX;
17
+ declare namespace IndicatorCircle {
18
+ namespace propTypes {
19
+ let color: PropTypes.Requireable<string>;
20
+ let paused: PropTypes.Requireable<boolean>;
21
+ let size: PropTypes.Requireable<number>;
22
+ let strokeWidth: PropTypes.Requireable<number>;
23
+ }
24
+ namespace defaultProps {
25
+ let color_1: string;
26
+ export { color_1 as color };
27
+ let paused_1: boolean;
28
+ export { paused_1 as paused };
29
+ let size_1: number;
30
+ export { size_1 as size };
31
+ let strokeWidth_1: number;
32
+ export { strokeWidth_1 as strokeWidth };
33
+ }
34
+ }
35
+ import PropTypes from 'prop-types';
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../IndicatorCircle/index.jsx"],"names":[],"mappings":";AA2CA;;;;;;;;GAQG;AACH,wEANG;IAAsB,IAAI,EAAlB,MAAM;IACQ,KAAK,EAAnB,MAAM;IACQ,WAAW,EAAzB,MAAM;IACS,MAAM,EAArB,OAAO;CACf,GAAU,GAAG,CA+Bf;;;;;;;;;;;;;;;;;;;sBAhFqB,YAAY"}
package/Price/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.string.replace.js";
2
1
  import React, { useMemo } from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import { I18n, Typography } from '@shopgate/engage/components';
@@ -1,4 +1,3 @@
1
- import "core-js/modules/es.array.includes.js";
2
1
  import React, { useState, useCallback, useMemo, useRef } from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import { makeStyles } from '@shopgate/engage/styles';
package/package.json CHANGED
@@ -1,16 +1,22 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-ui-shared",
3
- "version": "7.32.2-alpha.1",
3
+ "version": "7.32.2-alpha.2",
4
4
  "description": "Shopgate's shared UI components.",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/shopgate/pwa.git",
10
+ "directory": "libraries/ui-shared"
11
+ },
7
12
  "dependencies": {
8
- "@shopgate/pwa-ui-ios": "7.32.2-alpha.1",
9
- "@shopgate/pwa-ui-material": "7.32.2-alpha.1"
13
+ "@shopgate/pwa-ui-ios": "7.32.2-alpha.2",
14
+ "@shopgate/pwa-ui-material": "7.32.2-alpha.2",
15
+ "css-spring": "git+https://github.com/shopgate/css-spring.git#master"
10
16
  },
11
17
  "devDependencies": {
12
- "@shopgate/pwa-common": "7.32.2-alpha.1",
13
- "@shopgate/pwa-common-commerce": "7.32.2-alpha.1",
18
+ "@shopgate/pwa-common": "7.32.2-alpha.2",
19
+ "@shopgate/pwa-common-commerce": "7.32.2-alpha.2",
14
20
  "classnames": "2.5.1",
15
21
  "react": "^17.0.2"
16
22
  },