@shopgate/pwa-ui-material 7.30.3 → 7.31.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/Accordion/components/AccordionContent/index.js +23 -10
  2. package/Accordion/index.js +62 -12
  3. package/AppBar/components/Field/index.js +37 -39
  4. package/AppBar/components/Icon/index.js +47 -39
  5. package/AppBar/components/Title/index.js +44 -38
  6. package/AppBar/index.js +26 -5
  7. package/BaseDialog/components/Buttons/index.js +29 -18
  8. package/BaseDialog/components/Content/index.js +14 -3
  9. package/BaseDialog/components/Title/index.js +17 -5
  10. package/BaseDialog/index.js +71 -26
  11. package/FloatingActionButton/index.js +40 -12
  12. package/NavDrawer/components/Divider/index.js +24 -6
  13. package/NavDrawer/components/Item/index.js +91 -65
  14. package/NavDrawer/components/Title/index.js +16 -4
  15. package/NavDrawer/index.js +129 -120
  16. package/NavDrawer/spec.js +112 -14
  17. package/SnackBar/index.js +176 -166
  18. package/icons/ShareIcon.d.ts +7 -0
  19. package/icons/ShareIcon.d.ts.map +1 -0
  20. package/icons/ShareIcon.js +0 -2
  21. package/package.json +6 -4
  22. package/tsconfig.build.json +16 -0
  23. package/tsconfig.json +3 -0
  24. package/Accordion/components/AccordionContent/style.js +0 -9
  25. package/Accordion/style.js +0 -47
  26. package/AppBar/components/Field/style.js +0 -14
  27. package/AppBar/components/Icon/style.js +0 -14
  28. package/AppBar/components/Title/style.js +0 -11
  29. package/AppBar/style.js +0 -21
  30. package/BaseDialog/style.js +0 -64
  31. package/FloatingActionButton/style.js +0 -33
  32. package/NavDrawer/components/Divider/style.js +0 -12
  33. package/NavDrawer/components/Item/style.js +0 -49
  34. package/NavDrawer/components/Title/style.js +0 -8
  35. package/NavDrawer/style.js +0 -26
  36. package/SnackBar/style.js +0 -64
@@ -1,10 +1,50 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { FocusTrap } from '@shopgate/engage/a11y/components';
4
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
5
+ import { makeStyles, responsiveMediaQuery } from '@shopgate/engage/styles';
4
6
  import Title from "./components/Title";
5
7
  import Content from "./components/Content";
6
8
  import Buttons from "./components/Buttons";
7
- import styles from "./style";
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ const outerGap = 40;
11
+ const useStyles = makeStyles()(theme => ({
12
+ container: {
13
+ position: 'relative',
14
+ display: 'flex',
15
+ flexDirection: 'column',
16
+ width: `calc(100vw - ${outerGap * 2}px)`,
17
+ maxHeight: `calc(100vh - ${outerGap * 2}px)`,
18
+ borderRadius: 2,
19
+ boxShadow: themeConfig.shadows.dialog,
20
+ background: themeConfig.colors.light,
21
+ [responsiveMediaQuery('>xs', {
22
+ webOnly: true
23
+ })]: {
24
+ width: `calc(80vh - ${outerGap * 2}px)`,
25
+ maxHeight: `calc(80vh - ${outerGap * 2}px)`
26
+ },
27
+ [responsiveMediaQuery('>md', {
28
+ webOnly: true
29
+ })]: {
30
+ width: `calc(var(--page-content-width) * 0.5 - ${outerGap * 2}px)`,
31
+ maxHeight: `calc(var(--page-content-width) * 0.5 - ${outerGap * 2}px)`
32
+ }
33
+ },
34
+ content: {
35
+ padding: theme.spacing(3),
36
+ overflowY: 'auto'
37
+ },
38
+ actions: {
39
+ alignSelf: 'flex-end',
40
+ padding: theme.spacing(1)
41
+ },
42
+ innerActions: {
43
+ display: 'flex',
44
+ flexWrap: 'wrap',
45
+ justifyContent: 'flex-end'
46
+ }
47
+ }));
8
48
 
9
49
  /**
10
50
  * This component renders a basic dialog in Google Material Design.
@@ -15,36 +55,41 @@ import styles from "./style";
15
55
  * @param {string | ReactNode} props.title The title of the dialog.
16
56
  * @return {JSX.Element} The rendered dialog.
17
57
  */
18
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
58
  const BasicDialog = ({
20
59
  children,
21
60
  actions,
22
61
  title
23
- }) => /*#__PURE__*/_jsx(FocusTrap, {
24
- children: /*#__PURE__*/_jsxs("div", {
25
- className: `${styles.container} ui-material__base-dialog`,
26
- "data-test-id": "basicDialog",
27
- role: "alertdialog",
28
- "aria-modal": true,
29
- "aria-labelledby": "basicDialogTitle basicDialogDesc",
30
- children: [/*#__PURE__*/_jsxs("div", {
31
- className: styles.content,
32
- children: [/*#__PURE__*/_jsx(Title, {
33
- title: title
34
- }), /*#__PURE__*/_jsx(Content, {
35
- content: children
36
- })]
37
- }), /*#__PURE__*/_jsx("div", {
38
- className: styles.actions,
39
- children: /*#__PURE__*/_jsx("div", {
40
- className: styles.innerActions,
41
- children: /*#__PURE__*/_jsx(Buttons, {
42
- actions: actions
62
+ }) => {
63
+ const {
64
+ classes,
65
+ cx
66
+ } = useStyles();
67
+ return /*#__PURE__*/_jsx(FocusTrap, {
68
+ children: /*#__PURE__*/_jsxs("div", {
69
+ className: cx(classes.container, 'ui-material__base-dialog'),
70
+ "data-test-id": "basicDialog",
71
+ role: "alertdialog",
72
+ "aria-modal": true,
73
+ "aria-labelledby": "basicDialogTitle basicDialogDesc",
74
+ children: [/*#__PURE__*/_jsxs("div", {
75
+ className: classes.content,
76
+ children: [/*#__PURE__*/_jsx(Title, {
77
+ title: title
78
+ }), /*#__PURE__*/_jsx(Content, {
79
+ content: children
80
+ })]
81
+ }), /*#__PURE__*/_jsx("div", {
82
+ className: classes.actions,
83
+ children: /*#__PURE__*/_jsx("div", {
84
+ className: classes.innerActions,
85
+ children: /*#__PURE__*/_jsx(Buttons, {
86
+ actions: actions
87
+ })
43
88
  })
44
- })
45
- })]
46
- })
47
- });
89
+ })]
90
+ })
91
+ });
92
+ };
48
93
  BasicDialog.defaultProps = {
49
94
  children: null,
50
95
  actions: [],
@@ -1,17 +1,45 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import colors from "../colors";
5
- import styles from "./style";
3
+ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
4
+ import { makeStyles } from '@shopgate/engage/styles';
6
5
  import { jsx as _jsx } from "react/jsx-runtime";
7
6
  const SIZE_BIG = 'big';
8
7
  const SIZE_SMALL = 'small';
8
+ const useStyles = makeStyles()({
9
+ button: {
10
+ borderRadius: '50%',
11
+ outline: 0,
12
+ overflow: 'hidden',
13
+ padding: 0,
14
+ position: 'relative',
15
+ zIndex: 1,
16
+ ':disabled': {
17
+ cursor: 'not-allowed'
18
+ }
19
+ },
20
+ buttonSmall: {
21
+ height: 40,
22
+ width: 40
23
+ },
24
+ buttonLarge: {
25
+ height: 56,
26
+ width: 56
27
+ },
28
+ buttonShadow: {
29
+ boxShadow: themeConfig.shadows.buttons.elevated
30
+ }
31
+ });
32
+
9
33
  /**
10
34
  * The FloatingActionButton component.
11
35
  * @param {Object} props The component props.
12
36
  * @return {JSX}
13
37
  */
14
38
  const FloatingActionButton = props => {
39
+ const {
40
+ classes,
41
+ cx
42
+ } = useStyles();
15
43
  const {
16
44
  background,
17
45
  children,
@@ -21,17 +49,17 @@ const FloatingActionButton = props => {
21
49
  raised,
22
50
  ref,
23
51
  size,
24
- type
52
+ type,
53
+ testId
25
54
  } = props;
26
- const classes = classNames('floating-action-button', 'ui-material__floating-action-button', styles.button, {
55
+ const rootClass = cx('floating-action-button', 'ui-material__floating-action-button', classes.button, {
27
56
  [className]: className,
28
- [styles.buttonSmall]: size === SIZE_SMALL,
29
- [styles.buttonSmall]: size === SIZE_SMALL,
30
- [styles.buttonLarge]: size === SIZE_BIG,
31
- [styles.buttonShadow]: raised
57
+ [classes.buttonSmall]: size === SIZE_SMALL,
58
+ [classes.buttonLarge]: size === SIZE_BIG,
59
+ [classes.buttonShadow]: raised
32
60
  });
33
61
  return /*#__PURE__*/_jsx("button", {
34
- className: classes,
62
+ className: rootClass,
35
63
  disabled: disabled,
36
64
  onClick: onClick,
37
65
  ref: ref,
@@ -41,12 +69,12 @@ const FloatingActionButton = props => {
41
69
  // eslint-disable-next-line react/button-has-type
42
70
  ,
43
71
  type: type,
44
- "data-test-id": props.testId,
72
+ "data-test-id": testId,
45
73
  children: children
46
74
  });
47
75
  };
48
76
  FloatingActionButton.defaultProps = {
49
- background: `var(--color-primary, ${colors.primary})`,
77
+ background: 'var(--color-primary)',
50
78
  className: null,
51
79
  disabled: false,
52
80
  onClick: () => {},
@@ -1,12 +1,30 @@
1
1
  import React from 'react';
2
- import styles from "./style";
2
+ import { themeColors } from '@shopgate/pwa-common/helpers/config';
3
+ import { makeStyles } from '@shopgate/engage/styles';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const useStyles = makeStyles()({
6
+ root: {
7
+ // prevent two consecutive dividers
8
+ '& + hr': {
9
+ display: 'none'
10
+ },
11
+ background: themeColors.darkGray,
12
+ border: 0,
13
+ height: 1,
14
+ margin: '16px 0'
15
+ }
16
+ });
3
17
 
4
18
  /**
5
19
  * @returns {JSX}
6
20
  */
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- const NavDrawerDivider = () => /*#__PURE__*/_jsx("hr", {
9
- "aria-hidden": true,
10
- className: styles
11
- });
21
+ const NavDrawerDivider = () => {
22
+ const {
23
+ classes
24
+ } = useStyles();
25
+ return /*#__PURE__*/_jsx("hr", {
26
+ "aria-hidden": true,
27
+ className: classes.root
28
+ });
29
+ };
12
30
  export default NavDrawerDivider;
@@ -1,78 +1,104 @@
1
- import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
- import React, { Component } from 'react';
1
+ import React, { memo } from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import { UIEvents } from '@shopgate/pwa-core';
5
4
  import { withForwardedRef } from '@shopgate/engage/core';
6
5
  import { I18n } from '@shopgate/engage/components';
7
- import styles from "./style";
6
+ import { themeColors } from '@shopgate/pwa-common/helpers/config';
7
+ import { makeStyles } from '@shopgate/engage/styles';
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ const useStyles = makeStyles()({
10
+ srOnly: {
11
+ clip: 'rect(1px, 1px, 1px, 1px)',
12
+ height: '1px',
13
+ margin: 0,
14
+ overflow: 'hidden',
15
+ padding: 0,
16
+ position: 'absolute',
17
+ whiteSpace: 'nowrap',
18
+ width: '1px',
19
+ zIndex: -1000,
20
+ '&:first-of-type': {
21
+ marginTop: 'calc(16px + var(--safe-area-inset-top))'
22
+ }
23
+ },
24
+ button: {
25
+ alignItems: 'flex-start',
26
+ color: 'inherit',
27
+ display: 'flex',
28
+ fontWeight: 500,
29
+ outline: 0,
30
+ padding: '16px 8px 16px 0',
31
+ position: 'relative',
32
+ width: '100%',
33
+ '&:first-of-type': {
34
+ paddingTop: 'calc(16px + var(--safe-area-inset-top))'
35
+ }
36
+ },
37
+ label: {
38
+ marginTop: 2,
39
+ textAlign: 'left'
40
+ },
41
+ iconWrapper: {
42
+ width: 56,
43
+ flexShrink: 0
44
+ },
45
+ icon: {
46
+ boxSizing: 'content-box',
47
+ color: themeColors.gray,
48
+ padding: '0 32px 0 16px'
49
+ }
50
+ });
8
51
 
9
52
  /**
10
53
  * The NavDrawerItem component.
54
+ * @param {Object} props The component props.
55
+ * @returns {JSX}
11
56
  */
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- let NavDrawerItem = /*#__PURE__*/function (_Component) {
14
- function NavDrawerItem(...args) {
15
- var _this;
16
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
17
- /**
18
- * Handles an Item click by executing it's href.
19
- */
20
- _this.handleClick = () => {
21
- UIEvents.emit('navdrawer_close');
22
- setTimeout(_this.props.onClick, 300);
23
- };
24
- return _this;
25
- }
26
- _inheritsLoose(NavDrawerItem, _Component);
27
- var _proto = NavDrawerItem.prototype;
28
- /**
29
- * Only re-render when the label prop changes.
30
- * @param {Object} nextProps The next component props.
31
- * @returns {boolean}
32
- */
33
- _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
34
- return this.props.label !== nextProps.label || this.props['aria-label'] !== nextProps['aria-label'];
35
- };
57
+ const NavDrawerItem = ({
58
+ 'aria-hidden': ariaHidden,
59
+ 'aria-label': ariaLabel,
60
+ badge: Badge,
61
+ forwardedRef,
62
+ icon: Icon,
63
+ label,
64
+ srOnly,
65
+ style,
66
+ testId,
67
+ onClick
68
+ }) => {
69
+ const {
70
+ classes
71
+ } = useStyles();
72
+
36
73
  /**
37
- * Renders the component.
38
- * @returns {JSX}
74
+ * Handles the click event for the NavDrawerItem component.
39
75
  */
40
- _proto.render = function render() {
41
- const {
42
- 'aria-hidden': ariaHidden,
43
- 'aria-label': ariaLabel,
44
- badge: Badge,
45
- forwardedRef,
46
- icon: Icon,
47
- label,
48
- srOnly,
49
- style,
50
- testId
51
- } = this.props;
52
- return /*#__PURE__*/_jsxs("button", {
53
- ref: forwardedRef,
54
- className: srOnly ? styles.srOnly : styles.button,
55
- "data-test-id": testId,
56
- onClick: this.handleClick,
57
- style: style,
58
- type: "button",
59
- "aria-hidden": ariaHidden,
60
- "aria-label": ariaLabel,
61
- tabIndex: "0",
62
- children: [/*#__PURE__*/_jsx("div", {
63
- className: styles.iconWrapper,
64
- children: Icon && /*#__PURE__*/_jsx(Icon, {
65
- className: styles.icon,
66
- size: 24
67
- })
68
- }), /*#__PURE__*/_jsx(I18n.Text, {
69
- className: styles.label,
70
- string: label
71
- }), Badge && /*#__PURE__*/_jsx(Badge, {})]
72
- });
76
+ const handleClick = () => {
77
+ UIEvents.emit('navdrawer_close');
78
+ setTimeout(onClick, 300);
73
79
  };
74
- return NavDrawerItem;
75
- }(Component);
80
+ return /*#__PURE__*/_jsxs("button", {
81
+ ref: forwardedRef,
82
+ className: srOnly ? classes.srOnly : classes.button,
83
+ "data-test-id": testId,
84
+ onClick: handleClick,
85
+ style: style,
86
+ type: "button",
87
+ "aria-hidden": ariaHidden,
88
+ "aria-label": ariaLabel,
89
+ tabIndex: "0",
90
+ children: [/*#__PURE__*/_jsx("div", {
91
+ className: classes.iconWrapper,
92
+ children: Icon && /*#__PURE__*/_jsx(Icon, {
93
+ className: classes.icon,
94
+ size: 24
95
+ })
96
+ }), /*#__PURE__*/_jsx(I18n.Text, {
97
+ className: classes.label,
98
+ string: label
99
+ }), Badge && /*#__PURE__*/_jsx(Badge, {})]
100
+ });
101
+ };
76
102
  NavDrawerItem.defaultProps = {
77
103
  'aria-hidden': null,
78
104
  'aria-label': null,
@@ -84,4 +110,4 @@ NavDrawerItem.defaultProps = {
84
110
  style: {},
85
111
  testId: null
86
112
  };
87
- export default withForwardedRef(NavDrawerItem);
113
+ export default withForwardedRef(/*#__PURE__*/memo(NavDrawerItem));
@@ -1,21 +1,33 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import I18n from '@shopgate/pwa-common/components/I18n';
4
- import styles from "./style";
3
+ import { I18n } from '@shopgate/engage/components';
4
+ import { themeColors } from '@shopgate/pwa-common/helpers/config';
5
+ import { makeStyles } from '@shopgate/engage/styles';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const useStyles = makeStyles()({
8
+ root: {
9
+ color: themeColors.shade11,
10
+ fontSize: '0.875rem',
11
+ fontWeight: 500,
12
+ margin: '16px 0 0 16px'
13
+ }
14
+ });
5
15
 
6
16
  /**
7
17
  * @param {Object} props The component props.
8
18
  * @returns {JSX}
9
19
  */
10
- import { jsx as _jsx } from "react/jsx-runtime";
11
20
  const NavDrawerTitle = ({
12
21
  text
13
22
  }) => {
23
+ const {
24
+ classes
25
+ } = useStyles();
14
26
  if (!text.length) {
15
27
  return null;
16
28
  }
17
29
  return /*#__PURE__*/_jsx("div", {
18
- className: styles,
30
+ className: classes.root,
19
31
  children: /*#__PURE__*/_jsx(I18n.Text, {
20
32
  string: text
21
33
  })