@gympass/yoga 7.65.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.
Files changed (234) hide show
  1. package/cjs/Dialog/web/Dialog.js +12 -7
  2. package/cjs/Drawer/web/Drawer.js +5 -1
  3. package/cjs/Input/index.js +1 -0
  4. package/cjs/Input/web/Input.js +8 -3
  5. package/cjs/Input/web/Phone.js +144 -0
  6. package/cjs/Input/web/Phone.style.js +41 -0
  7. package/cjs/Input/web/data-images.js +10 -0
  8. package/cjs/Input/web/index.js +4 -0
  9. package/cjs/hooks/index.js +8 -0
  10. package/cjs/hooks/useCombinedRefs.js +32 -0
  11. package/esm/Accordion/web/Accordion.test.js +19 -0
  12. package/esm/ActionRequirement/index.native.js +2 -0
  13. package/esm/ActionRequirement/native/ActionRequirement.js +48 -0
  14. package/esm/ActionRequirement/native/ActionRequirement.test.js +45 -0
  15. package/esm/ActionRequirement/native/ActionRequirementStyles.js +25 -0
  16. package/esm/ActionRequirement/native/index.js +6 -0
  17. package/esm/ActionRequirement/web/ActionRequirement.test.js +36 -0
  18. package/esm/AutoComplete/web/AutoComplete.test.js +139 -0
  19. package/esm/Avatar/index.native.js +4 -0
  20. package/esm/Avatar/native/Avatar.js +96 -0
  21. package/esm/Avatar/native/Avatar.test.js +46 -0
  22. package/esm/Avatar/native/AvatarCircle.js +24 -0
  23. package/esm/Avatar/web/Avatar.test.js +63 -0
  24. package/esm/Banner/index.native.js +2 -0
  25. package/esm/Banner/native/Banner.js +128 -0
  26. package/esm/Banner/native/Banner.test.js +103 -0
  27. package/esm/Banner/native/index.js +2 -0
  28. package/esm/Banner/web/Banner.test.js +109 -0
  29. package/esm/BottomSheet/web/BottomSheet.test.js +48 -0
  30. package/esm/Box/index.native.js +2 -0
  31. package/esm/Box/native/Box.js +4 -0
  32. package/esm/Box/native/Box.test.js +16 -0
  33. package/esm/Box/native/index.js +2 -0
  34. package/esm/Box/web/Box.test.js +16 -0
  35. package/esm/Button/index.native.js +8 -0
  36. package/esm/Button/native/Button.js +110 -0
  37. package/esm/Button/native/Button.test.js +475 -0
  38. package/esm/Button/native/Icon.js +82 -0
  39. package/esm/Button/native/Link.js +35 -0
  40. package/esm/Button/native/Text.js +74 -0
  41. package/esm/Button/native/withTouchable.js +63 -0
  42. package/esm/Button/web/Button.test.js +772 -0
  43. package/esm/Card/index.native.js +2 -0
  44. package/esm/Card/native/Card/Actions.js +12 -0
  45. package/esm/Card/native/Card/Card.js +92 -0
  46. package/esm/Card/native/Card/Card.test.js +15 -0
  47. package/esm/Card/native/Card/Content.js +8 -0
  48. package/esm/Card/native/Card/Header.js +8 -0
  49. package/esm/Card/native/Card/index.js +8 -0
  50. package/esm/Card/native/EventCard/EventCard.js +169 -0
  51. package/esm/Card/native/EventCard/EventCard.test.js +65 -0
  52. package/esm/Card/native/EventCard/index.js +2 -0
  53. package/esm/Card/native/GymCard/CheckIn/Avatar.js +17 -0
  54. package/esm/Card/native/GymCard/CheckIn/CheckIn.js +66 -0
  55. package/esm/Card/native/GymCard/CheckIn/CheckIn.test.js +39 -0
  56. package/esm/Card/native/GymCard/CheckIn/Content.js +11 -0
  57. package/esm/Card/native/GymCard/CheckIn/Header.js +11 -0
  58. package/esm/Card/native/GymCard/CheckIn/index.js +2 -0
  59. package/esm/Card/native/GymCard/index.js +5 -0
  60. package/esm/Card/native/PlanCard/Actions.js +22 -0
  61. package/esm/Card/native/PlanCard/Content.js +75 -0
  62. package/esm/Card/native/PlanCard/List.js +73 -0
  63. package/esm/Card/native/PlanCard/PlanCard.js +51 -0
  64. package/esm/Card/native/PlanCard/PlanCard.test.js +84 -0
  65. package/esm/Card/native/PlanCard/Subtitle.js +15 -0
  66. package/esm/Card/native/PlanCard/Tag.js +34 -0
  67. package/esm/Card/native/PlanCard/index.js +15 -0
  68. package/esm/Card/native/index.js +5 -0
  69. package/esm/Card/web/Card/Card.test.js +14 -0
  70. package/esm/Card/web/EventCard/EventCard.test.js +27 -0
  71. package/esm/Card/web/PlanCard/PlanCard.test.js +94 -0
  72. package/esm/Checkbox/index.native.js +3 -0
  73. package/esm/Checkbox/native/Checkbox.js +179 -0
  74. package/esm/Checkbox/native/Checkbox.test.js +115 -0
  75. package/esm/Checkbox/native/Switch.js +115 -0
  76. package/esm/Checkbox/native/Switch.test.js +54 -0
  77. package/esm/Checkbox/native/index.js +3 -0
  78. package/esm/Checkbox/web/Checkbox.test.js +153 -0
  79. package/esm/Checkbox/web/Switch.test.js +56 -0
  80. package/esm/Chips/index.native.js +2 -0
  81. package/esm/Chips/native/Chips.js +104 -0
  82. package/esm/Chips/native/Chips.test.js +143 -0
  83. package/esm/Chips/native/Counter.js +20 -0
  84. package/esm/Chips/native/index.js +2 -0
  85. package/esm/Chips/web/Chips.test.js +128 -0
  86. package/esm/Datepicker/web/Datepicker.test.js +247 -0
  87. package/esm/Dialog/web/Dialog.js +13 -8
  88. package/esm/Dialog/web/Dialog.test.js +62 -0
  89. package/esm/Divider/index.native.js +2 -0
  90. package/esm/Divider/native/Divider.js +29 -0
  91. package/esm/Divider/native/Divider.test.js +29 -0
  92. package/esm/Divider/native/index.js +2 -0
  93. package/esm/Divider/web/Divider.test.js +29 -0
  94. package/esm/Drawer/web/Drawer.js +6 -2
  95. package/esm/Drawer/web/Drawer.test.js +33 -0
  96. package/esm/Dropdown/index.native.js +2 -0
  97. package/esm/Dropdown/native/Backdrop.js +93 -0
  98. package/esm/Dropdown/native/Backdrop.test.js +26 -0
  99. package/esm/Dropdown/native/Dropdown.js +142 -0
  100. package/esm/Dropdown/native/Dropdown.test.js +78 -0
  101. package/esm/Dropdown/native/Options.android.js +66 -0
  102. package/esm/Dropdown/native/Options.ios.js +71 -0
  103. package/esm/Dropdown/native/index.js +2 -0
  104. package/esm/Dropdown/web/Dropdown.test.js +93 -0
  105. package/esm/Feedback/web/Feedback.test.js +83 -0
  106. package/esm/Grid/web/Col.test.js +48 -0
  107. package/esm/Grid/web/Container.test.js +14 -0
  108. package/esm/Grid/web/Hide.test.js +31 -0
  109. package/esm/Grid/web/Row.test.js +14 -0
  110. package/esm/Header/web/Header.test.js +38 -0
  111. package/esm/Heading/web/Heading.test.js +58 -0
  112. package/esm/Icon/index.native.js +2 -0
  113. package/esm/Icon/native/Icon.test.js +47 -0
  114. package/esm/Icon/native/index.js +2 -0
  115. package/esm/Icon/web/Icon.test.js +47 -0
  116. package/esm/Input/index.js +2 -1
  117. package/esm/Input/index.native.js +6 -0
  118. package/esm/Input/native/Email.js +15 -0
  119. package/esm/Input/native/Email.test.js +13 -0
  120. package/esm/Input/native/Helper.js +62 -0
  121. package/esm/Input/native/Input.js +234 -0
  122. package/esm/Input/native/Input.test.js +181 -0
  123. package/esm/Input/native/Number.js +12 -0
  124. package/esm/Input/native/Number.test.js +13 -0
  125. package/esm/Input/native/Password.js +112 -0
  126. package/esm/Input/native/Password.test.js +125 -0
  127. package/esm/Input/native/Tel.js +14 -0
  128. package/esm/Input/native/Tel.test.js +13 -0
  129. package/esm/Input/native/index.js +6 -0
  130. package/esm/Input/web/Email.test.js +13 -0
  131. package/esm/Input/web/Input.js +9 -4
  132. package/esm/Input/web/Input.test.js +145 -0
  133. package/esm/Input/web/Number.test.js +13 -0
  134. package/esm/Input/web/Password.test.js +90 -0
  135. package/esm/Input/web/Phone.js +124 -0
  136. package/esm/Input/web/Phone.style.js +27 -0
  137. package/esm/Input/web/Phone.test.js +95 -0
  138. package/esm/Input/web/Tel.test.js +13 -0
  139. package/esm/Input/web/data-images.js +3 -0
  140. package/esm/Input/web/index.js +2 -1
  141. package/esm/List/index.native.js +3 -0
  142. package/esm/List/native/List.js +22 -0
  143. package/esm/List/native/List.test.js +106 -0
  144. package/esm/List/native/ListItem.js +51 -0
  145. package/esm/List/native/index.js +3 -0
  146. package/esm/List/web/List.test.js +62 -0
  147. package/esm/Menu/web/Menu.test.js +115 -0
  148. package/esm/Popover/web/Popover.test.js +19 -0
  149. package/esm/Progress/index.native.js +2 -0
  150. package/esm/Progress/native/Progress.js +103 -0
  151. package/esm/Progress/native/Progress.test.js +222 -0
  152. package/esm/Progress/native/index.js +2 -0
  153. package/esm/Progress/web/Progress.test.js +222 -0
  154. package/esm/RadioGroup/index.native.js +4 -0
  155. package/esm/RadioGroup/native/Button/RadioButton.js +64 -0
  156. package/esm/RadioGroup/native/Button/RadioButton.test.js +96 -0
  157. package/esm/RadioGroup/native/Radio/Radio.js +88 -0
  158. package/esm/RadioGroup/native/Radio/Radio.test.js +112 -0
  159. package/esm/RadioGroup/native/RadioGroup.js +66 -0
  160. package/esm/RadioGroup/native/RadioGroup.test.js +50 -0
  161. package/esm/RadioGroup/native/index.js +4 -0
  162. package/esm/RadioGroup/web/Button/RadioButton.test.js +121 -0
  163. package/esm/RadioGroup/web/Radio/Radio.test.js +108 -0
  164. package/esm/RadioGroup/web/RadioGroup.test.js +83 -0
  165. package/esm/Rating/index.native.js +2 -0
  166. package/esm/Rating/native/Rating.js +186 -0
  167. package/esm/Rating/native/Rating.test.js +121 -0
  168. package/esm/Rating/native/index.js +2 -0
  169. package/esm/Rating/web/Rating.test.js +184 -0
  170. package/esm/Result/index.native.js +8 -0
  171. package/esm/Result/native/Attendances.js +55 -0
  172. package/esm/Result/native/Details.js +97 -0
  173. package/esm/Result/native/Rate.js +35 -0
  174. package/esm/Result/native/Result.js +86 -0
  175. package/esm/Result/native/Result.test.js +107 -0
  176. package/esm/Result/native/ResultButton.js +13 -0
  177. package/esm/Result/native/Tags.js +41 -0
  178. package/esm/Result/native/TinyTextIcon.js +18 -0
  179. package/esm/Result/native/index.js +2 -0
  180. package/esm/Skeleton/index.native.js +2 -0
  181. package/esm/Skeleton/native/Skeleton.js +94 -0
  182. package/esm/Skeleton/native/Skeleton.test.js +78 -0
  183. package/esm/Skeleton/native/index.js +2 -0
  184. package/esm/Skeleton/web/Skeleton.test.js +77 -0
  185. package/esm/Slider/index.native.js +2 -0
  186. package/esm/Slider/native/Label.js +19 -0
  187. package/esm/Slider/native/Marker.js +68 -0
  188. package/esm/Slider/native/Slider.js +156 -0
  189. package/esm/Slider/native/Slider.test.js +122 -0
  190. package/esm/Slider/native/Step.js +14 -0
  191. package/esm/Slider/native/Tooltip.js +90 -0
  192. package/esm/Slider/web/Slider.test.js +86 -0
  193. package/esm/Snackbar/index.native.js +2 -0
  194. package/esm/Snackbar/native/Snackbar.js +199 -0
  195. package/esm/Snackbar/native/Snackbar.test.js +100 -0
  196. package/esm/Snackbar/native/SnackbarAnimationWrapper.js +124 -0
  197. package/esm/Snackbar/native/index.js +2 -0
  198. package/esm/Snackbar/web/Snackbar.test.js +118 -0
  199. package/esm/Stepper/index.native.js +3 -0
  200. package/esm/Stepper/native/Dots.js +45 -0
  201. package/esm/Stepper/native/Line.js +35 -0
  202. package/esm/Stepper/native/Step.js +19 -0
  203. package/esm/Stepper/native/Stepper.js +52 -0
  204. package/esm/Stepper/native/Stepper.test.js +70 -0
  205. package/esm/Stepper/native/index.js +3 -0
  206. package/esm/Stepper/web/Stepper.test.js +67 -0
  207. package/esm/Tag/index.native.js +4 -0
  208. package/esm/Tag/native/Informative.js +72 -0
  209. package/esm/Tag/native/Tag.js +75 -0
  210. package/esm/Tag/native/Tag.test.js +94 -0
  211. package/esm/Tag/native/index.js +2 -0
  212. package/esm/Tag/web/Tag.test.js +79 -0
  213. package/esm/Text/index.native.js +16 -0
  214. package/esm/Text/native/Text.js +69 -0
  215. package/esm/Text/native/Text.test.js +149 -0
  216. package/esm/Text/native/index.js +2 -0
  217. package/esm/Text/web/Text.test.js +149 -0
  218. package/esm/TextArea/index.native.js +2 -0
  219. package/esm/TextArea/native/TextArea.js +59 -0
  220. package/esm/TextArea/native/TextArea.test.js +11 -0
  221. package/esm/TextArea/native/index.js +2 -0
  222. package/esm/TextArea/web/TextArea.test.js +11 -0
  223. package/esm/Theme/Provider/index.native.js +2 -0
  224. package/esm/Theme/Provider/native/index.js +2 -0
  225. package/esm/Theme/Provider/web/FontLoader.test.js +11 -0
  226. package/esm/Theme/Provider/web/GlobalStyle.test.js +17 -0
  227. package/esm/Theme/helpers/themeReader/native/native.test.js +53 -0
  228. package/esm/Theme/helpers/themeReader/web/web.test.js +41 -0
  229. package/esm/Theme/index.native.js +5 -0
  230. package/esm/hooks/index.js +2 -1
  231. package/esm/hooks/useCombinedRefs.js +25 -0
  232. package/esm/index.native.js +26 -0
  233. package/esm/shared/index.native.js +2 -0
  234. package/package.json +4 -3
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import { render, fireEvent } from '@testing-library/react';
3
+ import RadioGroup from '..';
4
+ import ThemeProvider from '../../Theme';
5
+ describe('<RadioGroup />', function () {
6
+ describe('Snapshots', function () {
7
+ it('should match snapshot with default radiogroup', function () {
8
+ var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, null))),
9
+ container = _render.container;
10
+
11
+ expect(container).toMatchSnapshot();
12
+ });
13
+ it('should match snapshot with full radiogroup', function () {
14
+ var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
15
+ full: true
16
+ }))),
17
+ container = _render2.container;
18
+
19
+ expect(container).toMatchSnapshot();
20
+ });
21
+ it('should match snapshot with radios as children', function () {
22
+ var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
23
+ container = _render3.container,
24
+ getAllByText = _render3.getAllByText;
25
+
26
+ expect(container).toMatchSnapshot();
27
+ expect(getAllByText(/^Option/)).toHaveLength(3);
28
+ });
29
+ it('should match snapshot with small radios', function () {
30
+ var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
31
+ small: true
32
+ }, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
33
+ container = _render4.container;
34
+
35
+ expect(container).toMatchSnapshot();
36
+ });
37
+ it('should has setted the selected value', function () {
38
+ var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
39
+ selectedValue: "Option 2"
40
+ }, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
41
+ container = _render5.container,
42
+ getByText = _render5.getByText;
43
+
44
+ expect(container).toMatchSnapshot();
45
+ expect(getByText('Option 2').checked).toBe(true);
46
+ });
47
+ it('should set the name for all children', function () {
48
+ var groupName = 'test';
49
+
50
+ var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
51
+ name: groupName
52
+ }, /*#__PURE__*/React.createElement(RadioGroup.Button, {
53
+ "data-testid": "Option 1"
54
+ }, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, {
55
+ "data-testid": "Option 2"
56
+ }, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, {
57
+ "data-testid": "Option 3"
58
+ }, "Option 3")))),
59
+ container = _render6.container,
60
+ getAllByTestId = _render6.getAllByTestId;
61
+
62
+ expect(container).toMatchSnapshot(); // use testid to get the input[type=radio] instead of label
63
+
64
+ getAllByTestId(/^Option/).map(function (radio) {
65
+ return expect(radio.name).toBe(groupName);
66
+ });
67
+ });
68
+ });
69
+ });
70
+ describe('Events', function () {
71
+ it('should set the onchange for its children', function () {
72
+ var onChangeMock = jest.fn();
73
+
74
+ var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
75
+ onChange: onChangeMock
76
+ }, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
77
+ getByText = _render7.getByText;
78
+
79
+ var firstOption = getByText('Option 1');
80
+ fireEvent.click(firstOption);
81
+ expect(onChangeMock).toHaveBeenCalled();
82
+ });
83
+ });
@@ -0,0 +1,2 @@
1
+ import Rating from './native';
2
+ export default Rating;
@@ -0,0 +1,186 @@
1
+ var _excluded = ["value", "max", "readOnly", "onRate", "theme", "icon"];
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, { useState, useEffect } from 'react';
12
+ import { PanResponder } from 'react-native';
13
+ import styled, { withTheme } from 'styled-components';
14
+ import { number, func, bool, shape } from 'prop-types';
15
+ import { StarFilled } from '@gympass/yoga-icons';
16
+ import { max as maxPropType } from '../../shared';
17
+ var SVG_DEFAULT_SIZE = 12;
18
+ var RatingWrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n flex-direction: row;\n justify-content: center;\n align-items: center;\n\n ", "\n"])), function (_ref) {
19
+ var width = _ref.width,
20
+ height = _ref.height;
21
+ return "\n width: " + width + "px;\n height: " + height + "px;\n ";
22
+ });
23
+ /** Use the Rating component to view other people's opinions and experiences. */
24
+
25
+ var Rating = function Rating(_ref2) {
26
+ var value = _ref2.value,
27
+ max = _ref2.max,
28
+ readOnly = _ref2.readOnly,
29
+ onRate = _ref2.onRate,
30
+ _ref2$theme$yoga = _ref2.theme.yoga,
31
+ colors = _ref2$theme$yoga.colors,
32
+ rating = _ref2$theme$yoga.components.rating,
33
+ _ref2$icon = _ref2.icon,
34
+ _ref2$icon$type = _ref2$icon.type,
35
+ Icon = _ref2$icon$type === void 0 ? StarFilled : _ref2$icon$type,
36
+ _ref2$icon$size = _ref2$icon.size,
37
+ iconSize = _ref2$icon$size === void 0 ? 24 : _ref2$icon$size,
38
+ rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
39
+
40
+ var _useState = useState({}),
41
+ panResponder = _useState[0],
42
+ setPanResponder = _useState[1];
43
+
44
+ var _useState2 = useState({}),
45
+ wrapperLayout = _useState2[0],
46
+ setWrapperLayout = _useState2[1];
47
+
48
+ var _useState3 = useState(0),
49
+ swipeRating = _useState3[0],
50
+ setSwipeRating = _useState3[1];
51
+
52
+ var _useState4 = useState(false),
53
+ swipping = _useState4[0],
54
+ toggleSwipping = _useState4[1];
55
+
56
+ function getCurrentRating(swipeValue) {
57
+ var currentRating = 1;
58
+
59
+ if (swipeValue > wrapperLayout.width) {
60
+ currentRating = max;
61
+ } else if (swipeValue <= 0) {
62
+ currentRating = 0;
63
+ } else {
64
+ currentRating = Math.round(swipeValue / (wrapperLayout.width / max));
65
+ }
66
+
67
+ return currentRating || 1;
68
+ }
69
+
70
+ useEffect(function () {
71
+ var responder = PanResponder.create({
72
+ onStartShouldSetPanResponder: function onStartShouldSetPanResponder() {
73
+ return true;
74
+ },
75
+ onStartShouldSetPanResponderCapture: function onStartShouldSetPanResponderCapture() {
76
+ return true;
77
+ },
78
+ onMoveShouldSetPanResponder: function onMoveShouldSetPanResponder() {
79
+ return true;
80
+ },
81
+ onMoveShouldSetPanResponderCapture: function onMoveShouldSetPanResponderCapture() {
82
+ return true;
83
+ },
84
+ onPanResponderTerminationRequest: function onPanResponderTerminationRequest() {
85
+ return true;
86
+ },
87
+ onPanResponderGrant: function onPanResponderGrant(_ref3) {
88
+ var pageX = _ref3.nativeEvent.pageX;
89
+ toggleSwipping(true);
90
+ setSwipeRating(getCurrentRating(pageX - wrapperLayout.x));
91
+ },
92
+ onPanResponderMove: function onPanResponderMove(_ref4) {
93
+ var pageX = _ref4.nativeEvent.pageX;
94
+ setSwipeRating(getCurrentRating(pageX - wrapperLayout.x));
95
+ },
96
+ onPanResponderRelease: function onPanResponderRelease(_ref5) {
97
+ var pageX = _ref5.nativeEvent.pageX;
98
+ setSwipeRating(0);
99
+ toggleSwipping(false);
100
+ onRate(getCurrentRating(pageX - wrapperLayout.x));
101
+ }
102
+ });
103
+ setPanResponder(responder);
104
+ }, [wrapperLayout]);
105
+ return /*#__PURE__*/React.createElement(RatingWrapper, _extends({
106
+ height: iconSize,
107
+ width: iconSize * max,
108
+ pointerEvents: readOnly ? 'none' : 'auto'
109
+ }, rest, panResponder.panHandlers, {
110
+ onLayout: function onLayout(_ref6) {
111
+ var layout = _ref6.nativeEvent.layout;
112
+ return setWrapperLayout(layout);
113
+ }
114
+ }), Array.from({
115
+ length: max
116
+ }, function (_, i) {
117
+ var diff = i + 1 - value;
118
+
119
+ if (swipeRating >= i + 1 || !swipping && diff <= 0) {
120
+ return /*#__PURE__*/React.createElement(Icon, {
121
+ key: "filled-" + i,
122
+ fill: rating.backgroundColor,
123
+ width: iconSize,
124
+ height: iconSize
125
+ });
126
+ }
127
+
128
+ if (diff > 0 && diff < 1) {
129
+ var width = (1 - diff) * iconSize;
130
+ var dWidth = diff * iconSize;
131
+ var wViewBox = SVG_DEFAULT_SIZE * (1 - diff);
132
+ var dViewBox = SVG_DEFAULT_SIZE * diff;
133
+ return /*#__PURE__*/React.createElement(React.Fragment, {
134
+ key: "half-" + i
135
+ }, /*#__PURE__*/React.createElement(Icon, {
136
+ fill: rating.backgroundColor,
137
+ width: width,
138
+ height: iconSize,
139
+ viewBox: "0 0 " + wViewBox + " " + SVG_DEFAULT_SIZE
140
+ }), /*#__PURE__*/React.createElement(Icon, {
141
+ fill: colors.elements.lineAndBorders,
142
+ width: dWidth,
143
+ height: iconSize,
144
+ viewBox: wViewBox + " 0 " + dViewBox + " " + SVG_DEFAULT_SIZE
145
+ }));
146
+ }
147
+
148
+ return /*#__PURE__*/React.createElement(Icon, {
149
+ key: "unfilled-" + i,
150
+ fill: colors.elements.lineAndBorders,
151
+ width: iconSize,
152
+ height: iconSize
153
+ });
154
+ }));
155
+ };
156
+
157
+ Rating.propTypes = {
158
+ value: number,
159
+
160
+ /** The icon to display */
161
+ icon: shape({
162
+ type: func,
163
+ size: maxPropType(24)
164
+ }),
165
+
166
+ /** Maximum rating */
167
+ max: number,
168
+
169
+ /** false to make it interactable */
170
+ readOnly: bool,
171
+
172
+ /** Event to be fired on click */
173
+ onRate: func
174
+ };
175
+ Rating.defaultProps = {
176
+ value: undefined,
177
+ icon: {
178
+ type: StarFilled,
179
+ size: 24
180
+ },
181
+ max: 5,
182
+ readOnly: true,
183
+ onRate: function onRate(rating) {} // eslint-disable-line no-unused-vars
184
+
185
+ };
186
+ export default withTheme(Rating);
@@ -0,0 +1,121 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react-native';
3
+ import Svg, { Circle } from 'react-native-svg';
4
+ import { ThemeProvider } from '../..';
5
+ import Rating from '.';
6
+ describe('<Rating />', function () {
7
+ describe('Snapshots', function () {
8
+ it('should match snapshot with Rating', function () {
9
+ var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, null))),
10
+ toJSON = _render.toJSON;
11
+
12
+ expect(toJSON()).toMatchSnapshot();
13
+ });
14
+ it('should match snapshot when it is not readOnly', function () {
15
+ var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
16
+ readOnly: false
17
+ }))),
18
+ toJSON = _render2.toJSON;
19
+
20
+ expect(toJSON()).toMatchSnapshot();
21
+ });
22
+ it('should match snapshot with different values', function () {
23
+ var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
24
+ value: 0
25
+ }), /*#__PURE__*/React.createElement(Rating, {
26
+ value: 0.5
27
+ }), /*#__PURE__*/React.createElement(Rating, {
28
+ value: 1
29
+ }), /*#__PURE__*/React.createElement(Rating, {
30
+ value: 1.1
31
+ }), /*#__PURE__*/React.createElement(Rating, {
32
+ value: 1.2
33
+ }), /*#__PURE__*/React.createElement(Rating, {
34
+ value: 1.3
35
+ }), /*#__PURE__*/React.createElement(Rating, {
36
+ value: 1.4
37
+ }), /*#__PURE__*/React.createElement(Rating, {
38
+ value: 1.5
39
+ }), /*#__PURE__*/React.createElement(Rating, {
40
+ value: 1.6
41
+ }), /*#__PURE__*/React.createElement(Rating, {
42
+ value: 1.7
43
+ }), /*#__PURE__*/React.createElement(Rating, {
44
+ value: 1.8
45
+ }), /*#__PURE__*/React.createElement(Rating, {
46
+ value: 1.9
47
+ }), /*#__PURE__*/React.createElement(Rating, {
48
+ value: 2
49
+ }), /*#__PURE__*/React.createElement(Rating, {
50
+ value: 2.5
51
+ }), /*#__PURE__*/React.createElement(Rating, {
52
+ value: 3
53
+ }), /*#__PURE__*/React.createElement(Rating, {
54
+ value: 3.5
55
+ }), /*#__PURE__*/React.createElement(Rating, {
56
+ value: 4
57
+ }), /*#__PURE__*/React.createElement(Rating, {
58
+ value: 4.5
59
+ }))),
60
+ toJSON = _render3.toJSON;
61
+
62
+ expect(toJSON()).toMatchSnapshot();
63
+ });
64
+ it('should match snapshot with different icon quantity', function () {
65
+ var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
66
+ max: 3,
67
+ value: 0
68
+ }), /*#__PURE__*/React.createElement(Rating, {
69
+ max: 3,
70
+ value: 0.5
71
+ }), /*#__PURE__*/React.createElement(Rating, {
72
+ max: 3,
73
+ value: 1
74
+ }), /*#__PURE__*/React.createElement(Rating, {
75
+ max: 3,
76
+ value: 1.5
77
+ }), /*#__PURE__*/React.createElement(Rating, {
78
+ max: 3,
79
+ value: 2
80
+ }), /*#__PURE__*/React.createElement(Rating, {
81
+ max: 3,
82
+ value: 2.5
83
+ }), /*#__PURE__*/React.createElement(Rating, {
84
+ max: 3,
85
+ value: 3
86
+ }))),
87
+ toJSON = _render4.toJSON;
88
+
89
+ expect(toJSON()).toMatchSnapshot();
90
+ });
91
+ it('should match snapshot with different icon', function () {
92
+ var CircleIcon = function CircleIcon(props) {
93
+ return /*#__PURE__*/React.createElement(Svg, props, /*#__PURE__*/React.createElement(Circle, {
94
+ cx: 12,
95
+ cy: 12,
96
+ r: 12
97
+ }));
98
+ };
99
+
100
+ var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
101
+ icon: {
102
+ type: CircleIcon
103
+ },
104
+ value: 0
105
+ }), /*#__PURE__*/React.createElement(Rating, {
106
+ icon: {
107
+ type: CircleIcon
108
+ },
109
+ value: 1
110
+ }), /*#__PURE__*/React.createElement(Rating, {
111
+ icon: {
112
+ type: CircleIcon
113
+ },
114
+ value: 2
115
+ }))),
116
+ toJSON = _render5.toJSON;
117
+
118
+ expect(toJSON()).toMatchSnapshot();
119
+ });
120
+ });
121
+ });
@@ -0,0 +1,2 @@
1
+ import Rating from './Rating';
2
+ export default Rating;
@@ -0,0 +1,184 @@
1
+ /* eslint-disable jsx-a11y/mouse-events-have-key-events */
2
+ import React from 'react';
3
+ import { render, fireEvent } from '@testing-library/react';
4
+ import { ThemeProvider } from '../..';
5
+ import Rating from '.';
6
+ describe('<Rating />', function () {
7
+ var originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth');
8
+ beforeAll(function () {
9
+ Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
10
+ configurable: true,
11
+ value: 76 // 5 stars (5 * 12px + 4 * 4px gutter)
12
+
13
+ });
14
+ });
15
+ afterAll(function () {
16
+ Object.defineProperty(HTMLElement.prototype, 'offsetWidth', originalOffsetWidth);
17
+ });
18
+ describe('Snapshots', function () {
19
+ it('should match snapshot with Rating', function () {
20
+ var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, null))),
21
+ container = _render.container;
22
+
23
+ expect(container).toMatchSnapshot();
24
+ });
25
+ it('should match snapshot with different values', function () {
26
+ var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
27
+ value: 0
28
+ }), /*#__PURE__*/React.createElement(Rating, {
29
+ value: 0.5
30
+ }), /*#__PURE__*/React.createElement(Rating, {
31
+ value: 1
32
+ }), /*#__PURE__*/React.createElement(Rating, {
33
+ value: 1.1
34
+ }), /*#__PURE__*/React.createElement(Rating, {
35
+ value: 1.2
36
+ }), /*#__PURE__*/React.createElement(Rating, {
37
+ value: 1.3
38
+ }), /*#__PURE__*/React.createElement(Rating, {
39
+ value: 1.4
40
+ }), /*#__PURE__*/React.createElement(Rating, {
41
+ value: 1.5
42
+ }), /*#__PURE__*/React.createElement(Rating, {
43
+ value: 1.6
44
+ }), /*#__PURE__*/React.createElement(Rating, {
45
+ value: 1.7
46
+ }), /*#__PURE__*/React.createElement(Rating, {
47
+ value: 1.8
48
+ }), /*#__PURE__*/React.createElement(Rating, {
49
+ value: 1.9
50
+ }), /*#__PURE__*/React.createElement(Rating, {
51
+ value: 2
52
+ }), /*#__PURE__*/React.createElement(Rating, {
53
+ value: 2.5
54
+ }), /*#__PURE__*/React.createElement(Rating, {
55
+ value: 3
56
+ }), /*#__PURE__*/React.createElement(Rating, {
57
+ value: 3.5
58
+ }), /*#__PURE__*/React.createElement(Rating, {
59
+ value: 4
60
+ }), /*#__PURE__*/React.createElement(Rating, {
61
+ value: 4.5
62
+ }))),
63
+ container = _render2.container;
64
+
65
+ expect(container).toMatchSnapshot();
66
+ });
67
+ it('should match snapshot with different icon quantity', function () {
68
+ var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
69
+ max: 3,
70
+ value: 0
71
+ }), /*#__PURE__*/React.createElement(Rating, {
72
+ max: 3,
73
+ value: 0.5
74
+ }), /*#__PURE__*/React.createElement(Rating, {
75
+ max: 3,
76
+ value: 1
77
+ }), /*#__PURE__*/React.createElement(Rating, {
78
+ max: 3,
79
+ value: 1.5
80
+ }), /*#__PURE__*/React.createElement(Rating, {
81
+ max: 3,
82
+ value: 2
83
+ }), /*#__PURE__*/React.createElement(Rating, {
84
+ max: 3,
85
+ value: 2.5
86
+ }), /*#__PURE__*/React.createElement(Rating, {
87
+ max: 3,
88
+ value: 3
89
+ }))),
90
+ container = _render3.container;
91
+
92
+ expect(container).toMatchSnapshot();
93
+ });
94
+ it('should match snapshot with different icon', function () {
95
+ var Circle = function Circle(props) {
96
+ return /*#__PURE__*/React.createElement("svg", props, /*#__PURE__*/React.createElement("circle", {
97
+ cx: "12",
98
+ cy: "12",
99
+ r: "12"
100
+ }));
101
+ };
102
+
103
+ var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
104
+ icon: {
105
+ type: Circle
106
+ },
107
+ value: 0
108
+ }), /*#__PURE__*/React.createElement(Rating, {
109
+ icon: {
110
+ type: Circle
111
+ },
112
+ value: 1
113
+ }), /*#__PURE__*/React.createElement(Rating, {
114
+ icon: {
115
+ type: Circle
116
+ },
117
+ value: 2
118
+ }))),
119
+ container = _render4.container;
120
+
121
+ expect(container).toMatchSnapshot();
122
+ });
123
+ it('should match snapshot when mouse over', function () {
124
+ var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
125
+ readOnly: false
126
+ }))),
127
+ container = _render5.container;
128
+
129
+ var firstChild = container.firstChild;
130
+ fireEvent.mouseMove(firstChild, {
131
+ /** Each star has 12px. Gutter is 4px.
132
+ * For the third star, we should set clentX > 32px and < 48px */
133
+ clientX: 40
134
+ });
135
+ expect(container).toMatchSnapshot();
136
+ });
137
+ });
138
+ describe('Events', function () {
139
+ it('should call onRate when clicking', function () {
140
+ var onRateMock = jest.fn();
141
+
142
+ var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
143
+ onRate: onRateMock,
144
+ readOnly: false
145
+ }))),
146
+ container = _render6.container;
147
+
148
+ var firstChild = container.firstChild;
149
+ fireEvent.mouseMove(firstChild, {
150
+ clientX: 40 // third star position
151
+
152
+ });
153
+ fireEvent.click(firstChild);
154
+ expect(onRateMock).toHaveBeenCalled();
155
+ expect(onRateMock).toHaveBeenCalledWith(3);
156
+ });
157
+ it('should call onMouseOver callback', function () {
158
+ var onMouseOverMock = jest.fn();
159
+
160
+ var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
161
+ onMouseOver: onMouseOverMock,
162
+ readOnly: false
163
+ }))),
164
+ container = _render7.container;
165
+
166
+ var firstChild = container.firstChild;
167
+ fireEvent.mouseOver(firstChild);
168
+ expect(onMouseOverMock).toHaveBeenCalled();
169
+ });
170
+ it('should call onMouseLeave callback', function () {
171
+ var onMouseLeaveMock = jest.fn();
172
+
173
+ var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
174
+ onMouseLeave: onMouseLeaveMock,
175
+ readOnly: false
176
+ }))),
177
+ container = _render8.container;
178
+
179
+ var firstChild = container.firstChild;
180
+ fireEvent.mouseLeave(firstChild);
181
+ expect(onMouseLeaveMock).toHaveBeenCalled();
182
+ });
183
+ });
184
+ });
@@ -0,0 +1,8 @@
1
+ import Result from './native';
2
+ import ResultDetails from './native/Details';
3
+ import ResultButton from './native/ResultButton';
4
+ import ResultTags from './native/Tags';
5
+ Result.Details = ResultDetails;
6
+ Result.Button = ResultButton;
7
+ Result.Tags = ResultTags;
8
+ export default Result;
@@ -0,0 +1,55 @@
1
+ var _templateObject, _templateObject2;
2
+
3
+ function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
4
+
5
+ import { arrayOf, func, shape, string } from 'prop-types';
6
+ import React from 'react';
7
+ import styled from 'styled-components';
8
+ import Box from '../../Box';
9
+ import Text from '../../Text';
10
+ import Rate from './Rate';
11
+ import TinyTextIcon from './TinyTextIcon';
12
+ var List = styled(Text.Tiny).attrs({
13
+ numberOfLines: 1,
14
+ variant: 'deep'
15
+ })(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n flex: 1;\n"])));
16
+ var ItemSeparator = styled(Box).attrs({
17
+ width: 'xxxsmall',
18
+ height: 'zero'
19
+ })(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose([""])));
20
+
21
+ var Attendances = function Attendances(_ref) {
22
+ var attendances = _ref.attendances,
23
+ rate = _ref.rate;
24
+ return /*#__PURE__*/React.createElement(Box, {
25
+ display: "flex",
26
+ width: "100%",
27
+ alignItems: "center",
28
+ justifyContent: "center",
29
+ flexDirection: "row",
30
+ mb: "xxxsmall"
31
+ }, /*#__PURE__*/React.createElement(List, null, attendances.map(function (_ref2) {
32
+ var description = _ref2.description,
33
+ icon = _ref2.icon;
34
+ return /*#__PURE__*/React.createElement(React.Fragment, {
35
+ key: description
36
+ }, /*#__PURE__*/React.createElement(TinyTextIcon, {
37
+ as: icon,
38
+ fill: "deep"
39
+ }), /*#__PURE__*/React.createElement(ItemSeparator, null), description, /*#__PURE__*/React.createElement(ItemSeparator, null));
40
+ })), rate && /*#__PURE__*/React.createElement(Rate, {
41
+ rate: rate
42
+ }));
43
+ };
44
+
45
+ Attendances.propTypes = {
46
+ attendances: arrayOf(shape({
47
+ description: string,
48
+ icon: func
49
+ })).isRequired,
50
+ rate: string
51
+ };
52
+ Attendances.defaultProps = {
53
+ rate: undefined
54
+ };
55
+ export default Attendances;