@shopgate/pwa-ui-shared 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/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/Form/Builder/spec.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { mount } from 'enzyme';
|
|
4
4
|
import FormBuilder from '.';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
jest.mock('@shopgate/engage/components');
|
|
6
7
|
describe('<FormBuilder />', () => {
|
|
7
8
|
it('should render empty form', () => {
|
|
8
|
-
const wrapper = mount(/*#__PURE__*/
|
|
9
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
9
10
|
config: {
|
|
10
11
|
fields: {}
|
|
11
12
|
},
|
|
@@ -15,7 +16,7 @@ describe('<FormBuilder />', () => {
|
|
|
15
16
|
expect(wrapper).toMatchSnapshot();
|
|
16
17
|
});
|
|
17
18
|
it('should render two text fields', () => {
|
|
18
|
-
const wrapper = mount(/*#__PURE__*/
|
|
19
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
19
20
|
config: {
|
|
20
21
|
fields: {
|
|
21
22
|
firstName: {
|
|
@@ -37,7 +38,7 @@ describe('<FormBuilder />', () => {
|
|
|
37
38
|
expect(wrapper.find('TextField').length).toEqual(2);
|
|
38
39
|
});
|
|
39
40
|
it('should not render invisible field', () => {
|
|
40
|
-
const wrapper = mount(/*#__PURE__*/
|
|
41
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
41
42
|
config: {
|
|
42
43
|
fields: {
|
|
43
44
|
firstName: {
|
|
@@ -54,7 +55,7 @@ describe('<FormBuilder />', () => {
|
|
|
54
55
|
expect(wrapper.find('TextField').length).toEqual(0);
|
|
55
56
|
});
|
|
56
57
|
it('should hide element if setVisibilty rule applies', () => {
|
|
57
|
-
const wrapper = mount(/*#__PURE__*/
|
|
58
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
58
59
|
config: {
|
|
59
60
|
fields: {
|
|
60
61
|
foo: {
|
|
@@ -96,7 +97,7 @@ describe('<FormBuilder />', () => {
|
|
|
96
97
|
expect(wrapper.find('TextField').length).toEqual(1);
|
|
97
98
|
});
|
|
98
99
|
it('should reset value when rule applies', () => {
|
|
99
|
-
const wrapper = mount(/*#__PURE__*/
|
|
100
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
100
101
|
config: {
|
|
101
102
|
fields: {
|
|
102
103
|
foo: {
|
|
@@ -150,7 +151,7 @@ describe('<FormBuilder />', () => {
|
|
|
150
151
|
});
|
|
151
152
|
it('should call onChange callback when input is changed', () => {
|
|
152
153
|
const handleUpdate = jest.fn();
|
|
153
|
-
const wrapper = mount(/*#__PURE__*/
|
|
154
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
154
155
|
config: {
|
|
155
156
|
fields: {
|
|
156
157
|
foo: {
|
|
@@ -189,7 +190,7 @@ describe('<FormBuilder />', () => {
|
|
|
189
190
|
it('should take the updated state from action listener', () => {
|
|
190
191
|
const handleUpdate = jest.fn();
|
|
191
192
|
const ref = /*#__PURE__*/React.createRef();
|
|
192
|
-
mount(/*#__PURE__*/
|
|
193
|
+
mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
193
194
|
ref: ref,
|
|
194
195
|
validationErrors: [],
|
|
195
196
|
config: {
|
|
@@ -228,7 +229,7 @@ describe('<FormBuilder />', () => {
|
|
|
228
229
|
// Create mocked Form builder.
|
|
229
230
|
const handleUpdate = jest.fn();
|
|
230
231
|
const ref = /*#__PURE__*/React.createRef();
|
|
231
|
-
mount(/*#__PURE__*/
|
|
232
|
+
mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
232
233
|
ref: ref,
|
|
233
234
|
validationErrors: [{}],
|
|
234
235
|
config: {
|
|
@@ -301,7 +302,7 @@ describe('<FormBuilder />', () => {
|
|
|
301
302
|
...field1,
|
|
302
303
|
sortOrder: 2
|
|
303
304
|
}];
|
|
304
|
-
expect(fields.sort(builder.elementSortFunc)).toEqual([
|
|
305
|
+
expect(fields.sort(builder.elementSortFunc)).toEqual([].concat(fields));
|
|
305
306
|
});
|
|
306
307
|
});
|
|
307
308
|
});
|
package/Form/Checkbox/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
2
2
|
import React, { PureComponent } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -27,11 +27,17 @@ import style from "./style";
|
|
|
27
27
|
* @extends {React.Component<Props>}
|
|
28
28
|
* @returns {JSX.Element}
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
31
|
+
let Checkbox = /*#__PURE__*/function (_PureComponent) {
|
|
32
|
+
function Checkbox() {
|
|
33
|
+
return _PureComponent.apply(this, arguments) || this;
|
|
34
|
+
}
|
|
35
|
+
_inheritsLoose(Checkbox, _PureComponent);
|
|
36
|
+
var _proto = Checkbox.prototype;
|
|
31
37
|
/**
|
|
32
38
|
* @return {JSX}
|
|
33
39
|
*/
|
|
34
|
-
render() {
|
|
40
|
+
_proto.render = function render() {
|
|
35
41
|
const {
|
|
36
42
|
name,
|
|
37
43
|
label,
|
|
@@ -43,7 +49,7 @@ class Checkbox extends PureComponent {
|
|
|
43
49
|
checkboxClassName,
|
|
44
50
|
...restProps
|
|
45
51
|
} = this.props;
|
|
46
|
-
return /*#__PURE__*/
|
|
52
|
+
return /*#__PURE__*/_jsx(FormElement, {
|
|
47
53
|
className: classNames(className, style.root, 'checkbox', 'ui-shared__form__checkbox'),
|
|
48
54
|
htmlFor: name,
|
|
49
55
|
errorText: errorText,
|
|
@@ -51,23 +57,27 @@ class Checkbox extends PureComponent {
|
|
|
51
57
|
hasUnderline: false,
|
|
52
58
|
hasPlaceholder: false,
|
|
53
59
|
disabled: restProps.disabled,
|
|
54
|
-
showErrorText: showErrorText
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
60
|
+
showErrorText: showErrorText,
|
|
61
|
+
children: /*#__PURE__*/_jsx(UICheckbox, {
|
|
62
|
+
...restProps,
|
|
63
|
+
className: checkboxClassName,
|
|
64
|
+
name: name,
|
|
65
|
+
onCheck: onChange,
|
|
66
|
+
checkedClassName: `${className} ${style.checked}`,
|
|
67
|
+
unCheckedClassName: className,
|
|
68
|
+
labelPosition: "right",
|
|
69
|
+
label: typeof label === 'string' ? /*#__PURE__*/_jsx("div", {
|
|
70
|
+
className: classNames(style.labelWrapper, 'label'),
|
|
71
|
+
children: /*#__PURE__*/_jsx(I18n.Text, {
|
|
72
|
+
className: style.label,
|
|
73
|
+
string: label
|
|
74
|
+
})
|
|
75
|
+
}) : label
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
return Checkbox;
|
|
80
|
+
}(PureComponent);
|
|
71
81
|
Checkbox.defaultProps = {
|
|
72
82
|
className: '',
|
|
73
83
|
checkboxClassName: undefined,
|
package/Form/InfoField/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import style from "./style";
|
|
|
8
8
|
* @param {Object} props .
|
|
9
9
|
* @returns {JSX}
|
|
10
10
|
*/
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
const InfoField = props => {
|
|
12
13
|
const {
|
|
13
14
|
className,
|
|
@@ -20,24 +21,30 @@ const InfoField = props => {
|
|
|
20
21
|
hasValue,
|
|
21
22
|
showErrorText
|
|
22
23
|
} = props;
|
|
23
|
-
return /*#__PURE__*/
|
|
24
|
+
return /*#__PURE__*/_jsx(FormElement, {
|
|
24
25
|
className: className,
|
|
25
26
|
label: label,
|
|
26
27
|
errorText: errorText,
|
|
27
28
|
hasUnderline: hasUnderline,
|
|
28
29
|
isFocused: false,
|
|
29
30
|
hasValue: hasValue,
|
|
30
|
-
showErrorText: showErrorText
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
showErrorText: showErrorText,
|
|
32
|
+
children: /*#__PURE__*/_jsxs(Grid, {
|
|
33
|
+
children: [leftElement && /*#__PURE__*/_jsx(Grid.Item, {
|
|
34
|
+
grow: 0,
|
|
35
|
+
className: style.element,
|
|
36
|
+
children: leftElement
|
|
37
|
+
}), /*#__PURE__*/_jsx(Grid.Item, {
|
|
38
|
+
grow: 1,
|
|
39
|
+
className: `${style.info} info-field`,
|
|
40
|
+
children: children
|
|
41
|
+
}), rightElement && /*#__PURE__*/_jsx(Grid.Item, {
|
|
42
|
+
grow: 0,
|
|
43
|
+
className: style.element,
|
|
44
|
+
children: rightElement
|
|
45
|
+
})]
|
|
46
|
+
})
|
|
47
|
+
});
|
|
41
48
|
};
|
|
42
49
|
InfoField.defaultProps = {
|
|
43
50
|
className: '',
|
package/Form/InfoField/spec.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { shallow } from 'enzyme';
|
|
3
3
|
import InfoField from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
describe('<InfoField>', () => {
|
|
5
6
|
it('should render info field', () => {
|
|
6
|
-
const wrapper = shallow(/*#__PURE__*/
|
|
7
|
+
const wrapper = shallow(/*#__PURE__*/_jsx(InfoField, {
|
|
8
|
+
children: "Some info text"
|
|
9
|
+
}));
|
|
7
10
|
expect(wrapper).toMatchSnapshot();
|
|
8
11
|
});
|
|
9
12
|
});
|
package/Form/Password/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
3
|
import ToggleIcon from "../../ToggleIcon";
|
|
4
4
|
import VisibilityIcon from "../../icons/VisibilityIcon";
|
|
@@ -9,47 +9,54 @@ import style from "./style";
|
|
|
9
9
|
/**
|
|
10
10
|
* A component that provides a password field with visibility toggle.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
let Password = /*#__PURE__*/function (_Component) {
|
|
13
14
|
/**
|
|
14
15
|
* Initializes the component.
|
|
15
16
|
* @param {Object} props The components props.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
function Password(props) {
|
|
19
|
+
var _this;
|
|
20
|
+
_this = _Component.call(this, props) || this;
|
|
19
21
|
/**
|
|
20
22
|
* @param {boolean} isVisible The next isVisible state.
|
|
21
23
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
_this.togglePasswordVisibility = isVisible => {
|
|
25
|
+
_this.setState({
|
|
24
26
|
isVisible
|
|
25
27
|
});
|
|
26
28
|
};
|
|
27
|
-
|
|
29
|
+
_this.state = {
|
|
28
30
|
isVisible: false
|
|
29
31
|
};
|
|
32
|
+
return _this;
|
|
30
33
|
}
|
|
34
|
+
_inheritsLoose(Password, _Component);
|
|
35
|
+
var _proto = Password.prototype;
|
|
31
36
|
/**
|
|
32
37
|
* @return {*}
|
|
33
38
|
*/
|
|
34
|
-
render() {
|
|
39
|
+
_proto.render = function render() {
|
|
35
40
|
const {
|
|
36
41
|
isVisible
|
|
37
42
|
} = this.state;
|
|
38
|
-
return /*#__PURE__*/
|
|
43
|
+
return /*#__PURE__*/_jsx(TextField, {
|
|
44
|
+
...this.props,
|
|
39
45
|
className: `ui-shared__form__password ${this.props.className}`,
|
|
40
|
-
rightElement: /*#__PURE__*/
|
|
46
|
+
rightElement: /*#__PURE__*/_jsx(ToggleIcon, {
|
|
41
47
|
on: isVisible,
|
|
42
|
-
onIcon: /*#__PURE__*/
|
|
48
|
+
onIcon: /*#__PURE__*/_jsx(VisibilityIcon, {
|
|
43
49
|
size: 24
|
|
44
50
|
}),
|
|
45
|
-
offIcon: /*#__PURE__*/
|
|
51
|
+
offIcon: /*#__PURE__*/_jsx(VisibilityOffIcon, {
|
|
46
52
|
size: 24,
|
|
47
53
|
className: style.visOff
|
|
48
54
|
}),
|
|
49
55
|
toggleHandler: this.togglePasswordVisibility
|
|
50
56
|
}),
|
|
51
57
|
type: isVisible ? 'text' : 'password'
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
return Password;
|
|
61
|
+
}(Component);
|
|
55
62
|
export default Password;
|
package/Form/Password/spec.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { mount } from 'enzyme';
|
|
4
3
|
import Password from "./index";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
const inputProps = {
|
|
6
6
|
name: 'test-input'
|
|
7
7
|
};
|
|
8
8
|
describe('<Password>', () => {
|
|
9
9
|
it('should render a password field', () => {
|
|
10
|
-
const wrapper = mount(/*#__PURE__*/
|
|
10
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Password, {
|
|
11
|
+
...inputProps
|
|
12
|
+
}));
|
|
11
13
|
expect(wrapper).toMatchSnapshot();
|
|
12
14
|
expect(wrapper.find('input[type="password"]').length).toBe(1);
|
|
13
15
|
});
|
|
14
16
|
it('should trigger the onChange callback', () => {
|
|
15
17
|
const onChangeMock = jest.fn();
|
|
16
|
-
const wrapper = mount(/*#__PURE__*/
|
|
18
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Password, {
|
|
19
|
+
...inputProps,
|
|
17
20
|
onChange: onChangeMock
|
|
18
|
-
}))
|
|
21
|
+
}));
|
|
19
22
|
wrapper.find('input').simulate('change', {
|
|
20
23
|
target: {
|
|
21
24
|
value: 'a'
|
|
@@ -25,7 +28,9 @@ describe('<Password>', () => {
|
|
|
25
28
|
expect(wrapper.find('input').props().value).toEqual('a');
|
|
26
29
|
});
|
|
27
30
|
it('should toggle password visibility', () => {
|
|
28
|
-
const wrapper = mount(/*#__PURE__*/
|
|
31
|
+
const wrapper = mount(/*#__PURE__*/_jsx(Password, {
|
|
32
|
+
...inputProps
|
|
33
|
+
}));
|
|
29
34
|
const input = wrapper.find('ToggleIcon');
|
|
30
35
|
expect(wrapper.find('input[type="password"]').length).toBe(1);
|
|
31
36
|
input.simulate('click');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
2
2
|
import _camelCase from "lodash/camelCase";
|
|
3
3
|
import React, { PureComponent } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
@@ -9,12 +9,18 @@ import style from "./style";
|
|
|
9
9
|
/**
|
|
10
10
|
* RadioItem component.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
let RadioItem = /*#__PURE__*/function (_PureComponent) {
|
|
14
|
+
function RadioItem() {
|
|
15
|
+
return _PureComponent.apply(this, arguments) || this;
|
|
16
|
+
}
|
|
17
|
+
_inheritsLoose(RadioItem, _PureComponent);
|
|
18
|
+
var _proto = RadioItem.prototype;
|
|
13
19
|
/**
|
|
14
20
|
* Renders the component.
|
|
15
21
|
* @returns {JSX.Element}
|
|
16
22
|
*/
|
|
17
|
-
render() {
|
|
23
|
+
_proto.render = function render() {
|
|
18
24
|
const {
|
|
19
25
|
label: ItemLabel,
|
|
20
26
|
name,
|
|
@@ -27,31 +33,34 @@ class RadioItem extends PureComponent {
|
|
|
27
33
|
const {
|
|
28
34
|
disabled
|
|
29
35
|
} = attributes || {};
|
|
30
|
-
return /*#__PURE__*/
|
|
36
|
+
return /*#__PURE__*/_jsxs("label", {
|
|
31
37
|
className: classNames(style.container, className, {
|
|
32
38
|
[style.disabled]: !!disabled
|
|
33
39
|
}, _camelCase(name), 'radioItem'),
|
|
34
|
-
htmlFor: id || name
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
40
|
+
htmlFor: id || name,
|
|
41
|
+
children: [checked && /*#__PURE__*/_jsx(CheckedIcon, {
|
|
42
|
+
className: classNames(style.active, style.icon, 'checkedIcon')
|
|
43
|
+
}), !checked && /*#__PURE__*/_jsx(UncheckedIcon, {
|
|
44
|
+
className: classNames(style.icon, 'uncheckedIcon')
|
|
45
|
+
}), /*#__PURE__*/_jsx("input", {
|
|
46
|
+
className: classNames('sr-only', 'input'),
|
|
47
|
+
checked: checked,
|
|
48
|
+
id: id || name,
|
|
49
|
+
type: "radio",
|
|
50
|
+
name: name,
|
|
51
|
+
onChange: onChange,
|
|
52
|
+
"aria-labelledby": `${id || name}-label`,
|
|
53
|
+
...attributes
|
|
54
|
+
}), /*#__PURE__*/_jsx(I18n.Text, {
|
|
55
|
+
string: ItemLabel,
|
|
56
|
+
"aria-hidden": true,
|
|
57
|
+
id: `${id || name}-label`,
|
|
58
|
+
className: classNames(style.label, 'label')
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return RadioItem;
|
|
63
|
+
}(PureComponent);
|
|
55
64
|
RadioItem.defaultProps = {
|
|
56
65
|
attributes: null,
|
|
57
66
|
id: null,
|
package/Form/RadioGroup/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
1
2
|
import React, { Component, Children, cloneElement } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import classNames from 'classnames';
|
|
@@ -7,51 +8,56 @@ import style from "./style";
|
|
|
7
8
|
/**
|
|
8
9
|
* RadioGroup component.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
let RadioGroup = /*#__PURE__*/function (_Component) {
|
|
11
13
|
/**
|
|
12
14
|
* Initializes the component.
|
|
13
15
|
* @param {Object} props The components props.
|
|
14
16
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
function RadioGroup(props) {
|
|
18
|
+
var _this;
|
|
19
|
+
_this = _Component.call(this, props) || this;
|
|
17
20
|
/**
|
|
18
21
|
* @param {string} event click from radio element
|
|
19
22
|
*/
|
|
20
|
-
|
|
23
|
+
_this.handleChange = ({
|
|
21
24
|
target: {
|
|
22
25
|
name
|
|
23
26
|
}
|
|
24
27
|
}) => {
|
|
25
|
-
if (
|
|
28
|
+
if (_this.props.disabled) {
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
|
-
if (!
|
|
29
|
-
|
|
31
|
+
if (!_this.props.isControlled) {
|
|
32
|
+
_this.setState({
|
|
30
33
|
value: name
|
|
31
34
|
});
|
|
32
35
|
}
|
|
33
|
-
|
|
36
|
+
_this.props.onChange(name);
|
|
34
37
|
};
|
|
35
|
-
|
|
38
|
+
_this.state = {
|
|
36
39
|
value: props.value
|
|
37
40
|
};
|
|
41
|
+
return _this;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
/**
|
|
41
45
|
* @param {Object} nextProps props
|
|
42
46
|
*/
|
|
43
|
-
|
|
47
|
+
_inheritsLoose(RadioGroup, _Component);
|
|
48
|
+
var _proto = RadioGroup.prototype;
|
|
49
|
+
_proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
44
50
|
if (this.props.isControlled && this.state.value !== nextProps.value) {
|
|
45
51
|
this.setState({
|
|
46
52
|
value: nextProps.value
|
|
47
53
|
});
|
|
48
54
|
}
|
|
49
|
-
}
|
|
55
|
+
};
|
|
50
56
|
/**
|
|
51
57
|
* Renders the component.
|
|
52
58
|
* @returns {JSX}
|
|
53
59
|
*/
|
|
54
|
-
render() {
|
|
60
|
+
_proto.render = function render() {
|
|
55
61
|
const {
|
|
56
62
|
children,
|
|
57
63
|
className,
|
|
@@ -63,7 +69,7 @@ class RadioGroup extends Component {
|
|
|
63
69
|
disabled,
|
|
64
70
|
showErrorText
|
|
65
71
|
} = this.props;
|
|
66
|
-
return /*#__PURE__*/
|
|
72
|
+
return /*#__PURE__*/_jsx(FormElement, {
|
|
67
73
|
className: classNames(className, 'radioGroup', 'ui-shared__form__radio-group', {
|
|
68
74
|
disabled
|
|
69
75
|
}),
|
|
@@ -74,21 +80,24 @@ class RadioGroup extends Component {
|
|
|
74
80
|
showErrorText: showErrorText,
|
|
75
81
|
htmlFor: "none",
|
|
76
82
|
hasUnderline: false,
|
|
77
|
-
hasValue: true
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
83
|
+
hasValue: true,
|
|
84
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
85
|
+
className: classNames(style.container(direction), 'radioGroup'),
|
|
86
|
+
children: Children.map(children, child => {
|
|
87
|
+
if (!child) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
91
|
+
key: `${name}_${child.props.name}`,
|
|
92
|
+
checked: this.state.value === child.props.name,
|
|
93
|
+
onChange: this.handleChange
|
|
94
|
+
});
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
return RadioGroup;
|
|
100
|
+
}(Component);
|
|
92
101
|
RadioGroup.defaultProps = {
|
|
93
102
|
onChange: () => {},
|
|
94
103
|
children: null,
|
package/Form/RadioGroup/spec.js
CHANGED
|
@@ -1,54 +1,66 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { mount } from 'enzyme';
|
|
4
3
|
import RadioItem from "./components/Item";
|
|
5
4
|
import RadioGroup from '.';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
6
|
const defProps = {
|
|
7
7
|
name: 'radio'
|
|
8
8
|
};
|
|
9
9
|
jest.mock('@shopgate/engage/components');
|
|
10
10
|
describe('<RadioGroup />', () => {
|
|
11
11
|
it('should render empty group', () => {
|
|
12
|
-
const wrapper = mount(/*#__PURE__*/
|
|
12
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
|
|
13
|
+
...defProps
|
|
14
|
+
}));
|
|
13
15
|
expect(wrapper).toMatchSnapshot();
|
|
14
16
|
});
|
|
15
17
|
it('should render column group with items', () => {
|
|
16
|
-
const wrapper = mount(/*#__PURE__*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
|
|
19
|
+
...defProps,
|
|
20
|
+
children: /*#__PURE__*/_jsx(RadioItem, {
|
|
21
|
+
name: "foo",
|
|
22
|
+
label: "foo"
|
|
23
|
+
})
|
|
24
|
+
}));
|
|
20
25
|
expect(wrapper).toMatchSnapshot();
|
|
21
26
|
expect(wrapper.find(RadioItem).length).toEqual(1);
|
|
22
27
|
expect(typeof wrapper.find(RadioItem).prop('onChange')).toEqual('function');
|
|
23
28
|
});
|
|
24
29
|
it('should render rows group with items', () => {
|
|
25
|
-
const wrapper = mount(/*#__PURE__*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
|
|
31
|
+
...defProps,
|
|
32
|
+
direction: "rows",
|
|
33
|
+
children: /*#__PURE__*/_jsx(RadioItem, {
|
|
34
|
+
name: "foo",
|
|
35
|
+
label: "foo"
|
|
36
|
+
})
|
|
37
|
+
}));
|
|
31
38
|
expect(wrapper).toMatchSnapshot();
|
|
32
39
|
});
|
|
33
40
|
it('should use default value', () => {
|
|
34
|
-
const wrapper = mount(/*#__PURE__*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
|
|
42
|
+
...defProps,
|
|
43
|
+
value: "foo",
|
|
44
|
+
children: /*#__PURE__*/_jsx(RadioItem, {
|
|
45
|
+
name: "foo",
|
|
46
|
+
label: "foo"
|
|
47
|
+
})
|
|
48
|
+
}));
|
|
40
49
|
expect(wrapper).toMatchSnapshot();
|
|
41
50
|
expect(wrapper.find(RadioItem).length).toEqual(1);
|
|
42
51
|
expect(wrapper.find(RadioItem).prop('checked')).toEqual(true);
|
|
43
52
|
});
|
|
44
53
|
it('should have on value at a time', () => {
|
|
45
|
-
const wrapper = mount(/*#__PURE__*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
const wrapper = mount(/*#__PURE__*/_jsxs(RadioGroup, {
|
|
55
|
+
...defProps,
|
|
56
|
+
children: [/*#__PURE__*/_jsx(RadioItem, {
|
|
57
|
+
name: "foo",
|
|
58
|
+
label: "foo"
|
|
59
|
+
}), /*#__PURE__*/_jsx(RadioItem, {
|
|
60
|
+
name: "bar",
|
|
61
|
+
label: "bar"
|
|
62
|
+
})]
|
|
63
|
+
}));
|
|
52
64
|
expect(wrapper).toMatchSnapshot();
|
|
53
65
|
expect(wrapper.find(RadioItem).length).toEqual(2);
|
|
54
66
|
const radio1 = wrapper.find(RadioItem).at(0).find('input');
|
|
@@ -68,12 +80,14 @@ describe('<RadioGroup />', () => {
|
|
|
68
80
|
});
|
|
69
81
|
it('should call onChange callback', () => {
|
|
70
82
|
const onChange = jest.fn();
|
|
71
|
-
const wrapper = mount(/*#__PURE__*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
const wrapper = mount(/*#__PURE__*/_jsx(RadioGroup, {
|
|
84
|
+
...defProps,
|
|
85
|
+
onChange: onChange,
|
|
86
|
+
children: /*#__PURE__*/_jsx(RadioItem, {
|
|
87
|
+
name: "foo",
|
|
88
|
+
label: "foo"
|
|
89
|
+
})
|
|
90
|
+
}));
|
|
77
91
|
expect(wrapper).toMatchSnapshot();
|
|
78
92
|
expect(wrapper.find(RadioItem).length).toEqual(1);
|
|
79
93
|
const radio = wrapper.find(RadioItem).at(0).find('input');
|