@shopgate/pwa-ui-shared 7.32.0-beta.2 → 7.32.0-beta.20

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.
Files changed (68) hide show
  1. package/ActionButton/index.js +4 -0
  2. package/AddToCartButton/index.js +4 -1
  3. package/Button/index.js +10 -3
  4. package/ButtonLink/index.js +4 -0
  5. package/Card/index.js +13 -34
  6. package/CardList/components/Item/index.js +26 -20
  7. package/CardList/index.js +2 -1
  8. package/CartTotalLine/index.js +1 -1
  9. package/Dialog/components/PipelineErrorDialog/index.js +2 -1
  10. package/DiscountBadge/index.js +1 -1
  11. package/FavoritesButton/FavoritesButton.d.ts +74 -0
  12. package/FavoritesButton/FavoritesButton.d.ts.map +1 -0
  13. package/FavoritesButton/FavoritesButton.js +87 -0
  14. package/FavoritesButton/connector.d.ts +3 -0
  15. package/FavoritesButton/connector.d.ts.map +1 -0
  16. package/FavoritesButton/index.d.ts +3 -0
  17. package/FavoritesButton/index.d.ts.map +1 -0
  18. package/FavoritesButton/index.js +1 -134
  19. package/Glow/index.js +4 -3
  20. package/NoResults/components/Icon/index.js +4 -1
  21. package/NoResults/index.js +1 -1
  22. package/Price/index.js +11 -4
  23. package/PriceStriked/index.js +7 -1
  24. package/RatingStars/index.js +16 -5
  25. package/RippleButton/index.js +5 -1
  26. package/Sheet/index.js +11 -1
  27. package/TaxDisclaimer/index.js +0 -1
  28. package/package.json +5 -5
  29. package/AccordionContainer/spec.js +0 -35
  30. package/ActionButton/spec.js +0 -66
  31. package/AddToCartButton/spec.js +0 -68
  32. package/Availability/spec.js +0 -42
  33. package/Button/spec.js +0 -38
  34. package/ButtonLink/spec.js +0 -29
  35. package/Chip/spec.js +0 -27
  36. package/ContextMenu/spec.js +0 -113
  37. package/Dialog/components/HtmlContentDialog/spec.js +0 -107
  38. package/Dialog/components/PipelineErrorDialog/spec.js +0 -89
  39. package/Dialog/components/TextMessageDialog/spec.js +0 -62
  40. package/Dialog/components/VariantSelectModal/spec.js +0 -55
  41. package/Dialog/spec.js +0 -84
  42. package/DiscountBadge/spec.js +0 -20
  43. package/FavoritesButton/spec.js +0 -131
  44. package/Form/Builder/classes/ActionListener/spec.js +0 -323
  45. package/Form/Builder/spec.js +0 -309
  46. package/Form/InfoField/spec.js +0 -12
  47. package/Form/Password/spec.js +0 -39
  48. package/Form/RadioGroup/spec.js +0 -97
  49. package/Form/Select/spec.js +0 -39
  50. package/Form/SelectContextChoices/spec.js +0 -36
  51. package/Form/TextField/spec.js +0 -124
  52. package/FormElement/spec.js +0 -68
  53. package/Glow/spec.js +0 -14
  54. package/IndicatorCircle/spec.js +0 -26
  55. package/PlaceholderLabel/spec.js +0 -26
  56. package/PlaceholderParagraph/spec.js +0 -26
  57. package/ProgressBar/spec.js +0 -14
  58. package/RadioButton/spec.js +0 -22
  59. package/RatingStars/spec.js +0 -91
  60. package/RippleButton/spec.js +0 -58
  61. package/Sheet/components/Header/components/SearchBar/spec.js +0 -22
  62. package/Sheet/components/Header/spec.js +0 -17
  63. package/Sheet/spec.js +0 -100
  64. package/TaxDisclaimer/spec.js +0 -44
  65. package/TextField/spec.js +0 -146
  66. package/ToggleIcon/spec.js +0 -39
  67. package/tsconfig.build.json +0 -16
  68. package/tsconfig.json +0 -3
@@ -21,6 +21,10 @@ const CLICK_DELAY = 300;
21
21
 
22
22
  /**
23
23
  * The action button component.
24
+ * @deprecated Use `Button` from `@shopgate/engage/components/v2` instead. It defaults to
25
+ * `variant="contained"`, so pass `variant="text"` to match this component's `flat` default. Map
26
+ * `type="secondary"` to `color="primary"`, and `type="primary"` or the default to
27
+ * `color="secondary"`.
24
28
  * @param {Object} props Props.
25
29
  * @returns {JSX.Element}
26
30
  */
@@ -49,7 +49,10 @@ const useStyles = makeStyles()(theme => ({
49
49
  icon: {
50
50
  transition: 'opacity 450ms cubic-bezier(0.4, 0.0, 0.2, 1)',
51
51
  opacity: 1,
52
- position: 'absolute'
52
+ position: 'absolute',
53
+ display: 'flex',
54
+ left: '50%',
55
+ marginLeft: '-0.5em'
53
56
  },
54
57
  spinnerIcon: {
55
58
  left: '50%',
package/Button/index.js CHANGED
@@ -7,9 +7,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
7
7
  /**
8
8
  * @param {string} text Text color.
9
9
  * @param {string|null} background Fill color.
10
+ * @param {Object} theme Theme with button border radius.
10
11
  * @returns {Object} JSS for root button.
11
12
  */
12
- const baseButton = (text, background) => ({
13
+ const baseButton = (text, background, theme) => ({
13
14
  position: 'relative',
14
15
  display: 'inline-block',
15
16
  outline: 0,
@@ -20,7 +21,9 @@ const baseButton = (text, background) => ({
20
21
  ':disabled': {
21
22
  cursor: 'not-allowed'
22
23
  },
23
- ...themeConfig.variables.buttonBase
24
+ ...themeConfig.variables.buttonBase,
25
+ borderRadius: theme.components.button.borderRadius,
26
+ ...theme.typography.button
24
27
  });
25
28
 
26
29
  /**
@@ -30,7 +33,7 @@ const baseButton = (text, background) => ({
30
33
  * @returns {Object} Object with `button` and `content` style maps.
31
34
  */
32
35
  const pairFromColors = (textColor, fillColor, theme) => ({
33
- button: baseButton(textColor, fillColor),
36
+ button: baseButton(textColor, fillColor, theme),
34
37
  content: {
35
38
  padding: theme.spacing(0, 2, 0),
36
39
  color: textColor
@@ -71,6 +74,10 @@ const useStyles = makeStyles()((theme, {
71
74
 
72
75
  /**
73
76
  * The basic button component.
77
+ * @deprecated Use `Button` from `@shopgate/engage/components/v2` instead. Map `flat` to
78
+ * `variant="text"` and omit it for `variant="contained"`. The colors are named differently:
79
+ * `type="secondary"` becomes `color="primary"`, while `type="primary"` and the default become
80
+ * `color="secondary"`. `type="plain"` is unstyled — use `ButtonBase` for it.
74
81
  * @param {Object} props Props.
75
82
  * @returns {JSX.Element}
76
83
  */
@@ -44,6 +44,10 @@ let ButtonLink = /*#__PURE__*/function (_Component) {
44
44
  };
45
45
  return ButtonLink;
46
46
  }(Component);
47
+ /**
48
+ * @deprecated Use `Button` from `@shopgate/engage/components/v2` with `variant="link"` and
49
+ * `color="primary"` instead. It takes the same `href` and routes through the app router itself.
50
+ */
47
51
  ButtonLink.defaultProps = {
48
52
  disabled: false,
49
53
  className: '',
package/Card/index.js CHANGED
@@ -1,40 +1,19 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { makeStyles } from '@shopgate/engage/styles';
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- const useStyles = makeStyles()(theme => ({
6
- root: {
7
- boxShadow: '0 4px 8px rgba(0,0,0,0.16)',
8
- margin: '5px 5px 10px',
9
- borderRadius: 10,
10
- background: theme.palette.background.surface,
11
- overflow: 'hidden',
12
- position: 'relative'
13
- }
14
- }));
1
+ import React, { useEffect } from 'react';
2
+ import { logger } from '@shopgate/engage/core/helpers';
3
+ import { Card } from '@shopgate/engage/components';
15
4
 
16
5
  /**
17
- * Renders the card component.
18
- * @param {Object} props The component properties.
6
+ * @deprecated Use `import { Card } from '@shopgate/engage/components'` instead.
7
+ * @param {Object} props The component props.
19
8
  * @returns {JSX}
20
9
  */
21
- const Card = ({
22
- className,
23
- children,
24
- id
25
- }) => {
26
- const {
27
- classes,
28
- cx
29
- } = useStyles();
30
- return /*#__PURE__*/_jsx("div", {
31
- className: cx('ui-shared__card', classes.root, className),
32
- id: id,
33
- children: children
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const DeprecatedCard = props => {
12
+ useEffect(() => {
13
+ logger.warn('===== Card deprecated =====\n' + 'The Card component ' + '(@shopgate/pwa-ui-shared/Card) is deprecated.\n' + 'Please use: import { Card } from \'@shopgate/engage/components\'.\n' + '===================================');
14
+ }, []);
15
+ return /*#__PURE__*/_jsx(Card, {
16
+ ...props
34
17
  });
35
18
  };
36
- Card.defaultProps = {
37
- className: '',
38
- id: null
39
- };
40
- export default Card;
19
+ export default DeprecatedCard;
@@ -1,42 +1,48 @@
1
- import React, { Children } from 'react';
1
+ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import ListItem from '@shopgate/pwa-common/components/List/components/Item';
4
3
  import { makeStyles } from '@shopgate/engage/styles';
5
4
  import { jsx as _jsx } from "react/jsx-runtime";
6
- const useStyles = makeStyles()(theme => ({
7
- root: {
8
- background: theme.palette.background.surface,
9
- marginBottom: theme.spacing(0.5),
5
+ const useStyles = makeStyles()({
6
+ item: {
7
+ display: 'block',
10
8
  position: 'relative'
9
+ },
10
+ unselected: {
11
+ zIndex: 1
12
+ },
13
+ selected: {
14
+ zIndex: 2
11
15
  }
12
- }));
16
+ });
13
17
 
14
18
  /**
15
- * The Card List Item component implemented as class so that ref prop is available.
16
- * @param {Object} props The component props.
17
- * @return {JSX}
19
+ * The ListItem component.
20
+ * @returns {JSX}
18
21
  */
19
- const Item = ({
22
+ const ListItem = ({
20
23
  children,
21
24
  className,
22
- isSelected
25
+ isSelected,
26
+ role
23
27
  }) => {
24
28
  const {
25
29
  classes,
26
30
  cx
27
31
  } = useStyles();
28
- if (!Children.count(children)) {
32
+ if (!React.Children.count(children)) {
29
33
  return null;
30
34
  }
31
- return /*#__PURE__*/_jsx(ListItem, {
32
- className: cx(classes.root, className),
33
- isSelected: isSelected,
35
+ return /*#__PURE__*/_jsx("li", {
36
+ className: cx(classes.item, className, 'common__list__list-item', isSelected ? classes.selected : classes.unselected),
37
+ "data-test-id": "listItem",
38
+ role: role,
34
39
  children: children
35
40
  });
36
41
  };
37
- Item.defaultProps = {
38
- children: null,
42
+ ListItem.defaultProps = {
39
43
  className: null,
40
- isSelected: false
44
+ children: null,
45
+ isSelected: false,
46
+ role: null
41
47
  };
42
- export default Item;
48
+ export default ListItem;
package/CardList/index.js CHANGED
@@ -2,6 +2,7 @@ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
2
  import React, { Component, Children, isValidElement } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import List from '@shopgate/pwa-common/components/List';
5
+ import { cx } from '@shopgate/engage/styles';
5
6
  import Item from "./components/Item";
6
7
 
7
8
  /**
@@ -27,7 +28,7 @@ let CardList = /*#__PURE__*/function (_Component) {
27
28
  return null;
28
29
  }
29
30
  return /*#__PURE__*/_jsx(List, {
30
- className: `ui-shared__card-list ${className}`,
31
+ className: cx('ui-shared__card-list', className),
31
32
  children: Children.map(children, child => {
32
33
  if (! /*#__PURE__*/isValidElement(child)) {
33
34
  return null;
@@ -24,7 +24,7 @@ const useStyles = makeStyles()(theme => ({
24
24
  },
25
25
  grandTotal: {
26
26
  color: theme.palette.text.primary,
27
- fontSize: `${theme.typography.body1.fontSize} !important`
27
+ fontSize: theme.typography.body1.fontSize
28
28
  }
29
29
  }));
30
30
 
@@ -33,7 +33,8 @@ const PipelineErrorDialog = ({
33
33
  params,
34
34
  message
35
35
  }) => {
36
- const [devMode, setDevMode] = useState(false);
36
+ // May be opened directly in developer detail mode (e.g. via long-pressing an error toast).
37
+ const [devMode, setDevMode] = useState(!!params.openWithDetails);
37
38
  const tapTimeoutRef = useRef(null);
38
39
  const tapCounterRef = useRef(0);
39
40
  const handleTapTimeout = useCallback(() => {
@@ -7,7 +7,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
7
7
  const useStyles = makeStyles()(theme => {
8
8
  const badgeBase = {
9
9
  background: theme.components.discountBadge.background,
10
- borderRadius: 2,
10
+ borderRadius: theme.shape.borderRadius,
11
11
  color: theme.contrastColor(theme.components.discountBadge.background),
12
12
  padding: 5,
13
13
  width: '100%',
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ import type { IconButtonSize } from '@shopgate/engage/components/v2';
3
+ export interface FavoritesButtonOwnProps {
4
+ /**
5
+ * Whether the product is on a favorites list.
6
+ * @default false
7
+ */
8
+ active?: boolean;
9
+ /**
10
+ * Hides the button from assistive technology, for a surface that exposes the action elsewhere.
11
+ */
12
+ 'aria-hidden'?: boolean;
13
+ /**
14
+ * Custom class name for the button.
15
+ */
16
+ className?: string;
17
+ /**
18
+ * If `true`, the button reacts to the first click only.
19
+ * @default false
20
+ */
21
+ once?: boolean;
22
+ /**
23
+ * The product the button toggles.
24
+ */
25
+ productId?: string | null;
26
+ /**
27
+ * Milliseconds to wait before a product is removed again.
28
+ * @default 0
29
+ */
30
+ removeThrottle?: number;
31
+ /**
32
+ * Whether removing the product also removes the favorites of its variants.
33
+ * @default false
34
+ */
35
+ removeWithRelatives?: boolean;
36
+ /**
37
+ * The size of the button.
38
+ * @default 'small'
39
+ */
40
+ size?: IconButtonSize;
41
+ }
42
+ /**
43
+ * The props the connector provides. Optional, so that the defaults apply to a button that is
44
+ * rendered without it.
45
+ */
46
+ interface FavoritesButtonConnectedProps {
47
+ addFavorites?: (productId: string) => void;
48
+ removeFavorites?: (productId: string, removeWithRelatives?: boolean) => void;
49
+ loadWishlistOnAppStartEnabled?: boolean;
50
+ wishlistItemQuantityEnabled?: boolean;
51
+ }
52
+ export type FavoritesButtonProps = FavoritesButtonOwnProps & FavoritesButtonConnectedProps;
53
+ /**
54
+ * The favorites button toggles whether a product is on a favorites list, and shows which of the
55
+ * two states it is in. It renders nothing at all in a shop without the favorites feature.
56
+ */
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
+ className?: string | undefined;
59
+ size?: IconButtonSize | undefined;
60
+ active?: boolean | undefined;
61
+ addFavorites?: ((productId: string) => void) | undefined;
62
+ 'aria-hidden'?: boolean | undefined;
63
+ loadWishlistOnAppStartEnabled?: boolean | undefined;
64
+ once?: boolean | undefined;
65
+ productId?: string | null | undefined;
66
+ removeFavorites?: ((productId: string, removeWithRelatives?: boolean) => void) | undefined;
67
+ removeThrottle?: number | undefined;
68
+ removeWithRelatives?: boolean | undefined;
69
+ wishlistItemQuantityEnabled?: boolean | undefined;
70
+ context?: import("react-redux/es/components/Context").ReactReduxContextInstance | undefined;
71
+ store?: import("redux").Store | undefined;
72
+ }>;
73
+ export default FavoritesButtonComponent;
74
+ //# sourceMappingURL=FavoritesButton.d.ts.map
@@ -0,0 +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,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED;;;GAGG;AACH,UAAU,6BAA6B;IACrC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7E,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,GAAG,6BAA6B,CAAC;AAE3F;;;GAGG;AACH,QAAA,MAAM,wBAAwB,gRAnI3B,oBAAoB;gBAuFT,MAAM;WAwBX,cAAc;aAhCZ,OAAO;oBAwCD,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI;oBApC1B,OAAO;oCAsCS,OAAO;WA7BhC,OAAO;gBAIF,MAAM,GAAG,IAAI;uBAwBP,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,OAAO,KAAK,IAAI;qBAnB3D,MAAM;0BAKD,OAAO;kCAgBC,OAAO;;;EASwB,CAAC;AAEhE,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,87 @@
1
+ import React, { useCallback, useRef, useMemo, memo } from 'react';
2
+ import classNames from 'classnames';
3
+ import appConfig from '@shopgate/pwa-common/helpers/config';
4
+ import { i18n } from '@shopgate/engage/core/helpers';
5
+ import { IconButton } from '@shopgate/engage/components/v2';
6
+ import HeartIcon from "../icons/HeartIcon";
7
+ import HeartOutlineIcon from "../icons/HeartOutlineIcon";
8
+ import HeartPlusOutlineIcon from "../icons/HeartPlusOutlineIcon";
9
+ import HeartPlus from "../icons/HeartPlusIcon";
10
+ import connect from "./connector";
11
+
12
+ /**
13
+ * Renders the button. Exported through `FavoritesButtonComponent`, which carries the public docs.
14
+ */
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ const FavoritesButton = ({
17
+ active = false,
18
+ addFavorites,
19
+ 'aria-hidden': ariaHidden,
20
+ className = '',
21
+ loadWishlistOnAppStartEnabled = true,
22
+ once = false,
23
+ productId = null,
24
+ removeFavorites,
25
+ removeThrottle = 0,
26
+ removeWithRelatives = false,
27
+ size = 'small',
28
+ wishlistItemQuantityEnabled = false
29
+ }) => {
30
+ const clickedOnceRef = useRef(false);
31
+ const handleClick = useCallback(event => {
32
+ event.preventDefault();
33
+ event.stopPropagation();
34
+ if (once && clickedOnceRef.current) {
35
+ return;
36
+ }
37
+ clickedOnceRef.current = true;
38
+ if (!productId) {
39
+ return;
40
+ }
41
+ if (!active || wishlistItemQuantityEnabled) {
42
+ addFavorites?.(productId);
43
+ } else {
44
+ setTimeout(() => {
45
+ removeFavorites?.(productId, removeWithRelatives);
46
+ }, removeThrottle);
47
+ }
48
+ }, [once, productId, active, wishlistItemQuantityEnabled, addFavorites, removeFavorites, removeWithRelatives, removeThrottle]);
49
+ const icon = useMemo(() => {
50
+ if (!loadWishlistOnAppStartEnabled || wishlistItemQuantityEnabled && !active) {
51
+ return /*#__PURE__*/_jsx(HeartPlusOutlineIcon, {});
52
+ }
53
+ if (wishlistItemQuantityEnabled && active) {
54
+ return /*#__PURE__*/_jsx(HeartPlus, {});
55
+ }
56
+ if (active) {
57
+ return /*#__PURE__*/_jsx(HeartIcon, {});
58
+ }
59
+ return /*#__PURE__*/_jsx(HeartOutlineIcon, {});
60
+ }, [loadWishlistOnAppStartEnabled, wishlistItemQuantityEnabled, active]);
61
+ if (!appConfig.hasFavorites) {
62
+ return null;
63
+ }
64
+ return /*#__PURE__*/_jsx(IconButton, {
65
+ "aria-label": i18n.text(active ? 'favorites.remove' : 'favorites.add'),
66
+ "aria-hidden": ariaHidden,
67
+ variant: "surface",
68
+ color: "secondary",
69
+ size: size,
70
+ className: classNames('ui-shared__favorites-button', className),
71
+ onClick: handleClick,
72
+ testId: "favoriteButton",
73
+ children: icon
74
+ });
75
+ };
76
+
77
+ /**
78
+ * The props the connector provides. Optional, so that the defaults apply to a button that is
79
+ * rendered without it.
80
+ */
81
+
82
+ /**
83
+ * The favorites button toggles whether a product is on a favorites list, and shows which of the
84
+ * two states it is in. It renders nothing at all in a shop without the favorites feature.
85
+ */
86
+ const FavoritesButtonComponent = connect(/*#__PURE__*/memo(FavoritesButton));
87
+ export default FavoritesButtonComponent;
@@ -0,0 +1,3 @@
1
+ declare const _default: import("react-redux").InferableComponentEnhancerWithProps<Function & Object, {}>;
2
+ export default _default;
3
+ //# sourceMappingURL=connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../FavoritesButton/connector.js"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { default } from './FavoritesButton';
2
+ export type { FavoritesButtonOwnProps, FavoritesButtonProps } from './FavoritesButton';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../FavoritesButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,134 +1 @@
1
- import React, { useCallback, useRef, useMemo, memo } from 'react';
2
- import PropTypes from 'prop-types';
3
- import appConfig from '@shopgate/pwa-common/helpers/config';
4
- import { i18n } from '@shopgate/engage/core/helpers';
5
- import { makeStyles } from '@shopgate/engage/styles';
6
- import HeartIcon from "../icons/HeartIcon";
7
- import HeartOutlineIcon from "../icons/HeartOutlineIcon";
8
- import HeartPlusOutlineIcon from "../icons/HeartPlusOutlineIcon";
9
- import HeartPlus from "../icons/HeartPlusIcon";
10
- import Ripple from "../Ripple";
11
- import connect from "./connector";
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- const useStyles = makeStyles()(theme => {
14
- const buttonProto = {
15
- display: 'flex',
16
- alignItems: 'center',
17
- justifyContent: 'center',
18
- position: 'relative',
19
- background: theme.palette.common.white,
20
- borderRadius: '50%',
21
- padding: 0,
22
- fontSize: theme.components.icon.small,
23
- color: theme.palette.secondary.main,
24
- outline: 0
25
- };
26
- return {
27
- buttonFlat: {
28
- ...buttonProto
29
- },
30
- button: {
31
- ...buttonProto,
32
- boxShadow: '0 8px 13px rgba(0, 0, 0, 0.25)'
33
- },
34
- ripple: {
35
- padding: 6
36
- }
37
- };
38
- });
39
-
40
- /**
41
- * The favorites button component.
42
- * @param {Object} props Props.
43
- * @returns {JSX.Element|null}
44
- */
45
- const FavoritesButton = ({
46
- active,
47
- addFavorites,
48
- 'aria-hidden': ariaHidden,
49
- className,
50
- loadWishlistOnAppStartEnabled,
51
- noShadow,
52
- once,
53
- onRippleComplete,
54
- productId,
55
- removeFavorites,
56
- removeThrottle,
57
- removeWithRelatives,
58
- rippleClassName,
59
- wishlistItemQuantityEnabled
60
- }) => {
61
- const {
62
- classes,
63
- cx
64
- } = useStyles();
65
- const clickedOnceRef = useRef(false);
66
- const handleRippleComplete = useCallback(() => {
67
- onRippleComplete(active);
68
- }, [onRippleComplete, active]);
69
- const handleClick = useCallback(event => {
70
- event.preventDefault();
71
- event.stopPropagation();
72
- if (once && clickedOnceRef.current) {
73
- return;
74
- }
75
- clickedOnceRef.current = true;
76
- if (!productId) {
77
- return;
78
- }
79
- if (!active || wishlistItemQuantityEnabled) {
80
- addFavorites(productId);
81
- } else {
82
- setTimeout(() => {
83
- removeFavorites(productId, removeWithRelatives);
84
- }, removeThrottle);
85
- }
86
- }, [once, productId, active, wishlistItemQuantityEnabled, addFavorites, removeFavorites, removeWithRelatives, removeThrottle]);
87
- const icon = useMemo(() => {
88
- if (!loadWishlistOnAppStartEnabled || wishlistItemQuantityEnabled && !active) {
89
- return /*#__PURE__*/_jsx(HeartPlusOutlineIcon, {});
90
- }
91
- if (wishlistItemQuantityEnabled && active) {
92
- return /*#__PURE__*/_jsx(HeartPlus, {});
93
- }
94
- if (active) {
95
- return /*#__PURE__*/_jsx(HeartIcon, {});
96
- }
97
- return /*#__PURE__*/_jsx(HeartOutlineIcon, {});
98
- }, [loadWishlistOnAppStartEnabled, wishlistItemQuantityEnabled, active]);
99
- if (!appConfig.hasFavorites) {
100
- return null;
101
- }
102
- const buttonClass = noShadow ? classes.buttonFlat : classes.button;
103
- const ariaLabel = i18n.text(active ? 'favorites.remove' : 'favorites.add');
104
- return /*#__PURE__*/_jsx("button", {
105
- "aria-label": ariaLabel,
106
- "aria-hidden": ariaHidden,
107
- className: cx('ui-shared__favorites-button', buttonClass, className),
108
- onClick: handleClick,
109
- "data-test-id": "favoriteButton",
110
- type: "button",
111
- children: /*#__PURE__*/_jsx(Ripple, {
112
- className: cx(classes.ripple, rippleClassName),
113
- onComplete: handleRippleComplete,
114
- children: icon
115
- })
116
- });
117
- };
118
- FavoritesButton.defaultProps = {
119
- active: false,
120
- addFavorites: () => {},
121
- 'aria-hidden': null,
122
- className: '',
123
- noShadow: false,
124
- once: false,
125
- onRippleComplete: () => {},
126
- productId: null,
127
- removeFavorites: () => {},
128
- removeThrottle: 0,
129
- removeWithRelatives: false,
130
- rippleClassName: '',
131
- wishlistItemQuantityEnabled: false,
132
- loadWishlistOnAppStartEnabled: true
133
- };
134
- export default connect(/*#__PURE__*/memo(FavoritesButton));
1
+ export { default } from "./FavoritesButton";
package/Glow/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, { useState, useRef, useEffect, useCallback } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { withForwardedRef } from '@shopgate/engage/core';
4
- import { makeStyles } from '@shopgate/engage/styles';
4
+ import { makeStyles, useTheme } from '@shopgate/engage/styles';
5
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  const useStyles = makeStyles()({
7
7
  container: {
@@ -41,6 +41,7 @@ const Glow = ({
41
41
  classes,
42
42
  cx
43
43
  } = useStyles();
44
+ const theme = useTheme();
44
45
  const [hover, setHover] = useState(false);
45
46
  const timeoutRef = useRef(null);
46
47
  useEffect(() => () => {
@@ -58,7 +59,7 @@ const Glow = ({
58
59
  const innerInlineStyles = hover ? {
59
60
  ...propStyles.glow,
60
61
  ...propStyles.hover,
61
- background: color
62
+ background: color || theme?.palette?.action?.pressed
62
63
  } : {
63
64
  ...propStyles.glow
64
65
  };
@@ -80,7 +81,7 @@ const Glow = ({
80
81
  jsx-a11y/click-events-have-key-events */
81
82
  };
82
83
  Glow.defaultProps = {
83
- color: 'var(--sg-palette-grey-light)',
84
+ color: null,
84
85
  className: null,
85
86
  forwardedRef: null,
86
87
  disabled: false,
@@ -8,7 +8,10 @@ const useStyles = makeStyles()(theme => ({
8
8
  fill: 'currentColor'
9
9
  },
10
10
  background: {
11
- fill: theme.palette.background.surface
11
+ fill: theme.palette.common.white,
12
+ ...theme.applyStyles('dark', {
13
+ fill: theme.palette.grey[200]
14
+ })
12
15
  },
13
16
  circle: {
14
17
  fill: 'currentColor',
@@ -48,7 +48,7 @@ const NoResults = props => {
48
48
  } = useStyles();
49
49
  const imageSRC = useMemo(() => svgToDataUrl(noResultsImage), []);
50
50
  return /*#__PURE__*/_jsxs("div", {
51
- className: cx(classes.wrapper, props.className, ' ui-shared__no-results'),
51
+ className: cx(classes.wrapper, props.className, 'ui-shared__no-results'),
52
52
  "data-test-id": "noResults",
53
53
  children: [/*#__PURE__*/_jsx("div", {
54
54
  className: cx(classes.icon, 'no-results__image'),
package/Price/index.js CHANGED
@@ -7,11 +7,18 @@ import { makeStyles } from '@shopgate/engage/styles';
7
7
  import showTaxDisclaimer from '@shopgate/pwa-common-commerce/market/helpers/showTaxDisclaimer';
8
8
  import { useWidgetSettings } from '@shopgate/engage/core/hooks/useWidgetSettings';
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
- const useStyles = makeStyles()({
10
+ const useStyles = makeStyles()(theme => ({
11
11
  container: {
12
12
  display: 'flex',
13
13
  position: 'relative',
14
- whiteSpace: 'nowrap'
14
+ whiteSpace: 'nowrap',
15
+ color: theme.components.price.defaultColor,
16
+ '--font-size': theme.typography.price.fontSize,
17
+ '--font-family': theme.typography.price.fontFamily,
18
+ '--font-weight': theme.typography.price.fontWeight,
19
+ fontSize: 'var(--font-size)',
20
+ fontFamily: 'var(--font-family)',
21
+ fontWeight: 'var(--font-weight)'
15
22
  },
16
23
  disclaimer: {
17
24
  color: 'initial',
@@ -20,9 +27,9 @@ const useStyles = makeStyles()({
20
27
  top: 0
21
28
  },
22
29
  discounted: {
23
- color: 'var(--color-primary)'
30
+ color: theme.components.price.saleColor
24
31
  }
25
- });
32
+ }));
26
33
 
27
34
  /**
28
35
  * The Price component