@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
package/dist/Theme.js CHANGED
@@ -1,20 +1,25 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ThemeProvider } from "styled-components/native";
3
- import { THEMES } from "./tokens";
4
- export const Theme = ({ children, theme = "v3light" }) => {
5
- const currentTheme = getTheme(theme);
6
- return _jsx(ThemeProvider, { theme: currentTheme, children: children });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._test_THEMES = exports.Theme = void 0;
4
+ var jsx_runtime_1 = require("react/jsx-runtime");
5
+ var native_1 = require("styled-components/native");
6
+ var tokens_1 = require("./tokens");
7
+ var Theme = function (_a) {
8
+ var children = _a.children, _b = _a.theme, theme = _b === void 0 ? "v3light" : _b;
9
+ var currentTheme = getTheme(theme);
10
+ return (0, jsx_runtime_1.jsx)(native_1.ThemeProvider, { theme: currentTheme, children: children });
7
11
  };
8
- const getTheme = (theme) => {
12
+ exports.Theme = Theme;
13
+ var getTheme = function (theme) {
9
14
  if (theme === "v3light") {
10
- return THEMES.v3light;
15
+ return tokens_1.THEMES.v3light;
11
16
  }
12
17
  if (theme === "v3dark") {
13
- return THEMES.v3dark;
18
+ return tokens_1.THEMES.v3dark;
14
19
  }
15
- return THEMES.v3light;
20
+ return tokens_1.THEMES.v3light;
16
21
  };
17
22
  /**
18
23
  * Only use this if it's are absolutely neccessary, and only in tests.
19
24
  */
20
- export const _test_THEMES = THEMES;
25
+ exports._test_THEMES = tokens_1.THEMES;
@@ -1,44 +1,89 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Component } from "react";
3
- import { Animated } from "react-native";
4
- export class CssTransition extends Component {
5
- animatedValue = new Animated.Value(0);
6
- constructor(props) {
7
- super(props);
8
- this.state = {
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __rest = (this && this.__rest) || function (s, e) {
29
+ var t = {};
30
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
31
+ t[p] = s[p];
32
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
33
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
34
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
35
+ t[p[i]] = s[p[i]];
36
+ }
37
+ return t;
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.CssTransition = void 0;
41
+ var jsx_runtime_1 = require("react/jsx-runtime");
42
+ var react_1 = require("react");
43
+ var react_native_1 = require("react-native");
44
+ var CssTransition = /** @class */ (function (_super) {
45
+ __extends(CssTransition, _super);
46
+ function CssTransition(props) {
47
+ var _this = _super.call(this, props) || this;
48
+ _this.animatedValue = new react_native_1.Animated.Value(0);
49
+ _this.state = {
9
50
  previousStyle: props.style,
10
51
  };
52
+ return _this;
11
53
  }
12
- UNSAFE_componentWillReceiveProps(nextProps) {
54
+ CssTransition.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
13
55
  this.setState({
14
56
  previousStyle: this.props.style,
15
57
  });
16
- this.animatedValue = new Animated.Value(0);
17
- Animated.timing(this.animatedValue, {
58
+ this.animatedValue = new react_native_1.Animated.Value(0);
59
+ react_native_1.Animated.timing(this.animatedValue, {
18
60
  toValue: 1,
19
61
  duration: nextProps.duration,
20
62
  // not all style properties are animatable with the native driver
21
63
  useNativeDriver: false,
22
64
  }).start();
23
- }
24
- render() {
25
- const { style, duration, ...props } = this.props;
26
- const { previousStyle } = this.state;
27
- const prevStyle = this.mergeStyles(previousStyle);
28
- const nextStyle = this.mergeStyles(style);
29
- const animateCheckboxStyle = this.props.animate.reduce((acc, cssProperty) => {
30
- acc[cssProperty] = this.animatedValue.interpolate({
65
+ };
66
+ CssTransition.prototype.render = function () {
67
+ var _this = this;
68
+ var _a = this.props, style = _a.style, duration = _a.duration, props = __rest(_a, ["style", "duration"]);
69
+ var previousStyle = this.state.previousStyle;
70
+ var prevStyle = this.mergeStyles(previousStyle);
71
+ var nextStyle = this.mergeStyles(style);
72
+ var animateCheckboxStyle = this.props.animate.reduce(function (acc, cssProperty) {
73
+ acc[cssProperty] = _this.animatedValue.interpolate({
31
74
  inputRange: [0, 1],
32
75
  outputRange: [prevStyle[cssProperty], nextStyle[cssProperty]],
33
76
  });
34
77
  return acc;
35
78
  }, {});
36
- return _jsx(Animated.View, { style: [style, animateCheckboxStyle], ...props });
37
- }
38
- mergeStyles(style) {
39
- return style.reduce((acc, obj) => {
40
- Object.keys(obj).forEach((key) => (acc[key] = obj[key]));
79
+ return (0, jsx_runtime_1.jsx)(react_native_1.Animated.View, __assign({ style: [style, animateCheckboxStyle] }, props));
80
+ };
81
+ CssTransition.prototype.mergeStyles = function (style) {
82
+ return style.reduce(function (acc, obj) {
83
+ Object.keys(obj).forEach(function (key) { return (acc[key] = obj[key]); });
41
84
  return acc;
42
85
  }, {});
43
- }
44
- }
86
+ };
87
+ return CssTransition;
88
+ }(react_1.Component));
89
+ exports.CssTransition = CssTransition;
@@ -1 +1,17 @@
1
- export * from "./CssTransition";
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("./CssTransition"), exports);
package/dist/constants.js CHANGED
@@ -1,16 +1,20 @@
1
- import { PixelRatio } from "react-native";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_ANIMATION_DURATION = exports.setGlobalActiveOpacity = exports.DEFAULT_ACTIVE_OPACITY = exports.DEFAULT_ICON_SIZE_SMALL = exports.DEFAULT_ICON_SIZE = exports.DEFAULT_HIT_SLOP = void 0;
4
+ var react_native_1 = require("react-native");
2
5
  /**
3
6
  * Touch area box for UI elements
4
7
  */
5
- export const DEFAULT_HIT_SLOP = { top: 20, bottom: 20, left: 20, right: 20 };
6
- export const DEFAULT_ICON_SIZE = 24 * PixelRatio.getFontScale();
7
- export const DEFAULT_ICON_SIZE_SMALL = 16 * PixelRatio.getFontScale();
8
+ exports.DEFAULT_HIT_SLOP = { top: 20, bottom: 20, left: 20, right: 20 };
9
+ exports.DEFAULT_ICON_SIZE = 24 * react_native_1.PixelRatio.getFontScale();
10
+ exports.DEFAULT_ICON_SIZE_SMALL = 16 * react_native_1.PixelRatio.getFontScale();
8
11
  /**
9
12
  * Default active opacity for elements that use Palette's <Touchable />
10
13
  */
11
- export let DEFAULT_ACTIVE_OPACITY = 0.8;
14
+ exports.DEFAULT_ACTIVE_OPACITY = 0.8;
12
15
  // Set things globally
13
- export const setGlobalActiveOpacity = (opacity) => {
14
- DEFAULT_ACTIVE_OPACITY = opacity;
16
+ var setGlobalActiveOpacity = function (opacity) {
17
+ exports.DEFAULT_ACTIVE_OPACITY = opacity;
15
18
  };
16
- export const DEFAULT_ANIMATION_DURATION = 200;
19
+ exports.setGlobalActiveOpacity = setGlobalActiveOpacity;
20
+ exports.DEFAULT_ANIMATION_DURATION = 200;
@@ -1,7 +1,47 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Component, createRef, useContext, createContext } from "react";
3
- import { Dimensions, Keyboard, LayoutAnimation, StatusBar, Platform, StyleSheet, View, } from "react-native";
4
- export const ArtsyKeyboardAvoidingViewContext = createContext({
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __rest = (this && this.__rest) || function (s, e) {
29
+ var t = {};
30
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
31
+ t[p] = s[p];
32
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
33
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
34
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
35
+ t[p[i]] = s[p[i]];
36
+ }
37
+ return t;
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.ArtsyKeyboardAvoidingView = exports.ArtsyKeyboardAvoidingViewContext = void 0;
41
+ var jsx_runtime_1 = require("react/jsx-runtime");
42
+ var react_1 = require("react");
43
+ var react_native_1 = require("react-native");
44
+ exports.ArtsyKeyboardAvoidingViewContext = (0, react_1.createContext)({
5
45
  isPresentedModally: false,
6
46
  isVisible: true,
7
47
  /**
@@ -10,10 +50,12 @@ export const ArtsyKeyboardAvoidingViewContext = createContext({
10
50
  */
11
51
  bottomOffset: 0,
12
52
  });
13
- export const ArtsyKeyboardAvoidingView = ({ children }) => {
14
- const { isPresentedModally, isVisible, bottomOffset } = useContext(ArtsyKeyboardAvoidingViewContext);
15
- return (_jsx(KeyboardAvoidingView, { enabled: isVisible, mode: isPresentedModally ? "bottom-based" : "top-based", bottomOffset: bottomOffset, style: { flex: 1 }, children: children }));
53
+ var ArtsyKeyboardAvoidingView = function (_a) {
54
+ var children = _a.children;
55
+ var _b = (0, react_1.useContext)(exports.ArtsyKeyboardAvoidingViewContext), isPresentedModally = _b.isPresentedModally, isVisible = _b.isVisible, bottomOffset = _b.bottomOffset;
56
+ return ((0, jsx_runtime_1.jsx)(KeyboardAvoidingView, { enabled: isVisible, mode: isPresentedModally ? "bottom-based" : "top-based", bottomOffset: bottomOffset, style: { flex: 1 }, children: children }));
16
57
  };
58
+ exports.ArtsyKeyboardAvoidingView = ArtsyKeyboardAvoidingView;
17
59
  /**
18
60
  * This code was mostly copied directly from 'react-native'
19
61
  *
@@ -26,93 +68,98 @@ export const ArtsyKeyboardAvoidingView = ({ children }) => {
26
68
  * This source code is licensed under the MIT license found in the
27
69
  * LICENSE file in the root directory of https://github.com/facebook/react-native
28
70
  */
29
- class KeyboardAvoidingView extends Component {
30
- _frame = null;
31
- _subscriptions = [];
32
- _initialFrameHeight = 0;
33
- viewRef = createRef();
34
- constructor(props) {
35
- super(props);
36
- this.state = { bottom: 0 };
71
+ var KeyboardAvoidingView = /** @class */ (function (_super) {
72
+ __extends(KeyboardAvoidingView, _super);
73
+ function KeyboardAvoidingView(props) {
74
+ var _this = _super.call(this, props) || this;
75
+ _this._frame = null;
76
+ _this._subscriptions = [];
77
+ _this._initialFrameHeight = 0;
78
+ _this.viewRef = (0, react_1.createRef)();
79
+ _this._onKeyboardChange = function (event) {
80
+ if (event == null) {
81
+ _this.setState({ bottom: 0 });
82
+ return;
83
+ }
84
+ var duration = event.duration, easing = event.easing, endCoordinates = event.endCoordinates;
85
+ var height = _this._relativeKeyboardHeight(endCoordinates);
86
+ if (_this.state.bottom === height) {
87
+ return;
88
+ }
89
+ if (duration && easing) {
90
+ react_native_1.LayoutAnimation.configureNext({
91
+ // We have to pass the duration equal to minimal accepted duration defined here: RCTLayoutAnimation.m
92
+ duration: duration > 10 ? duration : 10,
93
+ update: {
94
+ duration: duration > 10 ? duration : 10,
95
+ type: react_native_1.LayoutAnimation.Types[easing] || "keyboard",
96
+ },
97
+ });
98
+ }
99
+ _this.setState({ bottom: height });
100
+ };
101
+ _this._onLayout = function (event) {
102
+ var _a;
103
+ _this._frame = event.nativeEvent.layout;
104
+ (_a = _this.viewRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(function (x, y) {
105
+ _this._frame.x = x;
106
+ _this._frame.y = y;
107
+ });
108
+ if (!_this._initialFrameHeight) {
109
+ // save the initial frame height, before the keyboard is visible
110
+ _this._initialFrameHeight = _this._frame.height;
111
+ }
112
+ };
113
+ _this.state = { bottom: 0 };
114
+ return _this;
37
115
  }
38
- _relativeKeyboardHeight(keyboardFrame) {
39
- const frame = this._frame;
116
+ KeyboardAvoidingView.prototype._relativeKeyboardHeight = function (keyboardFrame) {
117
+ var _a;
118
+ var frame = this._frame;
40
119
  if (!frame || !keyboardFrame) {
41
120
  return 0;
42
121
  }
43
122
  switch (this.props.mode) {
44
123
  case "top-based": {
45
- let keyboardY = keyboardFrame.screenY;
124
+ var keyboardY = keyboardFrame.screenY;
46
125
  // on android the View layout frame coords start at -statusBarHeight but the
47
126
  // keyboard screenY starts at 0 so we need to offset it to match the View frame
48
- if (Platform.OS === "android") {
49
- keyboardY -= StatusBar.currentHeight ?? 0;
127
+ if (react_native_1.Platform.OS === "android") {
128
+ keyboardY -= (_a = react_native_1.StatusBar.currentHeight) !== null && _a !== void 0 ? _a : 0;
50
129
  }
51
130
  // Calculate the displacement needed for the view such that it
52
131
  // no longer overlaps with the keyboard
53
132
  return Math.max(frame.y + frame.height - keyboardY, 0);
54
133
  }
55
134
  case "bottom-based": {
56
- let keyboardHeight = Dimensions.get("screen").height - keyboardFrame.screenY;
135
+ var keyboardHeight = react_native_1.Dimensions.get("screen").height - keyboardFrame.screenY;
57
136
  keyboardHeight -= this.props.bottomOffset;
58
137
  return Math.max(keyboardHeight, 0);
59
138
  }
60
139
  }
61
- }
62
- _onKeyboardChange = (event) => {
63
- if (event == null) {
64
- this.setState({ bottom: 0 });
65
- return;
66
- }
67
- const { duration, easing, endCoordinates } = event;
68
- const height = this._relativeKeyboardHeight(endCoordinates);
69
- if (this.state.bottom === height) {
70
- return;
71
- }
72
- if (duration && easing) {
73
- LayoutAnimation.configureNext({
74
- // We have to pass the duration equal to minimal accepted duration defined here: RCTLayoutAnimation.m
75
- duration: duration > 10 ? duration : 10,
76
- update: {
77
- duration: duration > 10 ? duration : 10,
78
- type: LayoutAnimation.Types[easing] || "keyboard",
79
- },
80
- });
81
- }
82
- this.setState({ bottom: height });
83
- };
84
- _onLayout = (event) => {
85
- this._frame = event.nativeEvent.layout;
86
- this.viewRef.current?.measureInWindow((x, y) => {
87
- this._frame.x = x;
88
- this._frame.y = y;
89
- });
90
- if (!this._initialFrameHeight) {
91
- // save the initial frame height, before the keyboard is visible
92
- this._initialFrameHeight = this._frame.height;
93
- }
94
140
  };
95
- componentDidMount() {
96
- if (Platform.OS === "ios") {
141
+ KeyboardAvoidingView.prototype.componentDidMount = function () {
142
+ if (react_native_1.Platform.OS === "ios") {
97
143
  this._subscriptions = [
98
- Keyboard.addListener("keyboardWillChangeFrame", this._onKeyboardChange),
144
+ react_native_1.Keyboard.addListener("keyboardWillChangeFrame", this._onKeyboardChange),
99
145
  ];
100
146
  }
101
147
  else {
102
148
  this._subscriptions = [
103
- Keyboard.addListener("keyboardDidHide", this._onKeyboardChange),
104
- Keyboard.addListener("keyboardDidShow", this._onKeyboardChange),
149
+ react_native_1.Keyboard.addListener("keyboardDidHide", this._onKeyboardChange),
150
+ react_native_1.Keyboard.addListener("keyboardDidShow", this._onKeyboardChange),
105
151
  ];
106
152
  }
107
- }
108
- componentWillUnmount() {
109
- this._subscriptions.forEach((subscription) => {
153
+ };
154
+ KeyboardAvoidingView.prototype.componentWillUnmount = function () {
155
+ this._subscriptions.forEach(function (subscription) {
110
156
  subscription.remove();
111
157
  });
112
- }
113
- render() {
114
- const { children, mode, enabled, style, ...props } = this.props;
115
- const bottomHeight = enabled ? this.state.bottom : 0;
116
- return (_jsx(View, { ref: this.viewRef, style: StyleSheet.compose(style, { paddingBottom: bottomHeight }), onLayout: this._onLayout, ...props, children: children }));
117
- }
118
- }
158
+ };
159
+ KeyboardAvoidingView.prototype.render = function () {
160
+ var _a = this.props, children = _a.children, mode = _a.mode, enabled = _a.enabled, style = _a.style, props = __rest(_a, ["children", "mode", "enabled", "style"]);
161
+ var bottomHeight = enabled ? this.state.bottom : 0;
162
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, __assign({ ref: this.viewRef, style: react_native_1.StyleSheet.compose(style, { paddingBottom: bottomHeight }), onLayout: this._onLayout }, props, { children: children })));
163
+ };
164
+ return KeyboardAvoidingView;
165
+ }(react_1.Component));
@@ -1 +1,17 @@
1
- export * from './ArtsyKeyboardAvoidingView';
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("./ArtsyKeyboardAvoidingView"), exports);
@@ -1,49 +1,58 @@
1
- import { normalizeText } from "../../utils/normalizeText";
2
- export class Autocomplete {
3
- entries;
4
- maxCacheItems;
5
- cache = {};
6
- cacheOrder = [];
7
- constructor(entries, maxCacheItems = 100, stopWords = ["of", "the", "and"]) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Autocomplete = void 0;
4
+ var normalizeText_1 = require("../../utils/normalizeText");
5
+ var Autocomplete = /** @class */ (function () {
6
+ function Autocomplete(entries, maxCacheItems, stopWords) {
7
+ var _a;
8
+ if (maxCacheItems === void 0) { maxCacheItems = 100; }
9
+ if (stopWords === void 0) { stopWords = ["of", "the", "and"]; }
8
10
  this.entries = entries;
9
11
  this.maxCacheItems = maxCacheItems;
10
- for (const entry of entries) {
11
- entry.searchTerms = entry.searchTerms.map(normalizeText);
12
- for (const searchTerm of entry.searchTerms.slice(0)) {
13
- const parts = searchTerm.split(/\s+/).filter((s) => !stopWords.includes(s));
12
+ this.cache = {};
13
+ this.cacheOrder = [];
14
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
15
+ var entry = entries_1[_i];
16
+ entry.searchTerms = entry.searchTerms.map(normalizeText_1.normalizeText);
17
+ for (var _b = 0, _c = entry.searchTerms.slice(0); _b < _c.length; _b++) {
18
+ var searchTerm = _c[_b];
19
+ var parts = searchTerm.split(/\s+/).filter(function (s) { return !stopWords.includes(s); });
14
20
  if (parts.length > 1) {
15
- entry.searchTerms.push(...parts);
21
+ (_a = entry.searchTerms).push.apply(_a, parts);
16
22
  }
17
23
  }
18
24
  }
19
25
  }
20
- getSuggestions(searchString) {
21
- searchString = normalizeText(searchString);
26
+ Autocomplete.prototype.getSuggestions = function (searchString) {
27
+ searchString = (0, normalizeText_1.normalizeText)(searchString);
22
28
  if (this.cache[searchString]) {
23
- return this.cache[searchString].map((e) => e.key);
29
+ return this.cache[searchString].map(function (e) { return e.key; });
24
30
  }
25
31
  // refine previous results if available
26
- let possibleEntries = this.entries;
27
- for (let i = searchString.length - 2; i > 0; i--) {
32
+ var possibleEntries = this.entries;
33
+ for (var i = searchString.length - 2; i > 0; i--) {
28
34
  if (this.cache[searchString.slice(0, i)]) {
29
35
  possibleEntries = this.cache[searchString.slice(0, i)];
30
36
  break;
31
37
  }
32
38
  }
33
- const results = possibleEntries.filter((entry) => {
34
- for (const searchTerm of entry.searchTerms) {
39
+ var results = possibleEntries.filter(function (entry) {
40
+ for (var _i = 0, _a = entry.searchTerms; _i < _a.length; _i++) {
41
+ var searchTerm = _a[_i];
35
42
  if (searchTerm.startsWith(searchString)) {
36
43
  return true;
37
44
  }
38
45
  }
39
46
  return false;
40
47
  });
41
- results.sort((a, b) => b.importance - a.importance);
48
+ results.sort(function (a, b) { return b.importance - a.importance; });
42
49
  this.cache[searchString] = results;
43
50
  this.cacheOrder.push(searchString);
44
51
  while (this.cacheOrder.length > this.maxCacheItems) {
45
52
  delete this.cache[this.cacheOrder.shift()];
46
53
  }
47
- return results.map((e) => e.key);
48
- }
49
- }
54
+ return results.map(function (e) { return e.key; });
55
+ };
56
+ return Autocomplete;
57
+ }());
58
+ exports.Autocomplete = Autocomplete;