@gympass/yoga 7.60.0 → 7.61.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.
Files changed (303) hide show
  1. package/cjs/Drawer/web/Content.js +1 -4
  2. package/cjs/Menu/web/Menu.js +1 -1
  3. package/cjs/Menu/web/MenuList.js +14 -7
  4. package/esm/Drawer/web/Content.js +1 -4
  5. package/esm/Menu/web/Menu.js +1 -1
  6. package/esm/Menu/web/MenuList.js +14 -7
  7. package/package.json +5 -5
  8. package/cjs/ActionRequirement/native/ActionRequirement.test.js +0 -1
  9. package/cjs/ActionRequirement/web/ActionRequirement.test.js +0 -40
  10. package/cjs/AutoComplete/web/AutoComplete.test.js +0 -156
  11. package/cjs/Avatar/native/Avatar.test.js +0 -1
  12. package/cjs/Avatar/web/Avatar.test.js +0 -72
  13. package/cjs/Banner/native/Banner.test.js +0 -1
  14. package/cjs/Banner/web/Banner.test.js +0 -121
  15. package/cjs/BottomSheet/web/BottomSheet.test.js +0 -61
  16. package/cjs/Box/native/Box.test.js +0 -1
  17. package/cjs/Box/web/Box.test.js +0 -23
  18. package/cjs/Button/native/Button.test.js +0 -1
  19. package/cjs/Button/web/Button.test.js +0 -778
  20. package/cjs/Card/native/Card/Card.test.js +0 -1
  21. package/cjs/Card/native/EventCard/EventCard.test.js +0 -1
  22. package/cjs/Card/native/GymCard/CheckIn/CheckIn.test.js +0 -1
  23. package/cjs/Card/native/PlanCard/PlanCard.test.js +0 -1
  24. package/cjs/Card/web/Card/Card.test.js +0 -22
  25. package/cjs/Card/web/EventCard/EventCard.test.js +0 -35
  26. package/cjs/Card/web/PlanCard/PlanCard.test.js +0 -104
  27. package/cjs/Checkbox/native/Checkbox.test.js +0 -1
  28. package/cjs/Checkbox/native/Switch.test.js +0 -1
  29. package/cjs/Checkbox/web/Checkbox.test.js +0 -161
  30. package/cjs/Checkbox/web/Switch.test.js +0 -65
  31. package/cjs/Chips/native/Chips.test.js +0 -1
  32. package/cjs/Chips/web/Chips.test.js +0 -138
  33. package/cjs/Datepicker/web/Datepicker.test.js +0 -286
  34. package/cjs/Dialog/web/Dialog.test.js +0 -78
  35. package/cjs/Divider/native/Divider.test.js +0 -1
  36. package/cjs/Divider/web/Divider.test.js +0 -36
  37. package/cjs/Drawer/web/Drawer.test.js +0 -46
  38. package/cjs/Dropdown/native/Backdrop.test.js +0 -1
  39. package/cjs/Dropdown/native/Dropdown.test.js +0 -1
  40. package/cjs/Dropdown/web/Dropdown.test.js +0 -102
  41. package/cjs/Feedback/web/Feedback.test.js +0 -89
  42. package/cjs/Grid/web/Col.test.js +0 -56
  43. package/cjs/Grid/web/Container.test.js +0 -22
  44. package/cjs/Grid/web/Hide.test.js +0 -39
  45. package/cjs/Grid/web/Row.test.js +0 -22
  46. package/cjs/Header/web/Header.test.js +0 -49
  47. package/cjs/Heading/web/Heading.test.js +0 -68
  48. package/cjs/Icon/native/Icon.test.js +0 -1
  49. package/cjs/Icon/web/Icon.test.js +0 -53
  50. package/cjs/Input/native/Email.test.js +0 -1
  51. package/cjs/Input/native/Input.test.js +0 -1
  52. package/cjs/Input/native/Number.test.js +0 -1
  53. package/cjs/Input/native/Password.test.js +0 -1
  54. package/cjs/Input/native/Tel.test.js +0 -1
  55. package/cjs/Input/web/Email.test.js +0 -20
  56. package/cjs/Input/web/Input.test.js +0 -161
  57. package/cjs/Input/web/Number.test.js +0 -20
  58. package/cjs/Input/web/Password.test.js +0 -103
  59. package/cjs/Input/web/Tel.test.js +0 -20
  60. package/cjs/List/native/List.test.js +0 -1
  61. package/cjs/List/web/List.test.js +0 -69
  62. package/cjs/Menu/web/Menu.test.js +0 -123
  63. package/cjs/Popover/web/Popover.test.js +0 -27
  64. package/cjs/Progress/native/Progress.test.js +0 -1
  65. package/cjs/Progress/web/Progress.test.js +0 -229
  66. package/cjs/RadioGroup/native/Button/RadioButton.test.js +0 -1
  67. package/cjs/RadioGroup/native/Radio/Radio.test.js +0 -1
  68. package/cjs/RadioGroup/native/RadioGroup.test.js +0 -1
  69. package/cjs/RadioGroup/web/Button/RadioButton.test.js +0 -132
  70. package/cjs/RadioGroup/web/Radio/Radio.test.js +0 -119
  71. package/cjs/RadioGroup/web/RadioGroup.test.js +0 -93
  72. package/cjs/Rating/native/Rating.test.js +0 -1
  73. package/cjs/Rating/web/Rating.test.js +0 -201
  74. package/cjs/Result/native/Result.test.js +0 -1
  75. package/cjs/Skeleton/native/Skeleton.test.js +0 -1
  76. package/cjs/Skeleton/web/Skeleton.test.js +0 -84
  77. package/cjs/Slider/native/Slider.test.js +0 -1
  78. package/cjs/Slider/web/Slider.test.js +0 -95
  79. package/cjs/Snackbar/native/Snackbar.test.js +0 -1
  80. package/cjs/Snackbar/web/Snackbar.test.js +0 -137
  81. package/cjs/Stepper/native/Stepper.test.js +0 -1
  82. package/cjs/Stepper/web/Stepper.test.js +0 -75
  83. package/cjs/Tag/native/Tag.test.js +0 -1
  84. package/cjs/Tag/web/Tag.test.js +0 -87
  85. package/cjs/Text/native/Text.test.js +0 -1
  86. package/cjs/Text/web/Text.test.js +0 -157
  87. package/cjs/TextArea/native/TextArea.test.js +0 -1
  88. package/cjs/TextArea/web/TextArea.test.js +0 -18
  89. package/cjs/Theme/Provider/web/FontLoader.test.js +0 -19
  90. package/cjs/Theme/Provider/web/GlobalStyle.test.js +0 -27
  91. package/cjs/Theme/helpers/themeReader/native/native.test.js +0 -1
  92. package/cjs/Theme/helpers/themeReader/web/web.test.js +0 -54
  93. package/esm/ActionRequirement/index.native.js +0 -2
  94. package/esm/ActionRequirement/native/ActionRequirement.js +0 -48
  95. package/esm/ActionRequirement/native/ActionRequirement.test.js +0 -45
  96. package/esm/ActionRequirement/native/ActionRequirementStyles.js +0 -25
  97. package/esm/ActionRequirement/native/index.js +0 -6
  98. package/esm/ActionRequirement/web/ActionRequirement.test.js +0 -31
  99. package/esm/AutoComplete/web/AutoComplete.test.js +0 -139
  100. package/esm/Avatar/index.native.js +0 -4
  101. package/esm/Avatar/native/Avatar.js +0 -96
  102. package/esm/Avatar/native/Avatar.test.js +0 -46
  103. package/esm/Avatar/native/AvatarCircle.js +0 -24
  104. package/esm/Avatar/web/Avatar.test.js +0 -63
  105. package/esm/Banner/index.native.js +0 -2
  106. package/esm/Banner/native/Banner.js +0 -128
  107. package/esm/Banner/native/Banner.test.js +0 -103
  108. package/esm/Banner/native/index.js +0 -2
  109. package/esm/Banner/web/Banner.test.js +0 -109
  110. package/esm/BottomSheet/web/BottomSheet.test.js +0 -48
  111. package/esm/Box/index.native.js +0 -2
  112. package/esm/Box/native/Box.js +0 -4
  113. package/esm/Box/native/Box.test.js +0 -16
  114. package/esm/Box/native/index.js +0 -2
  115. package/esm/Box/web/Box.test.js +0 -16
  116. package/esm/Button/index.native.js +0 -8
  117. package/esm/Button/native/Button.js +0 -110
  118. package/esm/Button/native/Button.test.js +0 -475
  119. package/esm/Button/native/Icon.js +0 -82
  120. package/esm/Button/native/Link.js +0 -35
  121. package/esm/Button/native/Text.js +0 -74
  122. package/esm/Button/native/withTouchable.js +0 -63
  123. package/esm/Button/web/Button.test.js +0 -764
  124. package/esm/Card/index.native.js +0 -2
  125. package/esm/Card/native/Card/Actions.js +0 -12
  126. package/esm/Card/native/Card/Card.js +0 -92
  127. package/esm/Card/native/Card/Card.test.js +0 -15
  128. package/esm/Card/native/Card/Content.js +0 -8
  129. package/esm/Card/native/Card/Header.js +0 -8
  130. package/esm/Card/native/Card/index.js +0 -8
  131. package/esm/Card/native/EventCard/EventCard.js +0 -169
  132. package/esm/Card/native/EventCard/EventCard.test.js +0 -65
  133. package/esm/Card/native/EventCard/index.js +0 -2
  134. package/esm/Card/native/GymCard/CheckIn/Avatar.js +0 -17
  135. package/esm/Card/native/GymCard/CheckIn/CheckIn.js +0 -66
  136. package/esm/Card/native/GymCard/CheckIn/CheckIn.test.js +0 -39
  137. package/esm/Card/native/GymCard/CheckIn/Content.js +0 -11
  138. package/esm/Card/native/GymCard/CheckIn/Header.js +0 -11
  139. package/esm/Card/native/GymCard/CheckIn/index.js +0 -2
  140. package/esm/Card/native/GymCard/index.js +0 -5
  141. package/esm/Card/native/PlanCard/Actions.js +0 -22
  142. package/esm/Card/native/PlanCard/Content.js +0 -75
  143. package/esm/Card/native/PlanCard/List.js +0 -73
  144. package/esm/Card/native/PlanCard/PlanCard.js +0 -51
  145. package/esm/Card/native/PlanCard/PlanCard.test.js +0 -84
  146. package/esm/Card/native/PlanCard/Subtitle.js +0 -15
  147. package/esm/Card/native/PlanCard/Tag.js +0 -34
  148. package/esm/Card/native/PlanCard/index.js +0 -15
  149. package/esm/Card/native/index.js +0 -5
  150. package/esm/Card/web/Card/Card.test.js +0 -14
  151. package/esm/Card/web/EventCard/EventCard.test.js +0 -27
  152. package/esm/Card/web/PlanCard/PlanCard.test.js +0 -94
  153. package/esm/Checkbox/index.native.js +0 -3
  154. package/esm/Checkbox/native/Checkbox.js +0 -179
  155. package/esm/Checkbox/native/Checkbox.test.js +0 -115
  156. package/esm/Checkbox/native/Switch.js +0 -115
  157. package/esm/Checkbox/native/Switch.test.js +0 -54
  158. package/esm/Checkbox/native/index.js +0 -3
  159. package/esm/Checkbox/web/Checkbox.test.js +0 -153
  160. package/esm/Checkbox/web/Switch.test.js +0 -56
  161. package/esm/Chips/index.native.js +0 -2
  162. package/esm/Chips/native/Chips.js +0 -104
  163. package/esm/Chips/native/Chips.test.js +0 -143
  164. package/esm/Chips/native/Counter.js +0 -20
  165. package/esm/Chips/native/index.js +0 -2
  166. package/esm/Chips/web/Chips.test.js +0 -128
  167. package/esm/Datepicker/web/Datepicker.test.js +0 -247
  168. package/esm/Dialog/web/Dialog.test.js +0 -62
  169. package/esm/Divider/index.native.js +0 -2
  170. package/esm/Divider/native/Divider.js +0 -29
  171. package/esm/Divider/native/Divider.test.js +0 -29
  172. package/esm/Divider/native/index.js +0 -2
  173. package/esm/Divider/web/Divider.test.js +0 -29
  174. package/esm/Drawer/web/Drawer.test.js +0 -33
  175. package/esm/Dropdown/index.native.js +0 -2
  176. package/esm/Dropdown/native/Backdrop.js +0 -93
  177. package/esm/Dropdown/native/Backdrop.test.js +0 -26
  178. package/esm/Dropdown/native/Dropdown.js +0 -142
  179. package/esm/Dropdown/native/Dropdown.test.js +0 -78
  180. package/esm/Dropdown/native/Options.android.js +0 -66
  181. package/esm/Dropdown/native/Options.ios.js +0 -71
  182. package/esm/Dropdown/native/index.js +0 -2
  183. package/esm/Dropdown/web/Dropdown.test.js +0 -93
  184. package/esm/Feedback/web/Feedback.test.js +0 -83
  185. package/esm/Grid/web/Col.test.js +0 -48
  186. package/esm/Grid/web/Container.test.js +0 -14
  187. package/esm/Grid/web/Hide.test.js +0 -31
  188. package/esm/Grid/web/Row.test.js +0 -14
  189. package/esm/Header/web/Header.test.js +0 -38
  190. package/esm/Heading/web/Heading.test.js +0 -58
  191. package/esm/Icon/index.native.js +0 -2
  192. package/esm/Icon/native/Icon.test.js +0 -47
  193. package/esm/Icon/native/index.js +0 -2
  194. package/esm/Icon/web/Icon.test.js +0 -47
  195. package/esm/Input/index.native.js +0 -6
  196. package/esm/Input/native/Email.js +0 -15
  197. package/esm/Input/native/Email.test.js +0 -13
  198. package/esm/Input/native/Helper.js +0 -62
  199. package/esm/Input/native/Input.js +0 -234
  200. package/esm/Input/native/Input.test.js +0 -181
  201. package/esm/Input/native/Number.js +0 -12
  202. package/esm/Input/native/Number.test.js +0 -13
  203. package/esm/Input/native/Password.js +0 -112
  204. package/esm/Input/native/Password.test.js +0 -125
  205. package/esm/Input/native/Tel.js +0 -14
  206. package/esm/Input/native/Tel.test.js +0 -13
  207. package/esm/Input/native/index.js +0 -6
  208. package/esm/Input/web/Email.test.js +0 -13
  209. package/esm/Input/web/Input.test.js +0 -145
  210. package/esm/Input/web/Number.test.js +0 -13
  211. package/esm/Input/web/Password.test.js +0 -90
  212. package/esm/Input/web/Tel.test.js +0 -13
  213. package/esm/List/index.native.js +0 -3
  214. package/esm/List/native/List.js +0 -22
  215. package/esm/List/native/List.test.js +0 -106
  216. package/esm/List/native/ListItem.js +0 -51
  217. package/esm/List/native/index.js +0 -3
  218. package/esm/List/web/List.test.js +0 -62
  219. package/esm/Menu/web/Menu.test.js +0 -115
  220. package/esm/Popover/web/Popover.test.js +0 -19
  221. package/esm/Progress/index.native.js +0 -2
  222. package/esm/Progress/native/Progress.js +0 -103
  223. package/esm/Progress/native/Progress.test.js +0 -222
  224. package/esm/Progress/native/index.js +0 -2
  225. package/esm/Progress/web/Progress.test.js +0 -222
  226. package/esm/RadioGroup/index.native.js +0 -4
  227. package/esm/RadioGroup/native/Button/RadioButton.js +0 -64
  228. package/esm/RadioGroup/native/Button/RadioButton.test.js +0 -96
  229. package/esm/RadioGroup/native/Radio/Radio.js +0 -88
  230. package/esm/RadioGroup/native/Radio/Radio.test.js +0 -112
  231. package/esm/RadioGroup/native/RadioGroup.js +0 -66
  232. package/esm/RadioGroup/native/RadioGroup.test.js +0 -50
  233. package/esm/RadioGroup/native/index.js +0 -4
  234. package/esm/RadioGroup/web/Button/RadioButton.test.js +0 -121
  235. package/esm/RadioGroup/web/Radio/Radio.test.js +0 -108
  236. package/esm/RadioGroup/web/RadioGroup.test.js +0 -83
  237. package/esm/Rating/index.native.js +0 -2
  238. package/esm/Rating/native/Rating.js +0 -186
  239. package/esm/Rating/native/Rating.test.js +0 -121
  240. package/esm/Rating/native/index.js +0 -2
  241. package/esm/Rating/web/Rating.test.js +0 -184
  242. package/esm/Result/index.native.js +0 -8
  243. package/esm/Result/native/Attendances.js +0 -55
  244. package/esm/Result/native/Details.js +0 -97
  245. package/esm/Result/native/Rate.js +0 -35
  246. package/esm/Result/native/Result.js +0 -86
  247. package/esm/Result/native/Result.test.js +0 -107
  248. package/esm/Result/native/ResultButton.js +0 -13
  249. package/esm/Result/native/Tags.js +0 -41
  250. package/esm/Result/native/TinyTextIcon.js +0 -18
  251. package/esm/Result/native/index.js +0 -2
  252. package/esm/Skeleton/index.native.js +0 -2
  253. package/esm/Skeleton/native/Skeleton.js +0 -94
  254. package/esm/Skeleton/native/Skeleton.test.js +0 -78
  255. package/esm/Skeleton/native/index.js +0 -2
  256. package/esm/Skeleton/web/Skeleton.test.js +0 -77
  257. package/esm/Slider/index.native.js +0 -2
  258. package/esm/Slider/native/Label.js +0 -19
  259. package/esm/Slider/native/Marker.js +0 -68
  260. package/esm/Slider/native/Slider.js +0 -156
  261. package/esm/Slider/native/Slider.test.js +0 -122
  262. package/esm/Slider/native/Step.js +0 -14
  263. package/esm/Slider/native/Tooltip.js +0 -90
  264. package/esm/Slider/web/Slider.test.js +0 -86
  265. package/esm/Snackbar/index.native.js +0 -2
  266. package/esm/Snackbar/native/Snackbar.js +0 -199
  267. package/esm/Snackbar/native/Snackbar.test.js +0 -100
  268. package/esm/Snackbar/native/SnackbarAnimationWrapper.js +0 -124
  269. package/esm/Snackbar/native/index.js +0 -2
  270. package/esm/Snackbar/web/Snackbar.test.js +0 -118
  271. package/esm/Stepper/index.native.js +0 -3
  272. package/esm/Stepper/native/Dots.js +0 -45
  273. package/esm/Stepper/native/Line.js +0 -35
  274. package/esm/Stepper/native/Step.js +0 -19
  275. package/esm/Stepper/native/Stepper.js +0 -52
  276. package/esm/Stepper/native/Stepper.test.js +0 -70
  277. package/esm/Stepper/native/index.js +0 -3
  278. package/esm/Stepper/web/Stepper.test.js +0 -67
  279. package/esm/Tag/index.native.js +0 -4
  280. package/esm/Tag/native/Informative.js +0 -72
  281. package/esm/Tag/native/Tag.js +0 -75
  282. package/esm/Tag/native/Tag.test.js +0 -94
  283. package/esm/Tag/native/index.js +0 -2
  284. package/esm/Tag/web/Tag.test.js +0 -79
  285. package/esm/Text/index.native.js +0 -16
  286. package/esm/Text/native/Text.js +0 -69
  287. package/esm/Text/native/Text.test.js +0 -149
  288. package/esm/Text/native/index.js +0 -2
  289. package/esm/Text/web/Text.test.js +0 -149
  290. package/esm/TextArea/index.native.js +0 -2
  291. package/esm/TextArea/native/TextArea.js +0 -59
  292. package/esm/TextArea/native/TextArea.test.js +0 -11
  293. package/esm/TextArea/native/index.js +0 -2
  294. package/esm/TextArea/web/TextArea.test.js +0 -11
  295. package/esm/Theme/Provider/index.native.js +0 -2
  296. package/esm/Theme/Provider/native/index.js +0 -2
  297. package/esm/Theme/Provider/web/FontLoader.test.js +0 -11
  298. package/esm/Theme/Provider/web/GlobalStyle.test.js +0 -17
  299. package/esm/Theme/helpers/themeReader/native/native.test.js +0 -53
  300. package/esm/Theme/helpers/themeReader/web/web.test.js +0 -41
  301. package/esm/Theme/index.native.js +0 -5
  302. package/esm/index.native.js +0 -26
  303. 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,2 +0,0 @@
1
- import Snackbar from './Snackbar';
2
- export default Snackbar;
@@ -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,3 +0,0 @@
1
- import { Stepper, Step } from './native';
2
- Stepper.Step = Step;
3
- export default Stepper;
@@ -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;