@artsy/palette-mobile 23.14.0 → 24.0.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 (220) hide show
  1. package/dist/Theme.js +16 -11
  2. package/dist/animation/CssTransition.js +71 -26
  3. package/dist/animation/index.js +17 -1
  4. package/dist/constants.js +12 -8
  5. package/dist/elements/ArtsyKeyboardAvoidingView/ArtsyKeyboardAvoidingView.js +116 -69
  6. package/dist/elements/ArtsyKeyboardAvoidingView/index.js +17 -1
  7. package/dist/elements/Autocomplete/Autocomplete.js +32 -23
  8. package/dist/elements/Autocomplete/Autocomplete.tests.js +128 -56
  9. package/dist/elements/Autocomplete/index.js +17 -1
  10. package/dist/elements/Avatar/Avatar.js +20 -15
  11. package/dist/elements/Avatar/Avatar.stories.js +29 -15
  12. package/dist/elements/Avatar/Avatar.tests.js +12 -10
  13. package/dist/elements/Avatar/index.js +17 -1
  14. package/dist/elements/BackButton/BackButton.js +16 -9
  15. package/dist/elements/BackButton/BackButton.stories.js +12 -8
  16. package/dist/elements/BackButton/index.js +17 -1
  17. package/dist/elements/Banner/Banner.js +45 -18
  18. package/dist/elements/Banner/Banner.stories.js +12 -8
  19. package/dist/elements/Banner/index.js +17 -1
  20. package/dist/elements/BorderBox/BorderBox.js +16 -11
  21. package/dist/elements/BorderBox/index.js +17 -1
  22. package/dist/elements/Box/Box.js +16 -14
  23. package/dist/elements/Box/Box.stories.js +21 -15
  24. package/dist/elements/Box/index.js +17 -1
  25. package/dist/elements/Button/Button.js +85 -64
  26. package/dist/elements/Button/Button.stories.js +48 -23
  27. package/dist/elements/Button/CTAButton.js +18 -3
  28. package/dist/elements/Button/FollowButton.js +38 -11
  29. package/dist/elements/Button/LinkButton.js +19 -4
  30. package/dist/elements/Button/colors.js +7 -3
  31. package/dist/elements/Button/index.js +20 -4
  32. package/dist/elements/ButtonNew/Button.js +114 -49
  33. package/dist/elements/ButtonNew/Button.stories.js +64 -38
  34. package/dist/elements/ButtonNew/Button.tests.js +23 -21
  35. package/dist/elements/ButtonNew/CTAButton.js +18 -3
  36. package/dist/elements/ButtonNew/FollowButton.js +36 -9
  37. package/dist/elements/ButtonNew/LinkButton.js +19 -4
  38. package/dist/elements/ButtonNew/colors.js +7 -3
  39. package/dist/elements/ButtonNew/index.js +20 -4
  40. package/dist/elements/Checkbox/Check.js +83 -46
  41. package/dist/elements/Checkbox/Checkbox.js +83 -47
  42. package/dist/elements/Checkbox/Checkbox.stories.js +10 -9
  43. package/dist/elements/Checkbox/index.js +18 -2
  44. package/dist/elements/Chip/Chip.js +23 -18
  45. package/dist/elements/Chip/Chip.stories.js +12 -8
  46. package/dist/elements/Chip/index.js +17 -1
  47. package/dist/elements/ClassTheme/ClassTheme.js +10 -5
  48. package/dist/elements/ClassTheme/index.js +17 -1
  49. package/dist/elements/Collapse/Collapse.js +9 -4
  50. package/dist/elements/Collapse/Collapse.stories.js +13 -9
  51. package/dist/elements/Collapse/index.js +17 -1
  52. package/dist/elements/CollapsibleMenuItem/CollapsibleMenuItem.js +32 -27
  53. package/dist/elements/CollapsibleMenuItem/CollapsibleMenuItem.stories.js +62 -37
  54. package/dist/elements/CollapsibleMenuItem/index.js +17 -1
  55. package/dist/elements/Dialog/Dialog.js +52 -26
  56. package/dist/elements/Dialog/Dialog.stories.js +41 -22
  57. package/dist/elements/Dialog/Dialog.tests.js +33 -31
  58. package/dist/elements/Dialog/index.js +17 -1
  59. package/dist/elements/EntityHeader/EntityHeader.js +42 -15
  60. package/dist/elements/EntityHeader/EntityHeader.stories.js +26 -18
  61. package/dist/elements/EntityHeader/index.js +17 -1
  62. package/dist/elements/Flex/Flex.js +32 -4
  63. package/dist/elements/Flex/index.js +17 -1
  64. package/dist/elements/Header/ArtsyLogoHeader.js +15 -8
  65. package/dist/elements/Header/index.js +17 -1
  66. package/dist/elements/Histogram/Histogram.js +19 -14
  67. package/dist/elements/Histogram/index.js +17 -1
  68. package/dist/elements/Image/Image.js +60 -28
  69. package/dist/elements/Image/Image.stories.js +35 -23
  70. package/dist/elements/Image/__tests__/getImageURL.tests.js +10 -8
  71. package/dist/elements/Image/helpers/getImageURL.js +13 -8
  72. package/dist/elements/Image/index.js +17 -1
  73. package/dist/elements/Input/Input.js +216 -168
  74. package/dist/elements/Input/Input.stories.js +15 -11
  75. package/dist/elements/Input/Input.tests.js +85 -39
  76. package/dist/elements/Input/InputTitle.js +9 -4
  77. package/dist/elements/Input/helpers.js +35 -27
  78. package/dist/elements/Input/index.js +19 -3
  79. package/dist/elements/Input/maskValue.js +25 -9
  80. package/dist/elements/Input/maskValue.tests.js +19 -17
  81. package/dist/elements/Join/Join.js +14 -9
  82. package/dist/elements/Join/index.js +17 -1
  83. package/dist/elements/LazyFlatlist/LazyFlatlist.js +11 -8
  84. package/dist/elements/LazyFlatlist/index.js +18 -2
  85. package/dist/elements/LazyFlatlist/useHasSeenItem.js +19 -12
  86. package/dist/elements/LegacyScreen/LegacyScreen.js +124 -83
  87. package/dist/elements/LegacyScreen/index.js +17 -1
  88. package/dist/elements/LegacyTabs/ContentTabs.js +18 -12
  89. package/dist/elements/LegacyTabs/NavigationalTabs.js +21 -15
  90. package/dist/elements/LegacyTabs/StepTabs.js +25 -19
  91. package/dist/elements/LegacyTabs/Tab.js +31 -19
  92. package/dist/elements/LegacyTabs/TabBarContainer.js +48 -39
  93. package/dist/elements/LegacyTabs/index.js +38 -9
  94. package/dist/elements/List/BulletedItem.js +34 -7
  95. package/dist/elements/List/List.stories.js +12 -8
  96. package/dist/elements/List/index.js +17 -1
  97. package/dist/elements/MeasuredView/MeasuredView.js +18 -12
  98. package/dist/elements/MeasuredView/index.js +17 -1
  99. package/dist/elements/MenuItem/MenuItem.js +14 -9
  100. package/dist/elements/MenuItem/MenuItem.stories.js +9 -5
  101. package/dist/elements/MenuItem/index.js +17 -1
  102. package/dist/elements/Message/Message.js +35 -19
  103. package/dist/elements/Message/Message.stories.d.ts +1 -1
  104. package/dist/elements/Message/Message.stories.js +23 -17
  105. package/dist/elements/Message/Message.tests.js +38 -36
  106. package/dist/elements/Message/index.js +17 -1
  107. package/dist/elements/Pill/Pill.js +116 -138
  108. package/dist/elements/Pill/Pill.stories.js +28 -20
  109. package/dist/elements/Pill/Pill.tests.js +15 -13
  110. package/dist/elements/Pill/index.js +17 -1
  111. package/dist/elements/PopIn/PopIn.js +13 -8
  112. package/dist/elements/PopIn/index.js +17 -1
  113. package/dist/elements/Popover/Popover.js +45 -15
  114. package/dist/elements/Popover/Popover.stories.js +25 -19
  115. package/dist/elements/Popover/index.js +17 -1
  116. package/dist/elements/ProgressBar/ProgressBar.js +68 -23
  117. package/dist/elements/ProgressBar/ProgressBar.stories.js +11 -7
  118. package/dist/elements/ProgressBar/ProgressBar.tests.js +48 -23
  119. package/dist/elements/ProgressBar/index.js +17 -1
  120. package/dist/elements/Radio/RadioButton.js +80 -44
  121. package/dist/elements/Radio/RadioButton.stories.js +17 -13
  122. package/dist/elements/Radio/RadioDot.js +31 -15
  123. package/dist/elements/Radio/index.js +7 -2
  124. package/dist/elements/Screen/Background.js +10 -3
  125. package/dist/elements/Screen/Body.js +37 -10
  126. package/dist/elements/Screen/BottomView.js +17 -9
  127. package/dist/elements/Screen/FloatingHeader.js +36 -9
  128. package/dist/elements/Screen/FullWidthDivider.js +20 -5
  129. package/dist/elements/Screen/FullWidthItem.js +20 -5
  130. package/dist/elements/Screen/Header.js +79 -26
  131. package/dist/elements/Screen/Screen.stories.js +46 -30
  132. package/dist/elements/Screen/ScreenBase.js +39 -11
  133. package/dist/elements/Screen/ScreenFlatList.js +26 -9
  134. package/dist/elements/Screen/ScreenScrollContext.js +21 -15
  135. package/dist/elements/Screen/ScreenScrollView.js +27 -9
  136. package/dist/elements/Screen/StickySubHeader.js +62 -23
  137. package/dist/elements/Screen/constants.js +8 -5
  138. package/dist/elements/Screen/hooks/useListenForScreenScroll.js +13 -9
  139. package/dist/elements/Screen/hooks/useShowLargeTitle.js +19 -14
  140. package/dist/elements/Screen/hooks/useTitleStyles.js +14 -10
  141. package/dist/elements/Screen/index.js +48 -31
  142. package/dist/elements/SearchInput/RoundSearchInput.js +79 -46
  143. package/dist/elements/SearchInput/SearchInput.js +43 -14
  144. package/dist/elements/SearchInput/index.js +18 -2
  145. package/dist/elements/Separator/Separator.js +20 -12
  146. package/dist/elements/Separator/Separator.stories.js +10 -6
  147. package/dist/elements/Separator/ShadowSeparator.js +14 -7
  148. package/dist/elements/Separator/index.js +18 -2
  149. package/dist/elements/SimpleMessage/SimpleMessage.js +47 -11
  150. package/dist/elements/SimpleMessage/index.js +17 -1
  151. package/dist/elements/Skeleton/Skeleton.js +50 -19
  152. package/dist/elements/Skeleton/Skeleton.stories.js +14 -10
  153. package/dist/elements/Skeleton/index.js +17 -1
  154. package/dist/elements/Spacer/Spacer.js +32 -3
  155. package/dist/elements/Spacer/Spacer.stories.js +35 -19
  156. package/dist/elements/Spacer/index.js +17 -1
  157. package/dist/elements/Spinner/Spinner.js +62 -33
  158. package/dist/elements/Spinner/index.js +17 -1
  159. package/dist/elements/Switch/Switch.js +50 -17
  160. package/dist/elements/Switch/Switch.stories.js +31 -14
  161. package/dist/elements/Switch/index.js +17 -1
  162. package/dist/elements/Tabs/SubTabBar.js +29 -20
  163. package/dist/elements/Tabs/TabFlashList.js +24 -12
  164. package/dist/elements/Tabs/TabFlatList.js +24 -12
  165. package/dist/elements/Tabs/TabMasonry.js +24 -12
  166. package/dist/elements/Tabs/TabScrollView.js +27 -14
  167. package/dist/elements/Tabs/Tabs.js +27 -24
  168. package/dist/elements/Tabs/Tabs.stories.js +93 -46
  169. package/dist/elements/Tabs/TabsContainer.js +62 -38
  170. package/dist/elements/Tabs/TabsWithHeader.js +41 -13
  171. package/dist/elements/Tabs/hooks/useListenForTabContentScroll.js +13 -9
  172. package/dist/elements/Tabs/index.js +17 -1
  173. package/dist/elements/Text/LinkText.js +32 -3
  174. package/dist/elements/Text/Text.js +61 -23
  175. package/dist/elements/Text/Text.stories.js +37 -28
  176. package/dist/elements/Text/Text.tests.js +7 -5
  177. package/dist/elements/Text/helpers.js +13 -7
  178. package/dist/elements/Text/index.js +19 -3
  179. package/dist/elements/ToolTip/ToolTip.js +67 -53
  180. package/dist/elements/ToolTip/ToolTip.stories.js +21 -14
  181. package/dist/elements/ToolTip/ToolTip.tests.js +15 -13
  182. package/dist/elements/ToolTip/ToolTipFlyout.js +68 -28
  183. package/dist/elements/ToolTip/index.js +17 -1
  184. package/dist/elements/Touchable/Touchable.js +41 -13
  185. package/dist/elements/Touchable/Touchable.stories.js +13 -9
  186. package/dist/elements/Touchable/TouchableHighlightColor.js +38 -12
  187. package/dist/elements/Touchable/TouchableWithScale.js +38 -11
  188. package/dist/elements/Touchable/index.js +19 -3
  189. package/dist/elements/VisualClue/VisualClue.stories.js +11 -7
  190. package/dist/elements/VisualClue/VisualClueDot.js +24 -14
  191. package/dist/elements/VisualClue/VisualClueText.js +26 -15
  192. package/dist/elements/VisualClue/index.js +18 -2
  193. package/dist/elements/index.js +62 -46
  194. package/dist/index.js +24 -8
  195. package/dist/setupJest.js +11 -6
  196. package/dist/storybook/decorators.js +36 -27
  197. package/dist/storybook/helpers.js +40 -22
  198. package/dist/tokens.js +28 -67
  199. package/dist/types.js +10 -5
  200. package/dist/utils/Wrap.js +16 -8
  201. package/dist/utils/colors.stories.js +31 -25
  202. package/dist/utils/createGeminiUrl.js +28 -22
  203. package/dist/utils/flattenChildren.js +20 -7
  204. package/dist/utils/formatLargeNumber.js +8 -4
  205. package/dist/utils/formatLargeNumbers.tests.js +15 -13
  206. package/dist/utils/hooks/index.js +20 -4
  207. package/dist/utils/hooks/useColor.js +6 -2
  208. package/dist/utils/hooks/useMeasure.js +40 -14
  209. package/dist/utils/hooks/useScreenDimensions.js +31 -20
  210. package/dist/utils/hooks/useSpace.js +6 -2
  211. package/dist/utils/hooks/useTheme.js +31 -23
  212. package/dist/utils/normalizeText.js +11 -6
  213. package/dist/utils/space.stories.js +15 -10
  214. package/dist/utils/tests/flattenChildren.tests.js +8 -6
  215. package/dist/utils/tests/isTestEnvironment.js +5 -1
  216. package/dist/utils/tests/renderWithWrappers.js +15 -7
  217. package/dist/utils/text.js +13 -9
  218. package/dist/utils/types.js +2 -0
  219. package/dist/utils/webTokensToMobile.js +16 -10
  220. package/package.json +30 -36
@@ -1,13 +1,42 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CloseIcon } from "@artsy/icons/native";
3
- import RNPopover from "react-native-popover-view";
4
- import { Easing } from "react-native-reanimated";
5
- import { useColor } from "../../utils/hooks";
6
- import { Flex } from "../Flex";
7
- import { Touchable } from "../Touchable";
8
- export const Popover = ({ variant = "dark", children, visible, onOpenComplete, onPressOutside, onDismiss, onCloseComplete, placement = "top", title, content, noCloseIcon, ...rest }) => {
9
- const color = useColor();
10
- const DROP_SHADOW = {
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ var __importDefault = (this && this.__importDefault) || function (mod) {
25
+ return (mod && mod.__esModule) ? mod : { "default": mod };
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.Popover = void 0;
29
+ var jsx_runtime_1 = require("react/jsx-runtime");
30
+ var native_1 = require("@artsy/icons/native");
31
+ var react_native_popover_view_1 = __importDefault(require("react-native-popover-view"));
32
+ var react_native_reanimated_1 = require("react-native-reanimated");
33
+ var hooks_1 = require("../../utils/hooks");
34
+ var Flex_1 = require("../Flex");
35
+ var Touchable_1 = require("../Touchable");
36
+ var Popover = function (_a) {
37
+ var _b = _a.variant, variant = _b === void 0 ? "dark" : _b, children = _a.children, visible = _a.visible, onOpenComplete = _a.onOpenComplete, onPressOutside = _a.onPressOutside, onDismiss = _a.onDismiss, onCloseComplete = _a.onCloseComplete, _c = _a.placement, placement = _c === void 0 ? "top" : _c, title = _a.title, content = _a.content, noCloseIcon = _a.noCloseIcon, rest = __rest(_a, ["variant", "children", "visible", "onOpenComplete", "onPressOutside", "onDismiss", "onCloseComplete", "placement", "title", "content", "noCloseIcon"]);
38
+ var color = (0, hooks_1.useColor)();
39
+ var DROP_SHADOW = {
11
40
  shadowColor: color("mono100"),
12
41
  shadowOffset: {
13
42
  width: 0,
@@ -17,7 +46,7 @@ export const Popover = ({ variant = "dark", children, visible, onOpenComplete, o
17
46
  shadowRadius: 2.62,
18
47
  elevation: 4,
19
48
  };
20
- const POPOVER_VARIANTS = {
49
+ var POPOVER_VARIANTS = {
21
50
  light: {
22
51
  backgroundColor: color("mono0"),
23
52
  fill: "mono100",
@@ -28,9 +57,10 @@ export const Popover = ({ variant = "dark", children, visible, onOpenComplete, o
28
57
  fill: "mono0",
29
58
  },
30
59
  };
31
- const style = POPOVER_VARIANTS[variant];
32
- return (_jsx(RNPopover, { backgroundStyle: { opacity: 0.5, backgroundColor: color("mono100") }, popoverStyle: [{ backgroundColor: style.backgroundColor }, style.shadow], from: children, isVisible: visible, onCloseComplete: onCloseComplete, onOpenComplete: onOpenComplete, onRequestClose: onPressOutside, placement: placement, arrowSize: { height: 11, width: 22 }, animationConfig: {
60
+ var style = POPOVER_VARIANTS[variant];
61
+ return ((0, jsx_runtime_1.jsx)(react_native_popover_view_1.default, __assign({ backgroundStyle: { opacity: 0.5, backgroundColor: color("mono100") }, popoverStyle: [{ backgroundColor: style.backgroundColor }, style.shadow], from: children, isVisible: visible, onCloseComplete: onCloseComplete, onOpenComplete: onOpenComplete, onRequestClose: onPressOutside, placement: placement, arrowSize: { height: 11, width: 22 }, animationConfig: {
33
62
  duration: 400,
34
- easing: Easing.out(Easing.exp),
35
- }, ...rest, children: _jsxs(Flex, { backgroundColor: POPOVER_VARIANTS[variant].backgroundColor, p: 1, children: [_jsxs(Flex, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", children: [title ? title : _jsx(Flex, {}), !noCloseIcon && (_jsx(Touchable, { onPress: onDismiss, accessibilityRole: "button", "aria-label": "Dismiss popover", children: _jsx(Flex, { ml: 0.5, children: _jsx(CloseIcon, { width: 18, height: 18, fill: style.fill }) }) }))] }), content] }) }));
63
+ easing: react_native_reanimated_1.Easing.out(react_native_reanimated_1.Easing.exp),
64
+ } }, rest, { children: (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { backgroundColor: POPOVER_VARIANTS[variant].backgroundColor, p: 1, children: [(0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", children: [title ? title : (0, jsx_runtime_1.jsx)(Flex_1.Flex, {}), !noCloseIcon && ((0, jsx_runtime_1.jsx)(Touchable_1.Touchable, { onPress: onDismiss, accessibilityRole: "button", "aria-label": "Dismiss popover", children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { ml: 0.5, children: (0, jsx_runtime_1.jsx)(native_1.CloseIcon, { width: 18, height: 18, fill: style.fill }) }) }))] }), content] }) })));
36
65
  };
66
+ exports.Popover = Popover;
@@ -1,28 +1,34 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import { Popover } from "./Popover";
4
- import { Button } from "../Button";
5
- import { Flex } from "../Flex";
6
- import { Text } from "../Text";
7
- export default {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EdgePositions = exports.WithTitleAndOrContent = exports.Variants = void 0;
4
+ var jsx_runtime_1 = require("react/jsx-runtime");
5
+ var react_1 = require("react");
6
+ var Popover_1 = require("./Popover");
7
+ var Button_1 = require("../Button");
8
+ var Flex_1 = require("../Flex");
9
+ var Text_1 = require("../Text");
10
+ exports.default = {
8
11
  title: "Popover",
9
12
  };
10
- export const Variants = () => {
11
- const [visible, setVisible] = useState(null);
12
- return (_jsxs(Flex, { flex: 1, alignSelf: "center", mt: 12, alignItems: "center", flexWrap: "wrap", children: [_jsx(Popover, { visible: visible === "top-dark", title: _jsx(Text, { color: "mono0", variant: "xs", children: "Popover Top Dark" }), onPressOutside: () => setVisible(null), onDismiss: () => setVisible(null), children: _jsx(Text, { onPress: () => setVisible("top-dark"), children: "Top Dark" }) }), _jsx(Popover, { visible: visible === "bottom-dark", placement: "bottom", title: _jsx(Text, { color: "mono0", variant: "xs", children: "Popover Bottom Dark" }), onPressOutside: () => setVisible(null), onDismiss: () => setVisible(null), children: _jsx(Text, { onPress: () => setVisible("bottom-dark"), children: "Bottom Dark" }) }), _jsx(Popover, { visible: visible === "top-light", placement: "top", variant: "light", title: _jsx(Text, { variant: "xs", children: "Popover Top Light" }), onPressOutside: () => setVisible(null), onDismiss: () => setVisible(null), children: _jsx(Text, { onPress: () => setVisible("top-light"), children: "Top Light" }) }), _jsx(Popover, { visible: visible === "bottom-light", placement: "bottom", variant: "light", title: _jsx(Text, { variant: "xs", children: "Popover Bottom Light" }), onPressOutside: () => setVisible(null), onDismiss: () => setVisible(null), children: _jsx(Text, { onPress: () => setVisible("bottom-light"), children: "Bottom Light" }) })] }));
13
+ var Variants = function () {
14
+ var _a = (0, react_1.useState)(null), visible = _a[0], setVisible = _a[1];
15
+ return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flex: 1, alignSelf: "center", mt: 12, alignItems: "center", flexWrap: "wrap", children: [(0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "top-dark", title: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "mono0", variant: "xs", children: "Popover Top Dark" }), onPressOutside: function () { return setVisible(null); }, onDismiss: function () { return setVisible(null); }, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: function () { return setVisible("top-dark"); }, children: "Top Dark" }) }), (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "bottom-dark", placement: "bottom", title: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "mono0", variant: "xs", children: "Popover Bottom Dark" }), onPressOutside: function () { return setVisible(null); }, onDismiss: function () { return setVisible(null); }, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: function () { return setVisible("bottom-dark"); }, children: "Bottom Dark" }) }), (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "top-light", placement: "top", variant: "light", title: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", children: "Popover Top Light" }), onPressOutside: function () { return setVisible(null); }, onDismiss: function () { return setVisible(null); }, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: function () { return setVisible("top-light"); }, children: "Top Light" }) }), (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "bottom-light", placement: "bottom", variant: "light", title: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", children: "Popover Bottom Light" }), onPressOutside: function () { return setVisible(null); }, onDismiss: function () { return setVisible(null); }, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: function () { return setVisible("bottom-light"); }, children: "Bottom Light" }) })] }));
13
16
  };
14
- export const WithTitleAndOrContent = () => {
15
- const [visible, setVisible] = useState(null);
16
- return (_jsxs(Flex, { flex: 1, alignSelf: "center", mt: 12, alignItems: "center", flexWrap: "wrap", children: [_jsx(Popover, { visible: visible === "title", title: _jsx(Text, { weight: "medium", color: "mono0", children: "Popover title" }), content: _jsxs(_Fragment, { children: [_jsx(Text, { color: "mono0", children: "Popover descriptive text with some not so long long long body" }), _jsx(Text, { color: "mono0", children: "And some line break" })] }), onDismiss: () => setVisible(null), children: _jsx(Text, { onPress: () => setVisible("title"), children: "Some title and description" }) }), _jsx(Popover, { visible: visible === "buttons", placement: "bottom", variant: "light", content: _jsxs(_Fragment, { children: [_jsx(Text, { weight: "medium", mb: 1, children: "Popover title" }), _jsx(Flex, { height: 80, backgroundColor: "mono30", mb: 1 }), _jsx(Text, { mb: 1, children: "Popover descriptive text" }), _jsxs(Flex, { flexDirection: "row", justifyContent: "flex-end", children: [_jsx(Button, { size: "small", variant: "outlineGray", children: "Learn more" }), _jsx(Button, { size: "small", ml: 1, onPress: () => setVisible(null), children: "Got it" })] })] }), onDismiss: () => setVisible(null), children: _jsx(Text, { onPress: () => setVisible("buttons"), children: "Buttons and more content" }) }), _jsx(Popover, { visible: visible === "no-close", placement: "bottom", noCloseIcon: true, variant: "light", content: _jsxs(_Fragment, { children: [_jsx(Text, { weight: "medium", mb: 1, children: "Popover title?" }), _jsx(Flex, { height: 80, backgroundColor: "mono30", mb: 1 }), _jsx(Text, { mb: 1, children: "Popover descriptive text" }), _jsx(Button, { size: "small", onPress: () => setVisible(null), children: "Got it" })] }), onDismiss: () => setVisible(null), children: _jsx(Text, { onPress: () => setVisible("no-close"), children: "Content without close icon" }) })] }));
17
+ exports.Variants = Variants;
18
+ var WithTitleAndOrContent = function () {
19
+ var _a = (0, react_1.useState)(null), visible = _a[0], setVisible = _a[1];
20
+ return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flex: 1, alignSelf: "center", mt: 12, alignItems: "center", flexWrap: "wrap", children: [(0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "title", title: (0, jsx_runtime_1.jsx)(Text_1.Text, { weight: "medium", color: "mono0", children: "Popover title" }), content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { color: "mono0", children: "Popover descriptive text with some not so long long long body" }), (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "mono0", children: "And some line break" })] }), onDismiss: function () { return setVisible(null); }, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: function () { return setVisible("title"); }, children: "Some title and description" }) }), (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "buttons", placement: "bottom", variant: "light", content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { weight: "medium", mb: 1, children: "Popover title" }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { height: 80, backgroundColor: "mono30", mb: 1 }), (0, jsx_runtime_1.jsx)(Text_1.Text, { mb: 1, children: "Popover descriptive text" }), (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flexDirection: "row", justifyContent: "flex-end", children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", variant: "outlineGray", children: "Learn more" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", ml: 1, onPress: function () { return setVisible(null); }, children: "Got it" })] })] }), onDismiss: function () { return setVisible(null); }, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: function () { return setVisible("buttons"); }, children: "Buttons and more content" }) }), (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: visible === "no-close", placement: "bottom", noCloseIcon: true, variant: "light", content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { weight: "medium", mb: 1, children: "Popover title?" }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { height: 80, backgroundColor: "mono30", mb: 1 }), (0, jsx_runtime_1.jsx)(Text_1.Text, { mb: 1, children: "Popover descriptive text" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", onPress: function () { return setVisible(null); }, children: "Got it" })] }), onDismiss: function () { return setVisible(null); }, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { onPress: function () { return setVisible("no-close"); }, children: "Content without close icon" }) })] }));
17
21
  };
18
- WithTitleAndOrContent.story = {
22
+ exports.WithTitleAndOrContent = WithTitleAndOrContent;
23
+ exports.WithTitleAndOrContent.story = {
19
24
  name: "With title and/or content",
20
25
  };
21
- export const EdgePositions = () => {
22
- const [topVisible, setTopVisible] = useState(true);
23
- const [bottomVisible, setBottomVisible] = useState(false);
24
- return (_jsxs(Flex, { flex: 1, backgroundColor: "mono30", justifyContent: "space-between", px: 1, children: [_jsx(Flex, { backgroundColor: "mono0", width: 80, px: 1, children: _jsx(Popover, { visible: topVisible, placement: "bottom", onDismiss: () => setTopVisible(false), onCloseComplete: () => setBottomVisible(true), title: _jsx(Text, { color: "mono0", variant: "xs", children: "Top-Left" }), children: _jsx(Text, { children: "Top-left" }) }) }), _jsx(Flex, { backgroundColor: "mono0", width: 120, mb: 6, alignSelf: "flex-end", px: 1, children: _jsx(Popover, { visible: bottomVisible, onDismiss: () => setBottomVisible(false), title: _jsx(Text, { color: "mono0", variant: "xs", children: "Bottom-Right" }), children: _jsx(Text, { children: "Bottom-right" }) }) })] }));
26
+ var EdgePositions = function () {
27
+ var _a = (0, react_1.useState)(true), topVisible = _a[0], setTopVisible = _a[1];
28
+ var _b = (0, react_1.useState)(false), bottomVisible = _b[0], setBottomVisible = _b[1];
29
+ return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flex: 1, backgroundColor: "mono30", justifyContent: "space-between", px: 1, children: [(0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "mono0", width: 80, px: 1, children: (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: topVisible, placement: "bottom", onDismiss: function () { return setTopVisible(false); }, onCloseComplete: function () { return setBottomVisible(true); }, title: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "mono0", variant: "xs", children: "Top-Left" }), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Top-left" }) }) }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "mono0", width: 120, mb: 6, alignSelf: "flex-end", px: 1, children: (0, jsx_runtime_1.jsx)(Popover_1.Popover, { visible: bottomVisible, onDismiss: function () { return setBottomVisible(false); }, title: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "mono0", variant: "xs", children: "Bottom-Right" }), children: (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "Bottom-right" }) }) })] }));
25
30
  };
26
- EdgePositions.story = {
31
+ exports.EdgePositions = EdgePositions;
32
+ exports.EdgePositions.story = {
27
33
  name: "Edge positions",
28
34
  };
@@ -1 +1,17 @@
1
- export * from "./Popover";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Popover"), exports);
@@ -1,29 +1,74 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useState } from "react";
3
- import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
4
- import { useSpace } from "../../utils/hooks";
5
- import { useColor } from "../../utils/hooks/useColor";
6
- import { Flex } from "../Flex";
7
- const clamp = (num, min, max) => Math.max(min, Math.min(num, max));
8
- export const ProgressBar = ({ animationDuration = 200, backgroundColor = "mono30", height = 2, onCompletion, progress: unclampedProgress, trackColor = "blue100", style, progressBarStyle, }) => {
9
- const color = useColor();
10
- const space = useSpace();
11
- const width = useSharedValue(0);
12
- const progress = clamp(unclampedProgress, 0, 100);
13
- const progressAnim = useAnimatedStyle(() => {
14
- return { width: `${width.get()}%` };
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.ProgressBar = void 0;
48
+ var jsx_runtime_1 = require("react/jsx-runtime");
49
+ var react_1 = require("react");
50
+ var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
51
+ var hooks_1 = require("../../utils/hooks");
52
+ var useColor_1 = require("../../utils/hooks/useColor");
53
+ var Flex_1 = require("../Flex");
54
+ var clamp = function (num, min, max) { return Math.max(min, Math.min(num, max)); };
55
+ var ProgressBar = function (_a) {
56
+ var _b = _a.animationDuration, animationDuration = _b === void 0 ? 200 : _b, _c = _a.backgroundColor, backgroundColor = _c === void 0 ? "mono30" : _c, _d = _a.height, height = _d === void 0 ? 2 : _d, onCompletion = _a.onCompletion, unclampedProgress = _a.progress, _e = _a.trackColor, trackColor = _e === void 0 ? "blue100" : _e, style = _a.style, progressBarStyle = _a.progressBarStyle;
57
+ var color = (0, useColor_1.useColor)();
58
+ var space = (0, hooks_1.useSpace)();
59
+ var width = (0, react_native_reanimated_1.useSharedValue)(0);
60
+ var progress = clamp(unclampedProgress, 0, 100);
61
+ var progressAnim = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
62
+ return { width: "".concat(width.get(), "%") };
15
63
  });
16
- const [onCompletionCalled, setOnCompletionCalled] = useState(false);
17
- useEffect(() => {
18
- width.set(() => withTiming(progress, { duration: animationDuration }));
64
+ var _f = (0, react_1.useState)(false), onCompletionCalled = _f[0], setOnCompletionCalled = _f[1];
65
+ (0, react_1.useEffect)(function () {
66
+ width.set(function () { return (0, react_native_reanimated_1.withTiming)(progress, { duration: animationDuration }); });
19
67
  if (progress === 100 && !onCompletionCalled) {
20
- onCompletion?.();
68
+ onCompletion === null || onCompletion === void 0 ? void 0 : onCompletion();
21
69
  setOnCompletionCalled(true);
22
70
  }
23
71
  }, [progress]);
24
- return (_jsx(Flex, { width: "10%", backgroundColor: backgroundColor, style: {
25
- marginVertical: space(1),
26
- width: "100%",
27
- ...style,
28
- }, children: _jsx(Animated.View, { testID: "progress-bar-track", style: [progressAnim, { height, backgroundColor: color(trackColor) }, progressBarStyle] }) }));
72
+ return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { width: "10%", backgroundColor: backgroundColor, style: __assign({ marginVertical: space(1), width: "100%" }, style), children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { testID: "progress-bar-track", style: [progressAnim, { height: height, backgroundColor: color(trackColor) }, progressBarStyle] }) }));
29
73
  };
74
+ exports.ProgressBar = ProgressBar;
@@ -1,11 +1,15 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ProgressBar } from "./";
3
- import { Flex } from "../Flex";
4
- import { Text } from "../Text";
5
- export default {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._ProgressBar = void 0;
4
+ var jsx_runtime_1 = require("react/jsx-runtime");
5
+ var _1 = require("./");
6
+ var Flex_1 = require("../Flex");
7
+ var Text_1 = require("../Text");
8
+ exports.default = {
6
9
  title: "Progress Indicators",
7
10
  };
8
- export const _ProgressBar = () => (_jsxs(Flex, { p: 2, children: [_jsx(Text, { children: "10%" }), _jsx(ProgressBar, { progress: 10 }), _jsx(Text, { children: "20%" }), _jsx(ProgressBar, { progress: 20 }), _jsx(Text, { children: "50%" }), _jsx(ProgressBar, { progress: 50 })] }));
9
- _ProgressBar.story = {
11
+ var _ProgressBar = function () { return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { p: 2, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { children: "10%" }), (0, jsx_runtime_1.jsx)(_1.ProgressBar, { progress: 10 }), (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "20%" }), (0, jsx_runtime_1.jsx)(_1.ProgressBar, { progress: 20 }), (0, jsx_runtime_1.jsx)(Text_1.Text, { children: "50%" }), (0, jsx_runtime_1.jsx)(_1.ProgressBar, { progress: 50 })] })); };
12
+ exports._ProgressBar = _ProgressBar;
13
+ exports._ProgressBar.story = {
10
14
  name: "ProgressBar",
11
15
  };
@@ -1,26 +1,51 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { waitFor } from "@testing-library/react-native";
3
- import { ProgressBar } from "./ProgressBar";
4
- import { renderWithWrappers } from "../../utils/tests/renderWithWrappers";
5
- describe("ProgressBar", () => {
6
- const getWrapper = (props) => {
7
- return renderWithWrappers(_jsx(ProgressBar, { ...props }));
8
- };
9
- it.skip("does not display the track view when progress is zero", async () => {
10
- const wrapper = getWrapper({ progress: 0 });
11
- const container = wrapper.getByTestId("progress-bar");
12
- const track = wrapper.getByTestId("progress-bar-track");
13
- expect(container.props.width).toEqual("100%");
14
- // width of 0% is invisible
15
- await waitFor(() => expect(track.props.style.width).toEqual("0%"));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var jsx_runtime_1 = require("react/jsx-runtime");
4
+ var react_native_1 = require("@testing-library/react-native");
5
+ var ProgressBar_1 = require("./ProgressBar");
6
+ var renderWithWrappers_1 = require("../../utils/tests/renderWithWrappers");
7
+ describe("ProgressBar", function () {
8
+ it("renders the progress bar track", function () {
9
+ (0, renderWithWrappers_1.renderWithWrappers)((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 50 }));
10
+ expect(react_native_1.screen.getByTestId("progress-bar-track")).toBeOnTheScreen();
16
11
  });
17
- it.skip("display the track view when progress is above zero", async () => {
18
- const wrapper = getWrapper({ progress: 50 });
19
- const container = wrapper.getByTestId("progress-bar");
20
- const track = wrapper.getByTestId("progress-bar-track");
21
- expect(container.props.width).toEqual("100%");
22
- // width of 50% is visible
23
- // wait for animations to finish running
24
- await waitFor(() => expect(track.props.style.width).toEqual("50%"));
12
+ it("applies the given height to the track", function () {
13
+ (0, renderWithWrappers_1.renderWithWrappers)((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 50, height: 10 }));
14
+ expect(react_native_1.screen.getByTestId("progress-bar-track")).toHaveStyle({ height: 10 });
15
+ });
16
+ it("applies custom progressBarStyle to the track", function () {
17
+ (0, renderWithWrappers_1.renderWithWrappers)((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 50, progressBarStyle: { borderRadius: 4 } }));
18
+ expect(react_native_1.screen.getByTestId("progress-bar-track")).toHaveStyle({ borderRadius: 4 });
19
+ });
20
+ describe("onCompletion", function () {
21
+ it("is not called when progress is below 100", function () {
22
+ var onCompletion = jest.fn();
23
+ (0, renderWithWrappers_1.renderWithWrappers)((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 99, onCompletion: onCompletion }));
24
+ expect(onCompletion).not.toHaveBeenCalled();
25
+ });
26
+ it("is called when progress reaches 100", function () {
27
+ var onCompletion = jest.fn();
28
+ (0, renderWithWrappers_1.renderWithWrappers)((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 100, onCompletion: onCompletion }));
29
+ expect(onCompletion).toHaveBeenCalledTimes(1);
30
+ });
31
+ it("is called when progress exceeds 100, since progress is clamped", function () {
32
+ var onCompletion = jest.fn();
33
+ (0, renderWithWrappers_1.renderWithWrappers)((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 150, onCompletion: onCompletion }));
34
+ expect(onCompletion).toHaveBeenCalledTimes(1);
35
+ });
36
+ it("is called when progress updates to 100", function () {
37
+ var onCompletion = jest.fn();
38
+ var rerender = (0, renderWithWrappers_1.renderWithWrappers)((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 50, onCompletion: onCompletion })).rerender;
39
+ expect(onCompletion).not.toHaveBeenCalled();
40
+ rerender((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 100, onCompletion: onCompletion }));
41
+ expect(onCompletion).toHaveBeenCalledTimes(1);
42
+ });
43
+ it("is only called once even if progress changes again", function () {
44
+ var onCompletion = jest.fn();
45
+ var rerender = (0, renderWithWrappers_1.renderWithWrappers)((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 100, onCompletion: onCompletion })).rerender;
46
+ rerender((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 50, onCompletion: onCompletion }));
47
+ rerender((0, jsx_runtime_1.jsx)(ProgressBar_1.ProgressBar, { progress: 100, onCompletion: onCompletion }));
48
+ expect(onCompletion).toHaveBeenCalledTimes(1);
49
+ });
25
50
  });
26
51
  });
@@ -1 +1,17 @@
1
- export * from "./ProgressBar";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ProgressBar"), exports);
@@ -1,30 +1,63 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { themeGet } from "@styled-system/theme-get";
3
- import { PixelRatio, StyleSheet, TouchableWithoutFeedback, View, } from "react-native";
4
- import styled from "styled-components/native";
5
- import { CssTransition } from "../../animation";
6
- import { useTheme } from "../../utils/hooks/useTheme";
7
- import { Flex } from "../Flex";
8
- import { Text } from "../Text";
9
- const RADIOBUTTON_SIZE = 20;
10
- const DURATION = 150;
11
- export const RadioButton = ({ accessibilityState, accessibilityLabel, block, disabled, error, onPress, selected, subtitle, text, textVariant = "sm-display", ...restProps }) => {
12
- const { color, space } = useTheme();
13
- const fontScale = PixelRatio.getFontScale();
14
- const radioButtonSize = RADIOBUTTON_SIZE * fontScale;
15
- const defaultRadioButtonStyle = {
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __rest = (this && this.__rest) || function (s, e) {
18
+ var t = {};
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
+ t[p] = s[p];
21
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
+ t[p[i]] = s[p[i]];
25
+ }
26
+ return t;
27
+ };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.DisabledDot = exports.RadioDot = exports.RadioButton = void 0;
33
+ var jsx_runtime_1 = require("react/jsx-runtime");
34
+ var theme_get_1 = require("@styled-system/theme-get");
35
+ var react_native_1 = require("react-native");
36
+ var native_1 = __importDefault(require("styled-components/native"));
37
+ var animation_1 = require("../../animation");
38
+ var useTheme_1 = require("../../utils/hooks/useTheme");
39
+ var Flex_1 = require("../Flex");
40
+ var Text_1 = require("../Text");
41
+ var RADIOBUTTON_SIZE = 20;
42
+ var DURATION = 150;
43
+ var RadioButton = function (_a) {
44
+ var accessibilityState = _a.accessibilityState, accessibilityLabel = _a.accessibilityLabel, block = _a.block, disabled = _a.disabled, error = _a.error, onPress = _a.onPress, selected = _a.selected, subtitle = _a.subtitle, text = _a.text, _b = _a.textVariant, textVariant = _b === void 0 ? "sm-display" : _b, restProps = __rest(_a, ["accessibilityState", "accessibilityLabel", "block", "disabled", "error", "onPress", "selected", "subtitle", "text", "textVariant"]);
45
+ var _c = (0, useTheme_1.useTheme)(), color = _c.color, space = _c.space;
46
+ var fontScale = react_native_1.PixelRatio.getFontScale();
47
+ var radioButtonSize = RADIOBUTTON_SIZE * fontScale;
48
+ var defaultRadioButtonStyle = {
16
49
  backgroundColor: color("mono0"),
17
50
  borderColor: color("mono30"),
18
51
  };
19
- const selectedRadioButtonStyle = {
52
+ var selectedRadioButtonStyle = {
20
53
  backgroundColor: color("mono100"),
21
54
  borderColor: color("mono100"),
22
55
  };
23
- const disabledRadioButtonStyle = {
56
+ var disabledRadioButtonStyle = {
24
57
  backgroundColor: color("mono5"),
25
58
  borderColor: color("mono10"),
26
59
  };
27
- const radioButtonStyles = {
60
+ var radioButtonStyles = {
28
61
  default: {
29
62
  notSelected: defaultRadioButtonStyle,
30
63
  selected: selectedRadioButtonStyle,
@@ -34,49 +67,52 @@ export const RadioButton = ({ accessibilityState, accessibilityLabel, block, dis
34
67
  selected: selectedRadioButtonStyle,
35
68
  },
36
69
  };
37
- const radioButtonStyle = disabled
70
+ var radioButtonStyle = disabled
38
71
  ? disabledRadioButtonStyle
39
72
  : radioButtonStyles[error ? "error" : "default"][selected ? "selected" : "notSelected"];
40
- const textColor = error ? color("red100") : disabled ? color("mono30") : color("mono100");
41
- const subtitleColor = error ? color("red100") : color("mono30");
42
- const AnimatedDot = (_jsx(Flex, { mt: "2px", children: _jsx(CssTransition, { style: [
73
+ var textColor = error ? color("red100") : disabled ? color("mono30") : color("mono100");
74
+ var subtitleColor = error ? color("red100") : color("mono30");
75
+ var AnimatedDot = ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { mt: "2px", children: (0, jsx_runtime_1.jsx)(animation_1.CssTransition, { style: [
43
76
  styles(fontScale).container,
44
77
  { marginRight: space(1) * fontScale },
45
78
  radioButtonStyle,
46
79
  ], animate: ["borderColor"], duration: DURATION, children: !!selected &&
47
- (!!disabled ? (_jsx(DisabledDot, { size: radioButtonSize })) : (_jsx(RadioDot, { size: radioButtonSize }))) }) }));
48
- return (_jsx(TouchableWithoutFeedback, { accessibilityRole: "radio", accessibilityLabel: accessibilityLabel, accessibilityState: accessibilityState, onPress: (event) => {
80
+ (!!disabled ? ((0, jsx_runtime_1.jsx)(exports.DisabledDot, { size: radioButtonSize })) : ((0, jsx_runtime_1.jsx)(exports.RadioDot, { size: radioButtonSize }))) }) }));
81
+ return ((0, jsx_runtime_1.jsx)(react_native_1.TouchableWithoutFeedback, { accessibilityRole: "radio", accessibilityLabel: accessibilityLabel, accessibilityState: accessibilityState, onPress: function (event) {
49
82
  if (disabled) {
50
83
  return;
51
84
  }
52
- onPress?.(event);
53
- }, children: _jsxs(Flex, { ...restProps, children: [_jsxs(Flex, { flexDirection: "row", alignItems: "center", justifyContent: block ? "space-between" : "flex-start", width: block ? "100%" : undefined, children: [!block && AnimatedDot, _jsx(Flex, { justifyContent: "center", children: !!text && (_jsx(Text, { variant: textVariant, color: textColor, children: text })) }), block && AnimatedDot] }), _jsx(Flex, { ml: block ? 0 : `${(RADIOBUTTON_SIZE + space(1)) * fontScale}px`, mt: block ? 0 : 0.5, children: !!subtitle && (_jsx(Text, { variant: "xs", color: subtitleColor, children: subtitle })) })] }) }));
85
+ onPress === null || onPress === void 0 ? void 0 : onPress(event);
86
+ }, children: (0, jsx_runtime_1.jsxs)(Flex_1.Flex, __assign({}, restProps, { children: [(0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flexDirection: "row", alignItems: "center", justifyContent: block ? "space-between" : "flex-start", width: block ? "100%" : undefined, children: [!block && AnimatedDot, (0, jsx_runtime_1.jsx)(Flex_1.Flex, { justifyContent: "center", children: !!text && ((0, jsx_runtime_1.jsx)(Text_1.Text, { variant: textVariant, color: textColor, children: text })) }), block && AnimatedDot] }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { ml: block ? 0 : "".concat((RADIOBUTTON_SIZE + space(1)) * fontScale, "px"), mt: block ? 0 : 0.5, children: !!subtitle && ((0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", color: subtitleColor, children: subtitle })) })] })) }));
54
87
  };
88
+ exports.RadioButton = RadioButton;
55
89
  // styled-component does not have support for Animated.View
56
- const styles = (fontScale) => StyleSheet.create({
57
- container: {
58
- display: "flex",
59
- justifyContent: "center",
60
- alignItems: "center",
61
- borderWidth: 1,
62
- borderStyle: "solid",
63
- height: RADIOBUTTON_SIZE * fontScale,
64
- width: RADIOBUTTON_SIZE * fontScale,
65
- borderRadius: (RADIOBUTTON_SIZE * fontScale) / 2,
66
- },
67
- });
90
+ var styles = function (fontScale) {
91
+ return react_native_1.StyleSheet.create({
92
+ container: {
93
+ display: "flex",
94
+ justifyContent: "center",
95
+ alignItems: "center",
96
+ borderWidth: 1,
97
+ borderStyle: "solid",
98
+ height: RADIOBUTTON_SIZE * fontScale,
99
+ width: RADIOBUTTON_SIZE * fontScale,
100
+ borderRadius: (RADIOBUTTON_SIZE * fontScale) / 2,
101
+ },
102
+ });
103
+ };
68
104
  // This component represents the white ● mark in CSS. We are not using styled-system since it's easier to specify raw CSS
69
105
  // properties with styled-component.
70
106
  // Height, Width, and Border Radius calculations are used to maintain the size of the white dot when scaling
71
- export const RadioDot = ({ size }) => {
72
- return (_jsx(View, { style: {
107
+ var RadioDot = function (_a) {
108
+ var size = _a.size;
109
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: {
73
110
  height: size * 0.625,
74
111
  width: size * 0.625,
75
112
  borderRadius: size * 0.3125,
76
113
  backgroundColor: "white",
77
114
  } }));
78
115
  };
79
- export const DisabledDot = styled(RadioDot) `
80
- border-bottom-color: ${themeGet("colors.mono30")};
81
- border-left-color: ${themeGet("colors.mono30")};
82
- `;
116
+ exports.RadioDot = RadioDot;
117
+ exports.DisabledDot = (0, native_1.default)(exports.RadioDot)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-bottom-color: ", ";\n border-left-color: ", ";\n"], ["\n border-bottom-color: ", ";\n border-left-color: ", ";\n"])), (0, theme_get_1.themeGet)("colors.mono30"), (0, theme_get_1.themeGet)("colors.mono30"));
118
+ var templateObject_1;
@@ -1,24 +1,28 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import { RadioButton } from "./RadioButton";
4
- import { List } from "../../storybook/helpers";
5
- import { Flex } from "../Flex";
6
- export default {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Default = void 0;
4
+ var jsx_runtime_1 = require("react/jsx-runtime");
5
+ var react_1 = require("react");
6
+ var RadioButton_1 = require("./RadioButton");
7
+ var helpers_1 = require("../../storybook/helpers");
8
+ var Flex_1 = require("../Flex");
9
+ exports.default = {
7
10
  title: "RadioButton",
8
11
  };
9
- export const Default = () => {
10
- const [metric, setMetric] = useState("cm");
11
- return (_jsxs(List, { contentContainerStyle: {
12
+ var Default = function () {
13
+ var _a = (0, react_1.useState)("cm"), metric = _a[0], setMetric = _a[1];
14
+ return ((0, jsx_runtime_1.jsxs)(helpers_1.List, { contentContainerStyle: {
12
15
  marginHorizontal: 20,
13
16
  justifyContent: "flex-start",
14
17
  alignItems: "flex-start",
15
- }, children: [_jsxs(Flex, { flexDirection: "row", gap: 2, children: [_jsx(RadioButton, { onPress: () => {
18
+ }, children: [(0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flexDirection: "row", gap: 2, children: [(0, jsx_runtime_1.jsx)(RadioButton_1.RadioButton, { onPress: function () {
16
19
  setMetric("cm");
17
- }, selected: metric === "cm", text: "centimeters" }), _jsx(RadioButton, { onPress: () => {
20
+ }, selected: metric === "cm", text: "centimeters" }), (0, jsx_runtime_1.jsx)(RadioButton_1.RadioButton, { onPress: function () {
18
21
  setMetric("in");
19
- }, selected: metric === "in", text: "inches" })] }), _jsxs(Flex, { children: [_jsx(RadioButton, { onPress: () => {
22
+ }, selected: metric === "in", text: "inches" })] }), (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { children: [(0, jsx_runtime_1.jsx)(RadioButton_1.RadioButton, { onPress: function () {
20
23
  setMetric("cm");
21
- }, block: true, selected: metric === "cm", text: "Centimeters" }), _jsx(RadioButton, { onPress: () => {
24
+ }, block: true, selected: metric === "cm", text: "Centimeters" }), (0, jsx_runtime_1.jsx)(RadioButton_1.RadioButton, { onPress: function () {
22
25
  setMetric("in");
23
26
  }, block: true, selected: metric === "in", text: "Inches" })] })] }));
24
27
  };
28
+ exports.Default = Default;