@fountain-ui/core 2.0.0-beta.12 → 2.0.0-beta.13

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 (61) hide show
  1. package/build/commonjs/ButtonBase/ButtonBase.js +56 -52
  2. package/build/commonjs/ButtonBase/ButtonBase.js.map +1 -1
  3. package/build/commonjs/CircularProgress/CircularProgress.js +10 -12
  4. package/build/commonjs/CircularProgress/CircularProgress.js.map +1 -1
  5. package/build/commonjs/ImageCore/ImageCoreNative.js +24 -26
  6. package/build/commonjs/ImageCore/ImageCoreNative.js.map +1 -1
  7. package/build/commonjs/Tooltip/Tooltip.js +14 -18
  8. package/build/commonjs/Tooltip/Tooltip.js.map +1 -1
  9. package/build/commonjs/animated/AnimatedPressable.js +2 -3
  10. package/build/commonjs/animated/AnimatedPressable.js.map +1 -1
  11. package/build/commonjs/hooks/useThrottle.js +3 -7
  12. package/build/commonjs/hooks/useThrottle.js.map +1 -1
  13. package/build/commonjs/internal/hooks/useHeight.js +2 -6
  14. package/build/commonjs/internal/hooks/useHeight.js.map +1 -1
  15. package/build/module/ButtonBase/ButtonBase.js +54 -48
  16. package/build/module/ButtonBase/ButtonBase.js.map +1 -1
  17. package/build/module/CircularProgress/CircularProgress.js +10 -11
  18. package/build/module/CircularProgress/CircularProgress.js.map +1 -1
  19. package/build/module/ImageCore/ImageCoreNative.js +20 -23
  20. package/build/module/ImageCore/ImageCoreNative.js.map +1 -1
  21. package/build/module/Tooltip/Tooltip.js +11 -11
  22. package/build/module/Tooltip/Tooltip.js.map +1 -1
  23. package/build/module/animated/AnimatedPressable.js +2 -3
  24. package/build/module/animated/AnimatedPressable.js.map +1 -1
  25. package/build/module/hooks/useThrottle.js +3 -3
  26. package/build/module/hooks/useThrottle.js.map +1 -1
  27. package/build/module/internal/hooks/useHeight.js +2 -2
  28. package/build/module/internal/hooks/useHeight.js.map +1 -1
  29. package/build/typescript/animated/AnimatedPressable.d.ts +2 -2
  30. package/package.json +2 -2
  31. package/src/ButtonBase/ButtonBase.tsx +65 -43
  32. package/src/CircularProgress/CircularProgress.tsx +15 -16
  33. package/src/ImageCore/ImageCoreNative.tsx +17 -19
  34. package/src/Tooltip/Tooltip.tsx +12 -12
  35. package/src/animated/AnimatedPressable.tsx +1 -2
  36. package/src/hooks/useThrottle.ts +3 -3
  37. package/src/internal/hooks/useHeight.ts +2 -2
  38. package/build/commonjs/ButtonBase/ButtonBase.ios.js +0 -101
  39. package/build/commonjs/ButtonBase/ButtonBase.ios.js.map +0 -1
  40. package/build/commonjs/ButtonBase/useDisabledReaction/index.js +0 -21
  41. package/build/commonjs/ButtonBase/useDisabledReaction/index.js.map +0 -1
  42. package/build/commonjs/ButtonBase/useDisabledReaction/index.native.js +0 -9
  43. package/build/commonjs/ButtonBase/useDisabledReaction/index.native.js.map +0 -1
  44. package/build/commonjs/ImageCore/ImageCoreNative.ios.js +0 -60
  45. package/build/commonjs/ImageCore/ImageCoreNative.ios.js.map +0 -1
  46. package/build/module/ButtonBase/ButtonBase.ios.js +0 -82
  47. package/build/module/ButtonBase/ButtonBase.ios.js.map +0 -1
  48. package/build/module/ButtonBase/useDisabledReaction/index.js +0 -12
  49. package/build/module/ButtonBase/useDisabledReaction/index.js.map +0 -1
  50. package/build/module/ButtonBase/useDisabledReaction/index.native.js +0 -2
  51. package/build/module/ButtonBase/useDisabledReaction/index.native.js.map +0 -1
  52. package/build/module/ImageCore/ImageCoreNative.ios.js +0 -45
  53. package/build/module/ImageCore/ImageCoreNative.ios.js.map +0 -1
  54. package/build/typescript/ButtonBase/ButtonBase.ios.d.ts +0 -2
  55. package/build/typescript/ButtonBase/useDisabledReaction/index.d.ts +0 -2
  56. package/build/typescript/ButtonBase/useDisabledReaction/index.native.d.ts +0 -2
  57. package/build/typescript/ImageCore/ImageCoreNative.ios.d.ts +0 -2
  58. package/src/ButtonBase/ButtonBase.ios.tsx +0 -95
  59. package/src/ButtonBase/useDisabledReaction/index.native.ts +0 -4
  60. package/src/ButtonBase/useDisabledReaction/index.ts +0 -17
  61. package/src/ImageCore/ImageCoreNative.ios.tsx +0 -46
@@ -6,19 +6,17 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ORIGINAL_OPACITY = exports.DISABLED_OPACITY = void 0;
7
7
  exports.default = ButtonBase;
8
8
 
9
- var _react = _interopRequireDefault(require("react"));
9
+ var _react = _interopRequireWildcard(require("react"));
10
10
 
11
- var _reactNativeReanimated = require("react-native-reanimated");
11
+ var _reactNative = require("react-native");
12
12
 
13
13
  var _hooks = require("../hooks");
14
14
 
15
15
  var _animated = require("../animated");
16
16
 
17
- var _styles = require("../styles");
17
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
18
 
19
- var _useDisabledReaction = _interopRequireDefault(require("./useDisabledReaction"));
20
-
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
22
20
 
23
21
  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); }
24
22
 
@@ -28,19 +26,18 @@ const DISABLED_OPACITY = .3;
28
26
  exports.DISABLED_OPACITY = DISABLED_OPACITY;
29
27
  const ACTIVE_OPACITY = .65;
30
28
  const ORIGINAL_SCALE = 1;
31
- const MINIFIED_SCALE = .96;
32
- const ANIMATION_CONFIG = {
33
- duration: 150
34
- };
29
+ const MINIFIED_SCALE = .96; // at "node_modules/react-native/Libraries/Pressability.js"
30
+ // const DEFAULT_MIN_PRESS_DURATION = 130;
35
31
 
36
- const styles = _styles.StyleSheet.create({
37
- disabled: {
38
- opacity: DISABLED_OPACITY,
39
- transform: [{
40
- scale: ORIGINAL_SCALE
41
- }]
42
- }
43
- });
32
+ const PRESS_IN_DELAY = 130;
33
+
34
+ const startTimingAnimationWithDefaults = (value, toValue) => {
35
+ _reactNative.Animated.timing(value, {
36
+ toValue,
37
+ duration: 150,
38
+ useNativeDriver: true
39
+ }).start();
40
+ };
44
41
 
45
42
  function ButtonBase(props) {
46
43
  const {
@@ -49,7 +46,7 @@ function ButtonBase(props) {
49
46
  disableThrottle = false,
50
47
  onPress,
51
48
  pressEffect = 'opacity',
52
- style,
49
+ style: styleProp,
53
50
  throttleMillis = 650,
54
51
  ...otherProps
55
52
  } = props;
@@ -57,51 +54,58 @@ function ButtonBase(props) {
57
54
  periodMillis: disableThrottle ? 0 : throttleMillis,
58
55
  callback: onPress
59
56
  });
60
- const opacity = (0, _reactNativeReanimated.useSharedValue)(ORIGINAL_OPACITY);
61
- const scale = (0, _reactNativeReanimated.useSharedValue)(ORIGINAL_SCALE);
62
- const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
63
- opacity: opacity.value,
64
- transform: [{
65
- scale: scale.value
66
- }]
67
- }), []);
68
- (0, _useDisabledReaction.default)(disabled, opacity);
69
-
70
- const startAnimation = function (pressIn) {
71
- let isHovered = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
72
-
73
- if (pressEffect === 'none') {
74
- return;
57
+ const opacity = (0, _react.useRef)(new _reactNative.Animated.Value(ORIGINAL_OPACITY)).current;
58
+ const scale = (0, _react.useRef)(new _reactNative.Animated.Value(ORIGINAL_SCALE)).current;
59
+ (0, _react.useEffect)(() => {
60
+ opacity.setValue(disabled ? DISABLED_OPACITY : ORIGINAL_OPACITY);
61
+ }, [disabled]);
62
+ const startScaleAnimation = (0, _react.useCallback)((pressIn, isHover) => {
63
+ if (!isHover) {
64
+ startTimingAnimationWithDefaults(scale, pressIn ? MINIFIED_SCALE : ORIGINAL_SCALE);
75
65
  }
76
-
77
- if (pressEffect === 'opacity') {
78
- if (pressIn) {
79
- opacity.value = ACTIVE_OPACITY;
80
- } else {
81
- opacity.value = (0, _reactNativeReanimated.withTiming)(ORIGINAL_OPACITY, ANIMATION_CONFIG);
82
- }
83
- } else if (!isHovered) {
84
- if (pressIn) {
85
- scale.value = (0, _reactNativeReanimated.withDelay)(100, (0, _reactNativeReanimated.withTiming)(MINIFIED_SCALE, ANIMATION_CONFIG));
86
- } else {
87
- scale.value = (0, _reactNativeReanimated.withTiming)(ORIGINAL_SCALE, ANIMATION_CONFIG);
88
- }
66
+ }, []);
67
+ const startOpacityAnimation = (0, _react.useCallback)(pressIn => {
68
+ if (pressIn) {
69
+ opacity.setValue(ACTIVE_OPACITY);
70
+ } else {
71
+ startTimingAnimationWithDefaults(opacity, ORIGINAL_OPACITY);
89
72
  }
73
+ }, []);
74
+ const startPressAnimation = (0, _react.useCallback)(function (pressIn) {
75
+ let isHover = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
76
+
77
+ if (pressEffect === 'scale') {
78
+ startScaleAnimation(pressIn, isHover);
79
+ } else if (pressEffect === 'opacity') {
80
+ startOpacityAnimation(pressIn, isHover);
81
+ }
82
+ }, [pressEffect]);
83
+ const handlePressIn = (0, _react.useCallback)(() => {
84
+ startPressAnimation(true, false);
85
+ }, [startPressAnimation]);
86
+ const handlePressOut = (0, _react.useCallback)(() => {
87
+ startPressAnimation(false, false);
88
+ }, [startPressAnimation]);
89
+ const animatedStyle = {
90
+ opacity,
91
+ transform: [{
92
+ scale
93
+ }]
90
94
  };
91
-
92
95
  return /*#__PURE__*/_react.default.createElement(_animated.AnimatedPressable, _extends({
93
96
  disabled: disabled,
94
97
  onPress: handlePress,
95
- onPressIn: () => startAnimation(true),
96
- onPressOut: () => startAnimation(false),
97
- style: [animatedStyle, disabled ? styles.disabled : undefined, style]
98
+ onPressIn: handlePressIn,
99
+ onPressOut: handlePressOut,
100
+ style: [animatedStyle, styleProp],
101
+ unstable_pressDelay: PRESS_IN_DELAY
98
102
  }, otherProps), typeof children !== 'function' ? _ref => {
99
103
  let {
100
104
  hovered
101
105
  } = _ref;
102
106
 
103
107
  if (hovered !== undefined && !disabled) {
104
- startAnimation(hovered, true);
108
+ startPressAnimation(hovered, true);
105
109
  }
106
110
 
107
111
  return children;
@@ -1 +1 @@
1
- {"version":3,"names":["ORIGINAL_OPACITY","DISABLED_OPACITY","ACTIVE_OPACITY","ORIGINAL_SCALE","MINIFIED_SCALE","ANIMATION_CONFIG","duration","styles","StyleSheet","create","disabled","opacity","transform","scale","ButtonBase","props","children","disableThrottle","onPress","pressEffect","style","throttleMillis","otherProps","handlePress","useThrottle","periodMillis","callback","useSharedValue","animatedStyle","useAnimatedStyle","value","useDisabledReaction","startAnimation","pressIn","isHovered","withTiming","withDelay","undefined","hovered"],"sources":["ButtonBase.tsx"],"sourcesContent":["import React from 'react';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport { useAnimatedStyle, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';\nimport { useThrottle } from '../hooks';\nimport { AnimatedPressable } from '../animated';\nimport { StyleSheet } from '../styles';\nimport type ButtonBaseProps from './ButtonBaseProps';\nimport useDisabledReaction from './useDisabledReaction';\n\nexport const ORIGINAL_OPACITY = 1;\nexport const DISABLED_OPACITY = .3;\nconst ACTIVE_OPACITY = .65;\n\nconst ORIGINAL_SCALE = 1;\nconst MINIFIED_SCALE = .96;\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 150 };\n\nconst styles = StyleSheet.create({\n disabled: {\n opacity: DISABLED_OPACITY,\n transform: [{ scale: ORIGINAL_SCALE }],\n },\n});\n\nexport default function ButtonBase(props: ButtonBaseProps) {\n const {\n children,\n disabled = false,\n disableThrottle = false,\n onPress,\n pressEffect = 'opacity',\n style,\n throttleMillis = 650,\n ...otherProps\n } = props;\n\n const handlePress = useThrottle({\n periodMillis: disableThrottle ? 0 : throttleMillis,\n callback: onPress,\n });\n\n const opacity = useSharedValue(ORIGINAL_OPACITY);\n const scale = useSharedValue(ORIGINAL_SCALE);\n\n const animatedStyle = useAnimatedStyle(() => ({\n opacity: opacity.value,\n transform: [{ scale: scale.value }],\n }), []);\n\n useDisabledReaction(disabled, opacity);\n\n const startAnimation = (pressIn: boolean, isHovered: boolean = false) => {\n if (pressEffect === 'none') {\n return;\n }\n\n if (pressEffect === 'opacity') {\n if (pressIn) {\n opacity.value = ACTIVE_OPACITY;\n } else {\n opacity.value = withTiming(ORIGINAL_OPACITY, ANIMATION_CONFIG);\n }\n } else if (!isHovered) {\n if (pressIn) {\n scale.value = withDelay(\n 100,\n withTiming(MINIFIED_SCALE, ANIMATION_CONFIG),\n );\n } else {\n scale.value = withTiming(ORIGINAL_SCALE, ANIMATION_CONFIG);\n }\n }\n };\n\n return (\n <AnimatedPressable\n disabled={disabled}\n onPress={handlePress}\n onPressIn={() => startAnimation(true)}\n onPressOut={() => startAnimation(false)}\n style={[\n animatedStyle,\n disabled ? styles.disabled : undefined,\n style,\n ]}\n {...otherProps}\n >\n {typeof children !== 'function' ? (\n ({ hovered }) => {\n if (hovered !== undefined && !disabled) {\n startAnimation(hovered, true);\n }\n\n return children;\n }\n ) : children}\n </AnimatedPressable>\n );\n};\n"],"mappings":";;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEO,MAAMA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RESS_IN_DELAY","startTimingAnimationWithDefaults","value","toValue","Animated","timing","duration","useNativeDriver","start","ButtonBase","props","children","disabled","disableThrottle","onPress","pressEffect","style","styleProp","throttleMillis","otherProps","handlePress","useThrottle","periodMillis","callback","opacity","useRef","Value","current","scale","useEffect","setValue","startScaleAnimation","useCallback","pressIn","isHover","startOpacityAnimation","startPressAnimation","handlePressIn","handlePressOut","animatedStyle","transform","hovered","undefined"],"sources":["ButtonBase.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport { useThrottle } from '../hooks';\nimport { AnimatedPressable } from '../animated';\nimport type ButtonBaseProps from './ButtonBaseProps';\n\ninterface StartPressAnimation {\n (pressIn: boolean, isHover: boolean): void;\n}\n\nexport const ORIGINAL_OPACITY = 1;\nexport const DISABLED_OPACITY = .3;\nconst ACTIVE_OPACITY = .65;\n\nconst ORIGINAL_SCALE = 1;\nconst MINIFIED_SCALE = .96;\n\n// at \"node_modules/react-native/Libraries/Pressability.js\"\n// const DEFAULT_MIN_PRESS_DURATION = 130;\nconst PRESS_IN_DELAY = 130;\n\ntype TimingAnimationValue = Animated.Value | Animated.ValueXY;\ntype TimingAnimationToValue = Animated.TimingAnimationConfig['toValue'];\n\nconst startTimingAnimationWithDefaults = (\n value: TimingAnimationValue,\n toValue: TimingAnimationToValue,\n) => {\n Animated.timing(value, {\n toValue,\n duration: 150,\n useNativeDriver: true,\n }).start();\n};\n\nexport default function ButtonBase(props: ButtonBaseProps) {\n const {\n children,\n disabled = false,\n disableThrottle = false,\n onPress,\n pressEffect = 'opacity',\n style: styleProp,\n throttleMillis = 650,\n ...otherProps\n } = props;\n\n const handlePress = useThrottle({\n periodMillis: disableThrottle ? 0 : throttleMillis,\n callback: onPress,\n });\n\n const opacity = useRef<Animated.Value>(new Animated.Value(ORIGINAL_OPACITY)).current;\n const scale = useRef<Animated.Value>(new Animated.Value(ORIGINAL_SCALE)).current;\n\n useEffect(() => {\n opacity.setValue(disabled ? DISABLED_OPACITY : ORIGINAL_OPACITY);\n }, [disabled]);\n\n const startScaleAnimation = useCallback<StartPressAnimation>((pressIn, isHover) => {\n if (!isHover) {\n startTimingAnimationWithDefaults(\n scale,\n pressIn ? MINIFIED_SCALE : ORIGINAL_SCALE,\n );\n }\n }, []);\n\n const startOpacityAnimation = useCallback<StartPressAnimation>((pressIn) => {\n if (pressIn) {\n opacity.setValue(ACTIVE_OPACITY);\n } else {\n startTimingAnimationWithDefaults(opacity, ORIGINAL_OPACITY);\n }\n }, []);\n\n const startPressAnimation = useCallback<StartPressAnimation>((pressIn, isHover = false) => {\n if (pressEffect === 'scale') {\n startScaleAnimation(pressIn, isHover);\n } else if (pressEffect === 'opacity') {\n startOpacityAnimation(pressIn, isHover);\n }\n }, [pressEffect]);\n\n const handlePressIn = useCallback(() => {\n startPressAnimation(true, false);\n }, [startPressAnimation]);\n\n const handlePressOut = useCallback(() => {\n startPressAnimation(false, false);\n }, [startPressAnimation]);\n\n const animatedStyle = {\n opacity,\n transform: [{ scale }],\n };\n\n return (\n <AnimatedPressable\n disabled={disabled}\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n style={[\n animatedStyle,\n styleProp,\n ]}\n unstable_pressDelay={PRESS_IN_DELAY}\n {...otherProps}\n >\n {typeof children !== 'function' ? (\n ({ hovered }) => {\n if (hovered !== undefined && !disabled) {\n startPressAnimation(hovered, true);\n }\n\n return children;\n }\n ) : children}\n </AnimatedPressable>\n );\n};\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAOO,MAAMA,gBAAgB,GAAG,CAAzB;;AACA,MAAMC,gBAAgB,GAAG,EAAzB;;AACP,MAAMC,cAAc,GAAG,GAAvB;AAEA,MAAMC,cAAc,GAAG,CAAvB;AACA,MAAMC,cAAc,GAAG,GAAvB,C,CAEA;AACA;;AACA,MAAMC,cAAc,GAAG,GAAvB;;AAKA,MAAMC,gCAAgC,GAAG,CACrCC,KADq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yB,CAAC9B,QAA9B,EAAwC;MACpCwB,mBAAmB,CAACK,OAAD,EAAU,IAAV,CAAnB;IACH;;IAED,OAAO9B,QAAP;EACH,CAPJ,GAQGA,QApBR,CADJ;AAwBH;;AAAA"}
@@ -11,8 +11,6 @@ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reani
11
11
 
12
12
  var _icons = require("../internal/icons");
13
13
 
14
- var _styles = require("../styles");
15
-
16
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
15
 
18
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -21,8 +19,8 @@ const ANIMATION_CONFIG = {
21
19
  duration: 900,
22
20
  easing: _reactNativeReanimated.Easing.linear
23
21
  };
24
- const MIN_ROTATE = 0;
25
- const MAX_ROTATE = 360;
22
+ const MIN_ROTATE_DEGREE = 0;
23
+ const MAX_ROTATE_DEGREE = 360;
26
24
 
27
25
  const useStyles = function () {
28
26
  return {
@@ -35,22 +33,22 @@ const useStyles = function () {
35
33
 
36
34
  function CircularProgress(props) {
37
35
  const {
38
- style
36
+ style: styleProp
39
37
  } = props;
40
38
  const styles = useStyles();
41
- const rootStyle = (0, _styles.css)([styles.root, style]);
42
- const rotate = (0, _reactNativeReanimated.useSharedValue)(MIN_ROTATE);
43
- const spinStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
39
+ const rotate = (0, _reactNativeReanimated.useSharedValue)(MIN_ROTATE_DEGREE);
40
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
44
41
  transform: [{
45
- rotate: `${rotate}deg`
42
+ rotate: `${rotate.value}deg`
46
43
  }]
47
44
  }), []);
48
45
  (0, _react.useEffect)(() => {
49
- rotate.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withTiming)(MAX_ROTATE, ANIMATION_CONFIG), -1, false);
46
+ rotate.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withTiming)(MAX_ROTATE_DEGREE, ANIMATION_CONFIG), -1, false);
50
47
  }, []);
51
48
  return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
52
- style: [spinStyle, rootStyle]
53
- }, /*#__PURE__*/_react.default.createElement(_icons.CircularProgress, null));
49
+ children: /*#__PURE__*/_react.default.createElement(_icons.CircularProgress, null),
50
+ style: [animatedStyle, styles.root, styleProp]
51
+ });
54
52
  }
55
53
 
56
54
  ;
@@ -1 +1 @@
1
- {"version":3,"names":["ANIMATION_CONFIG","duration","easing","Easing","linear","MIN_ROTATE","MAX_ROTATE","useStyles","root","alignItems","justifyContent","CircularProgress","props","style","styles","rootStyle","css","rotate","useSharedValue","spinStyle","useAnimatedStyle","transform","useEffect","value","withRepeat","withTiming"],"sources":["CircularProgress.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { ViewProps } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { Easing, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';\nimport { CircularProgress as CircularProgressIcon } from '../internal/icons';\nimport { css } from '../styles';\nimport { OverridableComponentProps } from '../types';\n\ntype CircularProgressStyles = NamedStylesStringUnion<'root'>;\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 900, easing: Easing.linear };\n\nconst MIN_ROTATE = 0;\nconst MAX_ROTATE = 360;\n\nconst useStyles: UseStyles<CircularProgressStyles> = function (): CircularProgressStyles {\n return {\n root: {\n alignItems: 'center',\n justifyContent: 'center',\n },\n };\n};\n\nexport default function CircularProgress(props: OverridableComponentProps<ViewProps>) {\n const { style } = props;\n\n const styles = useStyles();\n\n const rootStyle = css([\n styles.root,\n style,\n ]);\n\n const rotate = useSharedValue(MIN_ROTATE);\n\n const spinStyle = useAnimatedStyle(() => ({\n transform: [{ rotate: `${rotate}deg` }],\n }), []);\n\n useEffect(() => {\n rotate.value = withRepeat(\n withTiming(MAX_ROTATE, ANIMATION_CONFIG),\n -1,\n false,\n );\n }, []);\n\n return (\n <Animated.View style={[spinStyle, rootStyle]}>\n <CircularProgressIcon/>\n </Animated.View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;AACA;;;;;;AAKA,MAAMA,gBAA4C,GAAG;EAAEC,QAAQ,EAAE,GAAZ;EAAiBC,MAAM,EAAEC,6BAAA,CAAOC;AAAhC,CAArD;AAEA,MAAMC,UAAU,GAAG,CAAnB;AACA,MAAMC,UAAU,GAAG,GAAnB;;AAEA,MAAMC,SAA4C,GAAG,YAAoC;EACrF,OAAO;IACHC,IAAI,EAAE;MACFC,UAAU,EAAE,QADV;MAEFC,cAAc,EAAE;IAFd;EADH,CAAP;AAMH,CAPD;;AASe,SAASC,gBAAT,CAA0BC,KAA1B,EAAuE;EAClF,MAAM;IAAEC;EAAF,IAAYD,KAAlB;EAEA,MAAME,MAAM,GAAGP,SAAS,EAAxB;EAEA,MAAMQ,SAAS,GAAG,IAAAC,WAAA,EAAI,CAClBF,MAAM,CAACN,IADW,EAElBK,KAFkB,CAAJ,CAAlB;EAKA,MAAMI,MAAM,GAAG,IAAAC,qCAAA,EAAeb,UAAf,CAAf;EAEA,MAAMc,SAAS,GAAG,IAAAC,uCAAA,EAAiB,OAAO;IACtCC,SAAS,EAAE,CAAC;MAAEJ,MAAM,EAAG,GAAEA,MAAO;IAApB,CAAD;EAD2B,CAAP,CAAjB,EAEd,EAFc,CAAlB;EAIA,IAAAK,gBAAA,EAAU,MAAM;IACZL,MAAM,CAACM,KAAP,GAAe,IAAAC,iCAAA,EACX,IAAAC,iCAAA,EAAWnB,UAAX,EAAuBN,gBAAvB,CADW,EAEX,CAAC,CAFU,EAGX,KAHW,CAAf;EAKH,CAND,EAMG,EANH;EAQA,oBACI,6BAAC,8BAAD,CAAU,IAAV;IAAe,KAAK,EAAE,CAACmB,SAAD,EAAYJ,SAAZ;EAAtB,gBACI,6BAAC,uBAAD,OADJ,CADJ;AAKH;;AAAA"}
1
+ {"version":3,"names":["ANIMATION_CONFIG","duration","easing","Easing","linear","MIN_ROTATE_DEGREE","MAX_ROTATE_DEGREE","useStyles","root","alignItems","justifyContent","CircularProgress","props","style","styleProp","styles","rotate","useSharedValue","animatedStyle","useAnimatedStyle","transform","value","useEffect","withRepeat","withTiming"],"sources":["CircularProgress.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { ViewProps } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { Easing, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';\nimport { CircularProgress as CircularProgressIcon } from '../internal/icons';\nimport { OverridableComponentProps } from '../types';\n\ntype CircularProgressStyles = NamedStylesStringUnion<'root'>;\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 900, easing: Easing.linear };\n\nconst MIN_ROTATE_DEGREE = 0;\nconst MAX_ROTATE_DEGREE = 360;\n\nconst useStyles: UseStyles<CircularProgressStyles> = function (): CircularProgressStyles {\n return {\n root: {\n alignItems: 'center',\n justifyContent: 'center',\n },\n };\n};\n\nexport default function CircularProgress(props: OverridableComponentProps<ViewProps>) {\n const { style: styleProp } = props;\n\n const styles = useStyles();\n\n const rotate = useSharedValue(MIN_ROTATE_DEGREE);\n\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ rotate: `${rotate.value}deg` }],\n }), []);\n\n useEffect(() => {\n rotate.value = withRepeat(\n withTiming(MAX_ROTATE_DEGREE, ANIMATION_CONFIG),\n -1,\n false,\n );\n }, []);\n\n return (\n <Animated.View\n children={<CircularProgressIcon/>}\n style={[\n animatedStyle,\n styles.root,\n styleProp,\n ]}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;;;;;AAKA,MAAMA,gBAA4C,GAAG;EAAEC,QAAQ,EAAE,GAAZ;EAAiBC,MAAM,EAAEC,6BAAA,CAAOC;AAAhC,CAArD;AAEA,MAAMC,iBAAiB,GAAG,CAA1B;AACA,MAAMC,iBAAiB,GAAG,GAA1B;;AAEA,MAAMC,SAA4C,GAAG,YAAoC;EACrF,OAAO;IACHC,IAAI,EAAE;MACFC,UAAU,EAAE,QADV;MAEFC,cAAc,EAAE;IAFd;EADH,CAAP;AAMH,CAPD;;AASe,SAASC,gBAAT,CAA0BC,KAA1B,EAAuE;EAClF,MAAM;IAAEC,KAAK,EAAEC;EAAT,IAAuBF,KAA7B;EAEA,MAAMG,MAAM,GAAGR,SAAS,EAAxB;EAEA,MAAMS,MAAM,GAAG,IAAAC,qCAAA,EAAeZ,iBAAf,CAAf;EAEA,MAAMa,aAAa,GAAG,IAAAC,uCAAA,EAAiB,OAAO;IAC1CC,SAAS,EAAE,CAAC;MAAEJ,MAAM,EAAG,GAAEA,MAAM,CAACK,KAAM;IAA1B,CAAD;EAD+B,CAAP,CAAjB,EAElB,EAFkB,CAAtB;EAIA,IAAAC,gBAAA,EAAU,MAAM;IACZN,MAAM,CAACK,KAAP,GAAe,IAAAE,iCAAA,EACX,IAAAC,iCAAA,EAAWlB,iBAAX,EAA8BN,gBAA9B,CADW,EAEX,CAAC,CAFU,EAGX,KAHW,CAAf;EAKH,CAND,EAMG,EANH;EAQA,oBACI,6BAAC,8BAAD,CAAU,IAAV;IACI,QAAQ,eAAE,6BAAC,uBAAD,OADd;IAEI,KAAK,EAAE,CACHkB,aADG,EAEHH,MAAM,CAACP,IAFJ,EAGHM,SAHG;EAFX,EADJ;AAUH;;AAAA"}
@@ -5,24 +5,24 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = ImageCore;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _reactNative = require("react-native");
11
11
 
12
12
  var _reactNativeFastImage = _interopRequireDefault(require("react-native-fast-image"));
13
13
 
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
14
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
17
 
16
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
19
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
20
  // @ts-ignore
21
- const AnimatedFastImage = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeFastImage.default);
21
+ const AnimatedFastImage = _reactNative.Animated.createAnimatedComponent(_reactNativeFastImage.default);
22
22
 
23
- const ANIMATION_CONFIG = {
24
- duration: 150
25
- };
23
+ const INITIAL_OPACITY = 0;
24
+ const LOADED_OPACITY = 1;
25
+ const ANIMATION_DURATION = 200;
26
26
 
27
27
  function ImageCore(props) {
28
28
  const {
@@ -33,23 +33,16 @@ function ImageCore(props) {
33
33
  source,
34
34
  width
35
35
  } = props;
36
- const style = {
37
- width,
38
- height
39
- };
40
- const opacity = (0, _reactNativeReanimated.useSharedValue)(0);
41
- const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
42
- opacity: opacity.value
43
- }), []);
44
-
45
- const handleLoad = () => {
46
- opacity.value = (0, _reactNativeReanimated.withTiming)(1, ANIMATION_CONFIG);
47
-
48
- if (onLoad) {
49
- onLoad();
50
- }
51
- };
52
-
36
+ const opacity = (0, _react.useRef)(new _reactNative.Animated.Value(INITIAL_OPACITY)).current;
37
+ const handleLoad = (0, _react.useCallback)(() => {
38
+ _reactNative.Animated.timing(opacity, {
39
+ toValue: LOADED_OPACITY,
40
+ duration: ANIMATION_DURATION,
41
+ useNativeDriver: true
42
+ }).start();
43
+
44
+ onLoad === null || onLoad === void 0 ? void 0 : onLoad();
45
+ }, [onLoad]);
53
46
  return /*#__PURE__*/_react.default.createElement(AnimatedFastImage, {
54
47
  onError: onError,
55
48
  onLoad: handleLoad,
@@ -57,7 +50,12 @@ function ImageCore(props) {
57
50
  source: {
58
51
  uri: source.uri
59
52
  },
60
- style: [animatedStyle, style]
53
+ style: [{
54
+ opacity
55
+ }, {
56
+ width,
57
+ height
58
+ }]
61
59
  });
62
60
  }
63
61
 
@@ -1 +1 @@
1
- {"version":3,"names":["AnimatedFastImage","Animated","createAnimatedComponent","FastImage","ANIMATION_CONFIG","duration","ImageCore","props","height","onError","onLoad","resizeMode","source","width","style","opacity","useSharedValue","animatedStyle","useAnimatedStyle","value","handleLoad","withTiming","uri"],"sources":["ImageCoreNative.tsx"],"sourcesContent":["import React from 'react';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport FastImage from 'react-native-fast-image';\nimport type ImageCoreProps from './ImageCoreProps';\n\n// @ts-ignore\nconst AnimatedFastImage = Animated.createAnimatedComponent(FastImage);\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 150 };\n\nexport default function ImageCore(props: ImageCoreProps) {\n const {\n height,\n onError,\n onLoad,\n resizeMode,\n source,\n width,\n } = props;\n\n const style = { width, height };\n\n const opacity = useSharedValue(0);\n\n const animatedStyle = useAnimatedStyle(() => ({\n opacity: opacity.value,\n }), []);\n\n const handleLoad = () => {\n opacity.value = withTiming(1, ANIMATION_CONFIG);\n\n if (onLoad) {\n onLoad();\n }\n };\n\n return (\n <AnimatedFastImage\n onError={onError}\n onLoad={handleLoad}\n resizeMode={resizeMode}\n source={{ uri: source.uri }}\n style={[\n animatedStyle,\n style,\n ]}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;;;;;AAGA;AACA,MAAMA,iBAAiB,GAAGC,8BAAA,CAASC,uBAAT,CAAiCC,6BAAjC,CAA1B;;AAEA,MAAMC,gBAA4C,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAArD;;AAEe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;EACrD,MAAM;IACFC,MADE;IAEFC,OAFE;IAGFC,MAHE;IAIFC,UAJE;IAKFC,MALE;IAMFC;EANE,IAOFN,KAPJ;EASA,MAAMO,KAAK,GAAG;IAAED,KAAF;IAASL;EAAT,CAAd;EAEA,MAAMO,OAAO,GAAG,IAAAC,qCAAA,EAAe,CAAf,CAAhB;EAEA,MAAMC,aAAa,GAAG,IAAAC,uCAAA,EAAiB,OAAO;IAC1CH,OAAO,EAAEA,OAAO,CAACI;EADyB,CAAP,CAAjB,EAElB,EAFkB,CAAtB;;EAIA,MAAMC,UAAU,GAAG,MAAM;IACrBL,OAAO,CAACI,KAAR,GAAgB,IAAAE,iCAAA,EAAW,CAAX,EAAcjB,gBAAd,CAAhB;;IAEA,IAAIM,MAAJ,EAAY;MACRA,MAAM;IACT;EACJ,CAND;;EAQA,oBACI,6BAAC,iBAAD;IACI,OAAO,EAAED,OADb;IAEI,MAAM,EAAEW,UAFZ;IAGI,UAAU,EAAET,UAHhB;IAII,MAAM,EAAE;MAAEW,GAAG,EAAEV,MAAM,CAACU;IAAd,CAJZ;IAKI,KAAK,EAAE,CACHL,aADG,EAEHH,KAFG;EALX,EADJ;AAYH;;AAAA"}
1
+ {"version":3,"names":["AnimatedFastImage","Animated","createAnimatedComponent","FastImage","INITIAL_OPACITY","LOADED_OPACITY","ANIMATION_DURATION","ImageCore","props","height","onError","onLoad","resizeMode","source","width","opacity","useRef","Value","current","handleLoad","useCallback","timing","toValue","duration","useNativeDriver","start","uri"],"sources":["ImageCoreNative.tsx"],"sourcesContent":["import React, { useCallback, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport FastImage from 'react-native-fast-image';\nimport type ImageCoreProps from './ImageCoreProps';\n\n// @ts-ignore\nconst AnimatedFastImage = Animated.createAnimatedComponent(FastImage);\n\nconst INITIAL_OPACITY = 0;\nconst LOADED_OPACITY = 1;\n\nconst ANIMATION_DURATION = 200;\n\nexport default function ImageCore(props: ImageCoreProps) {\n const {\n height,\n onError,\n onLoad,\n resizeMode,\n source,\n width,\n } = props;\n\n const opacity = useRef<Animated.Value>(new Animated.Value(INITIAL_OPACITY)).current;\n\n const handleLoad = useCallback(() => {\n Animated.timing(opacity, {\n toValue: LOADED_OPACITY,\n duration: ANIMATION_DURATION,\n useNativeDriver: true,\n }).start();\n\n onLoad?.();\n }, [onLoad]);\n\n return (\n <AnimatedFastImage\n onError={onError}\n onLoad={handleLoad}\n resizeMode={resizeMode}\n source={{ uri: source.uri }}\n style={[\n { opacity },\n { width, height },\n ]}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;AAGA;AACA,MAAMA,iBAAiB,GAAGC,qBAAA,CAASC,uBAAT,CAAiCC,6BAAjC,CAA1B;;AAEA,MAAMC,eAAe,GAAG,CAAxB;AACA,MAAMC,cAAc,GAAG,CAAvB;AAEA,MAAMC,kBAAkB,GAAG,GAA3B;;AAEe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;EACrD,MAAM;IACFC,MADE;IAEFC,OAFE;IAGFC,MAHE;IAIFC,UAJE;IAKFC,MALE;IAMFC;EANE,IAOFN,KAPJ;EASA,MAAMO,OAAO,GAAG,IAAAC,aAAA,EAAuB,IAAIf,qBAAA,CAASgB,KAAb,CAAmBb,eAAnB,CAAvB,EAA4Dc,OAA5E;EAEA,MAAMC,UAAU,GAAG,IAAAC,kBAAA,EAAY,MAAM;IACjCnB,qBAAA,CAASoB,MAAT,CAAgBN,OAAhB,EAAyB;MACrBO,OAAO,EAAEjB,cADY;MAErBkB,QAAQ,EAAEjB,kBAFW;MAGrBkB,eAAe,EAAE;IAHI,CAAzB,EAIGC,KAJH;;IAMAd,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM;EACT,CARkB,EAQhB,CAACA,MAAD,CARgB,CAAnB;EAUA,oBACI,6BAAC,iBAAD;IACI,OAAO,EAAED,OADb;IAEI,MAAM,EAAES,UAFZ;IAGI,UAAU,EAAEP,UAHhB;IAII,MAAM,EAAE;MAAEc,GAAG,EAAEb,MAAM,CAACa;IAAd,CAJZ;IAKI,KAAK,EAAE,CACH;MAAEX;IAAF,CADG,EAEH;MAAED,KAAF;MAASL;IAAT,CAFG;EALX,EADJ;AAYH;;AAAA"}
@@ -5,29 +5,29 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = Tooltip;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
12
- var _reactNativeGestureHandler = require("react-native-gesture-handler");
13
-
14
12
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
15
13
 
16
14
  var _utils = require("@fountain-ui/utils");
17
15
 
16
+ var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
17
+
18
18
  var _styles = require("../styles");
19
19
 
20
20
  var _icons = require("../internal/icons");
21
21
 
22
22
  var _UpArrow = _interopRequireDefault(require("./UpArrow"));
23
23
 
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
24
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
27
 
26
28
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
29
 
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
- const defaultOpacity = 0.8;
30
+ const DEFAULT_OPACITY = 0.8;
31
31
  const initialLayout = {
32
32
  width: 0,
33
33
  height: 0,
@@ -52,11 +52,9 @@ function Tooltip(props) {
52
52
  visible = false
53
53
  } = props;
54
54
  const theme = (0, _styles.useTheme)();
55
-
56
- const [layout, setLayout] = _react.default.useState(initialLayout);
57
-
55
+ const [layout, setLayout] = (0, _react.useState)(initialLayout);
58
56
  const scale = (0, _reactNativeReanimated.useSharedValue)(0);
59
- const tooltipAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
57
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
60
58
  transform: [{
61
59
  scale: scale.value
62
60
  }]
@@ -74,15 +72,13 @@ function Tooltip(props) {
74
72
  height: visible ? undefined : 0,
75
73
  overflow: visible ? undefined : 'hidden'
76
74
  };
77
-
78
- _react.default.useEffect(() => {
75
+ (0, _react.useEffect)(() => {
79
76
  const nextScaleValue = visible ? 1 : 0;
80
77
  scale.value = (0, _reactNativeReanimated.withTiming)(nextScaleValue, ANIMATION_CONFIG);
81
78
  }, [visible]);
82
-
83
79
  const touchableStyle = {
84
80
  alignItems: 'center',
85
- backgroundColor: `rgba(${r}, ${g}, ${b}, ${defaultOpacity})`,
81
+ backgroundColor: `rgba(${r}, ${g}, ${b}, ${DEFAULT_OPACITY})`,
86
82
  borderRadius: theme.shape.roundness,
87
83
  flexDirection: 'row',
88
84
  padding: theme.spacing(2)
@@ -95,8 +91,8 @@ function Tooltip(props) {
95
91
  marginRight: theme.spacing(2)
96
92
  }]);
97
93
 
98
- const buttonElem = /*#__PURE__*/_react.default.createElement(_reactNativeGestureHandler.TouchableWithoutFeedback, {
99
- disallowInterruption: true,
94
+ const buttonElem = /*#__PURE__*/_react.default.createElement(_ButtonBase.default, {
95
+ pressEffect: 'none',
100
96
  onPress: onClose
101
97
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
102
98
  style: (0, _styles.css)(touchableStyle)
@@ -114,14 +110,14 @@ function Tooltip(props) {
114
110
  const arrowElem = /*#__PURE__*/_react.default.createElement(_UpArrow.default, {
115
111
  upsideDown: placement === 'top',
116
112
  fill: theme.palette.primary.main,
117
- opacity: defaultOpacity
113
+ opacity: DEFAULT_OPACITY
118
114
  });
119
115
 
120
116
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
121
117
  style: style
122
118
  }, children, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
123
119
  onLayout: event => setLayout(event.nativeEvent.layout),
124
- style: [tooltipAnimatedStyle, tooltipLayoutStyle, tooltipStyle]
120
+ style: [animatedStyle, tooltipLayoutStyle, tooltipStyle]
125
121
  }, placement === 'top' ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, buttonElem, arrowElem) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, arrowElem, buttonElem)));
126
122
  }
127
123
 
@@ -1 +1 @@
1
- {"version":3,"names":["defaultOpacity","initialLayout","width","height","x","y","ANIMATION_CONFIG","duration","Tooltip","props","children","left","onClose","placement","right","style","title","tooltipStyle","verticalOffset","visible","theme","useTheme","layout","setLayout","React","useState","scale","useSharedValue","tooltipAnimatedStyle","useAnimatedStyle","transform","value","r","g","b","rgb","palette","primary","main","totalVerticalOffset","tooltipLayoutStyle","alignItems","bottom","undefined","position","top","zIndex","tooltip","overflow","useEffect","nextScaleValue","withTiming","touchableStyle","backgroundColor","borderRadius","shape","roundness","flexDirection","padding","spacing","fontStyle","createFontStyle","selector","typo","caption2","color","contrastTextColor","textStyle","css","marginRight","buttonElem","arrowElem","event","nativeEvent"],"sources":["Tooltip.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View, ViewProps } from 'react-native';\nimport { TouchableWithoutFeedback } from 'react-native-gesture-handler';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport { rgb } from '@fountain-ui/utils';\nimport { createFontStyle, css, useTheme } from '../styles';\nimport { Close as CloseIcon } from '../internal/icons';\nimport type TooltipProps from './TooltipProps';\nimport UpArrow from './UpArrow';\n\nconst defaultOpacity = 0.8;\nconst initialLayout = { width: 0, height: 0, x: 0, y: 0 };\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 150 };\n\nexport default function Tooltip(props: TooltipProps) {\n const {\n children,\n left,\n onClose,\n placement = 'top',\n right,\n style,\n title,\n tooltipStyle,\n verticalOffset = 4,\n visible = false,\n } = props;\n\n const theme = useTheme();\n\n const [layout, setLayout] = React.useState(initialLayout);\n\n const scale = useSharedValue(0);\n\n const tooltipAnimatedStyle = useAnimatedStyle(() => ({\n transform: [{ scale: scale.value }],\n }), []);\n\n const [r, g, b] = rgb(theme.palette.primary.main);\n\n const totalVerticalOffset = -(layout.height + verticalOffset);\n const tooltipLayoutStyle: ViewProps['style'] = {\n alignItems: 'center',\n bottom: placement === 'bottom' ? totalVerticalOffset : undefined,\n left,\n position: 'absolute',\n right,\n top: placement === 'top' ? totalVerticalOffset : undefined,\n zIndex: theme.zIndex.tooltip,\n height: visible ? undefined : 0,\n overflow: visible ? undefined : 'hidden',\n };\n\n React.useEffect(() => {\n const nextScaleValue = visible ? 1 : 0;\n\n scale.value = withTiming(nextScaleValue, ANIMATION_CONFIG);\n }, [visible]);\n\n const touchableStyle: ViewProps['style'] = {\n alignItems: 'center',\n backgroundColor: `rgba(${r}, ${g}, ${b}, ${defaultOpacity})`,\n borderRadius: theme.shape.roundness,\n flexDirection: 'row',\n padding: theme.spacing(2),\n };\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption2,\n color: theme.palette.primary.contrastTextColor,\n });\n\n const textStyle = css([\n fontStyle,\n { marginRight: theme.spacing(2) },\n ]);\n\n const buttonElem = (\n <TouchableWithoutFeedback\n disallowInterruption={true}\n onPress={onClose}\n >\n <View style={css(touchableStyle)}>\n <Text\n children={title}\n // TODO: Should we provide text prop customization?\n numberOfLines={1}\n style={textStyle}\n />\n <CloseIcon\n fill={theme.palette.primary.contrastTextColor}\n width={20}\n height={20}\n />\n </View>\n </TouchableWithoutFeedback>\n );\n\n const arrowElem = (\n <UpArrow\n upsideDown={placement === 'top'}\n fill={theme.palette.primary.main}\n opacity={defaultOpacity}\n />\n );\n\n return (\n <View style={style}>\n {children}\n\n <Animated.View\n onLayout={(event) => setLayout(event.nativeEvent.layout)}\n style={[\n tooltipAnimatedStyle,\n tooltipLayoutStyle,\n tooltipStyle,\n ]}\n >\n {placement === 'top' ? (\n <React.Fragment>\n {buttonElem}\n {arrowElem}\n </React.Fragment>\n ) : (\n <React.Fragment>\n {arrowElem}\n {buttonElem}\n </React.Fragment>\n )}\n </Animated.View>\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;AAEA,MAAMA,cAAc,GAAG,GAAvB;AACA,MAAMC,aAAa,GAAG;EAAEC,KAAK,EAAE,CAAT;EAAYC,MAAM,EAAE,CAApB;EAAuBC,CAAC,EAAE,CAA1B;EAA6BC,CAAC,EAAE;AAAhC,CAAtB;AAEA,MAAMC,gBAA4C,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAArD;;AAEe,SAASC,OAAT,CAAiBC,KAAjB,EAAsC;EACjD,MAAM;IACFC,QADE;IAEFC,IAFE;IAGFC,OAHE;IAIFC,SAAS,GAAG,KAJV;IAKFC,KALE;IAMFC,KANE;IAOFC,KAPE;IAQFC,YARE;IASFC,cAAc,GAAG,CATf;IAUFC,OAAO,GAAG;EAVR,IAWFV,KAXJ;EAaA,MAAMW,KAAK,GAAG,IAAAC,gBAAA,GAAd;;EAEA,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBC,cAAA,CAAMC,QAAN,CAAexB,aAAf,CAA5B;;EAEA,MAAMyB,KAAK,GAAG,IAAAC,qCAAA,EAAe,CAAf,CAAd;EAEA,MAAMC,oBAAoB,GAAG,IAAAC,uCAAA,EAAiB,OAAO;IACjDC,SAAS,EAAE,CAAC;MAAEJ,KAAK,EAAEA,KAAK,CAACK;IAAf,CAAD;EADsC,CAAP,CAAjB,EAEzB,EAFyB,CAA7B;EA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,CADH,gBAMG,6BAAC,cAAD,CAAO,QAAP,QACKA,SADL,EAEKD,UAFL,CAdR,CAHJ,CADJ;AA0BH;;AAAA"}
1
+ {"version":3,"names":["DEFAULT_OPACITY","initialLayout","width","height","x","y","ANIMATION_CONFIG","duration","Tooltip","props","children","left","onClose","placement","right","style","title","tooltipStyle","verticalOffset","visible","theme","useTheme","layout","setLayout","useState","scale","useSharedValue","animatedStyle","useAnimatedStyle","transform","value","r","g","b","rgb","palette","primary","main","totalVerticalOffset","tooltipLayoutStyle","alignItems","bottom","undefined","position","top","zIndex","tooltip","overflow","useEffect","nextScaleValue","withTiming","touchableStyle","backgroundColor","borderRadius","shape","roundness","flexDirection","padding","spacing","fontStyle","createFontStyle","selector","typo","caption2","color","contrastTextColor","textStyle","css","marginRight","buttonElem","arrowElem","event","nativeEvent"],"sources":["Tooltip.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { Text, View, ViewProps } from 'react-native';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport { rgb } from '@fountain-ui/utils';\nimport ButtonBase from '../ButtonBase';\nimport { createFontStyle, css, useTheme } from '../styles';\nimport { Close as CloseIcon } from '../internal/icons';\nimport type TooltipProps from './TooltipProps';\nimport UpArrow from './UpArrow';\n\nconst DEFAULT_OPACITY = 0.8;\nconst initialLayout = { width: 0, height: 0, x: 0, y: 0 };\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 150 };\n\nexport default function Tooltip(props: TooltipProps) {\n const {\n children,\n left,\n onClose,\n placement = 'top',\n right,\n style,\n title,\n tooltipStyle,\n verticalOffset = 4,\n visible = false,\n } = props;\n\n const theme = useTheme();\n\n const [layout, setLayout] = useState(initialLayout);\n\n const scale = useSharedValue(0);\n\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ scale: scale.value }],\n }), []);\n\n const [r, g, b] = rgb(theme.palette.primary.main);\n\n const totalVerticalOffset = -(layout.height + verticalOffset);\n const tooltipLayoutStyle: ViewProps['style'] = {\n alignItems: 'center',\n bottom: placement === 'bottom' ? totalVerticalOffset : undefined,\n left,\n position: 'absolute',\n right,\n top: placement === 'top' ? totalVerticalOffset : undefined,\n zIndex: theme.zIndex.tooltip,\n height: visible ? undefined : 0,\n overflow: visible ? undefined : 'hidden',\n };\n\n useEffect(() => {\n const nextScaleValue = visible ? 1 : 0;\n\n scale.value = withTiming(nextScaleValue, ANIMATION_CONFIG);\n }, [visible]);\n\n const touchableStyle: ViewProps['style'] = {\n alignItems: 'center',\n backgroundColor: `rgba(${r}, ${g}, ${b}, ${DEFAULT_OPACITY})`,\n borderRadius: theme.shape.roundness,\n flexDirection: 'row',\n padding: theme.spacing(2),\n };\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption2,\n color: theme.palette.primary.contrastTextColor,\n });\n\n const textStyle = css([\n fontStyle,\n { marginRight: theme.spacing(2) },\n ]);\n\n const buttonElem = (\n <ButtonBase\n pressEffect={'none'}\n onPress={onClose}\n >\n <View style={css(touchableStyle)}>\n <Text\n children={title}\n // TODO: Should we provide text prop customization?\n numberOfLines={1}\n style={textStyle}\n />\n <CloseIcon\n fill={theme.palette.primary.contrastTextColor}\n width={20}\n height={20}\n />\n </View>\n </ButtonBase>\n );\n\n const arrowElem = (\n <UpArrow\n upsideDown={placement === 'top'}\n fill={theme.palette.primary.main}\n opacity={DEFAULT_OPACITY}\n />\n );\n\n return (\n <View style={style}>\n {children}\n\n <Animated.View\n onLayout={(event) => setLayout(event.nativeEvent.layout)}\n style={[\n animatedStyle,\n tooltipLayoutStyle,\n tooltipStyle,\n ]}\n >\n {placement === 'top' ? (\n <React.Fragment>\n {buttonElem}\n {arrowElem}\n </React.Fragment>\n ) : (\n <React.Fragment>\n {arrowElem}\n {buttonElem}\n </React.Fragment>\n )}\n </Animated.View>\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;A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AAuD,WAAA,EAAIhB,cAAJ;EAAb,gBACI,6BAAC,iBAAD;IACI,QAAQ,EAAEnC,KADd,CAEI;IAFJ;IAGI,aAAa,EAAE,CAHnB;IAII,KAAK,EAAEkD;EAJX,EADJ,eAOI,6BAAC,YAAD;IACI,IAAI,EAAE9C,KAAK,CAACe,OAAN,CAAcC,OAAd,CAAsB6B,iBADhC;IAEI,KAAK,EAAE,EAFX;IAGI,MAAM,EAAE;EAHZ,EAPJ,CAJJ,CADJ;;EAqBA,MAAMK,SAAS,gBACX,6BAAC,gBAAD;IACI,UAAU,EAAEzD,SAAS,KAAK,KAD9B;IAEI,IAAI,EAAEO,KAAK,CAACe,OAAN,CAAcC,OAAd,CAAsBC,IAFhC;IAGI,OAAO,EAAErC;EAHb,EADJ;;EAQA,oBACI,6BAAC,iBAAD;IAAM,KAAK,EAAEe;EAAb,GACKL,QADL,eAGI,6BAAC,8BAAD,CAAU,IAAV;IACI,QAAQ,EAAG6D,KAAD,IAAWhD,SAAS,CAACgD,KAAK,CAACC,WAAN,CAAkBlD,MAAnB,CADlC;IAEI,KAAK,EAAE,CACHK,aADG,EAEHY,kBAFG,EAGHtB,YAHG;EAFX,GAQKJ,SAAS,KAAK,KAAd,gBACG,6BAAC,cAAD,CAAO,QAAP,QACKwD,UADL,EAEKC,SAFL,CADH,gBAMG,6BAAC,cAAD,CAAO,QAAP,QACKA,SADL,EAEKD,UAFL,CAdR,CAHJ,CADJ;AA0BH;;AAAA"}
@@ -5,14 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
8
+ var _reactNative = require("react-native");
9
9
 
10
10
  var _Pressable = _interopRequireDefault(require("../Pressable"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- // @ts-ignore
15
- var _default = _reactNativeReanimated.default.createAnimatedComponent(_Pressable.default);
14
+ var _default = _reactNative.Animated.createAnimatedComponent(_Pressable.default);
16
15
 
17
16
  exports.default = _default;
18
17
  //# sourceMappingURL=AnimatedPressable.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Animated","createAnimatedComponent","Pressable"],"sources":["AnimatedPressable.tsx"],"sourcesContent":["import React from 'react';\nimport Animated from 'react-native-reanimated';\nimport Pressable from '../Pressable';\n\n// @ts-ignore\nexport default Animated.createAnimatedComponent(Pressable);\n"],"mappings":";;;;;;;AACA;;AACA;;;;AAEA;eACeA,8BAAA,CAASC,uBAAT,CAAiCC,kBAAjC,C"}
1
+ {"version":3,"names":["Animated","createAnimatedComponent","Pressable"],"sources":["AnimatedPressable.tsx"],"sourcesContent":["import React from 'react';\nimport { Animated } from 'react-native';\nimport Pressable from '../Pressable';\n\nexport default Animated.createAnimatedComponent(Pressable);\n"],"mappings":";;;;;;;AACA;;AACA;;;;eAEeA,qBAAA,CAASC,uBAAT,CAAiCC,kBAAjC,C"}
@@ -5,19 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = useThrottle;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ var _react = require("react");
11
9
 
12
10
  function useThrottle(options) {
13
11
  const {
14
12
  periodMillis,
15
13
  callback
16
14
  } = options;
17
-
18
- const lastExecMillisRef = _react.default.useRef(0);
19
-
20
- return _react.default.useCallback(function () {
15
+ const lastExecMillisRef = (0, _react.useRef)(0);
16
+ return (0, _react.useCallback)(function () {
21
17
  const now = Date.now();
22
18
  const millisAfterExecuted = now - lastExecMillisRef.current;
23
19
  lastExecMillisRef.current = now;
@@ -1 +1 @@
1
- {"version":3,"names":["useThrottle","options","periodMillis","callback","lastExecMillisRef","React","useRef","useCallback","now","Date","millisAfterExecuted","current"],"sources":["useThrottle.ts"],"sourcesContent":["import React from 'react';\n\nexport interface ThrottleOptions {\n periodMillis: number;\n callback?: (args?: any) => void;\n}\n\nexport default function useThrottle(options: ThrottleOptions) {\n const { periodMillis, callback } = options;\n\n const lastExecMillisRef = React.useRef(0);\n\n return React.useCallback((...args: any[]) => {\n const now = Date.now();\n const millisAfterExecuted = now - lastExecMillisRef.current;\n lastExecMillisRef.current = now;\n\n if (millisAfterExecuted > periodMillis || periodMillis <= 0) {\n if (callback) {\n callback(...args);\n }\n }\n }, [callback, periodMillis]);\n}\n"],"mappings":";;;;;;;AAAA;;;;AAOe,SAASA,WAAT,CAAqBC,OAArB,EAA+C;EAC1D,MAAM;IAAEC,YAAF;IAAgBC;EAAhB,IAA6BF,OAAnC;;EAEA,MAAMG,iBAAiB,GAAGC,cAAA,CAAMC,MAAN,CAAa,CAAb,CAA1B;;EAEA,OAAOD,cAAA,CAAME,WAAN,CAAkB,YAAoB;IACzC,MAAMC,GAAG,GAAGC,IAAI,CAACD,GAAL,EAAZ;IACA,MAAME,mBAAmB,GAAGF,GAAG,GAAGJ,iBAAiB,CAACO,OAApD;IACAP,iBAAiB,CAACO,OAAlB,GAA4BH,GAA5B;;IAEA,IAAIE,mBAAmB,GAAGR,YAAtB,IAAsCA,YAAY,IAAI,CAA1D,EAA6D;MACzD,IAAIC,QAAJ,EAAc;QACVA,QAAQ,CAAC,YAAD,CAAR;MACH;IACJ;EACJ,CAVM,EAUJ,CAACA,QAAD,EAAWD,YAAX,CAVI,CAAP;AAWH"}
1
+ {"version":3,"names":["useThrottle","options","periodMillis","callback","lastExecMillisRef","useRef","useCallback","now","Date","millisAfterExecuted","current"],"sources":["useThrottle.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\n\nexport interface ThrottleOptions {\n periodMillis: number;\n callback?: (args?: any) => void;\n}\n\nexport default function useThrottle(options: ThrottleOptions) {\n const { periodMillis, callback } = options;\n\n const lastExecMillisRef = useRef(0);\n\n return useCallback((...args: any[]) => {\n const now = Date.now();\n const millisAfterExecuted = now - lastExecMillisRef.current;\n lastExecMillisRef.current = now;\n\n if (millisAfterExecuted > periodMillis || periodMillis <= 0) {\n if (callback) {\n callback(...args);\n }\n }\n }, [callback, periodMillis]);\n}\n"],"mappings":";;;;;;;AAAA;;AAOe,SAASA,WAAT,CAAqBC,OAArB,EAA+C;EAC1D,MAAM;IAAEC,YAAF;IAAgBC;EAAhB,IAA6BF,OAAnC;EAEA,MAAMG,iBAAiB,GAAG,IAAAC,aAAA,EAAO,CAAP,CAA1B;EAEA,OAAO,IAAAC,kBAAA,EAAY,YAAoB;IACnC,MAAMC,GAAG,GAAGC,IAAI,CAACD,GAAL,EAAZ;IACA,MAAME,mBAAmB,GAAGF,GAAG,GAAGH,iBAAiB,CAACM,OAApD;IACAN,iBAAiB,CAACM,OAAlB,GAA4BH,GAA5B;;IAEA,IAAIE,mBAAmB,GAAGP,YAAtB,IAAsCA,YAAY,IAAI,CAA1D,EAA6D;MACzD,IAAIC,QAAJ,EAAc;QACVA,QAAQ,CAAC,YAAD,CAAR;MACH;IACJ;EACJ,CAVM,EAUJ,CAACA,QAAD,EAAWD,YAAX,CAVI,CAAP;AAWH"}
@@ -5,17 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = useHeight;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = require("react");
9
9
 
10
10
  var _reactNativeReanimated = require("react-native-reanimated");
11
11
 
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
12
  function useHeight() {
15
13
  let initialHeight = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
16
-
17
- const [height, setHeight] = _react.default.useState(initialHeight);
18
-
14
+ const [height, setHeight] = (0, _react.useState)(initialHeight);
19
15
  const onLayout = (0, _reactNativeReanimated.useWorkletCallback)(e => {
20
16
  setHeight(e.nativeEvent.layout.height);
21
17
  }, []);
@@ -1 +1 @@
1
- {"version":3,"names":["useHeight","initialHeight","height","setHeight","React","useState","onLayout","useWorkletCallback","e","nativeEvent","layout"],"sources":["useHeight.ts"],"sourcesContent":["import React from 'react';\nimport { ViewProps } from 'react-native';\nimport { useWorkletCallback } from 'react-native-reanimated';\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport default function useHeight(initialHeight = 0): [number, OnLayoutCallback] {\n const [height, setHeight] = React.useState<number>(initialHeight);\n\n const onLayout = useWorkletCallback((e) => {\n setHeight(e.nativeEvent.layout.height);\n }, []);\n\n return [height, onLayout];\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAIe,SAASA,SAAT,GAAkE;EAAA,IAA/CC,aAA+C,uEAA/B,CAA+B;;EAC7E,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBC,cAAA,CAAMC,QAAN,CAAuBJ,aAAvB,CAA5B;;EAEA,MAAMK,QAAQ,GAAG,IAAAC,yCAAA,EAAoBC,CAAD,IAAO;IACvCL,SAAS,CAACK,CAAC,CAACC,WAAF,CAAcC,MAAd,CAAqBR,MAAtB,CAAT;EACH,CAFgB,EAEd,EAFc,CAAjB;EAIA,OAAO,CAACA,MAAD,EAASI,QAAT,CAAP;AACH;;AAAA"}
1
+ {"version":3,"names":["useHeight","initialHeight","height","setHeight","useState","onLayout","useWorkletCallback","e","nativeEvent","layout"],"sources":["useHeight.ts"],"sourcesContent":["import { useState } from 'react';\nimport { ViewProps } from 'react-native';\nimport { useWorkletCallback } from 'react-native-reanimated';\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport default function useHeight(initialHeight = 0): [number, OnLayoutCallback] {\n const [height, setHeight] = useState<number>(initialHeight);\n\n const onLayout = useWorkletCallback((e) => {\n setHeight(e.nativeEvent.layout.height);\n }, []);\n\n return [height, onLayout];\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAIe,SAASA,SAAT,GAAkE;EAAA,IAA/CC,aAA+C,uEAA/B,CAA+B;EAC7E,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsB,IAAAC,eAAA,EAAiBH,aAAjB,CAA5B;EAEA,MAAMI,QAAQ,GAAG,IAAAC,yCAAA,EAAoBC,CAAD,IAAO;IACvCJ,SAAS,CAACI,CAAC,CAACC,WAAF,CAAcC,MAAd,CAAqBP,MAAtB,CAAT;EACH,CAFgB,EAEd,EAFc,CAAjB;EAIA,OAAO,CAACA,MAAD,EAASG,QAAT,CAAP;AACH;;AAAA"}