@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/Accordion/components/AccordionContent/index.js +12 -8
- package/Accordion/components/AccordionContent/spec.js +15 -10
- package/Accordion/index.js +53 -43
- package/Accordion/spec.js +8 -6
- package/AppBar/components/Below/index.js +11 -9
- package/AppBar/components/Center/index.js +11 -9
- package/AppBar/components/Field/index.js +22 -13
- package/AppBar/components/Icon/index.js +16 -7
- package/AppBar/components/Left/index.js +11 -9
- package/AppBar/components/Right/index.js +11 -9
- package/AppBar/components/Title/index.js +23 -14
- package/AppBar/index.js +19 -15
- package/BaseDialog/components/Buttons/index.js +7 -6
- package/BaseDialog/components/Buttons/spec.js +3 -2
- package/BaseDialog/components/Content/index.js +5 -3
- package/BaseDialog/components/Content/spec.js +3 -2
- package/BaseDialog/components/Title/index.js +10 -7
- package/BaseDialog/components/Title/spec.js +3 -2
- package/BaseDialog/index.js +26 -19
- package/BaseDialog/spec.js +8 -3
- package/FloatingActionButton/index.js +14 -14
- package/NavDrawer/components/Divider/index.js +2 -1
- package/NavDrawer/components/Divider/spec.js +2 -1
- package/NavDrawer/components/Item/index.js +30 -21
- package/NavDrawer/components/Section/index.js +6 -3
- package/NavDrawer/components/Title/index.js +7 -5
- package/NavDrawer/index.js +82 -69
- package/NavDrawer/spec.js +11 -5
- package/SnackBar/index.js +94 -76
- package/icons/ShareIcon.js +5 -4
- package/package.json +6 -6
package/SnackBar/index.js
CHANGED
|
@@ -1,39 +1,42 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
15
|
+
let SnackBar = /*#__PURE__*/function (_Component) {
|
|
14
16
|
/**
|
|
15
17
|
* @param {Object} props The component props.
|
|
16
18
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
28
|
+
_this.handleEntered = () => {
|
|
29
|
+
_this.timer = setTimeout(_this.hide, _this.props.toasts[0].duration || 2500);
|
|
27
30
|
};
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
+
_this.handleRest = () => {
|
|
32
|
+
if (_this.state.visible) {
|
|
33
|
+
_this.handleEntered();
|
|
31
34
|
return;
|
|
32
35
|
}
|
|
33
|
-
|
|
36
|
+
_this.props.removeToast();
|
|
34
37
|
};
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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__*/
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
};
|
package/icons/ShareIcon.js
CHANGED
|
@@ -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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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.
|
|
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.
|
|
9
|
-
"react": "
|
|
10
|
-
"react-dom": "
|
|
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": "
|
|
20
|
+
"react-use": "^17.6.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"react": "
|
|
23
|
+
"react": "^16.0.0 || ^17.0.0"
|
|
24
24
|
}
|
|
25
25
|
}
|