@gympass/yoga 7.60.0 → 7.60.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/cjs/Drawer/web/Content.js +1 -4
- package/esm/Drawer/web/Content.js +1 -4
- package/package.json +5 -5
- package/cjs/ActionRequirement/native/ActionRequirement.test.js +0 -1
- package/cjs/ActionRequirement/web/ActionRequirement.test.js +0 -40
- package/cjs/AutoComplete/web/AutoComplete.test.js +0 -156
- package/cjs/Avatar/native/Avatar.test.js +0 -1
- package/cjs/Avatar/web/Avatar.test.js +0 -72
- package/cjs/Banner/native/Banner.test.js +0 -1
- package/cjs/Banner/web/Banner.test.js +0 -121
- package/cjs/BottomSheet/web/BottomSheet.test.js +0 -61
- package/cjs/Box/native/Box.test.js +0 -1
- package/cjs/Box/web/Box.test.js +0 -23
- package/cjs/Button/native/Button.test.js +0 -1
- package/cjs/Button/web/Button.test.js +0 -778
- package/cjs/Card/native/Card/Card.test.js +0 -1
- package/cjs/Card/native/EventCard/EventCard.test.js +0 -1
- package/cjs/Card/native/GymCard/CheckIn/CheckIn.test.js +0 -1
- package/cjs/Card/native/PlanCard/PlanCard.test.js +0 -1
- package/cjs/Card/web/Card/Card.test.js +0 -22
- package/cjs/Card/web/EventCard/EventCard.test.js +0 -35
- package/cjs/Card/web/PlanCard/PlanCard.test.js +0 -104
- package/cjs/Checkbox/native/Checkbox.test.js +0 -1
- package/cjs/Checkbox/native/Switch.test.js +0 -1
- package/cjs/Checkbox/web/Checkbox.test.js +0 -161
- package/cjs/Checkbox/web/Switch.test.js +0 -65
- package/cjs/Chips/native/Chips.test.js +0 -1
- package/cjs/Chips/web/Chips.test.js +0 -138
- package/cjs/Datepicker/web/Datepicker.test.js +0 -286
- package/cjs/Dialog/web/Dialog.test.js +0 -78
- package/cjs/Divider/native/Divider.test.js +0 -1
- package/cjs/Divider/web/Divider.test.js +0 -36
- package/cjs/Drawer/web/Drawer.test.js +0 -46
- package/cjs/Dropdown/native/Backdrop.test.js +0 -1
- package/cjs/Dropdown/native/Dropdown.test.js +0 -1
- package/cjs/Dropdown/web/Dropdown.test.js +0 -102
- package/cjs/Feedback/web/Feedback.test.js +0 -89
- package/cjs/Grid/web/Col.test.js +0 -56
- package/cjs/Grid/web/Container.test.js +0 -22
- package/cjs/Grid/web/Hide.test.js +0 -39
- package/cjs/Grid/web/Row.test.js +0 -22
- package/cjs/Header/web/Header.test.js +0 -49
- package/cjs/Heading/web/Heading.test.js +0 -68
- package/cjs/Icon/native/Icon.test.js +0 -1
- package/cjs/Icon/web/Icon.test.js +0 -53
- package/cjs/Input/native/Email.test.js +0 -1
- package/cjs/Input/native/Input.test.js +0 -1
- package/cjs/Input/native/Number.test.js +0 -1
- package/cjs/Input/native/Password.test.js +0 -1
- package/cjs/Input/native/Tel.test.js +0 -1
- package/cjs/Input/web/Email.test.js +0 -20
- package/cjs/Input/web/Input.test.js +0 -161
- package/cjs/Input/web/Number.test.js +0 -20
- package/cjs/Input/web/Password.test.js +0 -103
- package/cjs/Input/web/Tel.test.js +0 -20
- package/cjs/List/native/List.test.js +0 -1
- package/cjs/List/web/List.test.js +0 -69
- package/cjs/Menu/web/Menu.test.js +0 -123
- package/cjs/Popover/web/Popover.test.js +0 -27
- package/cjs/Progress/native/Progress.test.js +0 -1
- package/cjs/Progress/web/Progress.test.js +0 -229
- package/cjs/RadioGroup/native/Button/RadioButton.test.js +0 -1
- package/cjs/RadioGroup/native/Radio/Radio.test.js +0 -1
- package/cjs/RadioGroup/native/RadioGroup.test.js +0 -1
- package/cjs/RadioGroup/web/Button/RadioButton.test.js +0 -132
- package/cjs/RadioGroup/web/Radio/Radio.test.js +0 -119
- package/cjs/RadioGroup/web/RadioGroup.test.js +0 -93
- package/cjs/Rating/native/Rating.test.js +0 -1
- package/cjs/Rating/web/Rating.test.js +0 -201
- package/cjs/Result/native/Result.test.js +0 -1
- package/cjs/Skeleton/native/Skeleton.test.js +0 -1
- package/cjs/Skeleton/web/Skeleton.test.js +0 -84
- package/cjs/Slider/native/Slider.test.js +0 -1
- package/cjs/Slider/web/Slider.test.js +0 -95
- package/cjs/Snackbar/native/Snackbar.test.js +0 -1
- package/cjs/Snackbar/web/Snackbar.test.js +0 -137
- package/cjs/Stepper/native/Stepper.test.js +0 -1
- package/cjs/Stepper/web/Stepper.test.js +0 -75
- package/cjs/Tag/native/Tag.test.js +0 -1
- package/cjs/Tag/web/Tag.test.js +0 -87
- package/cjs/Text/native/Text.test.js +0 -1
- package/cjs/Text/web/Text.test.js +0 -157
- package/cjs/TextArea/native/TextArea.test.js +0 -1
- package/cjs/TextArea/web/TextArea.test.js +0 -18
- package/cjs/Theme/Provider/web/FontLoader.test.js +0 -19
- package/cjs/Theme/Provider/web/GlobalStyle.test.js +0 -27
- package/cjs/Theme/helpers/themeReader/native/native.test.js +0 -1
- package/cjs/Theme/helpers/themeReader/web/web.test.js +0 -54
- package/esm/ActionRequirement/index.native.js +0 -2
- package/esm/ActionRequirement/native/ActionRequirement.js +0 -48
- package/esm/ActionRequirement/native/ActionRequirement.test.js +0 -45
- package/esm/ActionRequirement/native/ActionRequirementStyles.js +0 -25
- package/esm/ActionRequirement/native/index.js +0 -6
- package/esm/ActionRequirement/web/ActionRequirement.test.js +0 -31
- package/esm/AutoComplete/web/AutoComplete.test.js +0 -139
- package/esm/Avatar/index.native.js +0 -4
- package/esm/Avatar/native/Avatar.js +0 -96
- package/esm/Avatar/native/Avatar.test.js +0 -46
- package/esm/Avatar/native/AvatarCircle.js +0 -24
- package/esm/Avatar/web/Avatar.test.js +0 -63
- package/esm/Banner/index.native.js +0 -2
- package/esm/Banner/native/Banner.js +0 -128
- package/esm/Banner/native/Banner.test.js +0 -103
- package/esm/Banner/native/index.js +0 -2
- package/esm/Banner/web/Banner.test.js +0 -109
- package/esm/BottomSheet/web/BottomSheet.test.js +0 -48
- package/esm/Box/index.native.js +0 -2
- package/esm/Box/native/Box.js +0 -4
- package/esm/Box/native/Box.test.js +0 -16
- package/esm/Box/native/index.js +0 -2
- package/esm/Box/web/Box.test.js +0 -16
- package/esm/Button/index.native.js +0 -8
- package/esm/Button/native/Button.js +0 -110
- package/esm/Button/native/Button.test.js +0 -475
- package/esm/Button/native/Icon.js +0 -82
- package/esm/Button/native/Link.js +0 -35
- package/esm/Button/native/Text.js +0 -74
- package/esm/Button/native/withTouchable.js +0 -63
- package/esm/Button/web/Button.test.js +0 -764
- package/esm/Card/index.native.js +0 -2
- package/esm/Card/native/Card/Actions.js +0 -12
- package/esm/Card/native/Card/Card.js +0 -92
- package/esm/Card/native/Card/Card.test.js +0 -15
- package/esm/Card/native/Card/Content.js +0 -8
- package/esm/Card/native/Card/Header.js +0 -8
- package/esm/Card/native/Card/index.js +0 -8
- package/esm/Card/native/EventCard/EventCard.js +0 -169
- package/esm/Card/native/EventCard/EventCard.test.js +0 -65
- package/esm/Card/native/EventCard/index.js +0 -2
- package/esm/Card/native/GymCard/CheckIn/Avatar.js +0 -17
- package/esm/Card/native/GymCard/CheckIn/CheckIn.js +0 -66
- package/esm/Card/native/GymCard/CheckIn/CheckIn.test.js +0 -39
- package/esm/Card/native/GymCard/CheckIn/Content.js +0 -11
- package/esm/Card/native/GymCard/CheckIn/Header.js +0 -11
- package/esm/Card/native/GymCard/CheckIn/index.js +0 -2
- package/esm/Card/native/GymCard/index.js +0 -5
- package/esm/Card/native/PlanCard/Actions.js +0 -22
- package/esm/Card/native/PlanCard/Content.js +0 -75
- package/esm/Card/native/PlanCard/List.js +0 -73
- package/esm/Card/native/PlanCard/PlanCard.js +0 -51
- package/esm/Card/native/PlanCard/PlanCard.test.js +0 -84
- package/esm/Card/native/PlanCard/Subtitle.js +0 -15
- package/esm/Card/native/PlanCard/Tag.js +0 -34
- package/esm/Card/native/PlanCard/index.js +0 -15
- package/esm/Card/native/index.js +0 -5
- package/esm/Card/web/Card/Card.test.js +0 -14
- package/esm/Card/web/EventCard/EventCard.test.js +0 -27
- package/esm/Card/web/PlanCard/PlanCard.test.js +0 -94
- package/esm/Checkbox/index.native.js +0 -3
- package/esm/Checkbox/native/Checkbox.js +0 -179
- package/esm/Checkbox/native/Checkbox.test.js +0 -115
- package/esm/Checkbox/native/Switch.js +0 -115
- package/esm/Checkbox/native/Switch.test.js +0 -54
- package/esm/Checkbox/native/index.js +0 -3
- package/esm/Checkbox/web/Checkbox.test.js +0 -153
- package/esm/Checkbox/web/Switch.test.js +0 -56
- package/esm/Chips/index.native.js +0 -2
- package/esm/Chips/native/Chips.js +0 -104
- package/esm/Chips/native/Chips.test.js +0 -143
- package/esm/Chips/native/Counter.js +0 -20
- package/esm/Chips/native/index.js +0 -2
- package/esm/Chips/web/Chips.test.js +0 -128
- package/esm/Datepicker/web/Datepicker.test.js +0 -247
- package/esm/Dialog/web/Dialog.test.js +0 -62
- package/esm/Divider/index.native.js +0 -2
- package/esm/Divider/native/Divider.js +0 -29
- package/esm/Divider/native/Divider.test.js +0 -29
- package/esm/Divider/native/index.js +0 -2
- package/esm/Divider/web/Divider.test.js +0 -29
- package/esm/Drawer/web/Drawer.test.js +0 -33
- package/esm/Dropdown/index.native.js +0 -2
- package/esm/Dropdown/native/Backdrop.js +0 -93
- package/esm/Dropdown/native/Backdrop.test.js +0 -26
- package/esm/Dropdown/native/Dropdown.js +0 -142
- package/esm/Dropdown/native/Dropdown.test.js +0 -78
- package/esm/Dropdown/native/Options.android.js +0 -66
- package/esm/Dropdown/native/Options.ios.js +0 -71
- package/esm/Dropdown/native/index.js +0 -2
- package/esm/Dropdown/web/Dropdown.test.js +0 -93
- package/esm/Feedback/web/Feedback.test.js +0 -83
- package/esm/Grid/web/Col.test.js +0 -48
- package/esm/Grid/web/Container.test.js +0 -14
- package/esm/Grid/web/Hide.test.js +0 -31
- package/esm/Grid/web/Row.test.js +0 -14
- package/esm/Header/web/Header.test.js +0 -38
- package/esm/Heading/web/Heading.test.js +0 -58
- package/esm/Icon/index.native.js +0 -2
- package/esm/Icon/native/Icon.test.js +0 -47
- package/esm/Icon/native/index.js +0 -2
- package/esm/Icon/web/Icon.test.js +0 -47
- package/esm/Input/index.native.js +0 -6
- package/esm/Input/native/Email.js +0 -15
- package/esm/Input/native/Email.test.js +0 -13
- package/esm/Input/native/Helper.js +0 -62
- package/esm/Input/native/Input.js +0 -234
- package/esm/Input/native/Input.test.js +0 -181
- package/esm/Input/native/Number.js +0 -12
- package/esm/Input/native/Number.test.js +0 -13
- package/esm/Input/native/Password.js +0 -112
- package/esm/Input/native/Password.test.js +0 -125
- package/esm/Input/native/Tel.js +0 -14
- package/esm/Input/native/Tel.test.js +0 -13
- package/esm/Input/native/index.js +0 -6
- package/esm/Input/web/Email.test.js +0 -13
- package/esm/Input/web/Input.test.js +0 -145
- package/esm/Input/web/Number.test.js +0 -13
- package/esm/Input/web/Password.test.js +0 -90
- package/esm/Input/web/Tel.test.js +0 -13
- package/esm/List/index.native.js +0 -3
- package/esm/List/native/List.js +0 -22
- package/esm/List/native/List.test.js +0 -106
- package/esm/List/native/ListItem.js +0 -51
- package/esm/List/native/index.js +0 -3
- package/esm/List/web/List.test.js +0 -62
- package/esm/Menu/web/Menu.test.js +0 -115
- package/esm/Popover/web/Popover.test.js +0 -19
- package/esm/Progress/index.native.js +0 -2
- package/esm/Progress/native/Progress.js +0 -103
- package/esm/Progress/native/Progress.test.js +0 -222
- package/esm/Progress/native/index.js +0 -2
- package/esm/Progress/web/Progress.test.js +0 -222
- package/esm/RadioGroup/index.native.js +0 -4
- package/esm/RadioGroup/native/Button/RadioButton.js +0 -64
- package/esm/RadioGroup/native/Button/RadioButton.test.js +0 -96
- package/esm/RadioGroup/native/Radio/Radio.js +0 -88
- package/esm/RadioGroup/native/Radio/Radio.test.js +0 -112
- package/esm/RadioGroup/native/RadioGroup.js +0 -66
- package/esm/RadioGroup/native/RadioGroup.test.js +0 -50
- package/esm/RadioGroup/native/index.js +0 -4
- package/esm/RadioGroup/web/Button/RadioButton.test.js +0 -121
- package/esm/RadioGroup/web/Radio/Radio.test.js +0 -108
- package/esm/RadioGroup/web/RadioGroup.test.js +0 -83
- package/esm/Rating/index.native.js +0 -2
- package/esm/Rating/native/Rating.js +0 -186
- package/esm/Rating/native/Rating.test.js +0 -121
- package/esm/Rating/native/index.js +0 -2
- package/esm/Rating/web/Rating.test.js +0 -184
- package/esm/Result/index.native.js +0 -8
- package/esm/Result/native/Attendances.js +0 -55
- package/esm/Result/native/Details.js +0 -97
- package/esm/Result/native/Rate.js +0 -35
- package/esm/Result/native/Result.js +0 -86
- package/esm/Result/native/Result.test.js +0 -107
- package/esm/Result/native/ResultButton.js +0 -13
- package/esm/Result/native/Tags.js +0 -41
- package/esm/Result/native/TinyTextIcon.js +0 -18
- package/esm/Result/native/index.js +0 -2
- package/esm/Skeleton/index.native.js +0 -2
- package/esm/Skeleton/native/Skeleton.js +0 -94
- package/esm/Skeleton/native/Skeleton.test.js +0 -78
- package/esm/Skeleton/native/index.js +0 -2
- package/esm/Skeleton/web/Skeleton.test.js +0 -77
- package/esm/Slider/index.native.js +0 -2
- package/esm/Slider/native/Label.js +0 -19
- package/esm/Slider/native/Marker.js +0 -68
- package/esm/Slider/native/Slider.js +0 -156
- package/esm/Slider/native/Slider.test.js +0 -122
- package/esm/Slider/native/Step.js +0 -14
- package/esm/Slider/native/Tooltip.js +0 -90
- package/esm/Slider/web/Slider.test.js +0 -86
- package/esm/Snackbar/index.native.js +0 -2
- package/esm/Snackbar/native/Snackbar.js +0 -199
- package/esm/Snackbar/native/Snackbar.test.js +0 -100
- package/esm/Snackbar/native/SnackbarAnimationWrapper.js +0 -124
- package/esm/Snackbar/native/index.js +0 -2
- package/esm/Snackbar/web/Snackbar.test.js +0 -118
- package/esm/Stepper/index.native.js +0 -3
- package/esm/Stepper/native/Dots.js +0 -45
- package/esm/Stepper/native/Line.js +0 -35
- package/esm/Stepper/native/Step.js +0 -19
- package/esm/Stepper/native/Stepper.js +0 -52
- package/esm/Stepper/native/Stepper.test.js +0 -70
- package/esm/Stepper/native/index.js +0 -3
- package/esm/Stepper/web/Stepper.test.js +0 -67
- package/esm/Tag/index.native.js +0 -4
- package/esm/Tag/native/Informative.js +0 -72
- package/esm/Tag/native/Tag.js +0 -75
- package/esm/Tag/native/Tag.test.js +0 -94
- package/esm/Tag/native/index.js +0 -2
- package/esm/Tag/web/Tag.test.js +0 -79
- package/esm/Text/index.native.js +0 -16
- package/esm/Text/native/Text.js +0 -69
- package/esm/Text/native/Text.test.js +0 -149
- package/esm/Text/native/index.js +0 -2
- package/esm/Text/web/Text.test.js +0 -149
- package/esm/TextArea/index.native.js +0 -2
- package/esm/TextArea/native/TextArea.js +0 -59
- package/esm/TextArea/native/TextArea.test.js +0 -11
- package/esm/TextArea/native/index.js +0 -2
- package/esm/TextArea/web/TextArea.test.js +0 -11
- package/esm/Theme/Provider/index.native.js +0 -2
- package/esm/Theme/Provider/native/index.js +0 -2
- package/esm/Theme/Provider/web/FontLoader.test.js +0 -11
- package/esm/Theme/Provider/web/GlobalStyle.test.js +0 -17
- package/esm/Theme/helpers/themeReader/native/native.test.js +0 -53
- package/esm/Theme/helpers/themeReader/web/web.test.js +0 -41
- package/esm/Theme/index.native.js +0 -5
- package/esm/index.native.js +0 -26
- package/esm/shared/index.native.js +0 -2
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
var _excluded = ["value", "children"],
|
|
2
|
-
_excluded2 = ["onChange", "small", "selectedValue"];
|
|
3
|
-
|
|
4
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
|
-
|
|
6
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
7
|
-
|
|
8
|
-
import React, { useContext } from 'react';
|
|
9
|
-
import { string, oneOfType, number, node } from 'prop-types';
|
|
10
|
-
import { TouchableWithoutFeedback } from 'react-native';
|
|
11
|
-
import styled from 'styled-components';
|
|
12
|
-
import RadioGroupContext from '../../RadioGroupContext';
|
|
13
|
-
var RadioMark = styled.View(function (_ref) {
|
|
14
|
-
var radiogroup = _ref.theme.yoga.components.radiogroup,
|
|
15
|
-
small = _ref.small,
|
|
16
|
-
checked = _ref.checked;
|
|
17
|
-
return "\n align-items: center;\n justify-content: center;\n\n height: " + (small ? radiogroup.button.height.small : radiogroup.button.height.normal) + "px;\n padding-left: " + radiogroup.button.padding.left + "px;\n padding-right: " + radiogroup.button.padding.right + "px;\n\n background-color: " + radiogroup.button.backgroundColor + ";\n border-radius: " + radiogroup.button.border.radius + "px;\n\n font-size: " + radiogroup.font.size + "px;\n\n " + (checked ? "\n background-color: " + radiogroup.checked.backgroundColor + ";\n " : "") + "\n";
|
|
18
|
-
});
|
|
19
|
-
var Text = styled.Text(function (_ref2) {
|
|
20
|
-
var _ref2$theme$yoga = _ref2.theme.yoga,
|
|
21
|
-
baseFont = _ref2$theme$yoga.baseFont,
|
|
22
|
-
radiogroup = _ref2$theme$yoga.components.radiogroup,
|
|
23
|
-
checked = _ref2.checked;
|
|
24
|
-
return "\n font-family: " + baseFont.family + ";\n color: " + radiogroup.font.color + ";\n\n " + (checked ? "\n color: " + radiogroup.checked.font.color + ";\n font-weight: " + radiogroup.checked.font.weight + ";\n " : '') + "\n ";
|
|
25
|
-
});
|
|
26
|
-
/** Radio group allows user to select one option from a set of options. Use
|
|
27
|
-
value on group to set the selected option. */
|
|
28
|
-
|
|
29
|
-
var RadioGroupButton = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
30
|
-
var value = _ref3.value,
|
|
31
|
-
children = _ref3.children,
|
|
32
|
-
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
33
|
-
|
|
34
|
-
var _useContext = useContext(RadioGroupContext),
|
|
35
|
-
onChange = _useContext.onChange,
|
|
36
|
-
small = _useContext.small,
|
|
37
|
-
selectedValue = _useContext.selectedValue,
|
|
38
|
-
context = _objectWithoutPropertiesLoose(_useContext, _excluded2);
|
|
39
|
-
|
|
40
|
-
var inputValue = value || children;
|
|
41
|
-
var checked = inputValue === selectedValue;
|
|
42
|
-
return /*#__PURE__*/React.createElement(TouchableWithoutFeedback, _extends({
|
|
43
|
-
onPress: function onPress() {
|
|
44
|
-
onChange({
|
|
45
|
-
value: inputValue
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}, context), /*#__PURE__*/React.createElement(RadioMark, _extends({
|
|
49
|
-
small: small,
|
|
50
|
-
checked: checked,
|
|
51
|
-
ref: ref
|
|
52
|
-
}, rest), /*#__PURE__*/React.createElement(Text, {
|
|
53
|
-
checked: checked
|
|
54
|
-
}, children)));
|
|
55
|
-
});
|
|
56
|
-
RadioGroupButton.displayName = 'RadioGroup.Button';
|
|
57
|
-
RadioGroupButton.propTypes = {
|
|
58
|
-
value: oneOfType([string, number]),
|
|
59
|
-
children: node.isRequired
|
|
60
|
-
};
|
|
61
|
-
RadioGroupButton.defaultProps = {
|
|
62
|
-
value: ''
|
|
63
|
-
};
|
|
64
|
-
export default RadioGroupButton;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react-native';
|
|
3
|
-
import RadioGroup from '../..';
|
|
4
|
-
import ThemeProvider from '../../../Theme';
|
|
5
|
-
import RadioGroupContext from '../../RadioGroupContext';
|
|
6
|
-
describe('<RadioGroup />', function () {
|
|
7
|
-
describe('<RadioGroup.Button />', function () {
|
|
8
|
-
describe('Snapshots', function () {
|
|
9
|
-
it('should match snapshot with default radio button', function () {
|
|
10
|
-
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Radio 1"))),
|
|
11
|
-
container = _render.container,
|
|
12
|
-
toJSON = _render.toJSON;
|
|
13
|
-
|
|
14
|
-
expect(toJSON(container)).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
it('should match snapshot with small radio button', function () {
|
|
17
|
-
var _render2 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
18
|
-
value: {
|
|
19
|
-
small: true
|
|
20
|
-
}
|
|
21
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Radio 1")))),
|
|
22
|
-
container = _render2.container,
|
|
23
|
-
toJSON = _render2.toJSON;
|
|
24
|
-
|
|
25
|
-
expect(toJSON(container)).toMatchSnapshot();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
describe('Props', function () {
|
|
29
|
-
it('checked should be the selectedValue provided from Context', function () {
|
|
30
|
-
var _render3 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
31
|
-
value: {
|
|
32
|
-
selectedValue: 'Radio 2'
|
|
33
|
-
}
|
|
34
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Radio 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Radio 2")))),
|
|
35
|
-
getAllByText = _render3.getAllByText;
|
|
36
|
-
|
|
37
|
-
var _getAllByText = getAllByText(/^Radio/),
|
|
38
|
-
radio = _getAllByText[0],
|
|
39
|
-
radio2 = _getAllByText[1];
|
|
40
|
-
|
|
41
|
-
expect(radio.props.checked).toBe(false);
|
|
42
|
-
expect(radio2.props.checked).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe('Events', function () {
|
|
46
|
-
it('should call onchange from Context', function () {
|
|
47
|
-
var onChangeMock = jest.fn();
|
|
48
|
-
|
|
49
|
-
var _render4 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
50
|
-
value: {
|
|
51
|
-
onChange: onChangeMock
|
|
52
|
-
}
|
|
53
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Radio 1")))),
|
|
54
|
-
getByText = _render4.getByText;
|
|
55
|
-
|
|
56
|
-
var radio = getByText(/^Radio/);
|
|
57
|
-
fireEvent.press(radio);
|
|
58
|
-
expect(onChangeMock).toHaveBeenCalled();
|
|
59
|
-
});
|
|
60
|
-
it('value should be as prop value', function () {
|
|
61
|
-
var onChangeMock = jest.fn();
|
|
62
|
-
|
|
63
|
-
var _render5 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
64
|
-
value: {
|
|
65
|
-
onChange: onChangeMock
|
|
66
|
-
}
|
|
67
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
68
|
-
value: "radio1"
|
|
69
|
-
}, "Radio 1")))),
|
|
70
|
-
getByText = _render5.getByText;
|
|
71
|
-
|
|
72
|
-
var radio = getByText(/^Radio/);
|
|
73
|
-
fireEvent.press(radio);
|
|
74
|
-
expect(onChangeMock).toHaveBeenCalledWith({
|
|
75
|
-
value: 'radio1'
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
it('value should be children if prop value is ommited', function () {
|
|
79
|
-
var onChangeMock = jest.fn();
|
|
80
|
-
|
|
81
|
-
var _render6 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
82
|
-
value: {
|
|
83
|
-
onChange: onChangeMock
|
|
84
|
-
}
|
|
85
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Radio 1")))),
|
|
86
|
-
getByText = _render6.getByText;
|
|
87
|
-
|
|
88
|
-
var radio = getByText(/^Radio/);
|
|
89
|
-
fireEvent.press(radio);
|
|
90
|
-
expect(onChangeMock).toHaveBeenCalledWith({
|
|
91
|
-
value: 'Radio 1'
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
var _excluded = ["value", "disabled"],
|
|
2
|
-
_excluded2 = ["onChange", "small", "selectedValue"];
|
|
3
|
-
|
|
4
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
|
-
|
|
6
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
7
|
-
|
|
8
|
-
import React, { useContext, useState } from 'react';
|
|
9
|
-
import styled from 'styled-components';
|
|
10
|
-
import { string, oneOfType, number, bool } from 'prop-types';
|
|
11
|
-
import { TouchableWithoutFeedback } from 'react-native';
|
|
12
|
-
import { hexToRgb } from '@gympass/yoga-common';
|
|
13
|
-
import RadioGroupContext from '../../RadioGroupContext';
|
|
14
|
-
var RadioMark = styled.View(function (_ref) {
|
|
15
|
-
var _ref$theme$yoga = _ref.theme.yoga,
|
|
16
|
-
white = _ref$theme$yoga.colors.white,
|
|
17
|
-
radiogroup = _ref$theme$yoga.components.radiogroup,
|
|
18
|
-
checked = _ref.checked,
|
|
19
|
-
disabled = _ref.disabled,
|
|
20
|
-
pressed = _ref.pressed;
|
|
21
|
-
return "\n justify-content: center;\n align-items: center;\n \n height: " + radiogroup.radio.size + "px;\n width: " + radiogroup.radio.size + "px;\n\n background-color: " + (pressed ? hexToRgb(radiogroup.hover.backgroundColor, 0.75) : white) + ";\n\n border-width: " + radiogroup.radio.size * 0.1 + "px;\n border-style: solid;\n border-color: " + radiogroup.radio.backgroundColor + ";\n border-radius: " + radiogroup.radio.border.radius + "px;\n\n " + (checked ? "\n border-color: " + radiogroup.checked.backgroundColor + ";\n background-color: " + (pressed ? hexToRgb(radiogroup.checked.hover.backgroundColor, 0.75) : white) + "\n " : "") + "\n\n " + (disabled ? "\n border-color: " + radiogroup.disabled.backgroundColor + ";\n " : "") + "\n";
|
|
22
|
-
});
|
|
23
|
-
var Dot = styled.View(function (_ref2) {
|
|
24
|
-
var radiogroup = _ref2.theme.yoga.components.radiogroup,
|
|
25
|
-
checked = _ref2.checked,
|
|
26
|
-
disabled = _ref2.disabled;
|
|
27
|
-
return "\n height: " + radiogroup.radio.size * 0.5 + "px;\n width: " + radiogroup.radio.size * 0.5 + "px;\n\n background-color: " + radiogroup.radio.backgroundColor + ";\n border-radius: " + radiogroup.radio.border.radius + "px;\n\n " + (checked ? "\n background-color: " + radiogroup.checked.backgroundColor + ";\n " : "") + "\n\n " + (disabled ? "\n background-color: " + radiogroup.disabled.backgroundColor + ";\n " : "") + "\n";
|
|
28
|
-
});
|
|
29
|
-
var Shadow = styled.View(function (_ref3) {
|
|
30
|
-
var checked = _ref3.checked,
|
|
31
|
-
radiogroup = _ref3.theme.yoga.components.radiogroup;
|
|
32
|
-
return "\n position: absolute;\n height: " + (radiogroup.radio.size + radiogroup.radio.size * 0.4 * 2) + "px;\n width: " + (radiogroup.radio.size + radiogroup.radio.size * 0.4 * 2) + "px;\n\n border-width: " + radiogroup.radio.size * 0.4 + "px;\n border-style: solid;\n border-color: " + (checked ? hexToRgb(radiogroup.checked.hover.backgroundColor, 0.75) : hexToRgb(radiogroup.hover.backgroundColor, 0.75)) + ";\n border-radius: " + radiogroup.radio.border.radius + "px;\n\n opacity: 0.75;\n";
|
|
33
|
-
});
|
|
34
|
-
/** The Radio is a type of selection control that allows the user to select a
|
|
35
|
-
* single option from a list. */
|
|
36
|
-
|
|
37
|
-
var RadioGroupRadio = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
38
|
-
var value = _ref4.value,
|
|
39
|
-
disabled = _ref4.disabled,
|
|
40
|
-
rest = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
41
|
-
|
|
42
|
-
var _useContext = useContext(RadioGroupContext),
|
|
43
|
-
onChange = _useContext.onChange,
|
|
44
|
-
small = _useContext.small,
|
|
45
|
-
selectedValue = _useContext.selectedValue,
|
|
46
|
-
context = _objectWithoutPropertiesLoose(_useContext, _excluded2);
|
|
47
|
-
|
|
48
|
-
var _useState = useState(false),
|
|
49
|
-
pressing = _useState[0],
|
|
50
|
-
togglePressing = _useState[1];
|
|
51
|
-
|
|
52
|
-
var inputValue = value;
|
|
53
|
-
var checked = inputValue === selectedValue;
|
|
54
|
-
return /*#__PURE__*/React.createElement(TouchableWithoutFeedback, _extends({
|
|
55
|
-
onPressIn: function onPressIn() {
|
|
56
|
-
togglePressing(true);
|
|
57
|
-
},
|
|
58
|
-
onPress: function onPress() {
|
|
59
|
-
onChange({
|
|
60
|
-
value: inputValue
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
onPressOut: function onPressOut() {
|
|
64
|
-
togglePressing(false);
|
|
65
|
-
},
|
|
66
|
-
disabled: disabled
|
|
67
|
-
}, context), /*#__PURE__*/React.createElement(RadioMark, _extends({
|
|
68
|
-
checked: checked,
|
|
69
|
-
disabled: disabled,
|
|
70
|
-
pressed: pressing,
|
|
71
|
-
ref: ref
|
|
72
|
-
}, rest), checked && /*#__PURE__*/React.createElement(Dot, {
|
|
73
|
-
checked: checked,
|
|
74
|
-
disabled: disabled
|
|
75
|
-
}), pressing && /*#__PURE__*/React.createElement(Shadow, {
|
|
76
|
-
checked: checked
|
|
77
|
-
})));
|
|
78
|
-
});
|
|
79
|
-
RadioGroupRadio.displayName = 'RadioGroup.Radio';
|
|
80
|
-
RadioGroupRadio.propTypes = {
|
|
81
|
-
disabled: bool,
|
|
82
|
-
value: oneOfType([string, number])
|
|
83
|
-
};
|
|
84
|
-
RadioGroupRadio.defaultProps = {
|
|
85
|
-
disabled: false,
|
|
86
|
-
value: ''
|
|
87
|
-
};
|
|
88
|
-
export default RadioGroupRadio;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react-native';
|
|
3
|
-
import RadioGroup from '../..';
|
|
4
|
-
import ThemeProvider from '../../../Theme';
|
|
5
|
-
import RadioGroupContext from '../../RadioGroupContext';
|
|
6
|
-
describe('<RadioGroup />', function () {
|
|
7
|
-
describe('<RadioGroup.Radio />', function () {
|
|
8
|
-
describe('Snapshots', function () {
|
|
9
|
-
it('should match snapshot with default radio', function () {
|
|
10
|
-
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, null))),
|
|
11
|
-
container = _render.container,
|
|
12
|
-
toJSON = _render.toJSON;
|
|
13
|
-
|
|
14
|
-
expect(toJSON(container)).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
it('should match snapshot with disabled radio', function () {
|
|
17
|
-
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
18
|
-
disabled: true
|
|
19
|
-
}))),
|
|
20
|
-
container = _render2.container,
|
|
21
|
-
toJSON = _render2.toJSON;
|
|
22
|
-
|
|
23
|
-
expect(toJSON(container)).toMatchSnapshot();
|
|
24
|
-
});
|
|
25
|
-
it('should match snapshot with default radio', function () {
|
|
26
|
-
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, null))),
|
|
27
|
-
container = _render3.container,
|
|
28
|
-
toJSON = _render3.toJSON;
|
|
29
|
-
|
|
30
|
-
expect(toJSON(container)).toMatchSnapshot();
|
|
31
|
-
});
|
|
32
|
-
it('should match snapshot with default radio pressed', function () {
|
|
33
|
-
var onChangeMock = jest.fn();
|
|
34
|
-
|
|
35
|
-
var _render4 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
36
|
-
value: {
|
|
37
|
-
onChange: onChangeMock
|
|
38
|
-
}
|
|
39
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
40
|
-
testID: "radio"
|
|
41
|
-
})))),
|
|
42
|
-
container = _render4.container,
|
|
43
|
-
getByTestId = _render4.getByTestId,
|
|
44
|
-
toJSON = _render4.toJSON;
|
|
45
|
-
|
|
46
|
-
var radio = getByTestId(/^radio/);
|
|
47
|
-
fireEvent.press(radio);
|
|
48
|
-
expect(toJSON(container)).toMatchSnapshot();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
describe('Props', function () {
|
|
52
|
-
it('checked should be the selectedValue provided from Context', function () {
|
|
53
|
-
var _render5 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
54
|
-
value: {
|
|
55
|
-
selectedValue: 'Radio 2'
|
|
56
|
-
}
|
|
57
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
58
|
-
testID: "radio",
|
|
59
|
-
value: "Radio 1"
|
|
60
|
-
}), /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
61
|
-
testID: "radio",
|
|
62
|
-
value: "Radio 2"
|
|
63
|
-
})))),
|
|
64
|
-
getAllByTestId = _render5.getAllByTestId;
|
|
65
|
-
|
|
66
|
-
var _getAllByTestId = getAllByTestId(/^radio/),
|
|
67
|
-
radio = _getAllByTestId[0],
|
|
68
|
-
radio2 = _getAllByTestId[1];
|
|
69
|
-
|
|
70
|
-
expect(radio.props.checked).toBe(false);
|
|
71
|
-
expect(radio2.props.checked).toBe(true);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe('Events', function () {
|
|
75
|
-
it('should call onchange from Context', function () {
|
|
76
|
-
var onChangeMock = jest.fn();
|
|
77
|
-
|
|
78
|
-
var _render6 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
79
|
-
value: {
|
|
80
|
-
onChange: onChangeMock
|
|
81
|
-
}
|
|
82
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
83
|
-
testID: "radio"
|
|
84
|
-
})))),
|
|
85
|
-
getByTestId = _render6.getByTestId;
|
|
86
|
-
|
|
87
|
-
var radio = getByTestId(/^radio/);
|
|
88
|
-
fireEvent.press(radio);
|
|
89
|
-
expect(onChangeMock).toHaveBeenCalled();
|
|
90
|
-
});
|
|
91
|
-
it('value should be as prop value', function () {
|
|
92
|
-
var onChangeMock = jest.fn();
|
|
93
|
-
|
|
94
|
-
var _render7 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
95
|
-
value: {
|
|
96
|
-
onChange: onChangeMock
|
|
97
|
-
}
|
|
98
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
99
|
-
value: "radio1",
|
|
100
|
-
testID: "radio"
|
|
101
|
-
})))),
|
|
102
|
-
getByTestId = _render7.getByTestId;
|
|
103
|
-
|
|
104
|
-
var radio = getByTestId(/^radio/);
|
|
105
|
-
fireEvent.press(radio);
|
|
106
|
-
expect(onChangeMock).toHaveBeenCalledWith({
|
|
107
|
-
value: 'radio1'
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
var _excluded = ["onChange", "selectedValue", "small", "children"];
|
|
2
|
-
|
|
3
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
-
|
|
7
|
-
import React, { useState } from 'react';
|
|
8
|
-
import { View } from 'react-native';
|
|
9
|
-
import { string, func, oneOfType, number, bool, node } from 'prop-types';
|
|
10
|
-
import styled from 'styled-components';
|
|
11
|
-
import RadioGroupContext from '../RadioGroupContext';
|
|
12
|
-
import RadioButton from './Button/RadioButton';
|
|
13
|
-
var Group = styled.View(function () {
|
|
14
|
-
return "\n align-self: center;\n position: relative;\n flex-direction: row;\n ";
|
|
15
|
-
});
|
|
16
|
-
var GrayLine = styled.View(function (_ref) {
|
|
17
|
-
var radiogroup = _ref.theme.yoga.components.radiogroup;
|
|
18
|
-
return "\n position: absolute;\n height: 100%;\n border-radius: " + radiogroup.button.border.radius + "px;\n border-width: " + radiogroup.button.border.width + "px;\n border-color: " + radiogroup.button.border.color + ";\n ";
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
var RadioGroup = function RadioGroup(_ref2) {
|
|
22
|
-
var onChange = _ref2.onChange,
|
|
23
|
-
selectedValue = _ref2.selectedValue,
|
|
24
|
-
small = _ref2.small,
|
|
25
|
-
children = _ref2.children,
|
|
26
|
-
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
27
|
-
|
|
28
|
-
var _useState = useState(0),
|
|
29
|
-
groupSize = _useState[0],
|
|
30
|
-
setGroupSize = _useState[1];
|
|
31
|
-
|
|
32
|
-
var isButton = React.Children.map(children, function (child) {
|
|
33
|
-
return child.type;
|
|
34
|
-
}).every(function (child) {
|
|
35
|
-
return child === RadioButton;
|
|
36
|
-
});
|
|
37
|
-
return /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
38
|
-
value: _extends({
|
|
39
|
-
selectedValue: selectedValue,
|
|
40
|
-
onChange: onChange,
|
|
41
|
-
small: small
|
|
42
|
-
}, rest)
|
|
43
|
-
}, /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Group, _extends({}, rest, {
|
|
44
|
-
onLayout: function onLayout(_ref3) {
|
|
45
|
-
var width = _ref3.nativeEvent.layout.width;
|
|
46
|
-
return setGroupSize(width);
|
|
47
|
-
}
|
|
48
|
-
}), Boolean(isButton && groupSize) && /*#__PURE__*/React.createElement(GrayLine, {
|
|
49
|
-
style: {
|
|
50
|
-
width: groupSize
|
|
51
|
-
}
|
|
52
|
-
}), children)));
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
RadioGroup.propTypes = {
|
|
56
|
-
onChange: func,
|
|
57
|
-
selectedValue: oneOfType([string, number]),
|
|
58
|
-
small: bool,
|
|
59
|
-
children: node.isRequired
|
|
60
|
-
};
|
|
61
|
-
RadioGroup.defaultProps = {
|
|
62
|
-
onChange: function onChange() {},
|
|
63
|
-
selectedValue: '',
|
|
64
|
-
small: false
|
|
65
|
-
};
|
|
66
|
-
export default RadioGroup;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react-native';
|
|
3
|
-
import RadioGroup from '..';
|
|
4
|
-
import ThemeProvider from '../../Theme';
|
|
5
|
-
describe('<RadioGroup />', function () {
|
|
6
|
-
describe('Snapshots', function () {
|
|
7
|
-
it('should match snapshot with radio button as children', function () {
|
|
8
|
-
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
|
|
9
|
-
container = _render.container,
|
|
10
|
-
getAllByText = _render.getAllByText,
|
|
11
|
-
toJSON = _render.toJSON;
|
|
12
|
-
|
|
13
|
-
expect(toJSON(container)).toMatchSnapshot();
|
|
14
|
-
expect(getAllByText(/^Option/)).toHaveLength(3);
|
|
15
|
-
});
|
|
16
|
-
it('should match snapshot with small radios', function () {
|
|
17
|
-
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
|
|
18
|
-
small: true
|
|
19
|
-
}, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
|
|
20
|
-
container = _render2.container,
|
|
21
|
-
toJSON = _render2.toJSON;
|
|
22
|
-
|
|
23
|
-
expect(toJSON(container)).toMatchSnapshot();
|
|
24
|
-
});
|
|
25
|
-
it('should has setted the selected value', function () {
|
|
26
|
-
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
|
|
27
|
-
selectedValue: "Option 2"
|
|
28
|
-
}, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
|
|
29
|
-
toJSON = _render3.toJSON,
|
|
30
|
-
getByText = _render3.getByText;
|
|
31
|
-
|
|
32
|
-
expect(toJSON()).toMatchSnapshot();
|
|
33
|
-
expect(getByText('Option 2').props.checked).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe('Events', function () {
|
|
38
|
-
it('should set the onchange for its children', function () {
|
|
39
|
-
var onChangeMock = jest.fn();
|
|
40
|
-
|
|
41
|
-
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
|
|
42
|
-
onChange: onChangeMock
|
|
43
|
-
}, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
|
|
44
|
-
getByText = _render4.getByText;
|
|
45
|
-
|
|
46
|
-
var firstOption = getByText('Option 1');
|
|
47
|
-
fireEvent.press(firstOption);
|
|
48
|
-
expect(onChangeMock).toHaveBeenCalled();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
4
|
-
import RadioGroup from '../..';
|
|
5
|
-
import ThemeProvider from '../../../Theme';
|
|
6
|
-
import RadioGroupContext from '../../RadioGroupContext';
|
|
7
|
-
var originalError = console.error;
|
|
8
|
-
beforeEach(function () {
|
|
9
|
-
console.error = jest.fn();
|
|
10
|
-
});
|
|
11
|
-
afterEach(function () {
|
|
12
|
-
console.error = originalError;
|
|
13
|
-
});
|
|
14
|
-
describe('<RadioGroup />', function () {
|
|
15
|
-
describe('<RadioGroup.Button />', function () {
|
|
16
|
-
describe('Snapshots', function () {
|
|
17
|
-
it('should match snapshot with default radio button', function () {
|
|
18
|
-
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Radio 1"))),
|
|
19
|
-
container = _render.container;
|
|
20
|
-
|
|
21
|
-
expect(container).toMatchSnapshot();
|
|
22
|
-
});
|
|
23
|
-
it('should match snapshot with small radio button', function () {
|
|
24
|
-
var _render2 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
25
|
-
value: {
|
|
26
|
-
small: true
|
|
27
|
-
}
|
|
28
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Radio 1")))),
|
|
29
|
-
container = _render2.container;
|
|
30
|
-
|
|
31
|
-
expect(container).toMatchSnapshot();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe('Props', function () {
|
|
35
|
-
it('should contains input type radio', function () {
|
|
36
|
-
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
37
|
-
"data-testid": "radio"
|
|
38
|
-
}, "Radio 1"))),
|
|
39
|
-
getByTestId = _render3.getByTestId;
|
|
40
|
-
|
|
41
|
-
expect(getByTestId('radio').type).toBe('radio');
|
|
42
|
-
});
|
|
43
|
-
it('value should be as prop value', function () {
|
|
44
|
-
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
45
|
-
"data-testid": "radio",
|
|
46
|
-
value: "radio1"
|
|
47
|
-
}, "Radio 1"))),
|
|
48
|
-
getByTestId = _render4.getByTestId;
|
|
49
|
-
|
|
50
|
-
expect(getByTestId('radio').value).toBe('radio1');
|
|
51
|
-
});
|
|
52
|
-
it('value should be children if prop value is ommited', function () {
|
|
53
|
-
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
54
|
-
"data-testid": "radio"
|
|
55
|
-
}, "Radio 1"))),
|
|
56
|
-
getByTestId = _render5.getByTestId,
|
|
57
|
-
getByText = _render5.getByText;
|
|
58
|
-
|
|
59
|
-
var label = getByText('Radio 1');
|
|
60
|
-
var radio = getByTestId('radio');
|
|
61
|
-
expect(radio.value).toBe(label.textContent);
|
|
62
|
-
});
|
|
63
|
-
it('checked should be the selectedValue provided from Context', function () {
|
|
64
|
-
var _render6 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
65
|
-
value: {
|
|
66
|
-
selectedValue: 'Radio 2'
|
|
67
|
-
}
|
|
68
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
69
|
-
"data-testid": "radio"
|
|
70
|
-
}, "Radio 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
71
|
-
"data-testid": "radio"
|
|
72
|
-
}, "Radio 2")))),
|
|
73
|
-
getAllByTestId = _render6.getAllByTestId;
|
|
74
|
-
|
|
75
|
-
var _getAllByTestId = getAllByTestId('radio'),
|
|
76
|
-
radio = _getAllByTestId[0],
|
|
77
|
-
radio2 = _getAllByTestId[1];
|
|
78
|
-
|
|
79
|
-
expect(radio.checked).toBe(false);
|
|
80
|
-
expect(radio2.checked).toBe(true);
|
|
81
|
-
});
|
|
82
|
-
it('name should the one provided by context', function () {
|
|
83
|
-
var name = 'test';
|
|
84
|
-
|
|
85
|
-
var _render7 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
86
|
-
value: {
|
|
87
|
-
name: name
|
|
88
|
-
}
|
|
89
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
90
|
-
"data-testid": "radio"
|
|
91
|
-
}, "Radio 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
92
|
-
"data-testid": "radio"
|
|
93
|
-
}, "Radio 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
94
|
-
"data-testid": "radio"
|
|
95
|
-
}, "Radio 3")))),
|
|
96
|
-
getAllByTestId = _render7.getAllByTestId;
|
|
97
|
-
|
|
98
|
-
var radios = getAllByTestId('radio');
|
|
99
|
-
radios.map(function (radio) {
|
|
100
|
-
return expect(radio.name).toBe(name);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
describe('Events', function () {
|
|
105
|
-
it('should call onchange from Context', function () {
|
|
106
|
-
var onChangeMock = jest.fn();
|
|
107
|
-
|
|
108
|
-
var _render8 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
109
|
-
value: {
|
|
110
|
-
onChange: onChangeMock
|
|
111
|
-
}
|
|
112
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Radio 1")))),
|
|
113
|
-
getByText = _render8.getByText;
|
|
114
|
-
|
|
115
|
-
var radio = getByText('Radio 1');
|
|
116
|
-
fireEvent.click(radio);
|
|
117
|
-
expect(onChangeMock).toHaveBeenCalled();
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
});
|