@shopgate/pwa-ui-shared 7.30.0-alpha.10 → 7.30.0-alpha.11
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/AccordionContainer/index.js +17 -11
- package/AccordionContainer/spec.js +12 -3
- package/ActionButton/index.js +47 -33
- package/ActionButton/spec.js +5 -1
- package/AddToCartButton/index.js +44 -33
- package/AddToCartButton/mock.js +20 -8
- package/AddToCartButton/spec.js +4 -3
- package/Availability/index.js +5 -3
- package/Availability/spec.js +6 -5
- package/Button/index.js +73 -58
- package/Button/spec.js +16 -10
- package/ButtonLink/index.js +20 -12
- package/ButtonLink/spec.js +5 -3
- package/Card/index.js +5 -3
- package/CardList/components/Item/index.js +5 -3
- package/CardList/index.js +21 -12
- package/CartTotalLine/components/Amount/index.js +10 -8
- package/CartTotalLine/components/Hint/index.js +7 -5
- package/CartTotalLine/components/Label/index.js +12 -10
- package/CartTotalLine/components/Spacer/index.js +5 -3
- package/CartTotalLine/index.js +5 -3
- package/Checkbox/index.js +6 -5
- package/Chip/index.js +28 -22
- package/Chip/spec.js +9 -6
- package/ContextMenu/ContextMenuProvider.js +5 -3
- package/ContextMenu/components/Item/index.js +14 -11
- package/ContextMenu/components/Position/index.js +20 -12
- package/ContextMenu/index.js +54 -44
- package/ContextMenu/spec.js +31 -20
- package/Dialog/components/HtmlContentDialog/index.js +9 -7
- package/Dialog/components/HtmlContentDialog/spec.js +9 -6
- package/Dialog/components/PipelineErrorDialog/index.js +106 -47
- package/Dialog/components/PipelineErrorDialog/spec.js +5 -4
- package/Dialog/components/TextMessageDialog/index.js +9 -7
- package/Dialog/components/TextMessageDialog/spec.js +9 -6
- package/Dialog/components/VariantSelectModal/index.js +7 -5
- package/Dialog/components/VariantSelectModal/spec.js +6 -3
- package/Dialog/index.js +12 -8
- package/Dialog/spec.js +7 -6
- package/DiscountBadge/index.js +10 -8
- package/DiscountBadge/spec.js +3 -2
- package/FavoritesButton/index.js +40 -31
- package/FavoritesButton/spec.js +7 -3
- package/Form/Builder/classes/ActionListener/index.js +400 -401
- package/Form/Builder/components/CheckboxElement.js +13 -5
- package/Form/Builder/components/CountryElement.js +13 -5
- package/Form/Builder/components/ProvinceElement.js +13 -5
- package/Form/Builder/components/RadioElement.js +19 -11
- package/Form/Builder/components/SelectElement.js +26 -16
- package/Form/Builder/components/TextElement.js +13 -5
- package/Form/Builder/index.js +70 -60
- package/Form/Builder/spec.js +10 -9
- package/Form/Checkbox/index.js +31 -21
- package/Form/InfoField/index.js +19 -12
- package/Form/InfoField/spec.js +4 -1
- package/Form/Password/index.js +22 -15
- package/Form/Password/spec.js +10 -5
- package/Form/RadioGroup/components/Item/index.js +34 -25
- package/Form/RadioGroup/index.js +37 -28
- package/Form/RadioGroup/spec.js +45 -31
- package/Form/Select/index.js +52 -43
- package/Form/Select/spec.js +5 -2
- package/Form/SelectContextChoices/index.js +26 -22
- package/Form/SelectContextChoices/spec.js +4 -1
- package/Form/TextField/index.js +40 -27
- package/Form/TextField/spec.js +34 -21
- package/Form/index.js +23 -15
- package/FormElement/components/ErrorText/index.js +7 -5
- package/FormElement/components/Label/index.js +6 -4
- package/FormElement/components/Placeholder/index.js +7 -5
- package/FormElement/components/Underline/index.js +8 -6
- package/FormElement/index.js +62 -46
- package/FormElement/spec.js +10 -9
- package/Glow/index.js +30 -22
- package/Glow/spec.js +6 -1
- package/IndicatorCircle/index.js +10 -8
- package/IndicatorCircle/spec.js +3 -2
- package/LoadingIndicator/index.js +8 -6
- package/Manufacturer/index.js +9 -7
- package/MessageBar/index.js +20 -17
- package/MessageBar/spec.js +6 -5
- package/NoResults/components/Icon/index.js +134 -110
- package/NoResults/index.js +27 -21
- package/Placeholder/index.js +13 -5
- package/PlaceholderLabel/index.js +2 -1
- package/PlaceholderLabel/spec.js +13 -6
- package/PlaceholderParagraph/index.js +13 -12
- package/PlaceholderParagraph/spec.js +13 -6
- package/Price/index.js +46 -28
- package/PriceInfo/index.js +2 -1
- package/PriceStriked/index.js +41 -29
- package/ProductProperties/index.js +13 -10
- package/ProgressBar/index.js +28 -19
- package/ProgressBar/spec.js +2 -1
- package/RadioButton/index.js +6 -5
- package/RadioButton/spec.js +3 -2
- package/RatingNumber/index.js +2 -1
- package/RatingStars/index.js +50 -34
- package/RatingStars/spec.js +7 -6
- package/Ripple/components/RippleAnimation/index.js +12 -10
- package/Ripple/index.js +72 -62
- package/RippleButton/index.js +44 -27
- package/RippleButton/spec.js +20 -13
- package/ScannerOverlay/components/CameraOverlay/index.js +8 -5
- package/ScannerOverlay/components/ScannerBar/components/FlashlightButton/index.js +25 -21
- package/ScannerOverlay/components/ScannerBar/components/ScannerInstructions/index.js +7 -5
- package/ScannerOverlay/components/ScannerBar/index.js +17 -12
- package/ScannerOverlay/index.js +24 -15
- package/Sheet/components/Header/components/SearchBar/index.js +35 -28
- package/Sheet/components/Header/components/SearchBar/spec.js +2 -1
- package/Sheet/components/Header/index.js +47 -34
- package/Sheet/components/Header/spec.js +2 -1
- package/Sheet/index.js +80 -65
- package/Sheet/spec.js +27 -14
- package/TaxDisclaimer/index.js +13 -10
- package/TaxDisclaimer/spec.js +3 -2
- package/TextField/components/ErrorText/index.js +7 -5
- package/TextField/components/FormElement/index.js +4 -3
- package/TextField/components/Hint/index.js +7 -5
- package/TextField/components/Label/index.js +6 -4
- package/TextField/components/Underline/index.js +8 -6
- package/TextField/index.js +102 -85
- package/TextField/spec.js +37 -23
- package/ToggleIcon/index.js +23 -15
- package/ToggleIcon/spec.js +12 -8
- package/icons/AccountBoxIcon.js +5 -4
- package/icons/AddMoreIcon.js +5 -4
- package/icons/ArrowDropIcon.js +5 -4
- package/icons/ArrowIcon.js +5 -4
- package/icons/BarcodeScannerIcon.js +5 -4
- package/icons/BoxIcon.js +5 -4
- package/icons/BrowseIcon.js +5 -4
- package/icons/BurgerIcon.js +5 -4
- package/icons/CalendarIcon.js +5 -5
- package/icons/CartCouponIcon.js +5 -4
- package/icons/CartIcon.js +5 -4
- package/icons/CartPlusIcon.js +5 -4
- package/icons/CheckIcon.js +5 -4
- package/icons/CheckedIcon.js +5 -4
- package/icons/ChevronIcon.js +5 -4
- package/icons/CreditCardIcon.js +5 -4
- package/icons/CrossIcon.js +5 -4
- package/icons/DescriptionIcon.js +5 -4
- package/icons/FilterIcon.js +5 -4
- package/icons/FlashDisabledIcon.js +5 -4
- package/icons/FlashEnabledIcon.js +5 -4
- package/icons/GridIcon.js +5 -4
- package/icons/HeartIcon.js +5 -4
- package/icons/HeartOutlineIcon.js +5 -4
- package/icons/HeartPlusIcon.js +5 -4
- package/icons/HeartPlusOutlineIcon.js +5 -4
- package/icons/HomeIcon.js +5 -4
- package/icons/InfoIcon.js +5 -4
- package/icons/InfoOutlineIcon.js +5 -4
- package/icons/ListIcon.js +5 -4
- package/icons/LocalShippingIcon.js +5 -4
- package/icons/LocationIcon.js +5 -4
- package/icons/LocatorIcon.js +5 -4
- package/icons/LockIcon.js +5 -4
- package/icons/LogoutIcon.js +5 -4
- package/icons/MagnifierIcon.js +5 -4
- package/icons/MapMarkerIcon.js +5 -4
- package/icons/MoreIcon.js +5 -4
- package/icons/MoreVertIcon.js +5 -4
- package/icons/NotificationIcon.js +5 -4
- package/icons/PersonIcon.js +5 -4
- package/icons/PhoneIcon.js +5 -4
- package/icons/PlaceholderIcon.js +5 -4
- package/icons/RadioCheckedIcon.js +5 -4
- package/icons/RadioUncheckedIcon.js +5 -4
- package/icons/SecurityIcon.js +5 -4
- package/icons/ShippingMethodIcon.js +5 -4
- package/icons/ShoppingCartIcon.js +5 -4
- package/icons/SortIcon.js +5 -4
- package/icons/StarHalfIcon.js +5 -4
- package/icons/StarIcon.js +5 -4
- package/icons/StarOutlineIcon.js +5 -4
- package/icons/StopIcon.js +5 -4
- package/icons/TickIcon.js +5 -4
- package/icons/TimeIcon.js +5 -4
- package/icons/TrashIcon.js +5 -4
- package/icons/TrashOutlineIcon.js +5 -4
- package/icons/UncheckedIcon.js +5 -4
- package/icons/ViewListIcon.js +5 -4
- package/icons/VisibilityIcon.js +5 -4
- package/icons/VisibilityOffIcon.js +5 -4
- package/icons/WarningIcon.js +5 -4
- package/package.json +7 -8
package/ContextMenu/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import ContextMenuProvider from "./ContextMenuProvider";
|
|
|
25
25
|
* @param {boolean} props.showToggle Whether the toggle button should be shown.
|
|
26
26
|
* @returns {JSX}
|
|
27
27
|
*/
|
|
28
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
29
|
const ContextMenu = props => {
|
|
29
30
|
const {
|
|
30
31
|
children,
|
|
@@ -75,52 +76,61 @@ const ContextMenu = props => {
|
|
|
75
76
|
left: 0
|
|
76
77
|
};
|
|
77
78
|
const useScroll = typeof scroll === 'boolean' && !!scroll;
|
|
78
|
-
return /*#__PURE__*/
|
|
79
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
79
80
|
"data-test-id": "contextMenu",
|
|
80
81
|
ref: elementRef,
|
|
81
|
-
className: classNames(styles.container, classes.container, 'ui-shared__context-menu')
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
82
|
+
className: classNames(styles.container, classes.container, 'ui-shared__context-menu'),
|
|
83
|
+
children: [showToggle && /*#__PURE__*/_jsx("button", {
|
|
84
|
+
className: classNames(styles.button, classes.button, {
|
|
85
|
+
[styles.disabled]: disabled
|
|
86
|
+
}),
|
|
87
|
+
onClick: handleMenuToggle,
|
|
88
|
+
disabled: disabled,
|
|
89
|
+
type: "button",
|
|
90
|
+
"aria-label": i18n.text('navigation.open_menu'),
|
|
91
|
+
"aria-haspopup": "true",
|
|
92
|
+
"aria-expanded": active,
|
|
93
|
+
"aria-controls": "contextMenuDialog",
|
|
94
|
+
children: /*#__PURE__*/_jsx(MoreVertIcon, {
|
|
95
|
+
"aria-hidden": true
|
|
96
|
+
})
|
|
97
|
+
}), /*#__PURE__*/_jsx(ConnectedReactPortal, {
|
|
98
|
+
isOpened: active,
|
|
99
|
+
children: /*#__PURE__*/_jsx(FocusTrap, {
|
|
100
|
+
active: active,
|
|
101
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
102
|
+
className: styles.overlay,
|
|
103
|
+
children: [/*#__PURE__*/_jsx(Backdrop, {
|
|
104
|
+
isVisible: true,
|
|
105
|
+
level: 0,
|
|
106
|
+
opacity: 0,
|
|
107
|
+
onClick: handleMenuToggle
|
|
108
|
+
}), /*#__PURE__*/_jsx(Position, {
|
|
109
|
+
offset: offset,
|
|
110
|
+
children: /*#__PURE__*/_jsx(ContextMenuProvider, {
|
|
111
|
+
handleMenuToggle: handleMenuToggle,
|
|
112
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
113
|
+
className: classNames(styles.menu, {
|
|
114
|
+
[styles.scrollable]: useScroll
|
|
115
|
+
}),
|
|
116
|
+
ref: menuRef,
|
|
117
|
+
tabIndex: "-1",
|
|
118
|
+
"aria-modal": "true",
|
|
119
|
+
role: "dialog",
|
|
120
|
+
children: [children, /*#__PURE__*/_jsx("button", {
|
|
121
|
+
onClick: handleMenuToggle,
|
|
122
|
+
className: "sr-only",
|
|
123
|
+
"aria-label": i18n.text('common.close'),
|
|
124
|
+
type: "button",
|
|
125
|
+
children: i18n.text('common.close')
|
|
126
|
+
})]
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
})]
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
})]
|
|
133
|
+
});
|
|
124
134
|
};
|
|
125
135
|
ContextMenu.defaultProps = {
|
|
126
136
|
children: null,
|
package/ContextMenu/spec.js
CHANGED
|
@@ -3,7 +3,9 @@ import { mount, shallow } from 'enzyme';
|
|
|
3
3
|
import { act } from 'react-dom/test-utils';
|
|
4
4
|
import Backdrop from '@shopgate/pwa-common/components/Backdrop';
|
|
5
5
|
import ContextMenu from "./index";
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
7
|
jest.mock('@shopgate/engage/components');
|
|
8
|
+
jest.mock('@shopgate/engage/a11y/components');
|
|
7
9
|
global.requestAnimationFrame = fn => fn();
|
|
8
10
|
jest.useFakeTimers();
|
|
9
11
|
describe('<ContextMenu />', () => {
|
|
@@ -12,25 +14,30 @@ describe('<ContextMenu />', () => {
|
|
|
12
14
|
const numMenuItems = 2;
|
|
13
15
|
describe('Snapshot test', () => {
|
|
14
16
|
it('should match snapshot', () => {
|
|
15
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
16
|
-
isOpened: true
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const wrapper = shallow(/*#__PURE__*/_jsxs(ContextMenu, {
|
|
18
|
+
isOpened: true,
|
|
19
|
+
children: [/*#__PURE__*/_jsx(ContextMenu.Item, {
|
|
20
|
+
onClick: mockItemAClick,
|
|
21
|
+
className: "menu-active-item",
|
|
22
|
+
children: "Item A"
|
|
23
|
+
}), /*#__PURE__*/_jsx(ContextMenu.Item, {
|
|
24
|
+
onClick: mockItemBClick,
|
|
25
|
+
className: "menu-active-item",
|
|
26
|
+
children: "Item B"
|
|
27
|
+
})]
|
|
28
|
+
}));
|
|
24
29
|
expect(wrapper).toMatchSnapshot();
|
|
25
30
|
});
|
|
26
31
|
it('should match snapshot without toggle', () => {
|
|
27
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
32
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(ContextMenu, {
|
|
28
33
|
isOpened: true,
|
|
29
|
-
showToggle: false
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
showToggle: false,
|
|
35
|
+
children: /*#__PURE__*/_jsx(ContextMenu.Item, {
|
|
36
|
+
onClick: mockItemAClick,
|
|
37
|
+
className: "menu-active-item",
|
|
38
|
+
children: "Item A"
|
|
39
|
+
})
|
|
40
|
+
}));
|
|
34
41
|
expect(wrapper).toMatchSnapshot();
|
|
35
42
|
});
|
|
36
43
|
});
|
|
@@ -41,11 +48,15 @@ describe('<ContextMenu />', () => {
|
|
|
41
48
|
* The view component
|
|
42
49
|
*/
|
|
43
50
|
const renderComponent = () => {
|
|
44
|
-
renderedElement = mount(/*#__PURE__*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
renderedElement = mount(/*#__PURE__*/_jsxs(ContextMenu, {
|
|
52
|
+
children: [/*#__PURE__*/_jsx(ContextMenu.Item, {
|
|
53
|
+
onClick: mockItemAClick,
|
|
54
|
+
children: "Item A"
|
|
55
|
+
}), /*#__PURE__*/_jsx(ContextMenu.Item, {
|
|
56
|
+
onClick: mockItemBClick,
|
|
57
|
+
children: "Item B"
|
|
58
|
+
})]
|
|
59
|
+
}));
|
|
49
60
|
};
|
|
50
61
|
beforeEach(renderComponent);
|
|
51
62
|
it('should match snapshot', () => {
|
|
@@ -8,18 +8,20 @@ import BasicDialog from "../BasicDialog";
|
|
|
8
8
|
* @param {Object} props The component properties.
|
|
9
9
|
* @returns {JSX.Element} The rendered component.
|
|
10
10
|
*/
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
const HtmlContentDialog = ({
|
|
12
13
|
actions,
|
|
13
14
|
message,
|
|
14
15
|
title
|
|
15
|
-
}) => /*#__PURE__*/
|
|
16
|
+
}) => /*#__PURE__*/_jsx(BasicDialog, {
|
|
16
17
|
title: title,
|
|
17
|
-
actions: actions
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
18
|
+
actions: actions,
|
|
19
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
20
|
+
dangerouslySetInnerHTML: {
|
|
21
|
+
__html: message
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
});
|
|
23
25
|
HtmlContentDialog.defaultProps = {
|
|
24
26
|
title: BasicDialog.defaultProps.title
|
|
25
27
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { shallow } from 'enzyme';
|
|
3
3
|
import HtmlContentDialog from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
const message = '<p><i>This is a html message.</i></p>';
|
|
5
6
|
const title = 'This is the title.';
|
|
6
7
|
jest.mock('@shopgate/engage/a11y/components');
|
|
7
8
|
describe('<HtmlContentDialog />', () => {
|
|
8
9
|
it('should render with minimal props', () => {
|
|
9
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
10
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {
|
|
10
11
|
message: message,
|
|
11
12
|
actions: []
|
|
12
13
|
}));
|
|
@@ -14,7 +15,7 @@ describe('<HtmlContentDialog />', () => {
|
|
|
14
15
|
expect(wrapper.html()).toMatch(message);
|
|
15
16
|
});
|
|
16
17
|
it('should render with title and html message', () => {
|
|
17
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
18
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {
|
|
18
19
|
title: title,
|
|
19
20
|
message: message,
|
|
20
21
|
actions: []
|
|
@@ -23,7 +24,7 @@ describe('<HtmlContentDialog />', () => {
|
|
|
23
24
|
expect(wrapper.html()).toMatch(title);
|
|
24
25
|
});
|
|
25
26
|
it('should render with title, html message and messageParams', () => {
|
|
26
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
27
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {
|
|
27
28
|
title: title,
|
|
28
29
|
message: "Message with {name}",
|
|
29
30
|
params: {
|
|
@@ -38,7 +39,7 @@ describe('<HtmlContentDialog />', () => {
|
|
|
38
39
|
label: 'fooAction',
|
|
39
40
|
action: () => {}
|
|
40
41
|
}];
|
|
41
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
42
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {
|
|
42
43
|
title: title,
|
|
43
44
|
message: message,
|
|
44
45
|
actions: actions
|
|
@@ -47,8 +48,10 @@ describe('<HtmlContentDialog />', () => {
|
|
|
47
48
|
expect(wrapper.html()).toMatch(actions[0].label);
|
|
48
49
|
});
|
|
49
50
|
it('should pass title through', () => {
|
|
50
|
-
const customTitle = /*#__PURE__*/
|
|
51
|
-
|
|
51
|
+
const customTitle = /*#__PURE__*/_jsx("div", {
|
|
52
|
+
children: "Title"
|
|
53
|
+
});
|
|
54
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(HtmlContentDialog, {
|
|
52
55
|
title: customTitle,
|
|
53
56
|
message: message,
|
|
54
57
|
params: {},
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
2
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
3
|
import React, { Component } from 'react';
|
|
2
4
|
import PropTypes from 'prop-types';
|
|
3
5
|
import I18n from '@shopgate/pwa-common/components/I18n';
|
|
@@ -6,6 +8,7 @@ import BasicDialog from "../BasicDialog";
|
|
|
6
8
|
/**
|
|
7
9
|
* The number of taps required until the dialog switches to/from developer mode.
|
|
8
10
|
*/
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
12
|
const requiredTapsToSwitchModes = 10;
|
|
10
13
|
|
|
11
14
|
/**
|
|
@@ -18,45 +21,46 @@ const switchModeTapTimeout = 4000 / requiredTapsToSwitchModes;
|
|
|
18
21
|
* The special behaviour of this message is that the user may tap the message body
|
|
19
22
|
* ten times until it reveals additional information about the error that occurred.
|
|
20
23
|
*/
|
|
21
|
-
|
|
24
|
+
let PipelineErrorDialog = /*#__PURE__*/function (_Component) {
|
|
22
25
|
/**
|
|
23
26
|
* Creates the component.
|
|
24
27
|
* @param {Object} props The component props.
|
|
25
28
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
function PipelineErrorDialog(props) {
|
|
30
|
+
var _this;
|
|
31
|
+
_this = _Component.call(this, props) || this;
|
|
28
32
|
/**
|
|
29
33
|
* Clears the tap counter once the
|
|
30
34
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
_this.handleTapTimeout = () => {
|
|
36
|
+
_this.tapCounter = 0;
|
|
33
37
|
};
|
|
34
38
|
/**
|
|
35
39
|
* User tapped the message, increase the tap counter and switch view modes if required.
|
|
36
40
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
41
|
+
_this.handleClick = () => {
|
|
42
|
+
_this.tapCounter += 1;
|
|
43
|
+
if (_this.tapTimeout) {
|
|
40
44
|
// Clear the timeout.
|
|
41
|
-
clearTimeout(
|
|
45
|
+
clearTimeout(_this.tapTimeout);
|
|
42
46
|
}
|
|
43
|
-
if (
|
|
47
|
+
if (_this.tapCounter >= requiredTapsToSwitchModes) {
|
|
44
48
|
// Switch modes and reset the tap counter.
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
_this.tapCounter = 0;
|
|
50
|
+
_this.setState(({
|
|
47
51
|
devMode
|
|
48
52
|
}) => ({
|
|
49
53
|
devMode: !devMode
|
|
50
54
|
}));
|
|
51
55
|
} else {
|
|
52
|
-
|
|
56
|
+
_this.tapTimeout = setTimeout(_this.handleTapTimeout, switchModeTapTimeout);
|
|
53
57
|
}
|
|
54
58
|
};
|
|
55
59
|
/**
|
|
56
60
|
* Renders the error message in developer mode.
|
|
57
61
|
* @returns {JSX}
|
|
58
62
|
*/
|
|
59
|
-
|
|
63
|
+
_this.renderDevErrorMessage = () => {
|
|
60
64
|
/**
|
|
61
65
|
* Checks the input to be truthy, "0" or "false" and enables it to be rendered then.
|
|
62
66
|
* @param {Object|string|number|boolean} value The value to be checked if it should be rendered.
|
|
@@ -65,60 +69,115 @@ class PipelineErrorDialog extends Component {
|
|
|
65
69
|
const checkValue = value => !!value || value === 0 || value === false;
|
|
66
70
|
const {
|
|
67
71
|
params
|
|
68
|
-
} =
|
|
69
|
-
return /*#__PURE__*/
|
|
70
|
-
"aria-hidden": true
|
|
71
|
-
|
|
72
|
+
} = _this.props;
|
|
73
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
74
|
+
"aria-hidden": true,
|
|
75
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
76
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
77
|
+
children: "Pipeline:"
|
|
78
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
79
|
+
children: ` ${params.pipeline}`
|
|
80
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
81
|
+
}), checkValue(params.entityId) && /*#__PURE__*/_jsxs("span", {
|
|
82
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
83
|
+
children: "Entity id:"
|
|
84
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
85
|
+
children: ` ${params.entityId}`
|
|
86
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
87
|
+
}), checkValue(params.code) && /*#__PURE__*/_jsxs("span", {
|
|
88
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
89
|
+
children: "Code:"
|
|
90
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
91
|
+
children: ` ${params.code}`
|
|
92
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
93
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
94
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
95
|
+
children: "Message:"
|
|
96
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
97
|
+
children: ` ${params.message}`
|
|
98
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
99
|
+
}), checkValue(params.translated) && /*#__PURE__*/_jsxs("span", {
|
|
100
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
101
|
+
children: "Message Translated:"
|
|
102
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
103
|
+
children: ` ${params.translated.toString()}`
|
|
104
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
105
|
+
}), checkValue(params.messageParams) && /*#__PURE__*/_jsxs("p", {
|
|
106
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
107
|
+
children: "Message Params:"
|
|
108
|
+
}), /*#__PURE__*/_jsx("br", {}), /*#__PURE__*/_jsx("span", {
|
|
109
|
+
children: JSON.stringify(params.messageParams, null, ' ')
|
|
110
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
111
|
+
}), checkValue(params.request) && /*#__PURE__*/_jsxs("p", {
|
|
112
|
+
children: [/*#__PURE__*/_jsx("strong", {
|
|
113
|
+
children: "Request Params:"
|
|
114
|
+
}), /*#__PURE__*/_jsx("br", {}), /*#__PURE__*/_jsx("span", {
|
|
115
|
+
children: JSON.stringify(params.request, null, ' ')
|
|
116
|
+
}), /*#__PURE__*/_jsx("br", {})]
|
|
117
|
+
})]
|
|
118
|
+
});
|
|
72
119
|
};
|
|
73
120
|
/**
|
|
74
121
|
* Renders the regular error message in user mode.
|
|
75
122
|
* @returns {JSX}
|
|
76
123
|
*/
|
|
77
|
-
|
|
124
|
+
_this.renderUserErrorMessage = () => {
|
|
78
125
|
const {
|
|
79
126
|
message = '',
|
|
80
127
|
params = {}
|
|
81
|
-
} =
|
|
82
|
-
return /*#__PURE__*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
128
|
+
} = _this.props;
|
|
129
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
130
|
+
children: [!!params.translated && (message || params.message || /*#__PURE__*/_jsx(I18n.Text, {
|
|
131
|
+
string: "modal.body_error"
|
|
132
|
+
})), !params.translated && /*#__PURE__*/_jsx(I18n.Text, {
|
|
133
|
+
string: message || params.message || 'modal.body_error',
|
|
134
|
+
params: params.messageParams || {}
|
|
135
|
+
})]
|
|
136
|
+
});
|
|
88
137
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
138
|
+
_this.tapTimeout = null;
|
|
139
|
+
_this.tapCounter = 0;
|
|
140
|
+
_this.state = {
|
|
92
141
|
devMode: false // Indicating whether we are in dev mode.
|
|
93
142
|
};
|
|
143
|
+
return _this;
|
|
94
144
|
}
|
|
95
145
|
|
|
96
146
|
/**
|
|
97
147
|
* @return {string} The title based on the current state of the dialog.
|
|
98
148
|
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @return {JSX} The content component based on the the current state of the dialog.
|
|
105
|
-
*/
|
|
106
|
-
get content() {
|
|
107
|
-
return this.state.devMode ? this.renderDevErrorMessage() : this.renderUserErrorMessage();
|
|
108
|
-
}
|
|
149
|
+
_inheritsLoose(PipelineErrorDialog, _Component);
|
|
150
|
+
var _proto = PipelineErrorDialog.prototype;
|
|
109
151
|
/**
|
|
110
152
|
* Renders the error message depending on the current mode.
|
|
111
153
|
* @return {JSX}
|
|
112
154
|
*/
|
|
113
|
-
render() {
|
|
114
|
-
return /*#__PURE__*/
|
|
155
|
+
_proto.render = function render() {
|
|
156
|
+
return /*#__PURE__*/_jsx(BasicDialog, {
|
|
115
157
|
title: this.title,
|
|
116
|
-
actions: this.props.actions
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
158
|
+
actions: this.props.actions,
|
|
159
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
160
|
+
onClick: this.handleClick,
|
|
161
|
+
children: this.content
|
|
162
|
+
})
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
return _createClass(PipelineErrorDialog, [{
|
|
166
|
+
key: "title",
|
|
167
|
+
get: function () {
|
|
168
|
+
return this.state.devMode ? 'Pipeline Error' : 'modal.title_error';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @return {JSX} The content component based on the the current state of the dialog.
|
|
173
|
+
*/
|
|
174
|
+
}, {
|
|
175
|
+
key: "content",
|
|
176
|
+
get: function () {
|
|
177
|
+
return this.state.devMode ? this.renderDevErrorMessage() : this.renderUserErrorMessage();
|
|
178
|
+
}
|
|
179
|
+
}]);
|
|
180
|
+
}(Component);
|
|
122
181
|
PipelineErrorDialog.defaultProps = {
|
|
123
182
|
message: ''
|
|
124
183
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { mount } from 'enzyme';
|
|
3
3
|
import PipelineErrorDialog from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
jest.mock('@shopgate/engage/a11y/components');
|
|
5
6
|
describe('<PipelineErrorDialog />', () => {
|
|
6
7
|
const defaultParams = {
|
|
@@ -10,7 +11,7 @@ describe('<PipelineErrorDialog />', () => {
|
|
|
10
11
|
request: {}
|
|
11
12
|
};
|
|
12
13
|
it('should render with minimal props', () => {
|
|
13
|
-
const wrapper = mount(/*#__PURE__*/
|
|
14
|
+
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
14
15
|
actions: [],
|
|
15
16
|
params: defaultParams
|
|
16
17
|
}));
|
|
@@ -18,7 +19,7 @@ describe('<PipelineErrorDialog />', () => {
|
|
|
18
19
|
});
|
|
19
20
|
it('should show a custom message if a message is is provided', () => {
|
|
20
21
|
const message = 'Custom message';
|
|
21
|
-
const wrapper = mount(/*#__PURE__*/
|
|
22
|
+
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
22
23
|
actions: [],
|
|
23
24
|
message: message,
|
|
24
25
|
params: defaultParams
|
|
@@ -27,7 +28,7 @@ describe('<PipelineErrorDialog />', () => {
|
|
|
27
28
|
expect(wrapper.html()).toMatch(message);
|
|
28
29
|
});
|
|
29
30
|
it('should switch modes on tap', () => {
|
|
30
|
-
const wrapper = mount(/*#__PURE__*/
|
|
31
|
+
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
31
32
|
actions: [],
|
|
32
33
|
params: defaultParams
|
|
33
34
|
}));
|
|
@@ -51,7 +52,7 @@ describe('<PipelineErrorDialog />', () => {
|
|
|
51
52
|
});
|
|
52
53
|
it('should not switch modes if tapped too slow', () => {
|
|
53
54
|
jest.useFakeTimers();
|
|
54
|
-
const wrapper = mount(/*#__PURE__*/
|
|
55
|
+
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
55
56
|
actions: [],
|
|
56
57
|
params: defaultParams
|
|
57
58
|
}));
|
|
@@ -10,20 +10,22 @@ import BasicDialog from "../BasicDialog";
|
|
|
10
10
|
* @param {Object} props The component properties.
|
|
11
11
|
* @returns {JSX} The rendered component.
|
|
12
12
|
*/
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
const TextMessageDialog = ({
|
|
14
15
|
actions,
|
|
15
16
|
message,
|
|
16
17
|
title,
|
|
17
18
|
params,
|
|
18
19
|
children
|
|
19
|
-
}) => /*#__PURE__*/
|
|
20
|
+
}) => /*#__PURE__*/_jsxs(BasicDialog, {
|
|
20
21
|
title: title,
|
|
21
|
-
actions: actions
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}), children
|
|
22
|
+
actions: actions,
|
|
23
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
24
|
+
dangerouslySetInnerHTML: {
|
|
25
|
+
__html: nl2br(i18n.text(message, params))
|
|
26
|
+
}
|
|
27
|
+
}), children]
|
|
28
|
+
});
|
|
27
29
|
TextMessageDialog.defaultProps = {
|
|
28
30
|
title: BasicDialog.defaultProps.title,
|
|
29
31
|
params: I18n.Text.defaultProps.params,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { shallow } from 'enzyme';
|
|
3
3
|
import TextMessageDialog from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
const message = 'This is the message.';
|
|
5
6
|
const title = 'This is the title.';
|
|
6
7
|
jest.mock('@shopgate/engage/a11y/components');
|
|
7
8
|
describe('<TextMessageDialog />', () => {
|
|
8
9
|
it('should render with minimal props', () => {
|
|
9
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
10
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
10
11
|
message: message,
|
|
11
12
|
actions: []
|
|
12
13
|
}));
|
|
@@ -14,7 +15,7 @@ describe('<TextMessageDialog />', () => {
|
|
|
14
15
|
expect(wrapper.html()).toMatch(message);
|
|
15
16
|
});
|
|
16
17
|
it('should render with title and message', () => {
|
|
17
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
18
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
18
19
|
title: title,
|
|
19
20
|
message: message,
|
|
20
21
|
actions: []
|
|
@@ -23,7 +24,7 @@ describe('<TextMessageDialog />', () => {
|
|
|
23
24
|
expect(wrapper.html()).toMatch(title);
|
|
24
25
|
});
|
|
25
26
|
it('should render with title, message and messageParams', () => {
|
|
26
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
27
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
27
28
|
title: title,
|
|
28
29
|
message: "Message with {name}",
|
|
29
30
|
params: {
|
|
@@ -38,7 +39,7 @@ describe('<TextMessageDialog />', () => {
|
|
|
38
39
|
label: 'fooAction',
|
|
39
40
|
action: () => {}
|
|
40
41
|
}];
|
|
41
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
42
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
42
43
|
title: title,
|
|
43
44
|
message: message,
|
|
44
45
|
actions: actions
|
|
@@ -47,8 +48,10 @@ describe('<TextMessageDialog />', () => {
|
|
|
47
48
|
expect(wrapper.html()).toMatch(actions[0].label);
|
|
48
49
|
});
|
|
49
50
|
it('should pass title through', () => {
|
|
50
|
-
const customTitle = /*#__PURE__*/
|
|
51
|
-
|
|
51
|
+
const customTitle = /*#__PURE__*/_jsx("div", {
|
|
52
|
+
children: "Title"
|
|
53
|
+
});
|
|
54
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
52
55
|
title: customTitle,
|
|
53
56
|
message: message,
|
|
54
57
|
params: {},
|
|
@@ -14,6 +14,7 @@ import connect from "./connector";
|
|
|
14
14
|
* @param {string} navigate The navigate action.
|
|
15
15
|
* @return {Array} Reordered and extended actions.
|
|
16
16
|
*/
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
18
|
const reorderActions = (actions, {
|
|
18
19
|
productId
|
|
19
20
|
}, navigate) => {
|
|
@@ -61,12 +62,13 @@ const VariantSelectModal = ({
|
|
|
61
62
|
params
|
|
62
63
|
}) => {
|
|
63
64
|
const parsedActions = reorderActions(actions, params, navigate);
|
|
64
|
-
return /*#__PURE__*/
|
|
65
|
+
return /*#__PURE__*/_jsx(BasicDialog, {
|
|
65
66
|
title: title,
|
|
66
|
-
actions: parsedActions
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
actions: parsedActions,
|
|
68
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
69
|
+
string: message
|
|
70
|
+
})
|
|
71
|
+
});
|
|
70
72
|
};
|
|
71
73
|
VariantSelectModal.defaultProps = {
|
|
72
74
|
params: {
|