@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,98 @@
|
|
|
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, { useRef } from 'react';
|
|
4
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
5
|
+
import * as RN from 'react-native';
|
|
6
|
+
import { CheckedFull } from '@gympass/yoga-icons';
|
|
7
|
+
import { ThemeProvider, Snackbar } from '../..';
|
|
8
|
+
import { Button } from '../../Card/web/PlanCard/Actions';
|
|
9
|
+
RN.Animated.spring = jest.fn().mockReturnValue({
|
|
10
|
+
start: jest.fn()
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var Component = function Component(overrideProps) {
|
|
14
|
+
var snackbarRef = useRef();
|
|
15
|
+
return /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Button, {
|
|
16
|
+
onPress: function onPress() {
|
|
17
|
+
snackbarRef.current.open();
|
|
18
|
+
}
|
|
19
|
+
}, "Tap to open snackbar"), /*#__PURE__*/React.createElement(Snackbar, _extends({
|
|
20
|
+
ref: snackbarRef,
|
|
21
|
+
message: "Feedback Message"
|
|
22
|
+
}, overrideProps)));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe('<Snackbar />', function () {
|
|
26
|
+
it('should match snapshot when snackbar is default', function () {
|
|
27
|
+
var _render = render( /*#__PURE__*/React.createElement(Component, null)),
|
|
28
|
+
container = _render.container;
|
|
29
|
+
|
|
30
|
+
expect(container).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
it('should match snapshot when have an icon and action', function () {
|
|
33
|
+
var overrideProps = {
|
|
34
|
+
icon: CheckedFull,
|
|
35
|
+
actionLabel: 'Action',
|
|
36
|
+
onAction: function onAction() {}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var _render2 = render( /*#__PURE__*/React.createElement(Component, overrideProps)),
|
|
40
|
+
container = _render2.container;
|
|
41
|
+
|
|
42
|
+
expect(container).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
it('should match snapshot when have a long text', function () {
|
|
45
|
+
var overrideProps = {
|
|
46
|
+
message: 'Lorem Ipsum is simply dummy text of the printing and types.',
|
|
47
|
+
icon: CheckedFull,
|
|
48
|
+
actionLabel: 'Action',
|
|
49
|
+
onAction: function onAction() {}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var _render3 = render( /*#__PURE__*/React.createElement(Component, overrideProps)),
|
|
53
|
+
container = _render3.container;
|
|
54
|
+
|
|
55
|
+
expect(container).toMatchSnapshot();
|
|
56
|
+
});
|
|
57
|
+
it('should match snapshot when have a variant informative or attention prop', function () {
|
|
58
|
+
var overrideProps = {
|
|
59
|
+
variant: 'informative'
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var _render4 = render( /*#__PURE__*/React.createElement(Component, overrideProps)),
|
|
63
|
+
container = _render4.container;
|
|
64
|
+
|
|
65
|
+
expect(container).toMatchSnapshot();
|
|
66
|
+
});
|
|
67
|
+
it('should show and hide snackbar when the open and close Animation function is called', function () {
|
|
68
|
+
var overrideProps = {
|
|
69
|
+
onSnackbarClose: jest.fn(),
|
|
70
|
+
actionLabel: 'Action',
|
|
71
|
+
onAction: jest.fn()
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var _render5 = render( /*#__PURE__*/React.createElement(Component, overrideProps)),
|
|
75
|
+
getByText = _render5.getByText,
|
|
76
|
+
getByTestId = _render5.getByTestId;
|
|
77
|
+
|
|
78
|
+
fireEvent.layout(getByTestId('wrapper'), {
|
|
79
|
+
nativeEvent: {
|
|
80
|
+
layout: {
|
|
81
|
+
height: 200
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
fireEvent.press(getByText('Tap to open snackbar'));
|
|
86
|
+
expect(RN.Animated.spring.mock.calls[0][1]).toEqual({
|
|
87
|
+
toValue: 0,
|
|
88
|
+
bounciness: 0,
|
|
89
|
+
useNativeDriver: true
|
|
90
|
+
});
|
|
91
|
+
fireEvent.press(getByText('Action'));
|
|
92
|
+
expect(RN.Animated.spring.mock.calls[1][1]).toEqual({
|
|
93
|
+
toValue: 200,
|
|
94
|
+
bounciness: 0,
|
|
95
|
+
useNativeDriver: true
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
2
|
+
import { Animated, useWindowDimensions, View } from 'react-native';
|
|
3
|
+
import { func, node, oneOf } from 'prop-types';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
var durationDictionary = {
|
|
6
|
+
fast: 4000,
|
|
7
|
+
"default": 8000,
|
|
8
|
+
slow: 10000,
|
|
9
|
+
indefinite: -1
|
|
10
|
+
};
|
|
11
|
+
var Wrapper = styled(Animated.View)(function () {
|
|
12
|
+
return "\n position: absolute;\n width: 100%;\n bottom: 0px;\n ";
|
|
13
|
+
});
|
|
14
|
+
var SnackbarAnimationWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
15
|
+
var onSnackbarClose = _ref.onSnackbarClose,
|
|
16
|
+
children = _ref.children,
|
|
17
|
+
duration = _ref.duration;
|
|
18
|
+
|
|
19
|
+
var _useWindowDimensions = useWindowDimensions(),
|
|
20
|
+
windowHeight = _useWindowDimensions.height;
|
|
21
|
+
|
|
22
|
+
var _useState = useState(),
|
|
23
|
+
childrenHeight = _useState[0],
|
|
24
|
+
setChildrenHeight = _useState[1];
|
|
25
|
+
|
|
26
|
+
var _translateY = useRef(new Animated.Value(windowHeight)).current;
|
|
27
|
+
var timeoutRef = useRef();
|
|
28
|
+
var childrenRef = useRef();
|
|
29
|
+
|
|
30
|
+
var openAnimation = function openAnimation() {
|
|
31
|
+
Animated.spring(_translateY, {
|
|
32
|
+
toValue: 0,
|
|
33
|
+
bounciness: 0,
|
|
34
|
+
useNativeDriver: true
|
|
35
|
+
}).start();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var closeAnimation = function closeAnimation(callback) {
|
|
39
|
+
if (childrenHeight) {
|
|
40
|
+
Animated.spring(_translateY, {
|
|
41
|
+
toValue: childrenHeight,
|
|
42
|
+
bounciness: 0,
|
|
43
|
+
useNativeDriver: true
|
|
44
|
+
}).start(function (_ref2) {
|
|
45
|
+
var finished = _ref2.finished;
|
|
46
|
+
|
|
47
|
+
if (finished && callback) {
|
|
48
|
+
callback();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (onSnackbarClose) {
|
|
53
|
+
onSnackbarClose();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var setupSnackbarTimeout = function setupSnackbarTimeout() {
|
|
59
|
+
var timeoutDuration = durationDictionary[duration];
|
|
60
|
+
var shouldCloseOnTimer = childrenHeight && timeoutDuration > 0;
|
|
61
|
+
|
|
62
|
+
if (shouldCloseOnTimer) {
|
|
63
|
+
timeoutRef.current = setTimeout(function () {
|
|
64
|
+
clearTimeout(timeoutRef.current);
|
|
65
|
+
closeAnimation();
|
|
66
|
+
}, timeoutDuration);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var openSnackbar = function openSnackbar() {
|
|
71
|
+
openAnimation();
|
|
72
|
+
setupSnackbarTimeout();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
var closeSnackbar = function closeSnackbar(callback) {
|
|
76
|
+
clearTimeout(timeoutRef.current);
|
|
77
|
+
closeAnimation(callback);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
useImperativeHandle(ref, function () {
|
|
81
|
+
return {
|
|
82
|
+
open: function open() {
|
|
83
|
+
openSnackbar();
|
|
84
|
+
},
|
|
85
|
+
close: function close(callback) {
|
|
86
|
+
closeSnackbar(callback);
|
|
87
|
+
},
|
|
88
|
+
translateY: function translateY(dy) {
|
|
89
|
+
_translateY.setValue(dy);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
useEffect(function () {
|
|
94
|
+
return function () {
|
|
95
|
+
return clearTimeout(timeoutRef.current);
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
98
|
+
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
99
|
+
style: {
|
|
100
|
+
zIndex: 10,
|
|
101
|
+
transform: [{
|
|
102
|
+
translateY: _translateY
|
|
103
|
+
}]
|
|
104
|
+
}
|
|
105
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
106
|
+
testID: "wrapper",
|
|
107
|
+
ref: childrenRef,
|
|
108
|
+
onLayout: function onLayout(_ref3) {
|
|
109
|
+
var height = _ref3.nativeEvent.layout.height;
|
|
110
|
+
setChildrenHeight(height);
|
|
111
|
+
|
|
112
|
+
_translateY.setValue(height);
|
|
113
|
+
}
|
|
114
|
+
}, children));
|
|
115
|
+
});
|
|
116
|
+
SnackbarAnimationWrapper.propTypes = {
|
|
117
|
+
onSnackbarClose: func,
|
|
118
|
+
children: node.isRequired,
|
|
119
|
+
duration: oneOf(['fast', 'default', 'slow', 'indefinite']).isRequired
|
|
120
|
+
};
|
|
121
|
+
SnackbarAnimationWrapper.defaultProps = {
|
|
122
|
+
onSnackbarClose: undefined
|
|
123
|
+
};
|
|
124
|
+
export default SnackbarAnimationWrapper;
|
|
@@ -27,15 +27,7 @@ var StyledSnackbar = styled.div(_templateObject3 || (_templateObject3 = _taggedT
|
|
|
27
27
|
}, media.md(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n left: auto;\n bottom: ", "px;\n right: ", "px;\n\n min-width: ", "px;\n "])), theme.components.snackbar.position.desktop.bottom, theme.components.snackbar.position.desktop.right, theme.components.snackbar.minWidth.desktop));
|
|
28
28
|
var fadeIn = keyframes(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n"])));
|
|
29
29
|
var AnimatedSnackbar = styled(StyledSnackbar)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n animation: ", " 0.2s ease-in-out;\n"])), fadeIn);
|
|
30
|
-
|
|
31
|
-
* Gympass `<Snackbar />` is the proper component to show alert messages.
|
|
32
|
-
*
|
|
33
|
-
* For web components, the `Snackbar` may have an icon, a custom action and a close button.
|
|
34
|
-
*
|
|
35
|
-
* For native, the `Snackbar` may have an icon and a custom action.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
var Snackbar = function Snackbar(_ref2) {
|
|
30
|
+
var Snackbar = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
39
31
|
var open = _ref2.open,
|
|
40
32
|
duration = _ref2.duration,
|
|
41
33
|
variant = _ref2.variant,
|
|
@@ -65,7 +57,8 @@ var Snackbar = function Snackbar(_ref2) {
|
|
|
65
57
|
return open && /*#__PURE__*/React.createElement(AnimatedSnackbar, _extends({
|
|
66
58
|
role: "alert",
|
|
67
59
|
"aria-label": variant,
|
|
68
|
-
variant: variant
|
|
60
|
+
variant: variant,
|
|
61
|
+
ref: ref
|
|
69
62
|
}, props), !hideIcon && /*#__PURE__*/React.createElement(Box, {
|
|
70
63
|
display: "flex",
|
|
71
64
|
alignItems: "center",
|
|
@@ -92,8 +85,7 @@ var Snackbar = function Snackbar(_ref2) {
|
|
|
92
85
|
fill: "secondary",
|
|
93
86
|
size: "medium"
|
|
94
87
|
}))));
|
|
95
|
-
};
|
|
96
|
-
|
|
88
|
+
});
|
|
97
89
|
Snackbar.propTypes = {
|
|
98
90
|
/** Controls the snackbar visibility. */
|
|
99
91
|
open: bool,
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
+
|
|
3
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
7
|
+
import { ThemeProvider, Snackbar } from '../..';
|
|
8
|
+
describe('<Snackbar />', function () {
|
|
9
|
+
jest.useRealTimers();
|
|
10
|
+
it('should match snapshot', function () {
|
|
11
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
12
|
+
open: true,
|
|
13
|
+
message: "Make wellbeing universal",
|
|
14
|
+
onClose: jest.fn()
|
|
15
|
+
}))),
|
|
16
|
+
container = _render.container;
|
|
17
|
+
|
|
18
|
+
expect(container).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
it('should render a minimal snackbar', function () {
|
|
21
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
22
|
+
open: true,
|
|
23
|
+
message: "Make wellbeing universal",
|
|
24
|
+
onClose: jest.fn()
|
|
25
|
+
})));
|
|
26
|
+
screen.getByRole('alert');
|
|
27
|
+
screen.getByRole('img');
|
|
28
|
+
screen.getByLabelText('success');
|
|
29
|
+
screen.getByText('Make wellbeing universal');
|
|
30
|
+
});
|
|
31
|
+
it('should not render an icon', function () {
|
|
32
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
33
|
+
open: true,
|
|
34
|
+
message: "Make wellbeing universal",
|
|
35
|
+
onClose: jest.fn(),
|
|
36
|
+
hideIcon: true
|
|
37
|
+
})));
|
|
38
|
+
expect(screen.queryByRole('img')).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
it('should render a custom action button', function () {
|
|
41
|
+
var onActionMock = jest.fn();
|
|
42
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
43
|
+
open: true,
|
|
44
|
+
message: "Make wellbeing universal",
|
|
45
|
+
onAction: onActionMock,
|
|
46
|
+
onClose: jest.fn(),
|
|
47
|
+
actionLabel: "Let's go"
|
|
48
|
+
})));
|
|
49
|
+
var button = screen.getByRole('button', {
|
|
50
|
+
name: /let's go/i
|
|
51
|
+
});
|
|
52
|
+
fireEvent.click(button);
|
|
53
|
+
expect(onActionMock).toHaveBeenCalledTimes(1);
|
|
54
|
+
});
|
|
55
|
+
it('should render a close button', function () {
|
|
56
|
+
var onCloseMock = jest.fn();
|
|
57
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
58
|
+
open: true,
|
|
59
|
+
message: "Make wellbeing universal",
|
|
60
|
+
onClose: onCloseMock
|
|
61
|
+
})));
|
|
62
|
+
var button = screen.getByRole('button');
|
|
63
|
+
fireEvent.click(button);
|
|
64
|
+
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
65
|
+
});
|
|
66
|
+
it('should close after timeout', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
67
|
+
var onCloseMock;
|
|
68
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
69
|
+
while (1) {
|
|
70
|
+
switch (_context.prev = _context.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
jest.useFakeTimers();
|
|
73
|
+
onCloseMock = jest.fn();
|
|
74
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
75
|
+
open: true,
|
|
76
|
+
duration: 1000,
|
|
77
|
+
message: "Make wellbeing universal",
|
|
78
|
+
onClose: onCloseMock,
|
|
79
|
+
hideCloseButton: true
|
|
80
|
+
})));
|
|
81
|
+
expect(screen.queryByRole('button')).toBeNull();
|
|
82
|
+
jest.runAllTimers();
|
|
83
|
+
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
84
|
+
|
|
85
|
+
case 6:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, _callee);
|
|
91
|
+
})));
|
|
92
|
+
it('should close with timeout set up', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
93
|
+
var onCloseMock, button;
|
|
94
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
95
|
+
while (1) {
|
|
96
|
+
switch (_context2.prev = _context2.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
onCloseMock = jest.fn();
|
|
99
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
100
|
+
open: true,
|
|
101
|
+
duration: 1000,
|
|
102
|
+
message: "Make wellbeing universal",
|
|
103
|
+
onClose: onCloseMock
|
|
104
|
+
})));
|
|
105
|
+
button = screen.getByRole('button');
|
|
106
|
+
fireEvent.click(button);
|
|
107
|
+
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
108
|
+
|
|
109
|
+
case 5:
|
|
110
|
+
case "end":
|
|
111
|
+
return _context2.stop();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}, _callee2);
|
|
115
|
+
})));
|
|
116
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
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 from 'react';
|
|
6
|
+
import { number, arrayOf, string } from 'prop-types';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import activeDot from '../activeDot';
|
|
9
|
+
import Text from '../../Text';
|
|
10
|
+
var Wrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n flex-direction: row;\n justify-content: space-between;\n"])));
|
|
11
|
+
var DotWrapper = styled.View(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n width: 15px;\n"])));
|
|
12
|
+
var Dot = styled.View(function (_ref) {
|
|
13
|
+
var active = _ref.active,
|
|
14
|
+
stepper = _ref.theme.yoga.components.stepper;
|
|
15
|
+
return "\n width: 15px;\n height: 15px;\n\n margin-top: -6px;\n\n border-radius: " + stepper.dot.radius + "px;\n background-color: " + (active ? stepper.dot.backgroundColor.active : stepper.dot.backgroundColor.inactive) + ";\n ";
|
|
16
|
+
});
|
|
17
|
+
var Label = styled(Text.Bold)(function (_ref2) {
|
|
18
|
+
var active = _ref2.active,
|
|
19
|
+
stepper = _ref2.theme.yoga.components.stepper;
|
|
20
|
+
return "\n width: 95px;\n margin-top: 10px;\n margin-left: -40px;\n\n color: " + (active ? stepper.label.color.active : stepper.label.color.inactive) + ";\n\n font-size: " + stepper.label.font.size + "px;\n text-align: center;\n ";
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
var Dots = function Dots(_ref3) {
|
|
24
|
+
var activeStep = _ref3.activeStep,
|
|
25
|
+
labels = _ref3.labels;
|
|
26
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, labels.map(function (label, index) {
|
|
27
|
+
return /*#__PURE__*/React.createElement(DotWrapper, {
|
|
28
|
+
key: label
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Dot, {
|
|
30
|
+
active: activeDot(index, activeStep)
|
|
31
|
+
}), /*#__PURE__*/React.createElement(Label, {
|
|
32
|
+
active: activeDot(index, activeStep)
|
|
33
|
+
}, label));
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Dots.propTypes = {
|
|
38
|
+
activeStep: number,
|
|
39
|
+
labels: arrayOf(string)
|
|
40
|
+
};
|
|
41
|
+
Dots.defaultProps = {
|
|
42
|
+
activeStep: 0,
|
|
43
|
+
labels: []
|
|
44
|
+
};
|
|
45
|
+
export default Dots;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
|
|
3
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { number } from 'prop-types';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
var Wrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n position: relative;\n"])));
|
|
9
|
+
var InactiveLine = styled.View(function (_ref) {
|
|
10
|
+
var stepper = _ref.theme.yoga.components.stepper;
|
|
11
|
+
return "\n width: 100%;\n height: 4px;\n\n position: absolute;\n top: 0;\n\n background-color: " + stepper.line.backgroundColor.inactive + ";\n";
|
|
12
|
+
});
|
|
13
|
+
var ActiveLine = styled.View(function (_ref2) {
|
|
14
|
+
var width = _ref2.width,
|
|
15
|
+
stepper = _ref2.theme.yoga.components.stepper;
|
|
16
|
+
return "\n position: absolute;\n top: 0;\n\n background-color: " + stepper.line.backgroundColor.active + ";\n width: " + width + "%;\n height: 4px;\n";
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var Line = function Line(_ref3) {
|
|
20
|
+
var activeStep = _ref3.activeStep,
|
|
21
|
+
totalSteps = _ref3.totalSteps;
|
|
22
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(InactiveLine, null), /*#__PURE__*/React.createElement(ActiveLine, {
|
|
23
|
+
width: activeStep <= 0 ? 0 : activeStep / totalSteps * 100
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
Line.propTypes = {
|
|
28
|
+
activeStep: number,
|
|
29
|
+
totalSteps: number
|
|
30
|
+
};
|
|
31
|
+
Line.defaultProps = {
|
|
32
|
+
activeStep: 0,
|
|
33
|
+
totalSteps: 0
|
|
34
|
+
};
|
|
35
|
+
export default Line;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
|
|
3
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { string } from 'prop-types';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
var Wrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n width: 100%;\n"])));
|
|
9
|
+
|
|
10
|
+
var Step = function Step(props) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(Wrapper, props);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Step.displayName = 'Stepper.Step';
|
|
15
|
+
Step.propTypes = {
|
|
16
|
+
/** Label to be displayed below the stepper dot. */
|
|
17
|
+
label: string.isRequired
|
|
18
|
+
};
|
|
19
|
+
export default Step;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var _excluded = ["children", "activeStep"];
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
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
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import styled from 'styled-components';
|
|
11
|
+
import { limitChildren, typeOf } from '../../shared';
|
|
12
|
+
import Line from './Line';
|
|
13
|
+
import Dots from './Dots';
|
|
14
|
+
import Step from './Step';
|
|
15
|
+
var Wrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n width: 100%;\n"])));
|
|
16
|
+
var LineWrapper = styled.View(function (_ref) {
|
|
17
|
+
var stepper = _ref.theme.yoga.components.stepper;
|
|
18
|
+
return "\n width: 100%;\n padding: 0 " + stepper.padding.right + "px 0 " + stepper.padding.left + "px;\n";
|
|
19
|
+
});
|
|
20
|
+
/** Stepper is responsible for the logic that drives a stepped workflow, it
|
|
21
|
+
provides a wizard-like workflow by dividing content into logical steps. */
|
|
22
|
+
|
|
23
|
+
var Stepper = function Stepper(_ref2) {
|
|
24
|
+
var children = _ref2.children,
|
|
25
|
+
activeStep = _ref2.activeStep,
|
|
26
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
27
|
+
|
|
28
|
+
return /*#__PURE__*/React.createElement(Wrapper, rest, /*#__PURE__*/React.createElement(LineWrapper, null, /*#__PURE__*/React.createElement(Line, {
|
|
29
|
+
activeStep: activeStep,
|
|
30
|
+
totalSteps: React.Children.count(children) - 1
|
|
31
|
+
}), /*#__PURE__*/React.createElement(Dots, {
|
|
32
|
+
activeStep: activeStep,
|
|
33
|
+
labels: React.Children.map(children, function (child) {
|
|
34
|
+
return child.props.label;
|
|
35
|
+
})
|
|
36
|
+
})), React.Children.toArray(children)[activeStep]);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
Stepper.displayName = 'Stepper';
|
|
40
|
+
Stepper.propTypes = {
|
|
41
|
+
/** Must be a Stepper.Step component. */
|
|
42
|
+
children: typeOf(Step),
|
|
43
|
+
|
|
44
|
+
/** Controls the active step, it receive the index value for showing some
|
|
45
|
+
* step. Starting from 0. */
|
|
46
|
+
activeStep: limitChildren
|
|
47
|
+
};
|
|
48
|
+
Stepper.defaultProps = {
|
|
49
|
+
children: undefined,
|
|
50
|
+
activeStep: 0
|
|
51
|
+
};
|
|
52
|
+
export default Stepper;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { render, toJSON } from '@testing-library/react-native';
|
|
4
|
+
import ThemeProvider from '../../Theme';
|
|
5
|
+
import Stepper from '..';
|
|
6
|
+
describe('<Stepper />', function () {
|
|
7
|
+
describe('Snapshots', function () {
|
|
8
|
+
it('should match snapshot with first step active', function () {
|
|
9
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
10
|
+
activeStep: 0
|
|
11
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
12
|
+
label: "step one"
|
|
13
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step one content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
14
|
+
label: "step two"
|
|
15
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step two content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
16
|
+
label: "step three"
|
|
17
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step three content"))))),
|
|
18
|
+
container = _render.container;
|
|
19
|
+
|
|
20
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
it('should match snapshot with second step active', function () {
|
|
23
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
24
|
+
activeStep: 1
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
26
|
+
label: "step one"
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step one content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
28
|
+
label: "step two"
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step two content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
30
|
+
label: "step three"
|
|
31
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step three content"))))),
|
|
32
|
+
container = _render2.container;
|
|
33
|
+
|
|
34
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('Steps', function () {
|
|
38
|
+
it('should change the active step', function () {
|
|
39
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
40
|
+
activeStep: 0
|
|
41
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
42
|
+
label: "step one"
|
|
43
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step one content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
44
|
+
label: "step two"
|
|
45
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step two content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
46
|
+
label: "step three"
|
|
47
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step three content"))))),
|
|
48
|
+
queryByText = _render3.queryByText,
|
|
49
|
+
rerender = _render3.rerender;
|
|
50
|
+
|
|
51
|
+
expect(queryByText('step one content')).toBeTruthy();
|
|
52
|
+
expect(queryByText('step two content')).toBeFalsy();
|
|
53
|
+
expect(queryByText('step three content')).toBeFalsy();
|
|
54
|
+
rerender( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Stepper, {
|
|
55
|
+
activeStep: 1
|
|
56
|
+
}, /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
57
|
+
label: "step one"
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step one content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
59
|
+
label: "step two"
|
|
60
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step two content")), /*#__PURE__*/React.createElement(Stepper.Step, {
|
|
61
|
+
label: "step three"
|
|
62
|
+
}, /*#__PURE__*/React.createElement(Text, null, "step three content")))));
|
|
63
|
+
expect(queryByText('step one content')).toBeFalsy();
|
|
64
|
+
expect(queryByText('step two content')).toBeTruthy();
|
|
65
|
+
expect(queryByText('step three content')).toBeFalsy();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|