@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
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { useSpring, animated } from 'react-spring';
|
|
5
|
-
import useMeasure from 'react-use
|
|
5
|
+
import { useMeasure } from 'react-use';
|
|
6
6
|
import * as styles from "./style";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -10,6 +10,7 @@ import * as styles from "./style";
|
|
|
10
10
|
* @param {Object} props The component props.
|
|
11
11
|
* @returns {JSX}
|
|
12
12
|
*/
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
function AccordionContent(props) {
|
|
14
15
|
const {
|
|
15
16
|
children,
|
|
@@ -36,16 +37,19 @@ function AccordionContent(props) {
|
|
|
36
37
|
},
|
|
37
38
|
height: open ? contentHeight : 0
|
|
38
39
|
});
|
|
39
|
-
return /*#__PURE__*/
|
|
40
|
+
return /*#__PURE__*/_jsx(animated.div, {
|
|
40
41
|
className: classnames('ui-material__accordion-content', styles.content),
|
|
41
42
|
style: expand,
|
|
42
43
|
id: id,
|
|
43
|
-
"aria-hidden": !open
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
"aria-hidden": !open,
|
|
45
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
46
|
+
ref: ref,
|
|
47
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
48
|
+
className: classnames(styles.contentInner, className),
|
|
49
|
+
children: children
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
});
|
|
49
53
|
}
|
|
50
54
|
AccordionContent.defaultProps = {
|
|
51
55
|
open: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { mount } from 'enzyme';
|
|
3
3
|
import AccordionContent from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
jest.mock('react-spring', () => ({
|
|
5
6
|
...jest.requireActual('react-spring'),
|
|
6
7
|
useSpring: jest.fn().mockReturnValue({
|
|
@@ -9,22 +10,26 @@ jest.mock('react-spring', () => ({
|
|
|
9
10
|
}));
|
|
10
11
|
describe('<AccordionContent />', () => {
|
|
11
12
|
it('should render as closed', () => {
|
|
12
|
-
const wrapper = mount(/*#__PURE__*/
|
|
13
|
-
id: "some-id"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const wrapper = mount(/*#__PURE__*/_jsx(AccordionContent, {
|
|
14
|
+
id: "some-id",
|
|
15
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
16
|
+
id: "test",
|
|
17
|
+
children: "Some Child"
|
|
18
|
+
})
|
|
19
|
+
}));
|
|
17
20
|
expect(wrapper.find('#test').text()).toEqual('Some Child');
|
|
18
21
|
expect(wrapper.find('div').get(0).props['aria-hidden']).toEqual(true);
|
|
19
22
|
expect(wrapper).toMatchSnapshot();
|
|
20
23
|
});
|
|
21
24
|
it('should render as open', () => {
|
|
22
|
-
const wrapper = mount(/*#__PURE__*/
|
|
25
|
+
const wrapper = mount(/*#__PURE__*/_jsx(AccordionContent, {
|
|
23
26
|
open: true,
|
|
24
|
-
id: "some-id"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
id: "some-id",
|
|
28
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
29
|
+
id: "test",
|
|
30
|
+
children: "Some Child"
|
|
31
|
+
})
|
|
32
|
+
}));
|
|
28
33
|
expect(wrapper.find('#test').text()).toEqual('Some Child');
|
|
29
34
|
expect(wrapper.find('div').get(0).props['aria-hidden']).toEqual(false);
|
|
30
35
|
expect(wrapper).toMatchSnapshot();
|
package/Accordion/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import "core-js/modules/es.string.replace.js";
|
|
3
2
|
import * as React from 'react';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
@@ -28,6 +27,8 @@ import * as styles from "./style";
|
|
|
28
27
|
* for the accordion header
|
|
29
28
|
* @returns {JSX.Element}
|
|
30
29
|
*/
|
|
30
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
31
|
+
import { createElement as _createElement } from "react";
|
|
31
32
|
function Accordion(props) {
|
|
32
33
|
const {
|
|
33
34
|
renderLabel,
|
|
@@ -47,48 +48,57 @@ function Accordion(props) {
|
|
|
47
48
|
return null;
|
|
48
49
|
}
|
|
49
50
|
const controlsId = testId ? `${testId}-content`.replace(/[^\w\s]/gi, '-').replace(' ', '-') : 'accordion-content';
|
|
50
|
-
return /*#__PURE__*/
|
|
51
|
-
className: "ui-material__accordion-container"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
51
|
+
return /*#__PURE__*/_jsx("div", {
|
|
52
|
+
className: "ui-material__accordion-container",
|
|
53
|
+
children: /*#__PURE__*/_jsx(AccordionContainer, {
|
|
54
|
+
open: startOpened,
|
|
55
|
+
children: ({
|
|
56
|
+
handleOpen,
|
|
57
|
+
handleClose,
|
|
58
|
+
open
|
|
59
|
+
}) => {
|
|
60
|
+
const clickHandlers = {
|
|
61
|
+
onClick: open ? handleClose : handleOpen,
|
|
62
|
+
onKeyDown: open ? handleClose : handleOpen,
|
|
63
|
+
role
|
|
64
|
+
};
|
|
65
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
66
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
67
|
+
className: classnames('ui-material__accordion-title', className, styles.toggle),
|
|
68
|
+
"data-test-id": testId,
|
|
69
|
+
children: [/*#__PURE__*/_createElement("div", {
|
|
70
|
+
...(openWithChevron ? {} : clickHandlers),
|
|
71
|
+
key: "accordion-toggle",
|
|
72
|
+
"aria-expanded": open,
|
|
73
|
+
"aria-controls": controlsId,
|
|
74
|
+
"aria-label": handleLabel,
|
|
75
|
+
className: classnames(styles.labelContainer, {
|
|
76
|
+
[styles.toggleLeftAligned]: chevronPosition === 'left'
|
|
77
|
+
})
|
|
78
|
+
}, renderLabel({
|
|
79
|
+
open
|
|
80
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
81
|
+
className: classnames(styles.chevronContainer, chevronClassName, {
|
|
82
|
+
[styles.clickable]: openWithChevron
|
|
83
|
+
}),
|
|
84
|
+
...(openWithChevron ? clickHandlers : {}),
|
|
85
|
+
"aria-label": i18n.text(open ? 'favorites.close_list' : 'favorites.open_list'),
|
|
86
|
+
children: /*#__PURE__*/_jsx(ChevronIcon, {
|
|
87
|
+
className: open ? styles.chevronOpen : styles.chevronClosed
|
|
88
|
+
})
|
|
89
|
+
})), renderAdditionalHeaderContent && /*#__PURE__*/_jsx("div", {
|
|
90
|
+
children: renderAdditionalHeaderContent()
|
|
91
|
+
})]
|
|
92
|
+
}), /*#__PURE__*/_jsx(AccordionContent, {
|
|
93
|
+
open: open,
|
|
94
|
+
id: controlsId,
|
|
95
|
+
className: contentClassName,
|
|
96
|
+
children: children
|
|
97
|
+
}, controlsId)]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
});
|
|
92
102
|
}
|
|
93
103
|
Accordion.defaultProps = {
|
|
94
104
|
children: null,
|
package/Accordion/spec.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { mount } from 'enzyme';
|
|
3
3
|
import Accordion from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
jest.unmock('@shopgate/pwa-ui-shared');
|
|
5
6
|
jest.mock('@shopgate/engage/components');
|
|
6
7
|
jest.mock('react-spring', () => ({
|
|
@@ -14,22 +15,23 @@ describe('<Accordion />', () => {
|
|
|
14
15
|
jest.clearAllMocks();
|
|
15
16
|
});
|
|
16
17
|
it('should render with renderLabel prop and children', () => {
|
|
17
|
-
const wrapper = mount(/*#__PURE__*/
|
|
18
|
-
renderLabel: () => /*#__PURE__*/
|
|
19
|
-
testId: "Some Thing"
|
|
20
|
-
|
|
18
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Accordion, {
|
|
19
|
+
renderLabel: () => /*#__PURE__*/_jsx("div", {}),
|
|
20
|
+
testId: "Some Thing",
|
|
21
|
+
children: "Some content."
|
|
22
|
+
}));
|
|
21
23
|
expect(wrapper).toMatchSnapshot();
|
|
22
24
|
expect(wrapper.find('AccordionContent').exists()).toBe(true);
|
|
23
25
|
});
|
|
24
26
|
it('should not render without a renderLabel prop', () => {
|
|
25
|
-
const wrapper = mount(/*#__PURE__*/
|
|
27
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Accordion, {
|
|
26
28
|
testId: "Some Thing"
|
|
27
29
|
}));
|
|
28
30
|
expect(wrapper).toMatchSnapshot();
|
|
29
31
|
expect(wrapper.instance()).toEqual(null);
|
|
30
32
|
});
|
|
31
33
|
it('should not render without children', () => {
|
|
32
|
-
const wrapper = mount(/*#__PURE__*/
|
|
34
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Accordion, {
|
|
33
35
|
renderLabel: () => {},
|
|
34
36
|
testId: "Some Thing"
|
|
35
37
|
}));
|
|
@@ -7,18 +7,20 @@ import { APP_BAR_BELOW, APP_BAR_BELOW_BEFORE, APP_BAR_BELOW_AFTER } from '@shopg
|
|
|
7
7
|
* @param {Object} props The component props.
|
|
8
8
|
* @returns {JSX}
|
|
9
9
|
*/
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
11
|
function Below({
|
|
11
12
|
elements
|
|
12
13
|
}) {
|
|
13
|
-
return /*#__PURE__*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
return /*#__PURE__*/_jsxs(Fragment, {
|
|
15
|
+
children: [/*#__PURE__*/_jsx(Portal, {
|
|
16
|
+
name: APP_BAR_BELOW_BEFORE
|
|
17
|
+
}), /*#__PURE__*/_jsx(Portal, {
|
|
18
|
+
name: APP_BAR_BELOW,
|
|
19
|
+
children: elements
|
|
20
|
+
}), /*#__PURE__*/_jsx(Portal, {
|
|
21
|
+
name: APP_BAR_BELOW_AFTER
|
|
22
|
+
})]
|
|
23
|
+
}, "below");
|
|
22
24
|
}
|
|
23
25
|
Below.defaultProps = {
|
|
24
26
|
elements: null
|
|
@@ -7,18 +7,20 @@ import { APP_BAR_CENTER, APP_BAR_CENTER_BEFORE, APP_BAR_CENTER_AFTER } from '@sh
|
|
|
7
7
|
* @param {Object} props The component props.
|
|
8
8
|
* @returns {JSX}
|
|
9
9
|
*/
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
11
|
function Center({
|
|
11
12
|
elements
|
|
12
13
|
}) {
|
|
13
|
-
return /*#__PURE__*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
return /*#__PURE__*/_jsxs(Fragment, {
|
|
15
|
+
children: [/*#__PURE__*/_jsx(Portal, {
|
|
16
|
+
name: APP_BAR_CENTER_BEFORE
|
|
17
|
+
}), /*#__PURE__*/_jsx(Portal, {
|
|
18
|
+
name: APP_BAR_CENTER,
|
|
19
|
+
children: elements
|
|
20
|
+
}), /*#__PURE__*/_jsx(Portal, {
|
|
21
|
+
name: APP_BAR_CENTER_AFTER
|
|
22
|
+
})]
|
|
23
|
+
}, "center");
|
|
22
24
|
}
|
|
23
25
|
Center.defaultProps = {
|
|
24
26
|
elements: null
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import React, { PureComponent } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import styles from "./style";
|
|
@@ -5,11 +6,17 @@ import styles from "./style";
|
|
|
5
6
|
/**
|
|
6
7
|
* The AppBarField component.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
let AppBarField = /*#__PURE__*/function (_PureComponent) {
|
|
11
|
+
function AppBarField() {
|
|
12
|
+
return _PureComponent.apply(this, arguments) || this;
|
|
13
|
+
}
|
|
14
|
+
_inheritsLoose(AppBarField, _PureComponent);
|
|
15
|
+
var _proto = AppBarField.prototype;
|
|
9
16
|
/**
|
|
10
17
|
* @returns {JSX}
|
|
11
18
|
*/
|
|
12
|
-
render() {
|
|
19
|
+
_proto.render = function render() {
|
|
13
20
|
const {
|
|
14
21
|
fieldRef,
|
|
15
22
|
onChange,
|
|
@@ -18,18 +25,20 @@ class AppBarField extends PureComponent {
|
|
|
18
25
|
const {
|
|
19
26
|
__
|
|
20
27
|
} = this.context.i18n();
|
|
21
|
-
return /*#__PURE__*/
|
|
28
|
+
return /*#__PURE__*/_jsx("form", {
|
|
22
29
|
className: styles.form,
|
|
23
|
-
onSubmit: onSubmit
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
30
|
+
onSubmit: onSubmit,
|
|
31
|
+
children: /*#__PURE__*/_jsx("input", {
|
|
32
|
+
className: styles.field,
|
|
33
|
+
onChange: onChange,
|
|
34
|
+
placeholder: __('search.placeholder'),
|
|
35
|
+
ref: fieldRef,
|
|
36
|
+
"data-test-id": "searchInput"
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
return AppBarField;
|
|
41
|
+
}(PureComponent);
|
|
33
42
|
AppBarField.defaultProps = {
|
|
34
43
|
fieldRef: null,
|
|
35
44
|
onChange: null,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import React, { PureComponent } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import styles from "./style";
|
|
@@ -5,11 +6,17 @@ import styles from "./style";
|
|
|
5
6
|
/**
|
|
6
7
|
* The AppBarIcon component.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
let AppBarIcon = /*#__PURE__*/function (_PureComponent) {
|
|
11
|
+
function AppBarIcon() {
|
|
12
|
+
return _PureComponent.apply(this, arguments) || this;
|
|
13
|
+
}
|
|
14
|
+
_inheritsLoose(AppBarIcon, _PureComponent);
|
|
15
|
+
var _proto = AppBarIcon.prototype;
|
|
9
16
|
/**
|
|
10
17
|
* @returns {JSX}
|
|
11
18
|
*/
|
|
12
|
-
render() {
|
|
19
|
+
_proto.render = function render() {
|
|
13
20
|
const {
|
|
14
21
|
background,
|
|
15
22
|
badge: Badge,
|
|
@@ -20,7 +27,7 @@ class AppBarIcon extends PureComponent {
|
|
|
20
27
|
'aria-hidden': ariaHidden,
|
|
21
28
|
'aria-label': ariaLabel
|
|
22
29
|
} = this.props;
|
|
23
|
-
return /*#__PURE__*/
|
|
30
|
+
return /*#__PURE__*/_jsxs("button", {
|
|
24
31
|
className: styles,
|
|
25
32
|
onClick: onClick,
|
|
26
33
|
style: {
|
|
@@ -30,10 +37,12 @@ class AppBarIcon extends PureComponent {
|
|
|
30
37
|
"data-test-id": testId,
|
|
31
38
|
"aria-hidden": ariaHidden,
|
|
32
39
|
"aria-label": ariaLabel,
|
|
33
|
-
type: "button"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
40
|
+
type: "button",
|
|
41
|
+
children: [/*#__PURE__*/_jsx(Icon, {}), Badge && /*#__PURE__*/_jsx(Badge, {})]
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
return AppBarIcon;
|
|
45
|
+
}(PureComponent);
|
|
37
46
|
AppBarIcon.defaultProps = {
|
|
38
47
|
'aria-hidden': null,
|
|
39
48
|
'aria-label': null,
|
|
@@ -7,18 +7,20 @@ import { APP_BAR_LEFT, APP_BAR_LEFT_BEFORE, APP_BAR_LEFT_AFTER } from '@shopgate
|
|
|
7
7
|
* @param {Object} props The component props.
|
|
8
8
|
* @returns {JSX}
|
|
9
9
|
*/
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
11
|
function Left({
|
|
11
12
|
elements
|
|
12
13
|
}) {
|
|
13
|
-
return /*#__PURE__*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
return /*#__PURE__*/_jsxs(Fragment, {
|
|
15
|
+
children: [/*#__PURE__*/_jsx(Portal, {
|
|
16
|
+
name: APP_BAR_LEFT_BEFORE
|
|
17
|
+
}), /*#__PURE__*/_jsx(Portal, {
|
|
18
|
+
name: APP_BAR_LEFT,
|
|
19
|
+
children: elements
|
|
20
|
+
}), /*#__PURE__*/_jsx(Portal, {
|
|
21
|
+
name: APP_BAR_LEFT_AFTER
|
|
22
|
+
})]
|
|
23
|
+
}, "left");
|
|
22
24
|
}
|
|
23
25
|
Left.defaultProps = {
|
|
24
26
|
elements: null
|
|
@@ -7,18 +7,20 @@ import { APP_BAR_RIGHT, APP_BAR_RIGHT_BEFORE, APP_BAR_RIGHT_AFTER } from '@shopg
|
|
|
7
7
|
* @param {Object} props The component props.
|
|
8
8
|
* @returns {JSX}
|
|
9
9
|
*/
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
11
|
function Right({
|
|
11
12
|
elements
|
|
12
13
|
}) {
|
|
13
|
-
return /*#__PURE__*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
return /*#__PURE__*/_jsxs(Fragment, {
|
|
15
|
+
children: [/*#__PURE__*/_jsx(Portal, {
|
|
16
|
+
name: APP_BAR_RIGHT_BEFORE
|
|
17
|
+
}), /*#__PURE__*/_jsx(Portal, {
|
|
18
|
+
name: APP_BAR_RIGHT,
|
|
19
|
+
children: elements
|
|
20
|
+
}), /*#__PURE__*/_jsx(Portal, {
|
|
21
|
+
name: APP_BAR_RIGHT_AFTER
|
|
22
|
+
})]
|
|
23
|
+
}, "right");
|
|
22
24
|
}
|
|
23
25
|
Right.defaultProps = {
|
|
24
26
|
elements: null
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import React, { PureComponent } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import classNames from 'classnames';
|
|
@@ -6,33 +7,41 @@ import styles from "./style";
|
|
|
6
7
|
/**
|
|
7
8
|
* The AppBarTitle component.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
let AppBarTitle = /*#__PURE__*/function (_PureComponent) {
|
|
12
|
+
function AppBarTitle() {
|
|
13
|
+
return _PureComponent.apply(this, arguments) || this;
|
|
14
|
+
}
|
|
15
|
+
_inheritsLoose(AppBarTitle, _PureComponent);
|
|
16
|
+
var _proto = AppBarTitle.prototype;
|
|
10
17
|
/**
|
|
11
18
|
* @returns {JSX.Element}
|
|
12
19
|
*/
|
|
13
|
-
render() {
|
|
20
|
+
_proto.render = function render() {
|
|
14
21
|
const {
|
|
15
22
|
onClick,
|
|
16
23
|
title
|
|
17
24
|
} = this.props;
|
|
18
25
|
if (!title) return null;
|
|
19
|
-
return /*#__PURE__*/
|
|
26
|
+
return /*#__PURE__*/_jsx("div", {
|
|
20
27
|
className: classNames(styles, 'theme__app-bar__title'),
|
|
21
28
|
role: "heading",
|
|
22
29
|
"aria-labelledby": "titleLabel",
|
|
23
30
|
"aria-level": "1",
|
|
24
31
|
"data-test-id": `title: ${title}`,
|
|
25
|
-
tabIndex: -1
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
32
|
+
tabIndex: -1,
|
|
33
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
34
|
+
role: "presentation",
|
|
35
|
+
onClick: onClick,
|
|
36
|
+
id: "titleLabel",
|
|
37
|
+
dangerouslySetInnerHTML: {
|
|
38
|
+
__html: title
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
return AppBarTitle;
|
|
44
|
+
}(PureComponent);
|
|
36
45
|
AppBarTitle.defaultProps = {
|
|
37
46
|
onClick: null
|
|
38
47
|
};
|
package/AppBar/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import styles from "./style";
|
|
|
18
18
|
* Updates the --app-bar-height custom property
|
|
19
19
|
* @param {Object} ref The app bar ref.
|
|
20
20
|
*/
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
22
|
const updateAppBarHeight = ref => {
|
|
22
23
|
if (!ref.current) {
|
|
23
24
|
return;
|
|
@@ -57,25 +58,28 @@ const AppBar = ({
|
|
|
57
58
|
observer.disconnect();
|
|
58
59
|
};
|
|
59
60
|
}, [contentRef, observer]);
|
|
60
|
-
return /*#__PURE__*/
|
|
61
|
+
return /*#__PURE__*/_jsxs("header", {
|
|
61
62
|
ref: contentRef,
|
|
62
63
|
className: `${styles.outer} ui-material__app-bar`,
|
|
63
64
|
"data-test-id": "Navigator",
|
|
64
65
|
role: "banner",
|
|
65
|
-
style: style
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
style: style,
|
|
67
|
+
children: [/*#__PURE__*/_jsx(SurroundPortals, {
|
|
68
|
+
portalName: APP_BAR_CONTENT,
|
|
69
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
70
|
+
className: styles.inner,
|
|
71
|
+
children: [/*#__PURE__*/_jsx(Left, {
|
|
72
|
+
elements: left
|
|
73
|
+
}), /*#__PURE__*/_jsx(Center, {
|
|
74
|
+
elements: center
|
|
75
|
+
}), /*#__PURE__*/_jsx(Right, {
|
|
76
|
+
elements: right
|
|
77
|
+
})]
|
|
78
|
+
})
|
|
79
|
+
}), /*#__PURE__*/_jsx(Below, {
|
|
80
|
+
elements: below
|
|
81
|
+
})]
|
|
82
|
+
});
|
|
79
83
|
};
|
|
80
84
|
AppBar.defaultProps = {
|
|
81
85
|
backgroundColor: themeColors.light,
|
|
@@ -8,22 +8,23 @@ import styles from "../../style";
|
|
|
8
8
|
* @param {Object} props The component props.
|
|
9
9
|
* @returns {JSX}
|
|
10
10
|
*/
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
const Buttons = ({
|
|
12
13
|
actions
|
|
13
14
|
}) => actions.map(({
|
|
14
15
|
label,
|
|
15
16
|
action,
|
|
16
17
|
disabled = false
|
|
17
|
-
}) => /*#__PURE__*/
|
|
18
|
-
key: label,
|
|
18
|
+
}) => /*#__PURE__*/_jsx(Button, {
|
|
19
19
|
className: styles.button,
|
|
20
20
|
flat: true,
|
|
21
21
|
type: "primary",
|
|
22
22
|
onClick: action,
|
|
23
|
-
disabled: disabled
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
23
|
+
disabled: disabled,
|
|
24
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
25
|
+
string: label
|
|
26
|
+
})
|
|
27
|
+
}, label));
|
|
27
28
|
Buttons.defaultProps = {
|
|
28
29
|
actions: []
|
|
29
30
|
};
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { shallow } from 'enzyme';
|
|
3
3
|
import Button from '@shopgate/pwa-ui-shared/Button';
|
|
4
4
|
import Buttons from "./index";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
const actions = [{
|
|
6
7
|
label: 'action0',
|
|
7
8
|
action: jest.fn()
|
|
@@ -14,12 +15,12 @@ const actions = [{
|
|
|
14
15
|
}];
|
|
15
16
|
describe('<Buttons />', () => {
|
|
16
17
|
it('should not render if no actions are passed', () => {
|
|
17
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
18
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(Buttons, {}));
|
|
18
19
|
expect(wrapper).toMatchSnapshot();
|
|
19
20
|
expect(wrapper.instance()).toEqual(null);
|
|
20
21
|
});
|
|
21
22
|
it('should render buttons', () => {
|
|
22
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
23
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(Buttons, {
|
|
23
24
|
actions: actions
|
|
24
25
|
}));
|
|
25
26
|
expect(wrapper).toMatchSnapshot();
|