@gympass/yoga 7.60.0 → 7.60.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/Drawer/web/Content.js +1 -4
- package/esm/Drawer/web/Content.js +1 -4
- package/package.json +5 -5
- package/cjs/ActionRequirement/native/ActionRequirement.test.js +0 -1
- package/cjs/ActionRequirement/web/ActionRequirement.test.js +0 -40
- package/cjs/AutoComplete/web/AutoComplete.test.js +0 -156
- package/cjs/Avatar/native/Avatar.test.js +0 -1
- package/cjs/Avatar/web/Avatar.test.js +0 -72
- package/cjs/Banner/native/Banner.test.js +0 -1
- package/cjs/Banner/web/Banner.test.js +0 -121
- package/cjs/BottomSheet/web/BottomSheet.test.js +0 -61
- package/cjs/Box/native/Box.test.js +0 -1
- package/cjs/Box/web/Box.test.js +0 -23
- package/cjs/Button/native/Button.test.js +0 -1
- package/cjs/Button/web/Button.test.js +0 -778
- package/cjs/Card/native/Card/Card.test.js +0 -1
- package/cjs/Card/native/EventCard/EventCard.test.js +0 -1
- package/cjs/Card/native/GymCard/CheckIn/CheckIn.test.js +0 -1
- package/cjs/Card/native/PlanCard/PlanCard.test.js +0 -1
- package/cjs/Card/web/Card/Card.test.js +0 -22
- package/cjs/Card/web/EventCard/EventCard.test.js +0 -35
- package/cjs/Card/web/PlanCard/PlanCard.test.js +0 -104
- package/cjs/Checkbox/native/Checkbox.test.js +0 -1
- package/cjs/Checkbox/native/Switch.test.js +0 -1
- package/cjs/Checkbox/web/Checkbox.test.js +0 -161
- package/cjs/Checkbox/web/Switch.test.js +0 -65
- package/cjs/Chips/native/Chips.test.js +0 -1
- package/cjs/Chips/web/Chips.test.js +0 -138
- package/cjs/Datepicker/web/Datepicker.test.js +0 -286
- package/cjs/Dialog/web/Dialog.test.js +0 -78
- package/cjs/Divider/native/Divider.test.js +0 -1
- package/cjs/Divider/web/Divider.test.js +0 -36
- package/cjs/Drawer/web/Drawer.test.js +0 -46
- package/cjs/Dropdown/native/Backdrop.test.js +0 -1
- package/cjs/Dropdown/native/Dropdown.test.js +0 -1
- package/cjs/Dropdown/web/Dropdown.test.js +0 -102
- package/cjs/Feedback/web/Feedback.test.js +0 -89
- package/cjs/Grid/web/Col.test.js +0 -56
- package/cjs/Grid/web/Container.test.js +0 -22
- package/cjs/Grid/web/Hide.test.js +0 -39
- package/cjs/Grid/web/Row.test.js +0 -22
- package/cjs/Header/web/Header.test.js +0 -49
- package/cjs/Heading/web/Heading.test.js +0 -68
- package/cjs/Icon/native/Icon.test.js +0 -1
- package/cjs/Icon/web/Icon.test.js +0 -53
- package/cjs/Input/native/Email.test.js +0 -1
- package/cjs/Input/native/Input.test.js +0 -1
- package/cjs/Input/native/Number.test.js +0 -1
- package/cjs/Input/native/Password.test.js +0 -1
- package/cjs/Input/native/Tel.test.js +0 -1
- package/cjs/Input/web/Email.test.js +0 -20
- package/cjs/Input/web/Input.test.js +0 -161
- package/cjs/Input/web/Number.test.js +0 -20
- package/cjs/Input/web/Password.test.js +0 -103
- package/cjs/Input/web/Tel.test.js +0 -20
- package/cjs/List/native/List.test.js +0 -1
- package/cjs/List/web/List.test.js +0 -69
- package/cjs/Menu/web/Menu.test.js +0 -123
- package/cjs/Popover/web/Popover.test.js +0 -27
- package/cjs/Progress/native/Progress.test.js +0 -1
- package/cjs/Progress/web/Progress.test.js +0 -229
- package/cjs/RadioGroup/native/Button/RadioButton.test.js +0 -1
- package/cjs/RadioGroup/native/Radio/Radio.test.js +0 -1
- package/cjs/RadioGroup/native/RadioGroup.test.js +0 -1
- package/cjs/RadioGroup/web/Button/RadioButton.test.js +0 -132
- package/cjs/RadioGroup/web/Radio/Radio.test.js +0 -119
- package/cjs/RadioGroup/web/RadioGroup.test.js +0 -93
- package/cjs/Rating/native/Rating.test.js +0 -1
- package/cjs/Rating/web/Rating.test.js +0 -201
- package/cjs/Result/native/Result.test.js +0 -1
- package/cjs/Skeleton/native/Skeleton.test.js +0 -1
- package/cjs/Skeleton/web/Skeleton.test.js +0 -84
- package/cjs/Slider/native/Slider.test.js +0 -1
- package/cjs/Slider/web/Slider.test.js +0 -95
- package/cjs/Snackbar/native/Snackbar.test.js +0 -1
- package/cjs/Snackbar/web/Snackbar.test.js +0 -137
- package/cjs/Stepper/native/Stepper.test.js +0 -1
- package/cjs/Stepper/web/Stepper.test.js +0 -75
- package/cjs/Tag/native/Tag.test.js +0 -1
- package/cjs/Tag/web/Tag.test.js +0 -87
- package/cjs/Text/native/Text.test.js +0 -1
- package/cjs/Text/web/Text.test.js +0 -157
- package/cjs/TextArea/native/TextArea.test.js +0 -1
- package/cjs/TextArea/web/TextArea.test.js +0 -18
- package/cjs/Theme/Provider/web/FontLoader.test.js +0 -19
- package/cjs/Theme/Provider/web/GlobalStyle.test.js +0 -27
- package/cjs/Theme/helpers/themeReader/native/native.test.js +0 -1
- package/cjs/Theme/helpers/themeReader/web/web.test.js +0 -54
- package/esm/ActionRequirement/index.native.js +0 -2
- package/esm/ActionRequirement/native/ActionRequirement.js +0 -48
- package/esm/ActionRequirement/native/ActionRequirement.test.js +0 -45
- package/esm/ActionRequirement/native/ActionRequirementStyles.js +0 -25
- package/esm/ActionRequirement/native/index.js +0 -6
- package/esm/ActionRequirement/web/ActionRequirement.test.js +0 -31
- package/esm/AutoComplete/web/AutoComplete.test.js +0 -139
- package/esm/Avatar/index.native.js +0 -4
- package/esm/Avatar/native/Avatar.js +0 -96
- package/esm/Avatar/native/Avatar.test.js +0 -46
- package/esm/Avatar/native/AvatarCircle.js +0 -24
- package/esm/Avatar/web/Avatar.test.js +0 -63
- package/esm/Banner/index.native.js +0 -2
- package/esm/Banner/native/Banner.js +0 -128
- package/esm/Banner/native/Banner.test.js +0 -103
- package/esm/Banner/native/index.js +0 -2
- package/esm/Banner/web/Banner.test.js +0 -109
- package/esm/BottomSheet/web/BottomSheet.test.js +0 -48
- package/esm/Box/index.native.js +0 -2
- package/esm/Box/native/Box.js +0 -4
- package/esm/Box/native/Box.test.js +0 -16
- package/esm/Box/native/index.js +0 -2
- package/esm/Box/web/Box.test.js +0 -16
- package/esm/Button/index.native.js +0 -8
- package/esm/Button/native/Button.js +0 -110
- package/esm/Button/native/Button.test.js +0 -475
- package/esm/Button/native/Icon.js +0 -82
- package/esm/Button/native/Link.js +0 -35
- package/esm/Button/native/Text.js +0 -74
- package/esm/Button/native/withTouchable.js +0 -63
- package/esm/Button/web/Button.test.js +0 -764
- package/esm/Card/index.native.js +0 -2
- package/esm/Card/native/Card/Actions.js +0 -12
- package/esm/Card/native/Card/Card.js +0 -92
- package/esm/Card/native/Card/Card.test.js +0 -15
- package/esm/Card/native/Card/Content.js +0 -8
- package/esm/Card/native/Card/Header.js +0 -8
- package/esm/Card/native/Card/index.js +0 -8
- package/esm/Card/native/EventCard/EventCard.js +0 -169
- package/esm/Card/native/EventCard/EventCard.test.js +0 -65
- package/esm/Card/native/EventCard/index.js +0 -2
- package/esm/Card/native/GymCard/CheckIn/Avatar.js +0 -17
- package/esm/Card/native/GymCard/CheckIn/CheckIn.js +0 -66
- package/esm/Card/native/GymCard/CheckIn/CheckIn.test.js +0 -39
- package/esm/Card/native/GymCard/CheckIn/Content.js +0 -11
- package/esm/Card/native/GymCard/CheckIn/Header.js +0 -11
- package/esm/Card/native/GymCard/CheckIn/index.js +0 -2
- package/esm/Card/native/GymCard/index.js +0 -5
- package/esm/Card/native/PlanCard/Actions.js +0 -22
- package/esm/Card/native/PlanCard/Content.js +0 -75
- package/esm/Card/native/PlanCard/List.js +0 -73
- package/esm/Card/native/PlanCard/PlanCard.js +0 -51
- package/esm/Card/native/PlanCard/PlanCard.test.js +0 -84
- package/esm/Card/native/PlanCard/Subtitle.js +0 -15
- package/esm/Card/native/PlanCard/Tag.js +0 -34
- package/esm/Card/native/PlanCard/index.js +0 -15
- package/esm/Card/native/index.js +0 -5
- package/esm/Card/web/Card/Card.test.js +0 -14
- package/esm/Card/web/EventCard/EventCard.test.js +0 -27
- package/esm/Card/web/PlanCard/PlanCard.test.js +0 -94
- package/esm/Checkbox/index.native.js +0 -3
- package/esm/Checkbox/native/Checkbox.js +0 -179
- package/esm/Checkbox/native/Checkbox.test.js +0 -115
- package/esm/Checkbox/native/Switch.js +0 -115
- package/esm/Checkbox/native/Switch.test.js +0 -54
- package/esm/Checkbox/native/index.js +0 -3
- package/esm/Checkbox/web/Checkbox.test.js +0 -153
- package/esm/Checkbox/web/Switch.test.js +0 -56
- package/esm/Chips/index.native.js +0 -2
- package/esm/Chips/native/Chips.js +0 -104
- package/esm/Chips/native/Chips.test.js +0 -143
- package/esm/Chips/native/Counter.js +0 -20
- package/esm/Chips/native/index.js +0 -2
- package/esm/Chips/web/Chips.test.js +0 -128
- package/esm/Datepicker/web/Datepicker.test.js +0 -247
- package/esm/Dialog/web/Dialog.test.js +0 -62
- package/esm/Divider/index.native.js +0 -2
- package/esm/Divider/native/Divider.js +0 -29
- package/esm/Divider/native/Divider.test.js +0 -29
- package/esm/Divider/native/index.js +0 -2
- package/esm/Divider/web/Divider.test.js +0 -29
- package/esm/Drawer/web/Drawer.test.js +0 -33
- package/esm/Dropdown/index.native.js +0 -2
- package/esm/Dropdown/native/Backdrop.js +0 -93
- package/esm/Dropdown/native/Backdrop.test.js +0 -26
- package/esm/Dropdown/native/Dropdown.js +0 -142
- package/esm/Dropdown/native/Dropdown.test.js +0 -78
- package/esm/Dropdown/native/Options.android.js +0 -66
- package/esm/Dropdown/native/Options.ios.js +0 -71
- package/esm/Dropdown/native/index.js +0 -2
- package/esm/Dropdown/web/Dropdown.test.js +0 -93
- package/esm/Feedback/web/Feedback.test.js +0 -83
- package/esm/Grid/web/Col.test.js +0 -48
- package/esm/Grid/web/Container.test.js +0 -14
- package/esm/Grid/web/Hide.test.js +0 -31
- package/esm/Grid/web/Row.test.js +0 -14
- package/esm/Header/web/Header.test.js +0 -38
- package/esm/Heading/web/Heading.test.js +0 -58
- package/esm/Icon/index.native.js +0 -2
- package/esm/Icon/native/Icon.test.js +0 -47
- package/esm/Icon/native/index.js +0 -2
- package/esm/Icon/web/Icon.test.js +0 -47
- package/esm/Input/index.native.js +0 -6
- package/esm/Input/native/Email.js +0 -15
- package/esm/Input/native/Email.test.js +0 -13
- package/esm/Input/native/Helper.js +0 -62
- package/esm/Input/native/Input.js +0 -234
- package/esm/Input/native/Input.test.js +0 -181
- package/esm/Input/native/Number.js +0 -12
- package/esm/Input/native/Number.test.js +0 -13
- package/esm/Input/native/Password.js +0 -112
- package/esm/Input/native/Password.test.js +0 -125
- package/esm/Input/native/Tel.js +0 -14
- package/esm/Input/native/Tel.test.js +0 -13
- package/esm/Input/native/index.js +0 -6
- package/esm/Input/web/Email.test.js +0 -13
- package/esm/Input/web/Input.test.js +0 -145
- package/esm/Input/web/Number.test.js +0 -13
- package/esm/Input/web/Password.test.js +0 -90
- package/esm/Input/web/Tel.test.js +0 -13
- package/esm/List/index.native.js +0 -3
- package/esm/List/native/List.js +0 -22
- package/esm/List/native/List.test.js +0 -106
- package/esm/List/native/ListItem.js +0 -51
- package/esm/List/native/index.js +0 -3
- package/esm/List/web/List.test.js +0 -62
- package/esm/Menu/web/Menu.test.js +0 -115
- package/esm/Popover/web/Popover.test.js +0 -19
- package/esm/Progress/index.native.js +0 -2
- package/esm/Progress/native/Progress.js +0 -103
- package/esm/Progress/native/Progress.test.js +0 -222
- package/esm/Progress/native/index.js +0 -2
- package/esm/Progress/web/Progress.test.js +0 -222
- package/esm/RadioGroup/index.native.js +0 -4
- package/esm/RadioGroup/native/Button/RadioButton.js +0 -64
- package/esm/RadioGroup/native/Button/RadioButton.test.js +0 -96
- package/esm/RadioGroup/native/Radio/Radio.js +0 -88
- package/esm/RadioGroup/native/Radio/Radio.test.js +0 -112
- package/esm/RadioGroup/native/RadioGroup.js +0 -66
- package/esm/RadioGroup/native/RadioGroup.test.js +0 -50
- package/esm/RadioGroup/native/index.js +0 -4
- package/esm/RadioGroup/web/Button/RadioButton.test.js +0 -121
- package/esm/RadioGroup/web/Radio/Radio.test.js +0 -108
- package/esm/RadioGroup/web/RadioGroup.test.js +0 -83
- package/esm/Rating/index.native.js +0 -2
- package/esm/Rating/native/Rating.js +0 -186
- package/esm/Rating/native/Rating.test.js +0 -121
- package/esm/Rating/native/index.js +0 -2
- package/esm/Rating/web/Rating.test.js +0 -184
- package/esm/Result/index.native.js +0 -8
- package/esm/Result/native/Attendances.js +0 -55
- package/esm/Result/native/Details.js +0 -97
- package/esm/Result/native/Rate.js +0 -35
- package/esm/Result/native/Result.js +0 -86
- package/esm/Result/native/Result.test.js +0 -107
- package/esm/Result/native/ResultButton.js +0 -13
- package/esm/Result/native/Tags.js +0 -41
- package/esm/Result/native/TinyTextIcon.js +0 -18
- package/esm/Result/native/index.js +0 -2
- package/esm/Skeleton/index.native.js +0 -2
- package/esm/Skeleton/native/Skeleton.js +0 -94
- package/esm/Skeleton/native/Skeleton.test.js +0 -78
- package/esm/Skeleton/native/index.js +0 -2
- package/esm/Skeleton/web/Skeleton.test.js +0 -77
- package/esm/Slider/index.native.js +0 -2
- package/esm/Slider/native/Label.js +0 -19
- package/esm/Slider/native/Marker.js +0 -68
- package/esm/Slider/native/Slider.js +0 -156
- package/esm/Slider/native/Slider.test.js +0 -122
- package/esm/Slider/native/Step.js +0 -14
- package/esm/Slider/native/Tooltip.js +0 -90
- package/esm/Slider/web/Slider.test.js +0 -86
- package/esm/Snackbar/index.native.js +0 -2
- package/esm/Snackbar/native/Snackbar.js +0 -199
- package/esm/Snackbar/native/Snackbar.test.js +0 -100
- package/esm/Snackbar/native/SnackbarAnimationWrapper.js +0 -124
- package/esm/Snackbar/native/index.js +0 -2
- package/esm/Snackbar/web/Snackbar.test.js +0 -118
- package/esm/Stepper/index.native.js +0 -3
- package/esm/Stepper/native/Dots.js +0 -45
- package/esm/Stepper/native/Line.js +0 -35
- package/esm/Stepper/native/Step.js +0 -19
- package/esm/Stepper/native/Stepper.js +0 -52
- package/esm/Stepper/native/Stepper.test.js +0 -70
- package/esm/Stepper/native/index.js +0 -3
- package/esm/Stepper/web/Stepper.test.js +0 -67
- package/esm/Tag/index.native.js +0 -4
- package/esm/Tag/native/Informative.js +0 -72
- package/esm/Tag/native/Tag.js +0 -75
- package/esm/Tag/native/Tag.test.js +0 -94
- package/esm/Tag/native/index.js +0 -2
- package/esm/Tag/web/Tag.test.js +0 -79
- package/esm/Text/index.native.js +0 -16
- package/esm/Text/native/Text.js +0 -69
- package/esm/Text/native/Text.test.js +0 -149
- package/esm/Text/native/index.js +0 -2
- package/esm/Text/web/Text.test.js +0 -149
- package/esm/TextArea/index.native.js +0 -2
- package/esm/TextArea/native/TextArea.js +0 -59
- package/esm/TextArea/native/TextArea.test.js +0 -11
- package/esm/TextArea/native/index.js +0 -2
- package/esm/TextArea/web/TextArea.test.js +0 -11
- package/esm/Theme/Provider/index.native.js +0 -2
- package/esm/Theme/Provider/native/index.js +0 -2
- package/esm/Theme/Provider/web/FontLoader.test.js +0 -11
- package/esm/Theme/Provider/web/GlobalStyle.test.js +0 -17
- package/esm/Theme/helpers/themeReader/native/native.test.js +0 -53
- package/esm/Theme/helpers/themeReader/web/web.test.js +0 -41
- package/esm/Theme/index.native.js +0 -5
- package/esm/index.native.js +0 -26
- package/esm/shared/index.native.js +0 -2
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
var _excluded = ["icon", "message", "actionLabel", "onAction", "variant", "onSnackbarClose", "duration", "bottomOffset"];
|
|
2
|
-
|
|
3
|
-
var _templateObject;
|
|
4
|
-
|
|
5
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
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, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
12
|
-
import styled from 'styled-components';
|
|
13
|
-
import { string, oneOf, func, elementType, number } from 'prop-types';
|
|
14
|
-
import { PanResponder } from 'react-native';
|
|
15
|
-
import Box from '../../Box';
|
|
16
|
-
import Button from '../../Button';
|
|
17
|
-
import Icon from '../../Icon';
|
|
18
|
-
import Text from '../../Text';
|
|
19
|
-
import SnackbarAnimationWrapper from './SnackbarAnimationWrapper';
|
|
20
|
-
var SWIPE_THRESHOLD = 32;
|
|
21
|
-
var SnackbarContainer = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", "\n"])), function (_ref) {
|
|
22
|
-
var bottomOffset = _ref.bottomOffset,
|
|
23
|
-
variant = _ref.variant,
|
|
24
|
-
_ref$theme$yoga = _ref.theme.yoga,
|
|
25
|
-
feedback = _ref$theme$yoga.colors.feedback,
|
|
26
|
-
_ref$theme$yoga$compo = _ref$theme$yoga.components.snackbar,
|
|
27
|
-
padding = _ref$theme$yoga$compo.padding,
|
|
28
|
-
margin = _ref$theme$yoga$compo.margin,
|
|
29
|
-
_ref$theme$yoga$compo2 = _ref$theme$yoga$compo.variant.color[variant],
|
|
30
|
-
backgroundColor = _ref$theme$yoga$compo2 === void 0 ? feedback.success.light : _ref$theme$yoga$compo2,
|
|
31
|
-
border = _ref$theme$yoga$compo.border;
|
|
32
|
-
return "\n padding: " + padding.vertical + "px " + padding.horizontal + "px;\n margin-horizontal: " + margin.horizontal + "px\n margin-bottom: " + (margin.bottom + bottomOffset) + "px;\n background-color: " + backgroundColor + ";\n border-radius: " + border.radius + "px;\n flex-direction: row;\n align-items: center;\n ";
|
|
33
|
-
});
|
|
34
|
-
/**
|
|
35
|
-
* Gympass `<Snackbar />` is the proper component to show alert messages.
|
|
36
|
-
*
|
|
37
|
-
* For web components, the `Snackbar` may have an icon, a custom action and a close button.
|
|
38
|
-
*
|
|
39
|
-
* For native, the `Snackbar` may have an icon and a custom action.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
var Snackbar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
43
|
-
var icon = props.icon,
|
|
44
|
-
message = props.message,
|
|
45
|
-
actionLabel = props.actionLabel,
|
|
46
|
-
onAction = props.onAction,
|
|
47
|
-
variant = props.variant,
|
|
48
|
-
onSnackbarClose = props.onSnackbarClose,
|
|
49
|
-
duration = props.duration,
|
|
50
|
-
bottomOffset = props.bottomOffset,
|
|
51
|
-
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
52
|
-
|
|
53
|
-
var wrapperRef = useRef();
|
|
54
|
-
|
|
55
|
-
var _useState = useState({
|
|
56
|
-
icon: icon,
|
|
57
|
-
message: message,
|
|
58
|
-
actionLabel: actionLabel,
|
|
59
|
-
onAction: onAction,
|
|
60
|
-
variant: variant
|
|
61
|
-
}),
|
|
62
|
-
currentProps = _useState[0],
|
|
63
|
-
setCurrentProps = _useState[1];
|
|
64
|
-
|
|
65
|
-
useImperativeHandle(ref, function () {
|
|
66
|
-
return {
|
|
67
|
-
open: function open() {
|
|
68
|
-
wrapperRef.current.open();
|
|
69
|
-
},
|
|
70
|
-
close: function close() {
|
|
71
|
-
wrapperRef.current.close();
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
});
|
|
75
|
-
useEffect(function () {
|
|
76
|
-
if (wrapperRef.current && currentProps.message) {
|
|
77
|
-
wrapperRef.current.close(function () {
|
|
78
|
-
setCurrentProps({
|
|
79
|
-
icon: icon,
|
|
80
|
-
message: message,
|
|
81
|
-
actionLabel: actionLabel,
|
|
82
|
-
onAction: onAction,
|
|
83
|
-
variant: variant
|
|
84
|
-
});
|
|
85
|
-
wrapperRef.current.open();
|
|
86
|
-
});
|
|
87
|
-
} else {
|
|
88
|
-
setCurrentProps({
|
|
89
|
-
icon: icon,
|
|
90
|
-
message: message,
|
|
91
|
-
actionLabel: actionLabel,
|
|
92
|
-
onAction: onAction,
|
|
93
|
-
variant: variant
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}, [icon, message, actionLabel, onAction, variant]);
|
|
97
|
-
|
|
98
|
-
var handlePanResponderRelease = function handlePanResponderRelease(_evt, gestureState) {
|
|
99
|
-
if (gestureState.dy > SWIPE_THRESHOLD) {
|
|
100
|
-
wrapperRef.current.close();
|
|
101
|
-
} else {
|
|
102
|
-
wrapperRef.current.open();
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
var panResponder = PanResponder.create({
|
|
107
|
-
onPanResponderMove: function onPanResponderMove(_, gestureState) {
|
|
108
|
-
if (gestureState.dy > 0) {
|
|
109
|
-
wrapperRef.current.translateY(gestureState.dy);
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
onPanResponderRelease: handlePanResponderRelease,
|
|
113
|
-
onPanResponderTerminate: handlePanResponderRelease,
|
|
114
|
-
onStartShouldSetPanResponder: function onStartShouldSetPanResponder() {
|
|
115
|
-
return true;
|
|
116
|
-
},
|
|
117
|
-
onMoveShouldSetPanResponder: function onMoveShouldSetPanResponder(_, gestureState) {
|
|
118
|
-
return !(gestureState.dy <= 2 && gestureState.dy >= -2);
|
|
119
|
-
},
|
|
120
|
-
onMoveShouldSetPanResponderCapture: function onMoveShouldSetPanResponderCapture() {
|
|
121
|
-
return true;
|
|
122
|
-
},
|
|
123
|
-
onPanResponderTerminationRequest: function onPanResponderTerminationRequest() {
|
|
124
|
-
return true;
|
|
125
|
-
},
|
|
126
|
-
onShouldBlockNativeResponder: function onShouldBlockNativeResponder() {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
var handleOnAction = function handleOnAction() {
|
|
132
|
-
wrapperRef.current.close();
|
|
133
|
-
|
|
134
|
-
if (currentProps.onAction) {
|
|
135
|
-
currentProps.onAction();
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return /*#__PURE__*/React.createElement(SnackbarAnimationWrapper, {
|
|
140
|
-
onSnackbarClose: onSnackbarClose,
|
|
141
|
-
duration: duration,
|
|
142
|
-
ref: wrapperRef
|
|
143
|
-
}, /*#__PURE__*/React.createElement(SnackbarContainer, _extends({
|
|
144
|
-
variant: currentProps.variant,
|
|
145
|
-
bottomOffset: bottomOffset
|
|
146
|
-
}, rest, panResponder.panHandlers), currentProps.icon && /*#__PURE__*/React.createElement(Icon, {
|
|
147
|
-
as: currentProps.icon,
|
|
148
|
-
fill: "secondary",
|
|
149
|
-
size: "large",
|
|
150
|
-
marginRight: "xxsmall"
|
|
151
|
-
}), /*#__PURE__*/React.createElement(Text, {
|
|
152
|
-
flex: 1,
|
|
153
|
-
fontSize: "small",
|
|
154
|
-
marginVertical: "xxxsmall",
|
|
155
|
-
numberOfLines: 2
|
|
156
|
-
}, currentProps.message), currentProps.actionLabel && /*#__PURE__*/React.createElement(Box, {
|
|
157
|
-
as: Button.Text,
|
|
158
|
-
small: true,
|
|
159
|
-
secondary: true,
|
|
160
|
-
marginLeft: "xxsmall",
|
|
161
|
-
onPress: handleOnAction
|
|
162
|
-
}, currentProps.actionLabel)));
|
|
163
|
-
});
|
|
164
|
-
Snackbar.propTypes = {
|
|
165
|
-
/** The style variant change the color of the component, it may be "success", "informative" or "attention". */
|
|
166
|
-
variant: oneOf(['success', 'informative', 'attention']),
|
|
167
|
-
|
|
168
|
-
/** Can be any icon of yoga-icons. */
|
|
169
|
-
icon: elementType,
|
|
170
|
-
|
|
171
|
-
/** The message shown when snackbar is opened. The maximum number of lines is two. */
|
|
172
|
-
message: string,
|
|
173
|
-
|
|
174
|
-
/** Label for a custom action. */
|
|
175
|
-
actionLabel: string,
|
|
176
|
-
|
|
177
|
-
/** Function for the custom action. The `actionLabel` becomes required when passing this function. */
|
|
178
|
-
onAction: func,
|
|
179
|
-
|
|
180
|
-
/** Callback function triggered by the Snackbar close action. Can be used for events, for example. */
|
|
181
|
-
onSnackbarClose: func,
|
|
182
|
-
|
|
183
|
-
/** The duration sets how long it will take to close snackbar automatically, it may be "fast" (4 seconds), "default" (8 seconds), "slow" (10 seconds) or "indefinite" (it doesn't close automatically). */
|
|
184
|
-
duration: oneOf(['fast', 'default', 'slow', 'indefinite']),
|
|
185
|
-
|
|
186
|
-
/** Add extra margin to Snackbar. Can be useful for SafeAreaView or button cases. */
|
|
187
|
-
bottomOffset: number
|
|
188
|
-
};
|
|
189
|
-
Snackbar.defaultProps = {
|
|
190
|
-
variant: 'success',
|
|
191
|
-
icon: undefined,
|
|
192
|
-
message: '',
|
|
193
|
-
actionLabel: undefined,
|
|
194
|
-
onAction: undefined,
|
|
195
|
-
onSnackbarClose: undefined,
|
|
196
|
-
duration: 'default',
|
|
197
|
-
bottomOffset: 0
|
|
198
|
-
};
|
|
199
|
-
export default Snackbar;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
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 '../../Button';
|
|
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
|
-
full: true,
|
|
17
|
-
small: true,
|
|
18
|
-
onPress: function onPress() {
|
|
19
|
-
snackbarRef.current.open();
|
|
20
|
-
}
|
|
21
|
-
}, "Tap to open snackbar"), /*#__PURE__*/React.createElement(Snackbar, _extends({
|
|
22
|
-
ref: snackbarRef,
|
|
23
|
-
message: "Feedback Message"
|
|
24
|
-
}, overrideProps)));
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
describe('<Snackbar />', function () {
|
|
28
|
-
it('should match snapshot when snackbar is default', function () {
|
|
29
|
-
var _render = render( /*#__PURE__*/React.createElement(Component, null)),
|
|
30
|
-
toJSON = _render.toJSON;
|
|
31
|
-
|
|
32
|
-
expect(toJSON()).toMatchSnapshot();
|
|
33
|
-
});
|
|
34
|
-
it('should match snapshot when have an icon and action', function () {
|
|
35
|
-
var overrideProps = {
|
|
36
|
-
icon: CheckedFull,
|
|
37
|
-
actionLabel: 'Action',
|
|
38
|
-
onAction: function onAction() {}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
var _render2 = render( /*#__PURE__*/React.createElement(Component, overrideProps)),
|
|
42
|
-
toJSON = _render2.toJSON;
|
|
43
|
-
|
|
44
|
-
expect(toJSON()).toMatchSnapshot();
|
|
45
|
-
});
|
|
46
|
-
it('should match snapshot when have a long text', function () {
|
|
47
|
-
var overrideProps = {
|
|
48
|
-
message: 'Lorem Ipsum is simply dummy text of the printing and types.',
|
|
49
|
-
icon: CheckedFull,
|
|
50
|
-
actionLabel: 'Action',
|
|
51
|
-
onAction: function onAction() {}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var _render3 = render( /*#__PURE__*/React.createElement(Component, overrideProps)),
|
|
55
|
-
toJSON = _render3.toJSON;
|
|
56
|
-
|
|
57
|
-
expect(toJSON()).toMatchSnapshot();
|
|
58
|
-
});
|
|
59
|
-
it('should match snapshot when have a variant informative or attention prop', function () {
|
|
60
|
-
var overrideProps = {
|
|
61
|
-
variant: 'informative'
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
var _render4 = render( /*#__PURE__*/React.createElement(Component, overrideProps)),
|
|
65
|
-
toJSON = _render4.toJSON;
|
|
66
|
-
|
|
67
|
-
expect(toJSON()).toMatchSnapshot();
|
|
68
|
-
});
|
|
69
|
-
it('should show and hide snackbar when the open and close Animation function is called', function () {
|
|
70
|
-
var overrideProps = {
|
|
71
|
-
onSnackbarClose: jest.fn(),
|
|
72
|
-
actionLabel: 'Action',
|
|
73
|
-
onAction: jest.fn()
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
var _render5 = render( /*#__PURE__*/React.createElement(Component, overrideProps)),
|
|
77
|
-
getByText = _render5.getByText,
|
|
78
|
-
getByTestId = _render5.getByTestId;
|
|
79
|
-
|
|
80
|
-
fireEvent(getByTestId('wrapper'), 'layout', {
|
|
81
|
-
nativeEvent: {
|
|
82
|
-
layout: {
|
|
83
|
-
height: 200
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
fireEvent.press(getByText('Tap to open snackbar'));
|
|
88
|
-
expect(RN.Animated.spring.mock.calls[0][1]).toEqual({
|
|
89
|
-
toValue: 0,
|
|
90
|
-
bounciness: 0,
|
|
91
|
-
useNativeDriver: true
|
|
92
|
-
});
|
|
93
|
-
fireEvent.press(getByText('Action'));
|
|
94
|
-
expect(RN.Animated.spring.mock.calls[1][1]).toEqual({
|
|
95
|
-
toValue: 200,
|
|
96
|
-
bounciness: 0,
|
|
97
|
-
useNativeDriver: true
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,124 +0,0 @@
|
|
|
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;
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
2
|
-
|
|
3
|
-
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); } }
|
|
4
|
-
|
|
5
|
-
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); }); }; }
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
9
|
-
import { ThemeProvider, Snackbar } from '../..';
|
|
10
|
-
describe('<Snackbar />', function () {
|
|
11
|
-
jest.useRealTimers();
|
|
12
|
-
it('should match snapshot', function () {
|
|
13
|
-
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
14
|
-
open: true,
|
|
15
|
-
message: "Make wellbeing universal",
|
|
16
|
-
onClose: jest.fn()
|
|
17
|
-
}))),
|
|
18
|
-
container = _render.container;
|
|
19
|
-
|
|
20
|
-
expect(container).toMatchSnapshot();
|
|
21
|
-
});
|
|
22
|
-
it('should render a minimal snackbar', function () {
|
|
23
|
-
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
24
|
-
open: true,
|
|
25
|
-
message: "Make wellbeing universal",
|
|
26
|
-
onClose: jest.fn()
|
|
27
|
-
})));
|
|
28
|
-
screen.getByRole('alert');
|
|
29
|
-
screen.getByRole('img');
|
|
30
|
-
screen.getByLabelText('success');
|
|
31
|
-
screen.getByText('Make wellbeing universal');
|
|
32
|
-
});
|
|
33
|
-
it('should not render an icon', function () {
|
|
34
|
-
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
35
|
-
open: true,
|
|
36
|
-
message: "Make wellbeing universal",
|
|
37
|
-
onClose: jest.fn(),
|
|
38
|
-
hideIcon: true
|
|
39
|
-
})));
|
|
40
|
-
expect(screen.queryByRole('img')).toBeNull();
|
|
41
|
-
});
|
|
42
|
-
it('should render a custom action button', function () {
|
|
43
|
-
var onActionMock = jest.fn();
|
|
44
|
-
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
45
|
-
open: true,
|
|
46
|
-
message: "Make wellbeing universal",
|
|
47
|
-
onAction: onActionMock,
|
|
48
|
-
onClose: jest.fn(),
|
|
49
|
-
actionLabel: "Let's go"
|
|
50
|
-
})));
|
|
51
|
-
var button = screen.getByRole('button', {
|
|
52
|
-
name: /let's go/i
|
|
53
|
-
});
|
|
54
|
-
fireEvent.click(button);
|
|
55
|
-
expect(onActionMock).toHaveBeenCalledTimes(1);
|
|
56
|
-
});
|
|
57
|
-
it('should render a close button', function () {
|
|
58
|
-
var onCloseMock = jest.fn();
|
|
59
|
-
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
60
|
-
open: true,
|
|
61
|
-
message: "Make wellbeing universal",
|
|
62
|
-
onClose: onCloseMock
|
|
63
|
-
})));
|
|
64
|
-
var button = screen.getByRole('button');
|
|
65
|
-
fireEvent.click(button);
|
|
66
|
-
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
67
|
-
});
|
|
68
|
-
it('should close after timeout', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
69
|
-
var onCloseMock;
|
|
70
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
71
|
-
while (1) {
|
|
72
|
-
switch (_context.prev = _context.next) {
|
|
73
|
-
case 0:
|
|
74
|
-
jest.useFakeTimers();
|
|
75
|
-
onCloseMock = jest.fn();
|
|
76
|
-
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
77
|
-
open: true,
|
|
78
|
-
duration: 1000,
|
|
79
|
-
message: "Make wellbeing universal",
|
|
80
|
-
onClose: onCloseMock,
|
|
81
|
-
hideCloseButton: true
|
|
82
|
-
})));
|
|
83
|
-
expect(screen.queryByRole('button')).toBeNull();
|
|
84
|
-
jest.runAllTimers();
|
|
85
|
-
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
86
|
-
|
|
87
|
-
case 6:
|
|
88
|
-
case "end":
|
|
89
|
-
return _context.stop();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}, _callee);
|
|
93
|
-
})));
|
|
94
|
-
it('should close with timeout set up', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
95
|
-
var onCloseMock, button;
|
|
96
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
97
|
-
while (1) {
|
|
98
|
-
switch (_context2.prev = _context2.next) {
|
|
99
|
-
case 0:
|
|
100
|
-
onCloseMock = jest.fn();
|
|
101
|
-
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Snackbar, {
|
|
102
|
-
open: true,
|
|
103
|
-
duration: 1000,
|
|
104
|
-
message: "Make wellbeing universal",
|
|
105
|
-
onClose: onCloseMock
|
|
106
|
-
})));
|
|
107
|
-
button = screen.getByRole('button');
|
|
108
|
-
fireEvent.click(button);
|
|
109
|
-
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
110
|
-
|
|
111
|
-
case 5:
|
|
112
|
-
case "end":
|
|
113
|
-
return _context2.stop();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}, _callee2);
|
|
117
|
-
})));
|
|
118
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
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;
|
|
@@ -1,35 +0,0 @@
|
|
|
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;
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|