@gympass/yoga 7.37.1 → 7.39.0
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.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.test.js +1 -0
- 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/Card.native.theme.js +9 -7
- package/cjs/Card/Card.theme.js +1 -1
- package/cjs/Card/Card.web.theme.js +8 -6
- 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/Actions.js +1 -1
- package/cjs/Card/native/PlanCard/Content.js +1 -1
- package/cjs/Card/native/PlanCard/PlanCard.js +1 -1
- package/cjs/Card/native/PlanCard/PlanCard.test.js +1 -0
- 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/Actions.js +1 -1
- package/cjs/Card/web/PlanCard/Content.js +28 -32
- package/cjs/Card/web/PlanCard/PlanCard.js +1 -1
- 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.test.js +1 -0
- package/cjs/Chips/web/Chips.test.js +138 -0
- package/cjs/Dialog/web/Dialog.test.js +70 -0
- package/cjs/Divider/native/Divider.test.js +1 -0
- package/cjs/Divider/web/Divider.test.js +36 -0
- package/cjs/Dropdown/native/Backdrop.test.js +1 -0
- package/cjs/Dropdown/native/Dropdown.test.js +1 -0
- 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/Heading/web/RightButton.js +1 -1
- package/cjs/Icon/native/Icon.test.js +1 -0
- package/cjs/Icon/web/Icon.test.js +53 -0
- package/cjs/Input/native/Email.test.js +1 -0
- package/cjs/Input/native/Input.test.js +1 -0
- package/cjs/Input/native/Number.test.js +1 -0
- package/cjs/Input/native/Password.test.js +1 -0
- package/cjs/Input/native/Tel.test.js +1 -0
- package/cjs/Input/web/Email.test.js +20 -0
- package/cjs/Input/web/Input.test.js +161 -0
- package/cjs/Input/web/Number.test.js +20 -0
- package/cjs/Input/web/Password.test.js +103 -0
- package/cjs/Input/web/Tel.test.js +20 -0
- package/cjs/List/native/List.test.js +1 -0
- package/cjs/List/web/List.test.js +69 -0
- package/cjs/Progress/native/Progress.test.js +1 -0
- package/cjs/Progress/web/Progress.test.js +229 -0
- package/cjs/RadioGroup/native/Button/RadioButton.test.js +1 -0
- 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.test.js +132 -0
- 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.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/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.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.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/Card.native.theme.js +9 -7
- package/esm/Card/Card.theme.js +1 -1
- package/esm/Card/Card.web.theme.js +8 -6
- 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 +75 -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.test.js +14 -0
- package/esm/Card/web/EventCard/EventCard.test.js +27 -0
- package/esm/Card/web/PlanCard/Actions.js +1 -1
- package/esm/Card/web/PlanCard/Content.js +25 -30
- package/esm/Card/web/PlanCard/PlanCard.js +1 -1
- 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.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.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.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/Heading/web/RightButton.js +1 -1
- 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.test.js +13 -0
- package/esm/Input/web/Input.test.js +145 -0
- package/esm/Input/web/Number.test.js +13 -0
- package/esm/Input/web/Password.test.js +90 -0
- 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.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.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.test.js +121 -0
- 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 +100 -0
- package/esm/Snackbar/native/SnackbarAnimationWrapper.js +124 -0
- package/esm/Snackbar/native/index.js +2 -0
- 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/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,90 @@
|
|
|
1
|
+
var _excluded = ["children"],
|
|
2
|
+
_excluded2 = ["title", "description", "ribbon"];
|
|
3
|
+
|
|
4
|
+
var _templateObject, _templateObject2;
|
|
5
|
+
|
|
6
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
7
|
+
|
|
8
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
9
|
+
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { string, node } from 'prop-types';
|
|
12
|
+
import styled from 'styled-components';
|
|
13
|
+
import Text from '../../Text';
|
|
14
|
+
import Box from '../../Box';
|
|
15
|
+
var Wrapper = styled(Box).attrs(function (_ref) {
|
|
16
|
+
var slider = _ref.theme.yoga.components.slider;
|
|
17
|
+
return {
|
|
18
|
+
bgColor: slider.tooltip.ribbon.backgroundColor,
|
|
19
|
+
bottom: 38,
|
|
20
|
+
bRadius: slider.tooltip.radius,
|
|
21
|
+
elevation: slider.tooltip.shadow,
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
width: 95
|
|
24
|
+
};
|
|
25
|
+
})(_templateObject || (_templateObject = _taggedTemplateLiteralLoose([""])));
|
|
26
|
+
var Tip = styled.View(function (_ref2) {
|
|
27
|
+
var slider = _ref2.theme.yoga.components.slider;
|
|
28
|
+
return "\n background-color: " + slider.tooltip.backgroundColor + ";\n border-radius: " + slider.tooltip.radius + "px;\n padding: " + slider.tooltip.padding.top + "px " + slider.tooltip.padding.right + "px " + slider.tooltip.padding.bottom + "px " + slider.tooltip.padding.left + "px;\n justify-content: center;\n width: 95px;\n ";
|
|
29
|
+
});
|
|
30
|
+
var Title = styled(Text.Small)(function (_ref3) {
|
|
31
|
+
var slider = _ref3.theme.yoga.components.slider;
|
|
32
|
+
return "\n color: " + slider.tooltip.font.color + ";\n margin-bottom: 5px;\n text-align: center;\n ";
|
|
33
|
+
});
|
|
34
|
+
var Description = styled(Text.Small)(function (_ref4) {
|
|
35
|
+
var slider = _ref4.theme.yoga.components.slider;
|
|
36
|
+
return "\n color: " + slider.tooltip.font.color + ";\n text-align: center;\n ";
|
|
37
|
+
});
|
|
38
|
+
var Arrow = styled(Box).attrs(function (_ref5) {
|
|
39
|
+
var slider = _ref5.theme.yoga.components.slider;
|
|
40
|
+
return {
|
|
41
|
+
alignSelf: 'center',
|
|
42
|
+
bottom: '10px',
|
|
43
|
+
bRadius: '3px',
|
|
44
|
+
bgColor: slider.tooltip.backgroundColor,
|
|
45
|
+
height: 16,
|
|
46
|
+
width: 16,
|
|
47
|
+
mb: -17,
|
|
48
|
+
position: 'absolute'
|
|
49
|
+
};
|
|
50
|
+
})(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n transform: rotate(45deg);\n"])));
|
|
51
|
+
var RibbonWrapper = styled.View(function (_ref6) {
|
|
52
|
+
var slider = _ref6.theme.yoga.components.slider;
|
|
53
|
+
return "\n align-items: center;\n background-color: " + slider.tooltip.ribbon.backgroundColor + ";\n border-top-left-radius: " + slider.tooltip.ribbon.radius + "px;\n border-top-right-radius: " + slider.tooltip.ribbon.radius + "px;\n justify-content: center;\n padding: " + slider.tooltip.ribbon.padding.top + "px " + slider.tooltip.ribbon.padding.right + "px " + slider.tooltip.ribbon.padding.bottom + "px " + slider.tooltip.ribbon.padding.left + "px;\n position: relative;\n ";
|
|
54
|
+
});
|
|
55
|
+
var RibbonText = styled(Text.Bold)(function (_ref7) {
|
|
56
|
+
var slider = _ref7.theme.yoga.components.slider;
|
|
57
|
+
return "\n color: " + slider.tooltip.ribbon.font.color + ";\n\n font-size: " + slider.tooltip.ribbon.font.size + "px;\n\n text-align: center;\n ";
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
var Ribbon = function Ribbon(_ref8) {
|
|
61
|
+
var children = _ref8.children,
|
|
62
|
+
props = _objectWithoutPropertiesLoose(_ref8, _excluded);
|
|
63
|
+
|
|
64
|
+
return /*#__PURE__*/React.createElement(RibbonWrapper, props, /*#__PURE__*/React.createElement(RibbonText, null, children));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Ribbon.propTypes = {
|
|
68
|
+
children: node.isRequired
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
var Tooltip = function Tooltip(_ref9) {
|
|
72
|
+
var title = _ref9.title,
|
|
73
|
+
description = _ref9.description,
|
|
74
|
+
ribbon = _ref9.ribbon,
|
|
75
|
+
props = _objectWithoutPropertiesLoose(_ref9, _excluded2);
|
|
76
|
+
|
|
77
|
+
return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(Arrow, null), ribbon && /*#__PURE__*/React.createElement(Ribbon, null, ribbon), (title || description) && /*#__PURE__*/React.createElement(Tip, props, title && /*#__PURE__*/React.createElement(Title, null, title), description && /*#__PURE__*/React.createElement(Description, null, description)));
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
Tooltip.propTypes = {
|
|
81
|
+
title: string,
|
|
82
|
+
description: string,
|
|
83
|
+
ribbon: string
|
|
84
|
+
};
|
|
85
|
+
Tooltip.defaultProps = {
|
|
86
|
+
title: undefined,
|
|
87
|
+
description: undefined,
|
|
88
|
+
ribbon: undefined
|
|
89
|
+
};
|
|
90
|
+
export default Tooltip;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import ThemeProvider from '../../Theme';
|
|
4
|
+
import Slider from './Slider';
|
|
5
|
+
describe('<Slider />', function () {
|
|
6
|
+
describe('Snapshots', function () {
|
|
7
|
+
describe('With one marker', function () {
|
|
8
|
+
it('should match snapshot with default Slider', function () {
|
|
9
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, null))),
|
|
10
|
+
container = _render.container;
|
|
11
|
+
|
|
12
|
+
expect(container).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
it('should match snapshot with Slider with labels', function () {
|
|
15
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
16
|
+
minLabel: 0,
|
|
17
|
+
maxLabel: 10
|
|
18
|
+
}))),
|
|
19
|
+
container = _render2.container;
|
|
20
|
+
|
|
21
|
+
expect(container).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
it('should match snapshot with Slider snapped', function () {
|
|
24
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
25
|
+
snapped: true
|
|
26
|
+
}))),
|
|
27
|
+
container = _render3.container;
|
|
28
|
+
|
|
29
|
+
expect(container).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('With two markers', function () {
|
|
33
|
+
it('should match snapshot', function () {
|
|
34
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
35
|
+
values: [3, 7]
|
|
36
|
+
}))),
|
|
37
|
+
container = _render4.container;
|
|
38
|
+
|
|
39
|
+
expect(container).toMatchSnapshot();
|
|
40
|
+
});
|
|
41
|
+
it('should match snapshot with Slider snapped', function () {
|
|
42
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
43
|
+
values: [3, 7],
|
|
44
|
+
snapped: true
|
|
45
|
+
}))),
|
|
46
|
+
container = _render5.container;
|
|
47
|
+
|
|
48
|
+
expect(container).toMatchSnapshot();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe('Labels', function () {
|
|
53
|
+
it('should render labels', function () {
|
|
54
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
55
|
+
maxLabel: "max",
|
|
56
|
+
minLabel: "min"
|
|
57
|
+
}))),
|
|
58
|
+
getByText = _render6.getByText;
|
|
59
|
+
|
|
60
|
+
expect(getByText('max').textContent).toBe('max');
|
|
61
|
+
expect(getByText('min').textContent).toBe('min');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
describe('Tooltip', function () {
|
|
65
|
+
it('should render tooltips', function () {
|
|
66
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
67
|
+
values: [0],
|
|
68
|
+
tooltip: [{
|
|
69
|
+
ribbon: 'ribbon',
|
|
70
|
+
title: 'title',
|
|
71
|
+
description: 'description',
|
|
72
|
+
visible: true
|
|
73
|
+
}]
|
|
74
|
+
}))),
|
|
75
|
+
container = _render7.container,
|
|
76
|
+
getByRole = _render7.getByRole,
|
|
77
|
+
getByText = _render7.getByText;
|
|
78
|
+
|
|
79
|
+
fireEvent.mouseDown(getByRole('slider'));
|
|
80
|
+
expect(getByText('ribbon')).toBeTruthy();
|
|
81
|
+
expect(getByText('title')).toBeTruthy();
|
|
82
|
+
expect(getByText('description')).toBeTruthy();
|
|
83
|
+
expect(container).toMatchSnapshot();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
var _excluded = ["icon", "message", "actionLabel", "onAction", "variant", "onSnackbarClose", "duration", "bottomOffset"];
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
6
|
+
|
|
7
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
+
|
|
9
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
10
|
+
|
|
11
|
+
import React, { 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;
|
|
@@ -0,0 +1,100 @@
|
|
|
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 '../../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
|
+
container = _render.container;
|
|
31
|
+
|
|
32
|
+
expect(container).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
|
+
container = _render2.container;
|
|
43
|
+
|
|
44
|
+
expect(container).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
|
+
container = _render3.container;
|
|
56
|
+
|
|
57
|
+
expect(container).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
|
+
container = _render4.container;
|
|
66
|
+
|
|
67
|
+
expect(container).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.layout(getByTestId('wrapper'), {
|
|
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
|
+
});
|
|
@@ -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;
|