@gympass/yoga 7.66.0 → 7.66.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/Dialog/web/Dialog.js +12 -7
- package/cjs/Drawer/web/Drawer.js +5 -1
- package/esm/Accordion/web/Accordion.test.js +19 -0
- package/esm/ActionRequirement/index.native.js +2 -0
- package/esm/ActionRequirement/native/ActionRequirement.js +48 -0
- package/esm/ActionRequirement/native/ActionRequirement.test.js +45 -0
- package/esm/ActionRequirement/native/ActionRequirementStyles.js +25 -0
- package/esm/ActionRequirement/native/index.js +6 -0
- package/esm/ActionRequirement/web/ActionRequirement.test.js +36 -0
- package/esm/AutoComplete/web/AutoComplete.test.js +139 -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 +48 -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 +772 -0
- package/esm/Card/index.native.js +2 -0
- package/esm/Card/native/Card/Actions.js +12 -0
- package/esm/Card/native/Card/Card.js +92 -0
- package/esm/Card/native/Card/Card.test.js +15 -0
- package/esm/Card/native/Card/Content.js +8 -0
- package/esm/Card/native/Card/Header.js +8 -0
- package/esm/Card/native/Card/index.js +8 -0
- package/esm/Card/native/EventCard/EventCard.js +169 -0
- package/esm/Card/native/EventCard/EventCard.test.js +65 -0
- package/esm/Card/native/EventCard/index.js +2 -0
- package/esm/Card/native/GymCard/CheckIn/Avatar.js +17 -0
- package/esm/Card/native/GymCard/CheckIn/CheckIn.js +66 -0
- package/esm/Card/native/GymCard/CheckIn/CheckIn.test.js +39 -0
- package/esm/Card/native/GymCard/CheckIn/Content.js +11 -0
- package/esm/Card/native/GymCard/CheckIn/Header.js +11 -0
- package/esm/Card/native/GymCard/CheckIn/index.js +2 -0
- package/esm/Card/native/GymCard/index.js +5 -0
- package/esm/Card/native/PlanCard/Actions.js +22 -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 +51 -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 +34 -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/PlanCard.test.js +94 -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 +143 -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/Datepicker/web/Datepicker.test.js +247 -0
- package/esm/Dialog/web/Dialog.js +13 -8
- package/esm/Dialog/web/Dialog.test.js +62 -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/Drawer/web/Drawer.js +6 -2
- package/esm/Drawer/web/Drawer.test.js +33 -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 +38 -0
- package/esm/Heading/web/Heading.test.js +58 -0
- package/esm/Icon/index.native.js +2 -0
- package/esm/Icon/native/Icon.test.js +47 -0
- package/esm/Icon/native/index.js +2 -0
- package/esm/Icon/web/Icon.test.js +47 -0
- package/esm/Input/index.native.js +6 -0
- package/esm/Input/native/Email.js +15 -0
- package/esm/Input/native/Email.test.js +13 -0
- package/esm/Input/native/Helper.js +62 -0
- package/esm/Input/native/Input.js +234 -0
- package/esm/Input/native/Input.test.js +181 -0
- package/esm/Input/native/Number.js +12 -0
- package/esm/Input/native/Number.test.js +13 -0
- package/esm/Input/native/Password.js +112 -0
- package/esm/Input/native/Password.test.js +125 -0
- package/esm/Input/native/Tel.js +14 -0
- package/esm/Input/native/Tel.test.js +13 -0
- package/esm/Input/native/index.js +6 -0
- package/esm/Input/web/Email.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/Phone.test.js +95 -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/Menu/web/Menu.test.js +115 -0
- package/esm/Popover/web/Popover.test.js +19 -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 +96 -0
- package/esm/RadioGroup/native/Radio/Radio.js +88 -0
- package/esm/RadioGroup/native/Radio/Radio.test.js +112 -0
- package/esm/RadioGroup/native/RadioGroup.js +66 -0
- package/esm/RadioGroup/native/RadioGroup.test.js +50 -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/Skeleton/index.native.js +2 -0
- package/esm/Skeleton/native/Skeleton.js +94 -0
- package/esm/Skeleton/native/Skeleton.test.js +78 -0
- package/esm/Skeleton/native/index.js +2 -0
- package/esm/Skeleton/web/Skeleton.test.js +77 -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 +122 -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 +118 -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 +70 -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 +72 -0
- package/esm/Tag/native/Tag.js +75 -0
- package/esm/Tag/native/Tag.test.js +94 -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 +26 -0
- package/esm/shared/index.native.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
var _excluded = ["max", "maxLabel", "min", "minLabel", "snapped", "values", "tooltip", "sliderLength", "theme"];
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
5
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { View } from 'react-native';
|
|
9
|
+
import { bool, number, arrayOf, shape, string, oneOfType } from 'prop-types';
|
|
10
|
+
import { withTheme } from 'styled-components';
|
|
11
|
+
import MultiSlider from '@ptomasroos/react-native-multi-slider';
|
|
12
|
+
import { LabelView, LabelText } from './Label';
|
|
13
|
+
import Marker from './Marker';
|
|
14
|
+
import Step from './Step';
|
|
15
|
+
/** Sliders allow users to make selections from a range of values. Sliders
|
|
16
|
+
reflect a range of values along a bar, from which users may select a single
|
|
17
|
+
value. They are ideal for adjusting settings such as volume, brightness, or
|
|
18
|
+
applying image filters. */
|
|
19
|
+
|
|
20
|
+
var Slider = function Slider(_ref) {
|
|
21
|
+
var max = _ref.max,
|
|
22
|
+
maxLabel = _ref.maxLabel,
|
|
23
|
+
min = _ref.min,
|
|
24
|
+
minLabel = _ref.minLabel,
|
|
25
|
+
snapped = _ref.snapped,
|
|
26
|
+
values = _ref.values,
|
|
27
|
+
tooltip = _ref.tooltip,
|
|
28
|
+
sliderLength = _ref.sliderLength,
|
|
29
|
+
slider = _ref.theme.yoga.components.slider,
|
|
30
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
31
|
+
|
|
32
|
+
var renderSnapDots = function renderSnapDots() {
|
|
33
|
+
var items = [];
|
|
34
|
+
|
|
35
|
+
for (var i = min; i <= max; i++) {
|
|
36
|
+
if (values.length > 1) {
|
|
37
|
+
items.push( /*#__PURE__*/React.createElement(Step, {
|
|
38
|
+
key: i,
|
|
39
|
+
active: values[0] < i && values[1] > i
|
|
40
|
+
}));
|
|
41
|
+
} else {
|
|
42
|
+
items.push( /*#__PURE__*/React.createElement(Step, {
|
|
43
|
+
key: i,
|
|
44
|
+
active: values[0] > i
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return items;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var renderTooltip = function renderTooltip(side) {
|
|
53
|
+
var tooltipSide = side === 'left' ? 0 : 1;
|
|
54
|
+
return tooltip.filter(function (_ref2) {
|
|
55
|
+
var step = _ref2.step,
|
|
56
|
+
visible = _ref2.visible;
|
|
57
|
+
|
|
58
|
+
if (!step && step !== 0) {
|
|
59
|
+
return visible;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return visible && values[tooltipSide] === step;
|
|
63
|
+
})[0];
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
67
|
+
style: {
|
|
68
|
+
width: sliderLength
|
|
69
|
+
}
|
|
70
|
+
}, snapped && /*#__PURE__*/React.createElement(View, {
|
|
71
|
+
style: {
|
|
72
|
+
flexDirection: 'row',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
justifyContent: 'space-between',
|
|
75
|
+
bottom: -30
|
|
76
|
+
}
|
|
77
|
+
}, renderSnapDots()), /*#__PURE__*/React.createElement(MultiSlider, _extends({}, props, {
|
|
78
|
+
values: values,
|
|
79
|
+
sliderLength: sliderLength,
|
|
80
|
+
trackStyle: {
|
|
81
|
+
backgroundColor: slider.track.backgroundColor.inactive,
|
|
82
|
+
height: 4,
|
|
83
|
+
borderRadius: slider.track.border.radius
|
|
84
|
+
},
|
|
85
|
+
selectedStyle: {
|
|
86
|
+
backgroundColor: slider.track.backgroundColor.active
|
|
87
|
+
},
|
|
88
|
+
isMarkersSeparated: true,
|
|
89
|
+
min: min,
|
|
90
|
+
max: max,
|
|
91
|
+
snapped: snapped,
|
|
92
|
+
customMarkerLeft: function customMarkerLeft(_ref3) {
|
|
93
|
+
var pressed = _ref3.pressed;
|
|
94
|
+
return /*#__PURE__*/React.createElement(Marker, {
|
|
95
|
+
tooltip: renderTooltip('left'),
|
|
96
|
+
pressed: pressed
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
customMarkerRight: function customMarkerRight(_ref4) {
|
|
100
|
+
var pressed = _ref4.pressed;
|
|
101
|
+
return /*#__PURE__*/React.createElement(Marker, {
|
|
102
|
+
tooltip: renderTooltip('right'),
|
|
103
|
+
pressed: pressed
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
touchDimensions: {
|
|
107
|
+
slipDisplacement: 400
|
|
108
|
+
}
|
|
109
|
+
})), (minLabel || maxLabel) && /*#__PURE__*/React.createElement(LabelView, null, minLabel && /*#__PURE__*/React.createElement(LabelText, {
|
|
110
|
+
placement: "left"
|
|
111
|
+
}, minLabel), maxLabel && /*#__PURE__*/React.createElement(LabelText, {
|
|
112
|
+
placement: "right"
|
|
113
|
+
}, maxLabel)));
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
Slider.propTypes = {
|
|
117
|
+
/** set the max value */
|
|
118
|
+
max: number,
|
|
119
|
+
|
|
120
|
+
/** label to be displayed at max value */
|
|
121
|
+
maxLabel: oneOfType([string, number]),
|
|
122
|
+
|
|
123
|
+
/** set the min value */
|
|
124
|
+
min: number,
|
|
125
|
+
|
|
126
|
+
/** label to be displayed at min value */
|
|
127
|
+
minLabel: oneOfType([string, number]),
|
|
128
|
+
sliderLength: number,
|
|
129
|
+
|
|
130
|
+
/** make slider be snap through dots */
|
|
131
|
+
snapped: bool,
|
|
132
|
+
|
|
133
|
+
/** accepts a shape with 'ribbon', 'title', 'description', 'visible' and 'step' properties */
|
|
134
|
+
tooltip: arrayOf(shape({
|
|
135
|
+
description: string,
|
|
136
|
+
title: string,
|
|
137
|
+
ribbon: string,
|
|
138
|
+
visible: bool,
|
|
139
|
+
step: number
|
|
140
|
+
})),
|
|
141
|
+
|
|
142
|
+
/** an array that accepts one or two numbers, this determines how many markers will be displayed */
|
|
143
|
+
values: arrayOf(number)
|
|
144
|
+
};
|
|
145
|
+
Slider.defaultProps = {
|
|
146
|
+
max: 10,
|
|
147
|
+
maxLabel: undefined,
|
|
148
|
+
min: 0,
|
|
149
|
+
minLabel: undefined,
|
|
150
|
+
sliderLength: 280,
|
|
151
|
+
snapped: false,
|
|
152
|
+
tooltip: [],
|
|
153
|
+
values: [0]
|
|
154
|
+
};
|
|
155
|
+
Slider.displayName = 'Slider';
|
|
156
|
+
export default withTheme(Slider);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
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
|
+
toJSON = _render.toJSON;
|
|
12
|
+
|
|
13
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
14
|
+
});
|
|
15
|
+
it('should match snapshot with Slider with labels', function () {
|
|
16
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
17
|
+
minLabel: 0,
|
|
18
|
+
maxLabel: 10
|
|
19
|
+
}))),
|
|
20
|
+
container = _render2.container,
|
|
21
|
+
toJSON = _render2.toJSON;
|
|
22
|
+
|
|
23
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
it('should match snapshot with Slider snapped', function () {
|
|
26
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
27
|
+
snapped: true
|
|
28
|
+
}))),
|
|
29
|
+
container = _render3.container,
|
|
30
|
+
toJSON = _render3.toJSON;
|
|
31
|
+
|
|
32
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('With two markers', function () {
|
|
36
|
+
it('should match snapshot', function () {
|
|
37
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
38
|
+
values: [3, 7]
|
|
39
|
+
}))),
|
|
40
|
+
container = _render4.container,
|
|
41
|
+
toJSON = _render4.toJSON;
|
|
42
|
+
|
|
43
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
it('should match snapshot with Slider snapped', function () {
|
|
46
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
47
|
+
values: [3, 7],
|
|
48
|
+
snapped: true
|
|
49
|
+
}))),
|
|
50
|
+
container = _render5.container,
|
|
51
|
+
toJSON = _render5.toJSON;
|
|
52
|
+
|
|
53
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('Labels', function () {
|
|
58
|
+
it('should render labels', function () {
|
|
59
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
60
|
+
maxLabel: "max",
|
|
61
|
+
minLabel: "min"
|
|
62
|
+
}))),
|
|
63
|
+
getByText = _render6.getByText;
|
|
64
|
+
|
|
65
|
+
expect(getByText('max')).toHaveTextContent('max');
|
|
66
|
+
expect(getByText('min')).toHaveTextContent('min');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('Tooltip', function () {
|
|
70
|
+
it('should render tooltip', function () {
|
|
71
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
72
|
+
values: [0],
|
|
73
|
+
tooltip: [{
|
|
74
|
+
ribbon: 'ribbon',
|
|
75
|
+
title: 'title',
|
|
76
|
+
description: 'description',
|
|
77
|
+
visible: true
|
|
78
|
+
}]
|
|
79
|
+
}))),
|
|
80
|
+
container = _render7.container,
|
|
81
|
+
getByText = _render7.getByText,
|
|
82
|
+
getByRole = _render7.getByRole,
|
|
83
|
+
toJSON = _render7.toJSON;
|
|
84
|
+
|
|
85
|
+
fireEvent(getByRole('adjustable'), 'responderGrant', {
|
|
86
|
+
touchHistory: {
|
|
87
|
+
touchBank: {}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
expect(getByText('ribbon')).toBeTruthy();
|
|
91
|
+
expect(getByText('title')).toBeTruthy();
|
|
92
|
+
expect(getByText('description')).toBeTruthy();
|
|
93
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
94
|
+
});
|
|
95
|
+
it('should render tooltip on a specific step', function () {
|
|
96
|
+
var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Slider, {
|
|
97
|
+
values: [2],
|
|
98
|
+
tooltip: [{
|
|
99
|
+
ribbon: 'ribbon',
|
|
100
|
+
title: 'title',
|
|
101
|
+
description: 'description',
|
|
102
|
+
visible: true,
|
|
103
|
+
step: 2
|
|
104
|
+
}]
|
|
105
|
+
}))),
|
|
106
|
+
container = _render8.container,
|
|
107
|
+
getByText = _render8.getByText,
|
|
108
|
+
getByRole = _render8.getByRole,
|
|
109
|
+
toJSON = _render8.toJSON;
|
|
110
|
+
|
|
111
|
+
fireEvent(getByRole('adjustable'), 'responderGrant', {
|
|
112
|
+
touchHistory: {
|
|
113
|
+
touchBank: {}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
expect(getByText('ribbon')).toBeTruthy();
|
|
117
|
+
expect(getByText('title')).toBeTruthy();
|
|
118
|
+
expect(getByText('description')).toBeTruthy();
|
|
119
|
+
expect(toJSON(container)).toMatchSnapshot();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { bool } from 'prop-types';
|
|
3
|
+
var Step = styled.View(function (_ref) {
|
|
4
|
+
var active = _ref.active,
|
|
5
|
+
slider = _ref.theme.yoga.components.slider;
|
|
6
|
+
return "\n background-color: " + (active ? slider.step.backgroundColor.active : slider.step.backgroundColor.inactive) + ";\n border-radius: " + slider.step.border.radius + "px;\n height: 10px;\n width: 10px;\n ";
|
|
7
|
+
});
|
|
8
|
+
Step.propTypes = {
|
|
9
|
+
active: bool
|
|
10
|
+
};
|
|
11
|
+
Step.defaultProps = {
|
|
12
|
+
active: false
|
|
13
|
+
};
|
|
14
|
+
export default Step;
|
|
@@ -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 ? 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;
|