@shopgate/pwa-ui-material 7.30.0-alpha.10 → 7.30.0-alpha.12

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/SnackBar/index.js CHANGED
@@ -1,39 +1,42 @@
1
- import _extends from "@babel/runtime/helpers/extends";
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
3
  import React, { Component } from 'react';
3
4
  import PropTypes from 'prop-types';
4
5
  import { config } from 'react-spring';
5
6
  import { Spring } from 'react-spring/renderprops.cjs';
6
7
  import Ellipsis from '@shopgate/pwa-common/components/Ellipsis';
7
8
  import styles from "./style";
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
10
  const defaultToast = {};
9
11
 
10
12
  /**
11
13
  * The SnackBar component.
12
14
  */
13
- class SnackBar extends Component {
15
+ let SnackBar = /*#__PURE__*/function (_Component) {
14
16
  /**
15
17
  * @param {Object} props The component props.
16
18
  */
17
- constructor(props) {
18
- super(props);
19
- this.timer = null;
20
- this.handleAction = () => {
21
- clearTimeout(this.timer);
22
- this.props.toasts[0].action();
23
- this.hide();
19
+ function SnackBar(props) {
20
+ var _this;
21
+ _this = _Component.call(this, props) || this;
22
+ _this.timer = null;
23
+ _this.handleAction = () => {
24
+ clearTimeout(_this.timer);
25
+ _this.props.toasts[0].action();
26
+ _this.hide();
24
27
  };
25
- this.handleEntered = () => {
26
- this.timer = setTimeout(this.hide, this.props.toasts[0].duration || 2500);
28
+ _this.handleEntered = () => {
29
+ _this.timer = setTimeout(_this.hide, _this.props.toasts[0].duration || 2500);
27
30
  };
28
- this.handleRest = () => {
29
- if (this.state.visible) {
30
- this.handleEntered();
31
+ _this.handleRest = () => {
32
+ if (_this.state.visible) {
33
+ _this.handleEntered();
31
34
  return;
32
35
  }
33
- this.props.removeToast();
36
+ _this.props.removeToast();
34
37
  };
35
- this.hide = () => {
36
- this.setState({
38
+ _this.hide = () => {
39
+ _this.setState({
37
40
  visible: false
38
41
  });
39
42
  };
@@ -43,7 +46,7 @@ class SnackBar extends Component {
43
46
  * @param {string} actionLabel The snack bar action label.
44
47
  * @return {number}
45
48
  */
46
- this.calcRows = (message, actionLabel) => {
49
+ _this.calcRows = (message, actionLabel) => {
47
50
  /**
48
51
  * Calculates the amount of rows for a passed text.
49
52
  * @param {string} text The input text.
@@ -57,15 +60,18 @@ class SnackBar extends Component {
57
60
  */
58
61
  return calc(`${message}${actionLabel.repeat(calc(message))}`);
59
62
  };
60
- this.state = {
63
+ _this.state = {
61
64
  visible: true
62
65
  };
66
+ return _this;
63
67
  }
64
68
 
65
69
  /**
66
70
  * @param {Object} nextProps The next component props.
67
71
  */
68
- UNSAFE_componentWillReceiveProps(nextProps) {
72
+ _inheritsLoose(SnackBar, _Component);
73
+ var _proto = SnackBar.prototype;
74
+ _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
69
75
  const hasToast = nextProps.toasts.length > 0;
70
76
  this.setState({
71
77
  visible: hasToast
@@ -76,29 +82,14 @@ class SnackBar extends Component {
76
82
  * @param {Object} nextProps The next component props.
77
83
  * @param {Object} nextState The next component state.
78
84
  * @returns {boolean}
79
- */
80
- shouldComponentUpdate(nextProps, nextState) {
85
+ */;
86
+ _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
81
87
  return this.state.visible !== nextState.visible;
82
- }
83
- /**
84
- * Returns the first snack from the state.
85
- * @returns {Object}
86
- */
87
- get snack() {
88
- const {
89
- __
90
- } = this.context.i18n();
91
- const snack = this.props.toasts.length ? this.props.toasts[0] : defaultToast;
92
- return {
93
- ...snack,
94
- message: __(snack.message || '', snack.messageParams || {}),
95
- actionLabel: __(snack.actionLabel || '')
96
- };
97
- }
88
+ };
98
89
  /**
99
90
  * @returns {JSX}
100
91
  */
101
- render() {
92
+ _proto.render = function render() {
102
93
  const {
103
94
  visible
104
95
  } = this.state;
@@ -118,47 +109,74 @@ class SnackBar extends Component {
118
109
  // Calculate the required amount of rows and the height of the snack bar.
119
110
  const rows = this.calcRows(message, actionLabel);
120
111
  const snackBarHeight = 40 + rows * 20;
121
- return /*#__PURE__*/React.createElement("div", {
112
+ return /*#__PURE__*/_jsx("div", {
122
113
  className: `${styles.container} ui-material__snack-bar`,
123
114
  style: {
124
115
  '--snack-bar-height': `${snackBarHeight}px`
125
- }
126
- }, /*#__PURE__*/React.createElement(Spring, {
127
- from: {
128
- top: snackBarHeight
129
- },
130
- to: {
131
- top: 0
132
116
  },
133
- config: config.stiff,
134
- reverse: !visible,
135
- force: true,
136
- onRest: this.handleRest
137
- }, props =>
138
- /*#__PURE__*/
139
- // eslint-disable-next-line max-len
140
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
141
- React.createElement("div", {
142
- className: styles.wrapper,
143
- style: props,
144
- "data-footer-inset-update-ignore": "true",
145
- onClick: this.hide
146
- }, /*#__PURE__*/React.createElement("div", _extends({
147
- className: styles.box
148
- }, boxProps), /*#__PURE__*/React.createElement(Ellipsis, {
149
- rows: rows
150
- }, /*#__PURE__*/React.createElement("span", {
151
- className: styles.label,
152
- "aria-live": "assertive",
153
- role: "status"
154
- }, message)), action && actionLabel && /*#__PURE__*/React.createElement("button", {
155
- className: styles.button,
156
- onClick: this.handleAction,
157
- type: "button",
158
- "aria-hidden": true
159
- }, actionLabel)))));
160
- }
161
- }
117
+ children: /*#__PURE__*/_jsx(Spring, {
118
+ from: {
119
+ top: snackBarHeight
120
+ },
121
+ to: {
122
+ top: 0
123
+ },
124
+ config: config.stiff,
125
+ reverse: !visible,
126
+ force: true,
127
+ onRest: this.handleRest,
128
+ children: props =>
129
+ /*#__PURE__*/
130
+ // eslint-disable-next-line max-len
131
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
132
+ _jsx("div", {
133
+ className: styles.wrapper,
134
+ style: props,
135
+ "data-footer-inset-update-ignore": "true",
136
+ onClick: this.hide,
137
+ children: /*#__PURE__*/_jsxs("div", {
138
+ className: styles.box,
139
+ ...boxProps,
140
+ children: [/*#__PURE__*/_jsx(Ellipsis, {
141
+ rows: rows,
142
+ children: /*#__PURE__*/_jsx("span", {
143
+ className: styles.label,
144
+ "aria-live": "assertive",
145
+ role: "status",
146
+ children: message
147
+ })
148
+ }), action && actionLabel && /*#__PURE__*/_jsx("button", {
149
+ className: styles.button,
150
+ onClick: this.handleAction,
151
+ type: "button",
152
+ "aria-hidden": true,
153
+ children: actionLabel
154
+ })]
155
+ })
156
+ })
157
+ })
158
+ });
159
+ };
160
+ return _createClass(SnackBar, [{
161
+ key: "snack",
162
+ get:
163
+ /**
164
+ * Returns the first snack from the state.
165
+ * @returns {Object}
166
+ */
167
+ function () {
168
+ const {
169
+ __
170
+ } = this.context.i18n();
171
+ const snack = this.props.toasts.length ? this.props.toasts[0] : defaultToast;
172
+ return {
173
+ ...snack,
174
+ message: __(snack.message || '', snack.messageParams || {}),
175
+ actionLabel: __(snack.actionLabel || '')
176
+ };
177
+ }
178
+ }]);
179
+ }(Component);
162
180
  SnackBar.defaultProps = {
163
181
  toasts: null
164
182
  };
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import React from 'react';
3
2
  import Icon from '@shopgate/pwa-common/components/Icon';
4
3
  import { themeConfig } from '@shopgate/pwa-common/helpers/config';
@@ -8,7 +7,9 @@ import { themeConfig } from '@shopgate/pwa-common/helpers/config';
8
7
  * @param {Object} props The icon component properties.
9
8
  * @returns {JSX}
10
9
  */
11
- const ShareIcon = props => /*#__PURE__*/React.createElement(Icon, _extends({
12
- content: themeConfig.icons.share
13
- }, props));
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const ShareIcon = props => /*#__PURE__*/_jsx(Icon, {
12
+ content: themeConfig.icons.share,
13
+ ...props
14
+ });
14
15
  export default ShareIcon;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-ui-material",
3
- "version": "7.30.0-alpha.10",
3
+ "version": "7.30.0-alpha.12",
4
4
  "description": "Shopgate's material design UI components.",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "devDependencies": {
8
- "@shopgate/pwa-common": "7.30.0-alpha.10",
9
- "react": "~16.14.0",
10
- "react-dom": "~16.14.0",
8
+ "@shopgate/pwa-common": "7.30.0-alpha.12",
9
+ "react": "^17.0.2",
10
+ "react-dom": "^17.0.2",
11
11
  "redux": "^4.2.1"
12
12
  },
13
13
  "dependencies": {
@@ -17,9 +17,9 @@
17
17
  "prop-types": "~15.8.1",
18
18
  "react-spring": "^8.0.27",
19
19
  "react-transition-group": "^3.0.0",
20
- "react-use": "~13.12.2"
20
+ "react-use": "^17.6.0"
21
21
  },
22
22
  "peerDependencies": {
23
- "react": "~16.14.0"
23
+ "react": "^16.0.0 || ^17.0.0"
24
24
  }
25
25
  }