@shopgate/pwa-ui-shared 7.30.0-alpha.8 → 7.30.0-beta.1
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 +51 -32
- package/ActionButton/spec.js +13 -5
- package/AddToCartButton/index.js +44 -33
- package/AddToCartButton/mock.js +20 -8
- package/AddToCartButton/spec.js +29 -14
- 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 +27 -18
- 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 +48 -52
- 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/CameraOverlay/style.js +0 -1
- 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,9 +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";
|
|
6
|
+
jest.mock('@shopgate/engage/components');
|
|
5
7
|
describe('<FormBuilder />', () => {
|
|
6
8
|
it('should render empty form', () => {
|
|
7
|
-
const wrapper = mount(/*#__PURE__*/
|
|
9
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
8
10
|
config: {
|
|
9
11
|
fields: {}
|
|
10
12
|
},
|
|
@@ -14,7 +16,7 @@ describe('<FormBuilder />', () => {
|
|
|
14
16
|
expect(wrapper).toMatchSnapshot();
|
|
15
17
|
});
|
|
16
18
|
it('should render two text fields', () => {
|
|
17
|
-
const wrapper = mount(/*#__PURE__*/
|
|
19
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
18
20
|
config: {
|
|
19
21
|
fields: {
|
|
20
22
|
firstName: {
|
|
@@ -36,7 +38,7 @@ describe('<FormBuilder />', () => {
|
|
|
36
38
|
expect(wrapper.find('TextField').length).toEqual(2);
|
|
37
39
|
});
|
|
38
40
|
it('should not render invisible field', () => {
|
|
39
|
-
const wrapper = mount(/*#__PURE__*/
|
|
41
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
40
42
|
config: {
|
|
41
43
|
fields: {
|
|
42
44
|
firstName: {
|
|
@@ -53,7 +55,7 @@ describe('<FormBuilder />', () => {
|
|
|
53
55
|
expect(wrapper.find('TextField').length).toEqual(0);
|
|
54
56
|
});
|
|
55
57
|
it('should hide element if setVisibilty rule applies', () => {
|
|
56
|
-
const wrapper = mount(/*#__PURE__*/
|
|
58
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
57
59
|
config: {
|
|
58
60
|
fields: {
|
|
59
61
|
foo: {
|
|
@@ -95,7 +97,7 @@ describe('<FormBuilder />', () => {
|
|
|
95
97
|
expect(wrapper.find('TextField').length).toEqual(1);
|
|
96
98
|
});
|
|
97
99
|
it('should reset value when rule applies', () => {
|
|
98
|
-
const wrapper = mount(/*#__PURE__*/
|
|
100
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
99
101
|
config: {
|
|
100
102
|
fields: {
|
|
101
103
|
foo: {
|
|
@@ -149,7 +151,7 @@ describe('<FormBuilder />', () => {
|
|
|
149
151
|
});
|
|
150
152
|
it('should call onChange callback when input is changed', () => {
|
|
151
153
|
const handleUpdate = jest.fn();
|
|
152
|
-
const wrapper = mount(/*#__PURE__*/
|
|
154
|
+
const wrapper = mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
153
155
|
config: {
|
|
154
156
|
fields: {
|
|
155
157
|
foo: {
|
|
@@ -186,9 +188,10 @@ describe('<FormBuilder />', () => {
|
|
|
186
188
|
});
|
|
187
189
|
describe('FormBuilder::elementChangeHandler', () => {
|
|
188
190
|
it('should take the updated state from action listener', () => {
|
|
189
|
-
// Create mocked Form builder.
|
|
190
191
|
const handleUpdate = jest.fn();
|
|
191
|
-
const
|
|
192
|
+
const ref = /*#__PURE__*/React.createRef();
|
|
193
|
+
mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
194
|
+
ref: ref,
|
|
192
195
|
validationErrors: [],
|
|
193
196
|
config: {
|
|
194
197
|
fields: {
|
|
@@ -200,9 +203,11 @@ describe('<FormBuilder />', () => {
|
|
|
200
203
|
}
|
|
201
204
|
}
|
|
202
205
|
},
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
name: "foo",
|
|
207
|
+
id: "foo",
|
|
208
|
+
handleUpdate: handleUpdate
|
|
209
|
+
}));
|
|
210
|
+
ref.current.actionListener.notify = () => ({
|
|
206
211
|
formData: {
|
|
207
212
|
foo: 'bar'
|
|
208
213
|
},
|
|
@@ -213,7 +218,7 @@ describe('<FormBuilder />', () => {
|
|
|
213
218
|
});
|
|
214
219
|
|
|
215
220
|
// Trigger update
|
|
216
|
-
|
|
221
|
+
ref.current.elementChangeHandler('foo', 'bar');
|
|
217
222
|
|
|
218
223
|
// Test
|
|
219
224
|
expect(handleUpdate).toHaveBeenCalledWith({
|
|
@@ -223,7 +228,9 @@ describe('<FormBuilder />', () => {
|
|
|
223
228
|
it('should consider backend validations', () => {
|
|
224
229
|
// Create mocked Form builder.
|
|
225
230
|
const handleUpdate = jest.fn();
|
|
226
|
-
const
|
|
231
|
+
const ref = /*#__PURE__*/React.createRef();
|
|
232
|
+
mount(/*#__PURE__*/_jsx(FormBuilder, {
|
|
233
|
+
ref: ref,
|
|
227
234
|
validationErrors: [{}],
|
|
228
235
|
config: {
|
|
229
236
|
fields: {
|
|
@@ -235,9 +242,11 @@ describe('<FormBuilder />', () => {
|
|
|
235
242
|
}
|
|
236
243
|
}
|
|
237
244
|
},
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
245
|
+
name: "foo",
|
|
246
|
+
id: "foo",
|
|
247
|
+
handleUpdate: handleUpdate
|
|
248
|
+
}));
|
|
249
|
+
ref.current.actionListener.notify = () => ({
|
|
241
250
|
formData: {
|
|
242
251
|
foo: 'bar'
|
|
243
252
|
},
|
|
@@ -248,7 +257,7 @@ describe('<FormBuilder />', () => {
|
|
|
248
257
|
});
|
|
249
258
|
|
|
250
259
|
// Trigger update
|
|
251
|
-
|
|
260
|
+
ref.current.elementChangeHandler('foo', 'bar');
|
|
252
261
|
|
|
253
262
|
// Test
|
|
254
263
|
expect(handleUpdate).toHaveBeenCalledWith({
|
|
@@ -293,7 +302,7 @@ describe('<FormBuilder />', () => {
|
|
|
293
302
|
...field1,
|
|
294
303
|
sortOrder: 2
|
|
295
304
|
}];
|
|
296
|
-
expect(fields.sort(builder.elementSortFunc)).toEqual([
|
|
305
|
+
expect(fields.sort(builder.elementSortFunc)).toEqual([].concat(fields));
|
|
297
306
|
});
|
|
298
307
|
});
|
|
299
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,
|