@gympass/yoga 7.36.0 → 7.37.2
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/AutoComplete/web/AutoComplete.js +5 -3
- package/cjs/AutoComplete/web/AutoComplete.test.js +152 -0
- package/cjs/Avatar/native/Avatar.test.js +1 -0
- package/cjs/Avatar/web/Avatar.test.js +72 -0
- package/cjs/Banner/native/Banner.js +1 -1
- package/cjs/Banner/native/Banner.test.js +1 -0
- package/cjs/Banner/web/Banner.js +4 -3
- package/cjs/Banner/web/Banner.test.js +121 -0
- package/cjs/BottomSheet/web/BottomSheet.test.js +46 -0
- package/cjs/Box/native/Box.test.js +1 -0
- package/cjs/Box/web/Box.test.js +23 -0
- package/cjs/Button/native/Button.test.js +1 -0
- package/cjs/Button/web/Button.test.js +778 -0
- package/cjs/Card/native/Card/Card.js +1 -1
- package/cjs/Card/native/Card/Card.test.js +1 -0
- package/cjs/Card/native/EventCard/EventCard.test.js +1 -0
- package/cjs/Card/native/GymCard/CheckIn/CheckIn.test.js +1 -0
- package/cjs/Card/native/PlanCard/PlanCard.test.js +1 -0
- package/cjs/Card/web/Card/Card.js +7 -3
- package/cjs/Card/web/Card/Card.test.js +22 -0
- package/cjs/Card/web/EventCard/EventCard.test.js +35 -0
- package/cjs/Card/web/PlanCard/PlanCard.test.js +95 -0
- package/cjs/Checkbox/native/Checkbox.test.js +1 -0
- package/cjs/Checkbox/native/Switch.test.js +1 -0
- package/cjs/Checkbox/web/Checkbox.test.js +161 -0
- package/cjs/Checkbox/web/Switch.test.js +65 -0
- package/cjs/Chips/native/Chips.js +1 -1
- package/cjs/Chips/native/Chips.test.js +1 -0
- package/cjs/Chips/web/Chips.js +4 -3
- package/cjs/Chips/web/Chips.test.js +138 -0
- package/cjs/Dialog/web/Dialog.test.js +70 -0
- package/cjs/Divider/native/Divider.js +1 -1
- package/cjs/Divider/native/Divider.test.js +1 -0
- package/cjs/Divider/web/Divider.js +5 -4
- package/cjs/Divider/web/Divider.test.js +36 -0
- package/cjs/Dropdown/native/Backdrop.test.js +1 -0
- package/cjs/Dropdown/native/Dropdown.js +1 -1
- package/cjs/Dropdown/native/Dropdown.test.js +1 -0
- package/cjs/Dropdown/web/Dropdown.js +6 -3
- package/cjs/Dropdown/web/Dropdown.test.js +102 -0
- package/cjs/Feedback/web/Feedback.test.js +89 -0
- package/cjs/Grid/web/Col.test.js +56 -0
- package/cjs/Grid/web/Container.test.js +22 -0
- package/cjs/Grid/web/Hide.test.js +39 -0
- package/cjs/Grid/web/Row.test.js +22 -0
- package/cjs/Header/web/Header.test.js +44 -0
- package/cjs/Heading/web/Heading.test.js +55 -0
- package/cjs/Icon/native/Icon.test.js +1 -0
- package/cjs/Icon/web/Icon.test.js +53 -0
- package/cjs/Input/native/Email.js +1 -1
- package/cjs/Input/native/Email.test.js +1 -0
- package/cjs/Input/native/Helper.js +1 -1
- package/cjs/Input/native/Input.js +1 -1
- package/cjs/Input/native/Input.test.js +1 -0
- package/cjs/Input/native/Number.js +1 -1
- package/cjs/Input/native/Number.test.js +1 -0
- package/cjs/Input/native/Password.js +1 -1
- package/cjs/Input/native/Password.test.js +1 -0
- package/cjs/Input/native/Tel.js +1 -1
- package/cjs/Input/native/Tel.test.js +1 -0
- package/cjs/Input/web/Email.js +5 -3
- package/cjs/Input/web/Email.test.js +20 -0
- package/cjs/Input/web/Field.js +1 -1
- package/cjs/Input/web/Input.test.js +161 -0
- package/cjs/Input/web/Legend.js +7 -3
- package/cjs/Input/web/Number.js +6 -4
- package/cjs/Input/web/Number.test.js +20 -0
- package/cjs/Input/web/Password.test.js +103 -0
- package/cjs/Input/web/Tel.js +5 -3
- package/cjs/Input/web/Tel.test.js +20 -0
- package/cjs/List/native/List.js +1 -1
- package/cjs/List/native/List.test.js +1 -0
- package/cjs/List/web/List.js +4 -3
- package/cjs/List/web/List.test.js +69 -0
- package/cjs/Progress/native/Progress.js +1 -1
- package/cjs/Progress/native/Progress.test.js +1 -0
- package/cjs/Progress/web/Progress.js +4 -3
- package/cjs/Progress/web/Progress.test.js +229 -0
- package/cjs/RadioGroup/native/Button/RadioButton.js +1 -1
- package/cjs/RadioGroup/native/Button/RadioButton.test.js +1 -0
- package/cjs/RadioGroup/native/Radio/Radio.js +1 -1
- package/cjs/RadioGroup/native/Radio/Radio.test.js +1 -0
- package/cjs/RadioGroup/native/RadioGroup.test.js +1 -0
- package/cjs/RadioGroup/web/Button/RadioButton.js +4 -3
- package/cjs/RadioGroup/web/Button/RadioButton.test.js +132 -0
- package/cjs/RadioGroup/web/Radio/Radio.js +4 -3
- package/cjs/RadioGroup/web/Radio/Radio.test.js +119 -0
- package/cjs/RadioGroup/web/RadioGroup.test.js +93 -0
- package/cjs/Rating/native/Rating.test.js +1 -0
- package/cjs/Rating/web/Rating.test.js +201 -0
- package/cjs/Result/native/Result.test.js +1 -0
- package/cjs/Slider/native/Slider.test.js +1 -0
- package/cjs/Slider/web/Slider.test.js +95 -0
- package/cjs/Snackbar/native/Snackbar.test.js +1 -0
- package/cjs/Snackbar/web/Snackbar.js +5 -11
- package/cjs/Snackbar/web/Snackbar.test.js +135 -0
- package/cjs/Stepper/native/Stepper.test.js +1 -0
- package/cjs/Stepper/web/Stepper.test.js +75 -0
- package/cjs/Tag/native/Tag.test.js +1 -0
- package/cjs/Tag/web/Tag.test.js +87 -0
- package/cjs/Text/native/Text.test.js +1 -0
- package/cjs/Text/sharedTextStyle.js +1 -1
- package/cjs/Text/textStyle.android.js +1 -1
- package/cjs/Text/textStyle.ios.js +1 -1
- package/cjs/Text/textStyle.web.js +1 -1
- package/cjs/Text/web/Text.test.js +157 -0
- package/cjs/TextArea/native/TextArea.test.js +1 -0
- package/cjs/TextArea/web/TextArea.test.js +18 -0
- package/cjs/Theme/Provider/web/FontLoader.test.js +19 -0
- package/cjs/Theme/Provider/web/GlobalStyle.test.js +27 -0
- package/cjs/Theme/helpers/themeReader/native/native.test.js +1 -0
- package/cjs/Theme/helpers/themeReader/web/web.test.js +54 -0
- package/esm/AutoComplete/web/AutoComplete.js +5 -4
- package/esm/AutoComplete/web/AutoComplete.test.js +135 -0
- package/esm/Avatar/index.native.js +4 -0
- package/esm/Avatar/native/Avatar.js +96 -0
- package/esm/Avatar/native/Avatar.test.js +46 -0
- package/esm/Avatar/native/AvatarCircle.js +24 -0
- package/esm/Avatar/web/Avatar.test.js +63 -0
- package/esm/Banner/index.native.js +2 -0
- package/esm/Banner/native/Banner.js +128 -0
- package/esm/Banner/native/Banner.test.js +103 -0
- package/esm/Banner/native/index.js +2 -0
- package/esm/Banner/web/Banner.js +4 -5
- package/esm/Banner/web/Banner.test.js +109 -0
- package/esm/BottomSheet/web/BottomSheet.test.js +33 -0
- package/esm/Box/index.native.js +2 -0
- package/esm/Box/native/Box.js +4 -0
- package/esm/Box/native/Box.test.js +16 -0
- package/esm/Box/native/index.js +2 -0
- package/esm/Box/web/Box.test.js +16 -0
- package/esm/Button/index.native.js +8 -0
- package/esm/Button/native/Button.js +110 -0
- package/esm/Button/native/Button.test.js +475 -0
- package/esm/Button/native/Icon.js +82 -0
- package/esm/Button/native/Link.js +35 -0
- package/esm/Button/native/Text.js +74 -0
- package/esm/Button/native/withTouchable.js +63 -0
- package/esm/Button/web/Button.test.js +764 -0
- package/esm/Card/index.native.js +2 -0
- package/esm/Card/native/Card/Actions.js +12 -0
- package/esm/Card/native/Card/Card.js +92 -0
- package/esm/Card/native/Card/Card.test.js +15 -0
- package/esm/Card/native/Card/Content.js +8 -0
- package/esm/Card/native/Card/Header.js +8 -0
- package/esm/Card/native/Card/index.js +8 -0
- package/esm/Card/native/EventCard/EventCard.js +169 -0
- package/esm/Card/native/EventCard/EventCard.test.js +65 -0
- package/esm/Card/native/EventCard/index.js +2 -0
- package/esm/Card/native/GymCard/CheckIn/Avatar.js +17 -0
- package/esm/Card/native/GymCard/CheckIn/CheckIn.js +66 -0
- package/esm/Card/native/GymCard/CheckIn/CheckIn.test.js +39 -0
- package/esm/Card/native/GymCard/CheckIn/Content.js +11 -0
- package/esm/Card/native/GymCard/CheckIn/Header.js +11 -0
- package/esm/Card/native/GymCard/CheckIn/index.js +2 -0
- package/esm/Card/native/GymCard/index.js +5 -0
- package/esm/Card/native/PlanCard/Actions.js +24 -0
- package/esm/Card/native/PlanCard/Content.js +82 -0
- package/esm/Card/native/PlanCard/List.js +73 -0
- package/esm/Card/native/PlanCard/PlanCard.js +54 -0
- package/esm/Card/native/PlanCard/PlanCard.test.js +84 -0
- package/esm/Card/native/PlanCard/Subtitle.js +15 -0
- package/esm/Card/native/PlanCard/Tag.js +33 -0
- package/esm/Card/native/PlanCard/index.js +15 -0
- package/esm/Card/native/index.js +5 -0
- package/esm/Card/web/Card/Card.js +7 -5
- package/esm/Card/web/Card/Card.test.js +14 -0
- package/esm/Card/web/EventCard/EventCard.test.js +27 -0
- package/esm/Card/web/PlanCard/PlanCard.test.js +85 -0
- package/esm/Checkbox/index.native.js +3 -0
- package/esm/Checkbox/native/Checkbox.js +179 -0
- package/esm/Checkbox/native/Checkbox.test.js +115 -0
- package/esm/Checkbox/native/Switch.js +115 -0
- package/esm/Checkbox/native/Switch.test.js +54 -0
- package/esm/Checkbox/native/index.js +3 -0
- package/esm/Checkbox/web/Checkbox.test.js +153 -0
- package/esm/Checkbox/web/Switch.test.js +56 -0
- package/esm/Chips/index.native.js +2 -0
- package/esm/Chips/native/Chips.js +104 -0
- package/esm/Chips/native/Chips.test.js +134 -0
- package/esm/Chips/native/Counter.js +20 -0
- package/esm/Chips/native/index.js +2 -0
- package/esm/Chips/web/Chips.js +4 -5
- package/esm/Chips/web/Chips.test.js +128 -0
- package/esm/Dialog/web/Dialog.test.js +54 -0
- package/esm/Divider/index.native.js +2 -0
- package/esm/Divider/native/Divider.js +29 -0
- package/esm/Divider/native/Divider.test.js +29 -0
- package/esm/Divider/native/index.js +2 -0
- package/esm/Divider/web/Divider.js +5 -6
- package/esm/Divider/web/Divider.test.js +29 -0
- package/esm/Dropdown/index.native.js +2 -0
- package/esm/Dropdown/native/Backdrop.js +93 -0
- package/esm/Dropdown/native/Backdrop.test.js +26 -0
- package/esm/Dropdown/native/Dropdown.js +142 -0
- package/esm/Dropdown/native/Dropdown.test.js +78 -0
- package/esm/Dropdown/native/Options.android.js +66 -0
- package/esm/Dropdown/native/Options.ios.js +71 -0
- package/esm/Dropdown/native/index.js +2 -0
- package/esm/Dropdown/web/Dropdown.js +5 -4
- package/esm/Dropdown/web/Dropdown.test.js +93 -0
- package/esm/Feedback/web/Feedback.test.js +83 -0
- package/esm/Grid/web/Col.test.js +48 -0
- package/esm/Grid/web/Container.test.js +14 -0
- package/esm/Grid/web/Hide.test.js +31 -0
- package/esm/Grid/web/Row.test.js +14 -0
- package/esm/Header/web/Header.test.js +34 -0
- package/esm/Heading/web/Heading.test.js +45 -0
- package/esm/Icon/index.native.js +2 -0
- package/esm/Icon/native/Icon.test.js +47 -0
- package/esm/Icon/native/index.js +2 -0
- package/esm/Icon/web/Icon.test.js +47 -0
- package/esm/Input/index.native.js +6 -0
- package/esm/Input/native/Email.js +15 -0
- package/esm/Input/native/Email.test.js +13 -0
- package/esm/Input/native/Helper.js +62 -0
- package/esm/Input/native/Input.js +234 -0
- package/esm/Input/native/Input.test.js +181 -0
- package/esm/Input/native/Number.js +12 -0
- package/esm/Input/native/Number.test.js +13 -0
- package/esm/Input/native/Password.js +112 -0
- package/esm/Input/native/Password.test.js +125 -0
- package/esm/Input/native/Tel.js +14 -0
- package/esm/Input/native/Tel.test.js +13 -0
- package/esm/Input/native/index.js +6 -0
- package/esm/Input/web/Email.js +5 -5
- package/esm/Input/web/Email.test.js +13 -0
- package/esm/Input/web/Field.js +1 -1
- package/esm/Input/web/Input.test.js +145 -0
- package/esm/Input/web/Legend.js +7 -5
- package/esm/Input/web/Number.js +6 -6
- package/esm/Input/web/Number.test.js +13 -0
- package/esm/Input/web/Password.test.js +90 -0
- package/esm/Input/web/Tel.js +5 -5
- package/esm/Input/web/Tel.test.js +13 -0
- package/esm/List/index.native.js +3 -0
- package/esm/List/native/List.js +22 -0
- package/esm/List/native/List.test.js +106 -0
- package/esm/List/native/ListItem.js +51 -0
- package/esm/List/native/index.js +3 -0
- package/esm/List/web/List.js +4 -4
- package/esm/List/web/List.test.js +62 -0
- package/esm/Progress/index.native.js +2 -0
- package/esm/Progress/native/Progress.js +103 -0
- package/esm/Progress/native/Progress.test.js +222 -0
- package/esm/Progress/native/index.js +2 -0
- package/esm/Progress/web/Progress.js +4 -4
- package/esm/Progress/web/Progress.test.js +222 -0
- package/esm/RadioGroup/index.native.js +4 -0
- package/esm/RadioGroup/native/Button/RadioButton.js +64 -0
- package/esm/RadioGroup/native/Button/RadioButton.test.js +94 -0
- package/esm/RadioGroup/native/Radio/Radio.js +88 -0
- package/esm/RadioGroup/native/Radio/Radio.test.js +102 -0
- package/esm/RadioGroup/native/RadioGroup.js +66 -0
- package/esm/RadioGroup/native/RadioGroup.test.js +48 -0
- package/esm/RadioGroup/native/index.js +4 -0
- package/esm/RadioGroup/web/Button/RadioButton.js +4 -4
- package/esm/RadioGroup/web/Button/RadioButton.test.js +121 -0
- package/esm/RadioGroup/web/Radio/Radio.js +4 -4
- package/esm/RadioGroup/web/Radio/Radio.test.js +108 -0
- package/esm/RadioGroup/web/RadioGroup.test.js +83 -0
- package/esm/Rating/index.native.js +2 -0
- package/esm/Rating/native/Rating.js +186 -0
- package/esm/Rating/native/Rating.test.js +121 -0
- package/esm/Rating/native/index.js +2 -0
- package/esm/Rating/web/Rating.test.js +184 -0
- package/esm/Result/index.native.js +8 -0
- package/esm/Result/native/Attendances.js +55 -0
- package/esm/Result/native/Details.js +97 -0
- package/esm/Result/native/Rate.js +35 -0
- package/esm/Result/native/Result.js +86 -0
- package/esm/Result/native/Result.test.js +107 -0
- package/esm/Result/native/ResultButton.js +13 -0
- package/esm/Result/native/Tags.js +41 -0
- package/esm/Result/native/TinyTextIcon.js +18 -0
- package/esm/Result/native/index.js +2 -0
- package/esm/Slider/index.native.js +2 -0
- package/esm/Slider/native/Label.js +19 -0
- package/esm/Slider/native/Marker.js +68 -0
- package/esm/Slider/native/Slider.js +156 -0
- package/esm/Slider/native/Slider.test.js +115 -0
- package/esm/Slider/native/Step.js +14 -0
- package/esm/Slider/native/Tooltip.js +90 -0
- package/esm/Slider/web/Slider.test.js +86 -0
- package/esm/Snackbar/index.native.js +2 -0
- package/esm/Snackbar/native/Snackbar.js +199 -0
- package/esm/Snackbar/native/Snackbar.test.js +98 -0
- package/esm/Snackbar/native/SnackbarAnimationWrapper.js +124 -0
- package/esm/Snackbar/native/index.js +2 -0
- package/esm/Snackbar/web/Snackbar.js +4 -12
- package/esm/Snackbar/web/Snackbar.test.js +116 -0
- package/esm/Stepper/index.native.js +3 -0
- package/esm/Stepper/native/Dots.js +45 -0
- package/esm/Stepper/native/Line.js +35 -0
- package/esm/Stepper/native/Step.js +19 -0
- package/esm/Stepper/native/Stepper.js +52 -0
- package/esm/Stepper/native/Stepper.test.js +68 -0
- package/esm/Stepper/native/index.js +3 -0
- package/esm/Stepper/web/Stepper.test.js +67 -0
- package/esm/Tag/index.native.js +4 -0
- package/esm/Tag/native/Informative.js +71 -0
- package/esm/Tag/native/Tag.js +75 -0
- package/esm/Tag/native/Tag.test.js +92 -0
- package/esm/Tag/native/index.js +2 -0
- package/esm/Tag/web/Tag.test.js +79 -0
- package/esm/Text/index.native.js +16 -0
- package/esm/Text/native/Text.js +69 -0
- package/esm/Text/native/Text.test.js +149 -0
- package/esm/Text/native/index.js +2 -0
- package/esm/Text/sharedTextStyle.js +1 -1
- package/esm/Text/textStyle.android.js +1 -1
- package/esm/Text/textStyle.ios.js +1 -1
- package/esm/Text/textStyle.web.js +1 -1
- package/esm/Text/web/Text.test.js +149 -0
- package/esm/TextArea/index.native.js +2 -0
- package/esm/TextArea/native/TextArea.js +59 -0
- package/esm/TextArea/native/TextArea.test.js +11 -0
- package/esm/TextArea/native/index.js +2 -0
- package/esm/TextArea/web/TextArea.test.js +11 -0
- package/esm/Theme/Provider/index.native.js +2 -0
- package/esm/Theme/Provider/native/index.js +2 -0
- package/esm/Theme/Provider/web/FontLoader.test.js +11 -0
- package/esm/Theme/Provider/web/GlobalStyle.test.js +17 -0
- package/esm/Theme/helpers/themeReader/native/native.test.js +53 -0
- package/esm/Theme/helpers/themeReader/web/web.test.js +41 -0
- package/esm/Theme/index.native.js +5 -0
- package/esm/index.native.js +24 -0
- package/esm/shared/index.native.js +2 -0
- package/package.json +6 -6
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
var _excluded = ["label", "helper", "disabled", "checked", "error", "style", "onPressIn", "onPressOut", "inverted", "theme"];
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
10
|
+
|
|
11
|
+
import React, { useState } from 'react';
|
|
12
|
+
import { bool, func, string, shape } from 'prop-types';
|
|
13
|
+
import styled, { withTheme } from 'styled-components';
|
|
14
|
+
import { TouchableWithoutFeedback, View } from 'react-native';
|
|
15
|
+
import { hexToRgb } from '@gympass/yoga-common';
|
|
16
|
+
import { Check } from '@gympass/yoga-icons';
|
|
17
|
+
import Text from '../../Text';
|
|
18
|
+
var CheckboxWrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n flex-direction: row;\n align-items: center;\n"])));
|
|
19
|
+
var Label = styled(Text.Regular)(function (_ref) {
|
|
20
|
+
var checkbox = _ref.theme.yoga.components.checkbox;
|
|
21
|
+
return "\n padding-left: " + checkbox.label.padding.left + "px;\n\n font-size: " + checkbox.label.font.size + "px;\n\n color: " + checkbox.label.font.color + ";\n";
|
|
22
|
+
});
|
|
23
|
+
var HelperWrapper = styled.View(function (_ref2) {
|
|
24
|
+
var checkbox = _ref2.theme.yoga.components.checkbox;
|
|
25
|
+
return "\n margin-top: " + checkbox.helper.margin.top + "px;\n";
|
|
26
|
+
});
|
|
27
|
+
var Helper = styled(Text.Regular)(function (_ref3) {
|
|
28
|
+
var error = _ref3.error,
|
|
29
|
+
_ref3$theme$yoga = _ref3.theme.yoga,
|
|
30
|
+
feedback = _ref3$theme$yoga.colors.feedback,
|
|
31
|
+
checkbox = _ref3$theme$yoga.components.checkbox;
|
|
32
|
+
return "\n font-size: " + checkbox.helper.font.size + "px;\n\n color: " + (error ? feedback.attention[1] : checkbox.helper.font.color) + ";\n";
|
|
33
|
+
});
|
|
34
|
+
var CheckBackground = styled.View(function (_ref4) {
|
|
35
|
+
var checked = _ref4.checked,
|
|
36
|
+
disabled = _ref4.disabled,
|
|
37
|
+
inverted = _ref4.inverted,
|
|
38
|
+
error = _ref4.error,
|
|
39
|
+
_ref4$theme$yoga = _ref4.theme.yoga,
|
|
40
|
+
_ref4$theme$yoga$colo = _ref4$theme$yoga.colors,
|
|
41
|
+
primary = _ref4$theme$yoga$colo.primary,
|
|
42
|
+
feedback = _ref4$theme$yoga$colo.feedback,
|
|
43
|
+
elements = _ref4$theme$yoga$colo.elements,
|
|
44
|
+
white = _ref4$theme$yoga$colo.white,
|
|
45
|
+
checkbox = _ref4$theme$yoga.components.checkbox;
|
|
46
|
+
var borderColor = primary;
|
|
47
|
+
var bgColor = 'transparent';
|
|
48
|
+
|
|
49
|
+
if (error) {
|
|
50
|
+
var _feedback$attention = feedback.attention;
|
|
51
|
+
borderColor = _feedback$attention[1];
|
|
52
|
+
|
|
53
|
+
if (checked) {
|
|
54
|
+
var _feedback$attention2 = feedback.attention;
|
|
55
|
+
bgColor = _feedback$attention2[1];
|
|
56
|
+
}
|
|
57
|
+
} else if (disabled) {
|
|
58
|
+
borderColor = checkbox.disabled.border.color;
|
|
59
|
+
|
|
60
|
+
if (checked) {
|
|
61
|
+
bgColor = checkbox.disabled.backgroundColor;
|
|
62
|
+
borderColor = elements.lineAndBorders;
|
|
63
|
+
}
|
|
64
|
+
} else if (checked) {
|
|
65
|
+
borderColor = primary;
|
|
66
|
+
bgColor = primary;
|
|
67
|
+
|
|
68
|
+
if (inverted) {
|
|
69
|
+
bgColor = white;
|
|
70
|
+
borderColor = white;
|
|
71
|
+
}
|
|
72
|
+
} else if (inverted) {
|
|
73
|
+
borderColor = white;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return "\n position: absolute;\n\n width: " + checkbox.size + "px;\n height: " + checkbox.size + "px;\n\n border-radius: " + checkbox.border.radius + "px;\n border-width: " + checkbox.border.width + "px;\n border-style: solid;\n\n background-color: " + bgColor + ";\n\n border-color: " + borderColor + ";\n ";
|
|
77
|
+
});
|
|
78
|
+
var Shadow = styled.View(function (_ref5) {
|
|
79
|
+
var checked = _ref5.checked,
|
|
80
|
+
inverted = _ref5.inverted,
|
|
81
|
+
_ref5$theme$yoga = _ref5.theme.yoga,
|
|
82
|
+
_ref5$theme$yoga$colo = _ref5$theme$yoga.colors,
|
|
83
|
+
primary = _ref5$theme$yoga$colo.primary,
|
|
84
|
+
elements = _ref5$theme$yoga$colo.elements,
|
|
85
|
+
white = _ref5$theme$yoga$colo.white,
|
|
86
|
+
checkbox = _ref5$theme$yoga.components.checkbox;
|
|
87
|
+
var size = checkbox.size * 1.67;
|
|
88
|
+
var shadowColor = checked ? primary : elements.backgroundAndDisabled;
|
|
89
|
+
return "\n width: " + size + "px;\n height: " + size + "px;\n\n background-color: " + hexToRgb(inverted ? white : shadowColor, 0.75) + ";\n border-radius: " + checkbox.hover.border.radius + "px;\n ";
|
|
90
|
+
});
|
|
91
|
+
var CheckArea = styled.View(function (_ref6) {
|
|
92
|
+
var checkbox = _ref6.theme.yoga.components.checkbox;
|
|
93
|
+
return "\n justify-content: center;\n align-items: center;\n\n width: " + checkbox.size + "px;\n height: " + checkbox.size + "px;\n";
|
|
94
|
+
});
|
|
95
|
+
/** The checkbox component is used when the user needs to select one or more
|
|
96
|
+
* items on a task. This component can also allow the user to turn an option on
|
|
97
|
+
* or off. */
|
|
98
|
+
|
|
99
|
+
var Checkbox = function Checkbox(_ref7) {
|
|
100
|
+
var label = _ref7.label,
|
|
101
|
+
helper = _ref7.helper,
|
|
102
|
+
disabled = _ref7.disabled,
|
|
103
|
+
checked = _ref7.checked,
|
|
104
|
+
error = _ref7.error,
|
|
105
|
+
style = _ref7.style,
|
|
106
|
+
_onPressIn = _ref7.onPressIn,
|
|
107
|
+
_onPressOut = _ref7.onPressOut,
|
|
108
|
+
inverted = _ref7.inverted,
|
|
109
|
+
_ref7$theme$yoga = _ref7.theme.yoga,
|
|
110
|
+
checkbox = _ref7$theme$yoga.components.checkbox,
|
|
111
|
+
colors = _ref7$theme$yoga.colors,
|
|
112
|
+
rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
|
|
113
|
+
|
|
114
|
+
var _useState = useState(false),
|
|
115
|
+
pressed = _useState[0],
|
|
116
|
+
setPressed = _useState[1];
|
|
117
|
+
|
|
118
|
+
return /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(TouchableWithoutFeedback, _extends({}, rest, {
|
|
119
|
+
disabled: disabled,
|
|
120
|
+
onPressIn: function onPressIn(e) {
|
|
121
|
+
setPressed(true);
|
|
122
|
+
|
|
123
|
+
_onPressIn(e);
|
|
124
|
+
},
|
|
125
|
+
onPressOut: function onPressOut(e) {
|
|
126
|
+
setPressed(false);
|
|
127
|
+
|
|
128
|
+
_onPressOut(e);
|
|
129
|
+
}
|
|
130
|
+
}), /*#__PURE__*/React.createElement(CheckboxWrapper, {
|
|
131
|
+
style: style
|
|
132
|
+
}, /*#__PURE__*/React.createElement(CheckArea, null, pressed && !disabled && /*#__PURE__*/React.createElement(Shadow, {
|
|
133
|
+
pressed: pressed,
|
|
134
|
+
checked: checked,
|
|
135
|
+
inverted: inverted
|
|
136
|
+
}), /*#__PURE__*/React.createElement(CheckBackground, {
|
|
137
|
+
disabled: disabled,
|
|
138
|
+
checked: checked,
|
|
139
|
+
error: error,
|
|
140
|
+
pressed: pressed,
|
|
141
|
+
inverted: inverted
|
|
142
|
+
}), checked && /*#__PURE__*/React.createElement(Check, {
|
|
143
|
+
fill: inverted ? colors.primary : checkbox.checked.icon.color,
|
|
144
|
+
style: {
|
|
145
|
+
position: 'absolute'
|
|
146
|
+
},
|
|
147
|
+
width: 24,
|
|
148
|
+
height: 24
|
|
149
|
+
})), label && /*#__PURE__*/React.createElement(Label, null, label))), (helper || error) && /*#__PURE__*/React.createElement(HelperWrapper, null, /*#__PURE__*/React.createElement(Helper, {
|
|
150
|
+
error: error
|
|
151
|
+
}, error || helper)));
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
Checkbox.propTypes = {
|
|
155
|
+
label: string,
|
|
156
|
+
|
|
157
|
+
/** set a short helper text under checkbox */
|
|
158
|
+
helper: string,
|
|
159
|
+
checked: bool,
|
|
160
|
+
disabled: bool,
|
|
161
|
+
inverted: bool,
|
|
162
|
+
error: string,
|
|
163
|
+
style: shape({}),
|
|
164
|
+
onPressIn: func,
|
|
165
|
+
onPressOut: func
|
|
166
|
+
};
|
|
167
|
+
Checkbox.defaultProps = {
|
|
168
|
+
label: undefined,
|
|
169
|
+
helper: undefined,
|
|
170
|
+
checked: false,
|
|
171
|
+
disabled: false,
|
|
172
|
+
inverted: false,
|
|
173
|
+
error: undefined,
|
|
174
|
+
style: {},
|
|
175
|
+
onPressIn: function onPressIn() {},
|
|
176
|
+
onPressOut: function onPressOut() {}
|
|
177
|
+
};
|
|
178
|
+
Checkbox.displayName = 'Checkbox';
|
|
179
|
+
export default withTheme(Checkbox);
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { render, fireEvent, toJSON } from '@testing-library/react-native';
|
|
5
|
+
import Checkbox from '..';
|
|
6
|
+
import ThemeProvider from '../../Theme';
|
|
7
|
+
var data = {
|
|
8
|
+
label: 'Checkbox Component',
|
|
9
|
+
helper: 'Helper Text'
|
|
10
|
+
};
|
|
11
|
+
describe('<Checkbox />', function () {
|
|
12
|
+
describe('Snapshots', function () {
|
|
13
|
+
it('should match snapshot without label', function () {
|
|
14
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, null))),
|
|
15
|
+
container = _render.container;
|
|
16
|
+
|
|
17
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
it('should match snapshot without label', function () {
|
|
20
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, null))),
|
|
21
|
+
container = _render2.container;
|
|
22
|
+
|
|
23
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
it('should match snapshot with default checkbox', function () {
|
|
26
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, data))),
|
|
27
|
+
container = _render3.container;
|
|
28
|
+
|
|
29
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
it('should match snapshot with disabled checkbox', function () {
|
|
32
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
33
|
+
disabled: true
|
|
34
|
+
})))),
|
|
35
|
+
container = _render4.container;
|
|
36
|
+
|
|
37
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
it('should match snapshot with checked checkbox', function () {
|
|
40
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
41
|
+
checked: true
|
|
42
|
+
})))),
|
|
43
|
+
container = _render5.container;
|
|
44
|
+
|
|
45
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
it('should match snapshot with disabled and checked checkbox', function () {
|
|
48
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
49
|
+
disabled: true,
|
|
50
|
+
checked: true
|
|
51
|
+
})))),
|
|
52
|
+
container = _render6.container;
|
|
53
|
+
|
|
54
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
55
|
+
});
|
|
56
|
+
it('should match snapshot with error checkbox', function () {
|
|
57
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
58
|
+
error: "Error text"
|
|
59
|
+
})))),
|
|
60
|
+
container = _render7.container;
|
|
61
|
+
|
|
62
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
63
|
+
});
|
|
64
|
+
it('should match snapshot with error and checked checkbox', function () {
|
|
65
|
+
var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
66
|
+
error: "Error text",
|
|
67
|
+
checked: true
|
|
68
|
+
})))),
|
|
69
|
+
container = _render8.container;
|
|
70
|
+
|
|
71
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
72
|
+
});
|
|
73
|
+
it('should match snapshot with inverted', function () {
|
|
74
|
+
var _render9 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
75
|
+
inverted: true
|
|
76
|
+
})))),
|
|
77
|
+
container = _render9.container;
|
|
78
|
+
|
|
79
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
80
|
+
});
|
|
81
|
+
it('should match snapshot with inverted and checked', function () {
|
|
82
|
+
var _render10 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
83
|
+
inverted: true,
|
|
84
|
+
checked: true
|
|
85
|
+
})))),
|
|
86
|
+
container = _render10.container;
|
|
87
|
+
|
|
88
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
89
|
+
});
|
|
90
|
+
it('should match snapshot with inverted and checked and disabled', function () {
|
|
91
|
+
var _render11 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
92
|
+
inverted: true,
|
|
93
|
+
checked: true,
|
|
94
|
+
disabled: true
|
|
95
|
+
})))),
|
|
96
|
+
container = _render11.container;
|
|
97
|
+
|
|
98
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
describe('Events', function () {
|
|
102
|
+
it('should call onChange function when press on Checkbox', function () {
|
|
103
|
+
var onChangeMock = jest.fn();
|
|
104
|
+
|
|
105
|
+
var _render12 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
106
|
+
onPress: onChangeMock,
|
|
107
|
+
testID: "checkbox"
|
|
108
|
+
})))),
|
|
109
|
+
getByTestId = _render12.getByTestId;
|
|
110
|
+
|
|
111
|
+
fireEvent.press(getByTestId('checkbox'));
|
|
112
|
+
expect(onChangeMock).toHaveBeenCalled();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var _templateObject, _templateObject2;
|
|
2
|
+
|
|
3
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
4
|
+
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
|
+
import { bool } from 'prop-types';
|
|
7
|
+
import styled, { withTheme } from 'styled-components';
|
|
8
|
+
import { hexToRgb } from '@gympass/yoga-common';
|
|
9
|
+
import { Animated } from 'react-native';
|
|
10
|
+
import withTouchable from '../../Button/native/withTouchable';
|
|
11
|
+
import Box from '../../Box';
|
|
12
|
+
var SwitchTrack = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", ";\n"])), function (_ref) {
|
|
13
|
+
var checkboxswitch = _ref.theme.yoga.components.checkboxswitch,
|
|
14
|
+
checked = _ref.checked,
|
|
15
|
+
disabled = _ref.disabled;
|
|
16
|
+
return "\n display: flex;\n justify-content: center;\n width: " + checkboxswitch.track.width + "px;\n height: " + checkboxswitch.track.height + "px;\n borderRadius: " + checkboxswitch.track.radii + "px;\n background-color: " + (checked ? checkboxswitch.track.checked.backgroundColor : checkboxswitch.track.backgroundColor) + ";\n\n " + (disabled ? "\n background-color: " + checkboxswitch.track.disabled.backgroundColor + ";" : '') + "\n ";
|
|
17
|
+
});
|
|
18
|
+
var ThumbShadow = styled.View(function (_ref2) {
|
|
19
|
+
var _ref2$theme$yoga = _ref2.theme.yoga,
|
|
20
|
+
colors = _ref2$theme$yoga.colors,
|
|
21
|
+
checkboxswitch = _ref2$theme$yoga.components.checkboxswitch,
|
|
22
|
+
checked = _ref2.checked;
|
|
23
|
+
var width = checkboxswitch.thumb.width * checkboxswitch.thumb.shadowScale;
|
|
24
|
+
var height = checkboxswitch.thumb.height * checkboxswitch.thumb.shadowScale;
|
|
25
|
+
return "\n width: " + width + "px;\n height: " + height + "px;\n position: absolute;\n background-color: " + (checked ? hexToRgb(colors.primary, 0.75) : hexToRgb(colors.elements.backgroundAndDisabled, 0.75)) + ";\n border-radius: " + checkboxswitch.thumb.radii + "px;\n ";
|
|
26
|
+
});
|
|
27
|
+
var SwitchThumb = styled(Box).attrs(function (_ref3) {
|
|
28
|
+
var checkboxswitch = _ref3.theme.yoga.components.checkboxswitch,
|
|
29
|
+
disabled = _ref3.disabled;
|
|
30
|
+
return {
|
|
31
|
+
width: checkboxswitch.thumb.width,
|
|
32
|
+
height: checkboxswitch.thumb.height,
|
|
33
|
+
borderRadius: checkboxswitch.thumb.radii,
|
|
34
|
+
bgColor: disabled ? checkboxswitch.thumb.disabled.backgroundColor : checkboxswitch.thumb.backgroundColor,
|
|
35
|
+
elevation: checkboxswitch.thumb.shadow
|
|
36
|
+
};
|
|
37
|
+
})(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose([""])));
|
|
38
|
+
|
|
39
|
+
var CheckboxSwitch = function CheckboxSwitch(_ref4) {
|
|
40
|
+
var checked = _ref4.checked,
|
|
41
|
+
pressed = _ref4.pressed,
|
|
42
|
+
disabled = _ref4.disabled,
|
|
43
|
+
checkboxswitch = _ref4.theme.yoga.components.checkboxswitch;
|
|
44
|
+
|
|
45
|
+
var _useState = useState(new Animated.Value(Number(checked))),
|
|
46
|
+
thumbPosition = _useState[0];
|
|
47
|
+
|
|
48
|
+
var thumbTo = checkboxswitch.track.width - checkboxswitch.thumb.width - checkboxswitch.thumb.left;
|
|
49
|
+
var thumbFrom = checkboxswitch.thumb.left;
|
|
50
|
+
var shadowDiameter = checkboxswitch.thumb.width * checkboxswitch.thumb.shadowScale;
|
|
51
|
+
var shadowAndThumbDiff = shadowDiameter - checkboxswitch.thumb.width;
|
|
52
|
+
var halfDiff = shadowAndThumbDiff / 2;
|
|
53
|
+
var thumbShadowFrom = (halfDiff - checkboxswitch.thumb.left) * -1;
|
|
54
|
+
var thumbShadowTo = thumbTo - halfDiff;
|
|
55
|
+
useEffect(function () {
|
|
56
|
+
var toggle = function toggle(isChecked, position) {
|
|
57
|
+
var animValue = {
|
|
58
|
+
fromValue: isChecked ? 0 : 1,
|
|
59
|
+
toValue: isChecked ? 1 : 0,
|
|
60
|
+
duration: 100,
|
|
61
|
+
useNativeDriver: false
|
|
62
|
+
};
|
|
63
|
+
Animated.timing(position, animValue).start();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
toggle(!checked, thumbPosition);
|
|
67
|
+
}, [checked]);
|
|
68
|
+
return /*#__PURE__*/React.createElement(SwitchTrack, {
|
|
69
|
+
checked: checked,
|
|
70
|
+
disabled: disabled,
|
|
71
|
+
as: Animated.View,
|
|
72
|
+
style: !disabled && {
|
|
73
|
+
backgroundColor: thumbPosition.interpolate({
|
|
74
|
+
inputRange: [0, 1],
|
|
75
|
+
outputRange: [checkboxswitch.track.checked.backgroundColor, checkboxswitch.track.backgroundColor]
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}, pressed && !disabled && /*#__PURE__*/React.createElement(ThumbShadow, {
|
|
79
|
+
checked: checked,
|
|
80
|
+
as: Animated.View,
|
|
81
|
+
style: {
|
|
82
|
+
transform: [{
|
|
83
|
+
translateX: thumbPosition.interpolate({
|
|
84
|
+
inputRange: [0, 1],
|
|
85
|
+
outputRange: [thumbShadowTo, thumbShadowFrom]
|
|
86
|
+
})
|
|
87
|
+
}]
|
|
88
|
+
}
|
|
89
|
+
}), /*#__PURE__*/React.createElement(SwitchThumb, {
|
|
90
|
+
checked: checked,
|
|
91
|
+
disabled: disabled,
|
|
92
|
+
as: Animated.View,
|
|
93
|
+
style: {
|
|
94
|
+
transform: [{
|
|
95
|
+
translateX: thumbPosition.interpolate({
|
|
96
|
+
inputRange: [0, 1],
|
|
97
|
+
outputRange: [thumbTo, thumbFrom]
|
|
98
|
+
})
|
|
99
|
+
}]
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
CheckboxSwitch.propTypes = {
|
|
105
|
+
checked: bool,
|
|
106
|
+
disabled: bool,
|
|
107
|
+
pressed: bool
|
|
108
|
+
};
|
|
109
|
+
CheckboxSwitch.defaultProps = {
|
|
110
|
+
checked: false,
|
|
111
|
+
disabled: false,
|
|
112
|
+
pressed: false
|
|
113
|
+
};
|
|
114
|
+
CheckboxSwitch.displayName = 'Checkbox.Switch';
|
|
115
|
+
export default withTouchable(withTheme(CheckboxSwitch));
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent, toJSON } from '@testing-library/react-native';
|
|
3
|
+
import Checkbox from '..';
|
|
4
|
+
import ThemeProvider from '../../Theme';
|
|
5
|
+
jest.useFakeTimers();
|
|
6
|
+
describe('<Checkbox />', function () {
|
|
7
|
+
describe('<Checkbox.Switch />', function () {
|
|
8
|
+
describe('Snapshots', function () {
|
|
9
|
+
it('should match snapshot with default switch', function () {
|
|
10
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox.Switch, null))),
|
|
11
|
+
container = _render.container;
|
|
12
|
+
|
|
13
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
14
|
+
});
|
|
15
|
+
it('should match snapshot with disabled switch', function () {
|
|
16
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox.Switch, {
|
|
17
|
+
disabled: true
|
|
18
|
+
}))),
|
|
19
|
+
container = _render2.container;
|
|
20
|
+
|
|
21
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
it('should match snapshot with checked switch', function () {
|
|
24
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox.Switch, {
|
|
25
|
+
checked: true
|
|
26
|
+
}))),
|
|
27
|
+
container = _render3.container;
|
|
28
|
+
|
|
29
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
it('should match snapshot with disabled and checked switch', function () {
|
|
32
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox.Switch, {
|
|
33
|
+
disabled: true,
|
|
34
|
+
checked: true
|
|
35
|
+
}))),
|
|
36
|
+
container = _render4.container;
|
|
37
|
+
|
|
38
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
it('should call onChange function when click on Checkbox.Switch', function () {
|
|
41
|
+
var onChangeMock = jest.fn();
|
|
42
|
+
|
|
43
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox.Switch, {
|
|
44
|
+
onChange: onChangeMock,
|
|
45
|
+
accessibilityRole: "button"
|
|
46
|
+
}))),
|
|
47
|
+
getByRole = _render5.getByRole;
|
|
48
|
+
|
|
49
|
+
fireEvent.press(getByRole('button'));
|
|
50
|
+
expect(onChangeMock).toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-console */
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
6
|
+
import Checkbox from '..';
|
|
7
|
+
import ThemeProvider from '../../Theme';
|
|
8
|
+
var data = {
|
|
9
|
+
label: 'Checkbox Component',
|
|
10
|
+
helper: 'Helper Text'
|
|
11
|
+
};
|
|
12
|
+
var originalError = console.error;
|
|
13
|
+
beforeEach(function () {
|
|
14
|
+
console.error = jest.fn();
|
|
15
|
+
});
|
|
16
|
+
afterEach(function () {
|
|
17
|
+
console.error = originalError;
|
|
18
|
+
});
|
|
19
|
+
describe('<Checkbox />', function () {
|
|
20
|
+
describe('Snapshots', function () {
|
|
21
|
+
it('should match snapshot without props', function () {
|
|
22
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, null))),
|
|
23
|
+
container = _render.container;
|
|
24
|
+
|
|
25
|
+
expect(container).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
it('should match snapshot with default checkbox', function () {
|
|
28
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, data))),
|
|
29
|
+
container = _render2.container;
|
|
30
|
+
|
|
31
|
+
expect(container).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
it('should match snapshot with disabled checkbox', function () {
|
|
34
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
35
|
+
disabled: true
|
|
36
|
+
})))),
|
|
37
|
+
container = _render3.container;
|
|
38
|
+
|
|
39
|
+
expect(container).toMatchSnapshot();
|
|
40
|
+
});
|
|
41
|
+
it('should match snapshot with checked checkbox', function () {
|
|
42
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
43
|
+
checked: true
|
|
44
|
+
})))),
|
|
45
|
+
container = _render4.container;
|
|
46
|
+
|
|
47
|
+
expect(container).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
it('should match snapshot with disabled and checked checkbox', function () {
|
|
50
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
51
|
+
disabled: true,
|
|
52
|
+
checked: true
|
|
53
|
+
})))),
|
|
54
|
+
container = _render5.container;
|
|
55
|
+
|
|
56
|
+
expect(container).toMatchSnapshot();
|
|
57
|
+
});
|
|
58
|
+
it('should match snapshot with error checkbox', function () {
|
|
59
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
60
|
+
error: "Error msg"
|
|
61
|
+
})))),
|
|
62
|
+
container = _render6.container;
|
|
63
|
+
|
|
64
|
+
expect(container).toMatchSnapshot();
|
|
65
|
+
});
|
|
66
|
+
it('should match snapshot with error and checked checkbox', function () {
|
|
67
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
68
|
+
error: "Error msg",
|
|
69
|
+
checked: true
|
|
70
|
+
})))),
|
|
71
|
+
container = _render7.container;
|
|
72
|
+
|
|
73
|
+
expect(container).toMatchSnapshot();
|
|
74
|
+
});
|
|
75
|
+
it('should match snapshot with inverted', function () {
|
|
76
|
+
var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
77
|
+
inverted: true
|
|
78
|
+
})))),
|
|
79
|
+
container = _render8.container;
|
|
80
|
+
|
|
81
|
+
expect(container).toMatchSnapshot();
|
|
82
|
+
});
|
|
83
|
+
it('should match snapshot with inverted and checked', function () {
|
|
84
|
+
var _render9 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
85
|
+
inverted: true,
|
|
86
|
+
checked: true
|
|
87
|
+
})))),
|
|
88
|
+
container = _render9.container;
|
|
89
|
+
|
|
90
|
+
expect(container).toMatchSnapshot();
|
|
91
|
+
});
|
|
92
|
+
it('should match snapshot with inverted and checked and disabled', function () {
|
|
93
|
+
var _render10 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
94
|
+
inverted: true,
|
|
95
|
+
checked: true,
|
|
96
|
+
disabled: true
|
|
97
|
+
})))),
|
|
98
|
+
container = _render10.container;
|
|
99
|
+
|
|
100
|
+
expect(container).toMatchSnapshot();
|
|
101
|
+
});
|
|
102
|
+
it('should match snapshot with indeterminate', function () {
|
|
103
|
+
var _render11 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, {
|
|
104
|
+
indeterminate: true
|
|
105
|
+
}))),
|
|
106
|
+
container = _render11.container;
|
|
107
|
+
|
|
108
|
+
expect(container).toMatchSnapshot();
|
|
109
|
+
});
|
|
110
|
+
it('should match snapshot with indeterminate and disabled checkbox', function () {
|
|
111
|
+
var _render12 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, {
|
|
112
|
+
indeterminate: true,
|
|
113
|
+
disabled: true
|
|
114
|
+
}))),
|
|
115
|
+
container = _render12.container;
|
|
116
|
+
|
|
117
|
+
expect(container).toMatchSnapshot();
|
|
118
|
+
});
|
|
119
|
+
it('should match snapshot with error and indeterminate checkbox', function () {
|
|
120
|
+
var _render13 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
121
|
+
error: "Error msg",
|
|
122
|
+
indeterminate: true
|
|
123
|
+
})))),
|
|
124
|
+
container = _render13.container;
|
|
125
|
+
|
|
126
|
+
expect(container).toMatchSnapshot();
|
|
127
|
+
});
|
|
128
|
+
it('should match snapshot with inverted and indeterminate', function () {
|
|
129
|
+
var _render14 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
130
|
+
inverted: true,
|
|
131
|
+
indeterminate: true
|
|
132
|
+
})))),
|
|
133
|
+
container = _render14.container;
|
|
134
|
+
|
|
135
|
+
expect(container).toMatchSnapshot();
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
describe('Events', function () {
|
|
139
|
+
it('should call onChange function when press on Checkbox', function () {
|
|
140
|
+
var onChangeMock = jest.fn();
|
|
141
|
+
|
|
142
|
+
var _render15 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
143
|
+
onChange: onChangeMock
|
|
144
|
+
})))),
|
|
145
|
+
getByRole = _render15.getByRole;
|
|
146
|
+
|
|
147
|
+
fireEvent.click(getByRole('checkbox', {
|
|
148
|
+
hidden: true
|
|
149
|
+
}));
|
|
150
|
+
expect(onChangeMock).toHaveBeenCalled();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import Checkbox from '..';
|
|
4
|
+
import ThemeProvider from '../../Theme';
|
|
5
|
+
describe('<Checkbox />', function () {
|
|
6
|
+
describe('<Checkbox.Switch />', function () {
|
|
7
|
+
describe('Snapshots', function () {
|
|
8
|
+
it('should match snapshot with default switch', function () {
|
|
9
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox.Switch, null))),
|
|
10
|
+
container = _render.container;
|
|
11
|
+
|
|
12
|
+
expect(container).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
it('should match snapshot with disabled switch', function () {
|
|
15
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox.Switch, {
|
|
16
|
+
disabled: true
|
|
17
|
+
}))),
|
|
18
|
+
container = _render2.container;
|
|
19
|
+
|
|
20
|
+
expect(container).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
it('should match snapshot with checked switch', function () {
|
|
23
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox.Switch, {
|
|
24
|
+
checked: true
|
|
25
|
+
}))),
|
|
26
|
+
container = _render3.container;
|
|
27
|
+
|
|
28
|
+
expect(container).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
it('should match snapshot with disabled and checked switch', function () {
|
|
31
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox.Switch, {
|
|
32
|
+
disabled: true,
|
|
33
|
+
checked: true
|
|
34
|
+
}))),
|
|
35
|
+
container = _render4.container;
|
|
36
|
+
|
|
37
|
+
expect(container).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
it('should call onChange function when click on Checkbox.Switch', function () {
|
|
40
|
+
var onChangeMock = jest.fn();
|
|
41
|
+
|
|
42
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox.Switch, {
|
|
43
|
+
disabled: true,
|
|
44
|
+
checked: true,
|
|
45
|
+
onChange: onChangeMock
|
|
46
|
+
}))),
|
|
47
|
+
getByRole = _render5.getByRole;
|
|
48
|
+
|
|
49
|
+
fireEvent.click(getByRole('switch', {
|
|
50
|
+
hidden: true
|
|
51
|
+
}));
|
|
52
|
+
expect(onChangeMock).toHaveBeenCalled();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|