@fountain-ui/core 2.0.0-beta.11 → 2.0.0-beta.14

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 (127) hide show
  1. package/build/commonjs/Accordion/Accordion.js +3 -3
  2. package/build/commonjs/Accordion/Accordion.js.map +1 -1
  3. package/build/commonjs/ButtonBase/ButtonBase.js +56 -52
  4. package/build/commonjs/ButtonBase/ButtonBase.js.map +1 -1
  5. package/build/commonjs/CircularProgress/CircularProgress.js +19 -24
  6. package/build/commonjs/CircularProgress/CircularProgress.js.map +1 -1
  7. package/build/commonjs/ImageCore/ImageCoreNative.js +24 -26
  8. package/build/commonjs/ImageCore/ImageCoreNative.js.map +1 -1
  9. package/build/commonjs/Slide/Slide.js +12 -13
  10. package/build/commonjs/Slide/Slide.js.map +1 -1
  11. package/build/commonjs/Tab/Tab.js +9 -5
  12. package/build/commonjs/Tab/Tab.js.map +1 -1
  13. package/build/commonjs/Tabs/IndexAwareTab.js +28 -0
  14. package/build/commonjs/Tabs/IndexAwareTab.js.map +1 -0
  15. package/build/commonjs/Tabs/TabIndicator.js +19 -13
  16. package/build/commonjs/Tabs/TabIndicator.js.map +1 -1
  17. package/build/commonjs/Tabs/TabIndicatorProps.js.map +1 -1
  18. package/build/commonjs/Tabs/Tabs.js +41 -61
  19. package/build/commonjs/Tabs/Tabs.js.map +1 -1
  20. package/build/commonjs/Tabs/TabsProps.js.map +1 -1
  21. package/build/commonjs/Tabs/index.js.map +1 -1
  22. package/build/commonjs/Tabs/useScrollViewReaction.js +54 -0
  23. package/build/commonjs/Tabs/useScrollViewReaction.js.map +1 -0
  24. package/build/commonjs/Tooltip/Tooltip.js +18 -22
  25. package/build/commonjs/Tooltip/Tooltip.js.map +1 -1
  26. package/build/commonjs/animated/AnimatedPressable.js +2 -3
  27. package/build/commonjs/animated/AnimatedPressable.js.map +1 -1
  28. package/build/commonjs/hooks/useCollapsibleAppBar.js +24 -30
  29. package/build/commonjs/hooks/useCollapsibleAppBar.js.map +1 -1
  30. package/build/commonjs/hooks/useFadeInAppBar.js +13 -14
  31. package/build/commonjs/hooks/useFadeInAppBar.js.map +1 -1
  32. package/build/commonjs/hooks/useThrottle.js +3 -7
  33. package/build/commonjs/hooks/useThrottle.js.map +1 -1
  34. package/build/commonjs/internal/hooks/useHeight.js +2 -6
  35. package/build/commonjs/internal/hooks/useHeight.js.map +1 -1
  36. package/build/module/Accordion/Accordion.js +3 -3
  37. package/build/module/Accordion/Accordion.js.map +1 -1
  38. package/build/module/ButtonBase/ButtonBase.js +54 -48
  39. package/build/module/ButtonBase/ButtonBase.js.map +1 -1
  40. package/build/module/CircularProgress/CircularProgress.js +20 -21
  41. package/build/module/CircularProgress/CircularProgress.js.map +1 -1
  42. package/build/module/ImageCore/ImageCoreNative.js +20 -23
  43. package/build/module/ImageCore/ImageCoreNative.js.map +1 -1
  44. package/build/module/Slide/Slide.js +14 -10
  45. package/build/module/Slide/Slide.js.map +1 -1
  46. package/build/module/Tab/Tab.js +5 -5
  47. package/build/module/Tab/Tab.js.map +1 -1
  48. package/build/module/Tabs/IndexAwareTab.js +18 -0
  49. package/build/module/Tabs/IndexAwareTab.js.map +1 -0
  50. package/build/module/Tabs/TabIndicator.js +19 -14
  51. package/build/module/Tabs/TabIndicator.js.map +1 -1
  52. package/build/module/Tabs/TabIndicatorProps.js.map +1 -1
  53. package/build/module/Tabs/Tabs.js +40 -60
  54. package/build/module/Tabs/Tabs.js.map +1 -1
  55. package/build/module/Tabs/TabsProps.js.map +1 -1
  56. package/build/module/Tabs/index.js.map +1 -1
  57. package/build/module/Tabs/useScrollViewReaction.js +44 -0
  58. package/build/module/Tabs/useScrollViewReaction.js.map +1 -0
  59. package/build/module/Tooltip/Tooltip.js +15 -15
  60. package/build/module/Tooltip/Tooltip.js.map +1 -1
  61. package/build/module/animated/AnimatedPressable.js +2 -3
  62. package/build/module/animated/AnimatedPressable.js.map +1 -1
  63. package/build/module/hooks/useCollapsibleAppBar.js +24 -28
  64. package/build/module/hooks/useCollapsibleAppBar.js.map +1 -1
  65. package/build/module/hooks/useFadeInAppBar.js +13 -10
  66. package/build/module/hooks/useFadeInAppBar.js.map +1 -1
  67. package/build/module/hooks/useThrottle.js +3 -3
  68. package/build/module/hooks/useThrottle.js.map +1 -1
  69. package/build/module/internal/hooks/useHeight.js +2 -2
  70. package/build/module/internal/hooks/useHeight.js.map +1 -1
  71. package/build/typescript/Tabs/IndexAwareTab.d.ts +9 -0
  72. package/build/typescript/Tabs/TabIndicatorProps.d.ts +2 -2
  73. package/build/typescript/Tabs/Tabs.d.ts +4 -1
  74. package/build/typescript/Tabs/TabsProps.d.ts +19 -11
  75. package/build/typescript/Tabs/index.d.ts +1 -1
  76. package/build/typescript/Tabs/useScrollViewReaction.d.ts +9 -0
  77. package/build/typescript/animated/AnimatedPressable.d.ts +2 -2
  78. package/package.json +2 -2
  79. package/src/Accordion/Accordion.tsx +5 -3
  80. package/src/ButtonBase/ButtonBase.tsx +65 -43
  81. package/src/CircularProgress/CircularProgress.tsx +24 -30
  82. package/src/ImageCore/ImageCoreNative.tsx +17 -19
  83. package/src/Slide/Slide.tsx +17 -15
  84. package/src/Tab/Tab.tsx +5 -5
  85. package/src/Tabs/IndexAwareTab.tsx +30 -0
  86. package/src/Tabs/TabIndicator.tsx +18 -14
  87. package/src/Tabs/TabIndicatorProps.ts +2 -2
  88. package/src/Tabs/Tabs.tsx +47 -62
  89. package/src/Tabs/TabsProps.ts +22 -12
  90. package/src/Tabs/index.ts +1 -1
  91. package/src/Tabs/useScrollViewReaction.ts +55 -0
  92. package/src/Tooltip/Tooltip.tsx +16 -16
  93. package/src/animated/AnimatedPressable.tsx +1 -2
  94. package/src/hooks/useCollapsibleAppBar.ts +21 -22
  95. package/src/hooks/useFadeInAppBar.ts +13 -12
  96. package/src/hooks/useThrottle.ts +3 -3
  97. package/src/internal/hooks/useHeight.ts +2 -2
  98. package/build/commonjs/ButtonBase/ButtonBase.ios.js +0 -101
  99. package/build/commonjs/ButtonBase/ButtonBase.ios.js.map +0 -1
  100. package/build/commonjs/ButtonBase/useDisabledReaction/index.js +0 -21
  101. package/build/commonjs/ButtonBase/useDisabledReaction/index.js.map +0 -1
  102. package/build/commonjs/ButtonBase/useDisabledReaction/index.native.js +0 -9
  103. package/build/commonjs/ButtonBase/useDisabledReaction/index.native.js.map +0 -1
  104. package/build/commonjs/ImageCore/ImageCoreNative.ios.js +0 -60
  105. package/build/commonjs/ImageCore/ImageCoreNative.ios.js.map +0 -1
  106. package/build/commonjs/Tabs/useTabsWidth.js +0 -26
  107. package/build/commonjs/Tabs/useTabsWidth.js.map +0 -1
  108. package/build/module/ButtonBase/ButtonBase.ios.js +0 -82
  109. package/build/module/ButtonBase/ButtonBase.ios.js.map +0 -1
  110. package/build/module/ButtonBase/useDisabledReaction/index.js +0 -12
  111. package/build/module/ButtonBase/useDisabledReaction/index.js.map +0 -1
  112. package/build/module/ButtonBase/useDisabledReaction/index.native.js +0 -2
  113. package/build/module/ButtonBase/useDisabledReaction/index.native.js.map +0 -1
  114. package/build/module/ImageCore/ImageCoreNative.ios.js +0 -45
  115. package/build/module/ImageCore/ImageCoreNative.ios.js.map +0 -1
  116. package/build/module/Tabs/useTabsWidth.js +0 -18
  117. package/build/module/Tabs/useTabsWidth.js.map +0 -1
  118. package/build/typescript/ButtonBase/ButtonBase.ios.d.ts +0 -2
  119. package/build/typescript/ButtonBase/useDisabledReaction/index.d.ts +0 -2
  120. package/build/typescript/ButtonBase/useDisabledReaction/index.native.d.ts +0 -2
  121. package/build/typescript/ImageCore/ImageCoreNative.ios.d.ts +0 -2
  122. package/build/typescript/Tabs/useTabsWidth.d.ts +0 -2
  123. package/src/ButtonBase/ButtonBase.ios.tsx +0 -95
  124. package/src/ButtonBase/useDisabledReaction/index.native.ts +0 -4
  125. package/src/ButtonBase/useDisabledReaction/index.ts +0 -16
  126. package/src/ImageCore/ImageCoreNative.ios.tsx +0 -46
  127. package/src/Tabs/useTabsWidth.ts +0 -20
@@ -29,7 +29,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
29
29
 
30
30
  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; }
31
31
 
32
- const ANIMATION_OPTION = {
32
+ const ANIMATION_CONFIG = {
33
33
  duration: 250
34
34
  };
35
35
 
@@ -58,11 +58,11 @@ function Accordion(props) {
58
58
  transform: [{
59
59
  rotate: `${rotate.value}deg`
60
60
  }]
61
- }));
61
+ }), []);
62
62
 
63
63
  const onPress = () => {
64
64
  setIsExpanded(prev => !prev);
65
- rotate.value = (0, _reactNativeReanimated.withTiming)(!isExpanded ? 180 : 0, ANIMATION_OPTION);
65
+ rotate.value = (0, _reactNativeReanimated.withTiming)(!isExpanded ? 180 : 0, ANIMATION_CONFIG);
66
66
  };
67
67
 
68
68
  return /*#__PURE__*/_react.default.createElement(_Column.default, null, /*#__PURE__*/_react.default.createElement(_ButtonBase.default, {
@@ -1 +1 @@
1
- {"version":3,"names":["ANIMATION_OPTION","duration","useStyles","theme","useTheme","root","flexDirection","paddingVertical","spacing","Accordion","props","content","LeftIcon","RightIcon","title","titleVariant","styles","isExpanded","setIsExpanded","useState","rotate","useSharedValue","animatedChevronDownStyles","useAnimatedStyle","transform","value","onPress","prev","withTiming","React","isValidElement"],"sources":["Accordion.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { ChevronDown as ChevronDownIcon } from '../internal/icons';\nimport ButtonBase from '../ButtonBase';\nimport Column from '../Column';\nimport Divider from '../Divider';\nimport Spacer from '../Spacer';\nimport Typography from '../Typography';\nimport { useTheme } from '../styles';\n\nimport AccordionProps from './AccordionProps';\n\ntype AccordionStyles = NamedStylesStringUnion<'root'>;\n\nconst ANIMATION_OPTION = { duration: 250 };\n\nconst useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {\n const theme = useTheme();\n\n return {\n root: {\n flexDirection: 'row',\n paddingVertical: theme.spacing(3),\n },\n };\n};\n\nexport default function Accordion(props: AccordionProps) {\n const {\n content,\n LeftIcon,\n RightIcon,\n title,\n titleVariant = 'subtitle2',\n } = props;\n\n const styles = useStyles();\n\n const [isExpanded, setIsExpanded] = useState(false);\n const rotate = useSharedValue(0);\n\n const animatedChevronDownStyles = useAnimatedStyle(() => ({\n transform: [{ rotate: `${rotate.value}deg` }],\n }));\n\n const onPress = () => {\n setIsExpanded(prev => !prev);\n rotate.value = withTiming(!isExpanded ? 180 : 0, ANIMATION_OPTION);\n };\n\n return (\n <Column>\n <ButtonBase\n onPress={onPress}\n style={styles.root}\n >\n {LeftIcon ? (\n <React.Fragment>\n {LeftIcon}\n <Spacer size={2}/>\n </React.Fragment>\n ) : null}\n\n <Typography\n children={title}\n variant={titleVariant}\n />\n\n <Spacer flex={1}/>\n\n <Spacer size={2}/>\n\n <Column>\n <Animated.View style={animatedChevronDownStyles}>\n {RightIcon ? RightIcon : <ChevronDownIcon/>}\n </Animated.View>\n </Column>\n </ButtonBase>\n\n {isExpanded ? (\n React.isValidElement(content) ? (content) : (\n <Typography\n children={content}\n color={'textSecondary'}\n variant={'body2'}\n />\n )\n ) : null}\n\n <Divider/>\n </Column>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAE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GAKL,IATR,eAWI,6BAAC,mBAAD;IACI,QAAQ,EAAEE,KADd;IAEI,OAAO,EAAEC;EAFb,EAXJ,eAgBI,6BAAC,eAAD;IAAQ,IAAI,EAAE;EAAd,EAhBJ,eAkBI,6BAAC,eAAD;IAAQ,IAAI,EAAE;EAAd,EAlBJ,eAoBI,6BAAC,eAAD,qBACI,6BAAC,8BAAD,CAAU,IAAV;IAAe,KAAK,EAAEO;EAAtB,GACKT,SAAS,GAAGA,SAAH,gBAAe,6BAAC,kBAAD,OAD7B,CADJ,CApBJ,CADJ,EA4BKI,UAAU,GACP,aAAAY,cAAA,CAAMC,cAAN,CAAqBnB,OAArB,IAAiCA,OAAjC,gBACI,6BAAC,mBAAD;IACI,QAAQ,EAAEA,OADd;IAEI,KAAK,EAAE,eAFX;IAGI,OAAO,EAAE;EAHb,EAFG,GAQP,IApCR,eAsCI,6BAAC,gBAAD,OAtCJ,CADJ;AA0CH"}
1
+ {"version":3,"names":["ANIMATION_CONFIG","duration","useStyles","theme","useTheme","root","flexDirection","paddingVertical","spacing","Accordion","props","content","LeftIcon","RightIcon","title","titleVariant","styles","isExpanded","setIsExpanded","useState","rotate","useSharedValue","animatedChevronDownStyles","useAnimatedStyle","transform","value","onPress","prev","withTiming","React","isValidElement"],"sources":["Accordion.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { ChevronDown as ChevronDownIcon } from '../internal/icons';\nimport ButtonBase from '../ButtonBase';\nimport Column from '../Column';\nimport Divider from '../Divider';\nimport Spacer from '../Spacer';\nimport Typography from '../Typography';\nimport { useTheme } from '../styles';\n\nimport AccordionProps from './AccordionProps';\n\ntype AccordionStyles = NamedStylesStringUnion<'root'>;\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 250 };\n\nconst useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {\n const theme = useTheme();\n\n return {\n root: {\n flexDirection: 'row',\n paddingVertical: theme.spacing(3),\n },\n };\n};\n\nexport default function Accordion(props: AccordionProps) {\n const {\n content,\n LeftIcon,\n RightIcon,\n title,\n titleVariant = 'subtitle2',\n } = props;\n\n const styles = useStyles();\n\n const [isExpanded, setIsExpanded] = useState(false);\n\n const rotate = useSharedValue(0);\n\n const animatedChevronDownStyles = useAnimatedStyle(() => ({\n transform: [{ rotate: `${rotate.value}deg` }],\n }), []);\n\n const onPress = () => {\n setIsExpanded(prev => !prev);\n rotate.value = withTiming(!isExpanded ? 180 : 0, ANIMATION_CONFIG);\n };\n\n return (\n <Column>\n <ButtonBase\n onPress={onPress}\n style={styles.root}\n >\n {LeftIcon ? (\n <React.Fragment>\n {LeftIcon}\n <Spacer size={2}/>\n </React.Fragment>\n ) : null}\n\n <Typography\n children={title}\n variant={titleVariant}\n />\n\n <Spacer flex={1}/>\n\n <Spacer size={2}/>\n\n <Column>\n <Animated.View style={animatedChevronDownStyles}>\n {RightIcon ? RightIcon : <ChevronDownIcon/>}\n </Animated.View>\n </Column>\n </ButtonBase>\n\n {isExpanded ? (\n React.isValidElement(content) ? (content) : (\n <Typography\n children={content}\n color={'textSecondary'}\n variant={'body2'}\n />\n )\n ) : null}\n\n <Divider/>\n </Column>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAMA,MAAMA,gBAA4C,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAArD;;AAEA,MAAMC,SAAqC,GAAG,YAA6B;EACvE,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,aAAa,EAAE,KADb;MAEFC,eAAe,EAAEJ,KAAK,CAACK,OAAN,CAAc,CAAd;IAFf;EADH,CAAP;AAMH,CATD;;AAWe,SAASC,SAAT,CAAmBC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,CApBJ,CADJ,EA4BKI,UAAU,GACP,aAAAY,cAAA,CAAMC,cAAN,CAAqBnB,OAArB,IAAiCA,OAAjC,gBACI,6BAAC,mBAAD;IACI,QAAQ,EAAEA,OADd;IAEI,KAAK,EAAE,eAFX;IAGI,OAAO,EAAE;EAHb,EAFG,GAQP,IApCR,eAsCI,6BAAC,gBAAD,OAtCJ,CADJ;AA0CH"}
@@ -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 animationTimingConfig = {
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, animationTimingConfig);
82
- }
83
- } else if (!isHovered) {
84
- if (pressIn) {
85
- scale.value = (0, _reactNativeReanimated.withDelay)(100, (0, _reactNativeReanimated.withTiming)(MINIFIED_SCALE, animationTimingConfig));
86
- } else {
87
- scale.value = (0, _reactNativeReanimated.withTiming)(ORIGINAL_SCALE, animationTimingConfig);
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","animationTimingConfig","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 animationTimingConfig: 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, animationTimingConfig);\n }\n } else if (!isHovered) {\n if (pressIn) {\n scale.value = withDelay(\n 100,\n withTiming(MINIFIED_SCALE, animationTimingConfig),\n );\n } else {\n scale.value = withTiming(ORIGINAL_SCALE, animationTimingConfig);\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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AA"}
1
+ {"version":3,"names":["ORIGINAL_OPACITY","DISABLED_OPACITY","ACTIVE_OPACITY","ORIGINAL_SCALE","MINIFIED_SCALE","PRESS_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,cAA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AP,KAAoB,UAApB,GACG,QAAiB;IAAA,IAAhB;MAAE8B;IAAF,CAAgB;;IACb,IAAIA,OAAO,KAAKC,SAAZ,IAAyB,CAAC9B,QAA9B,EAAwC;MACpCwB,mBAAmB,CAACK,OAAD,EAAU,IAAV,CAAnB;IACH;;IAED,OAAO9B,QAAP;EACH,CAPJ,GAQGA,QApBR,CADJ;AAwBH;;AAAA"}
@@ -5,19 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = CircularProgress;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
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; }
19
17
 
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ const ANIMATION_CONFIG = {
19
+ duration: 900,
20
+ easing: _reactNativeReanimated.Easing.linear
21
+ };
22
+ const MIN_ROTATE_DEGREE = 0;
23
+ const MAX_ROTATE_DEGREE = 360;
21
24
 
22
25
  const useStyles = function () {
23
26
  return {
@@ -30,30 +33,22 @@ const useStyles = function () {
30
33
 
31
34
  function CircularProgress(props) {
32
35
  const {
33
- style
36
+ style: styleProp
34
37
  } = props;
35
38
  const styles = useStyles();
36
- const rootStyle = (0, _styles.css)([styles.root, style]);
37
- const sharedSpin = (0, _reactNativeReanimated.useSharedValue)(0);
38
- const spinStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
39
- const interpolatedSpin = (0, _reactNativeReanimated.interpolate)(sharedSpin.value, [0, 1], [0, 360]);
40
- return {
41
- transform: [{
42
- rotate: `${interpolatedSpin}deg`
43
- }]
44
- };
45
- });
46
-
47
- _react.default.useEffect(() => {
48
- sharedSpin.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withTiming)(1, {
49
- duration: 900,
50
- easing: _reactNativeReanimated.Easing.linear
51
- }), -1, false);
39
+ const rotate = (0, _reactNativeReanimated.useSharedValue)(MIN_ROTATE_DEGREE);
40
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
41
+ transform: [{
42
+ rotate: `${rotate.value}deg`
43
+ }]
44
+ }), []);
45
+ (0, _react.useEffect)(() => {
46
+ rotate.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withTiming)(MAX_ROTATE_DEGREE, ANIMATION_CONFIG), -1, false);
52
47
  }, []);
53
-
54
48
  return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
55
- style: [spinStyle, rootStyle]
56
- }, /*#__PURE__*/_react.default.createElement(_icons.CircularProgress, null));
49
+ children: /*#__PURE__*/_react.default.createElement(_icons.CircularProgress, null),
50
+ style: [animatedStyle, styles.root, styleProp]
51
+ });
57
52
  }
58
53
 
59
54
  ;
@@ -1 +1 @@
1
- {"version":3,"names":["useStyles","root","alignItems","justifyContent","CircularProgress","props","style","styles","rootStyle","css","sharedSpin","useSharedValue","spinStyle","useAnimatedStyle","interpolatedSpin","interpolate","value","transform","rotate","React","useEffect","withRepeat","withTiming","duration","easing","Easing","linear"],"sources":["CircularProgress.tsx"],"sourcesContent":["import React from 'react';\nimport { ViewProps } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport Animated, {\n Easing,\n interpolate,\n useAnimatedStyle,\n useSharedValue,\n withRepeat,\n withTiming,\n} 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 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 sharedSpin = useSharedValue(0);\n\n const spinStyle = useAnimatedStyle(() => {\n const interpolatedSpin = interpolate(sharedSpin.value, [0, 1], [0, 360]);\n\n return {\n transform: [{ rotate: `${interpolatedSpin}deg` }],\n };\n });\n\n React.useEffect(() => {\n sharedSpin.value = withRepeat(\n withTiming(1, { duration: 900, easing: Easing.linear }),\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;;AAGA;;AAQA;;AACA;;;;;;;;AAKA,MAAMA,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,UAAU,GAAG,IAAAC,qCAAA,EAAe,CAAf,CAAnB;EAEA,MAAMC,SAAS,GAAG,IAAAC,uCAAA,EAAiB,MAAM;IACrC,MAAMC,gBAAgB,GAAG,IAAAC,kCAAA,EAAYL,UAAU,CAACM,KAAvB,EAA8B,CAAC,CAAD,EAAI,CAAJ,CAA9B,EAAsC,CAAC,CAAD,EAAI,GAAJ,CAAtC,CAAzB;IAEA,OAAO;MACHC,SAAS,EAAE,CAAC;QAAEC,MAAM,EAAG,GAAEJ,gBAAiB;MAA9B,CAAD;IADR,CAAP;EAGH,CANiB,CAAlB;;EAQAK,cAAA,CAAMC,SAAN,CAAgB,MAAM;IAClBV,UAAU,CAACM,KAAX,GAAmB,IAAAK,iCAAA,EACf,IAAAC,iCAAA,EAAW,CAAX,EAAc;MAAEC,QAAQ,EAAE,GAAZ;MAAiBC,MAAM,EAAEC,6BAAA,CAAOC;IAAhC,CAAd,CADe,EAEf,CAAC,CAFc,EAGf,KAHe,CAAnB;EAKH,CAND,EAMG,EANH;;EAQA,oBACI,6BAAC,8BAAD,CAAU,IAAV;IAAe,KAAK,EAAE,CAACd,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 animationConfig = {
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, animationConfig);
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","animationConfig","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 animationConfig: 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, animationConfig);\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,eAAiC,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAA1C;;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,CAAtB;;EAIA,MAAMC,UAAU,GAAG,MAAM;IACrBL,OAAO,CAACI,KAAR,GAAgB,IAAAE,iCAAA,EAAW,CAAX,EAAcjB,eAAd,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,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = Slide;
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
 
@@ -15,13 +15,13 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
15
15
 
16
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; }
17
17
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
18
  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); }
21
19
 
22
20
  const defaultEnterDuration = 300;
23
21
  const defaultExitDuration = 300;
24
22
 
23
+ const getDisappearingOffsetY = () => _reactNative.Dimensions.get('window').height;
24
+
25
25
  function Slide(props) {
26
26
  const {
27
27
  animatedY: animatedYProp,
@@ -35,41 +35,40 @@ function Slide(props) {
35
35
  style,
36
36
  ...otherProps
37
37
  } = props;
38
- const window = (0, _reactNative.useWindowDimensions)();
39
- const y = (0, _reactNativeReanimated.useSharedValue)(window.height);
38
+ const y = (0, _reactNativeReanimated.useSharedValue)(getDisappearingOffsetY());
40
39
  const animatedY = animatedYProp || y;
41
40
  const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
42
41
  transform: [{
43
42
  translateY: animatedY.value
44
43
  }]
45
- }));
46
-
47
- _react.default.useEffect(() => {
44
+ }), []);
45
+ (0, _react.useEffect)(() => {
48
46
  if (appear) {
47
+ onEnter === null || onEnter === void 0 ? void 0 : onEnter();
48
+ const toValue = 0;
49
49
  const enterConfig = {
50
50
  duration: enterDuration,
51
51
  easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.exp)
52
52
  };
53
- onEnter === null || onEnter === void 0 ? void 0 : onEnter();
54
- animatedY.value = (0, _reactNativeReanimated.withTiming)(0, enterConfig, isFinished => {
53
+ animatedY.value = (0, _reactNativeReanimated.withTiming)(toValue, enterConfig, isFinished => {
55
54
  if (isFinished && onEntered) {
56
55
  (0, _reactNativeReanimated.runOnJS)(onEntered)();
57
56
  }
58
57
  });
59
58
  } else {
59
+ onExit === null || onExit === void 0 ? void 0 : onExit();
60
+ const toValue = getDisappearingOffsetY();
60
61
  const exitConfig = {
61
62
  duration: exitDuration,
62
63
  easing: _reactNativeReanimated.Easing.in(_reactNativeReanimated.Easing.ease)
63
64
  };
64
- onExit === null || onExit === void 0 ? void 0 : onExit();
65
- animatedY.value = (0, _reactNativeReanimated.withTiming)(window.height, exitConfig, isFinished => {
65
+ animatedY.value = (0, _reactNativeReanimated.withTiming)(toValue, exitConfig, isFinished => {
66
66
  if (isFinished && onExited) {
67
67
  (0, _reactNativeReanimated.runOnJS)(onExited)();
68
68
  }
69
69
  });
70
70
  }
71
71
  }, [appear, onEnter, onEntered, onExit, onExited]);
72
-
73
72
  return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, _extends({
74
73
  style: [animatedStyle, style]
75
74
  }, otherProps));
@@ -1 +1 @@
1
- {"version":3,"names":["defaultEnterDuration","defaultExitDuration","Slide","props","animatedY","animatedYProp","appear","enterDuration","exitDuration","onEnter","onEntered","onExit","onExited","style","otherProps","window","useWindowDimensions","y","useSharedValue","height","animatedStyle","useAnimatedStyle","transform","translateY","value","React","useEffect","enterConfig","duration","easing","Easing","out","exp","withTiming","isFinished","runOnJS","exitConfig","in","ease"],"sources":["Slide.tsx"],"sourcesContent":["import React from 'react';\nimport { useWindowDimensions } from 'react-native';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { Easing, runOnJS, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport type SlideProps from './SlideProps';\n\nconst defaultEnterDuration = 300;\nconst defaultExitDuration = 300;\n\nexport default function Slide(props: SlideProps) {\n const {\n animatedY: animatedYProp,\n appear,\n enterDuration = defaultEnterDuration,\n exitDuration = defaultExitDuration,\n onEnter,\n onEntered,\n onExit,\n onExited,\n style,\n ...otherProps\n } = props;\n\n const window = useWindowDimensions();\n\n const y = useSharedValue(window.height);\n const animatedY = animatedYProp || y;\n\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: animatedY.value }],\n }));\n\n React.useEffect(() => {\n if (appear) {\n const enterConfig: WithTimingConfig = {\n duration: enterDuration,\n easing: Easing.out(Easing.exp),\n };\n\n onEnter?.();\n\n animatedY.value = withTiming(0, enterConfig, isFinished => {\n if (isFinished && onEntered) {\n runOnJS(onEntered)();\n }\n });\n } else {\n const exitConfig: WithTimingConfig = {\n duration: exitDuration,\n easing: Easing.in(Easing.ease),\n };\n\n onExit?.();\n\n animatedY.value = withTiming(window.height, exitConfig, isFinished => {\n if (isFinished && onExited) {\n runOnJS(onExited)();\n }\n });\n }\n }, [appear, onEnter, onEntered,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MACH,MAAM0B,UAA4B,GAAG;QACjCR,QAAQ,EAAEpB,YADuB;QAEjCqB,MAAM,EAAEC,6BAAA,CAAOO,EAAP,CAAUP,6BAAA,CAAOQ,IAAjB;MAFyB,CAArC;MAKA3B,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM;MAENP,SAAS,CAACoB,KAAV,GAAkB,IAAAS,iCAAA,EAAWlB,MAAM,CAACI,MAAlB,EAA0BiB,UAA1B,EAAsCF,UAAU,IAAI;QAClE,IAAIA,UAAU,IAAItB,QAAlB,EAA4B;UACxB,IAAAuB,8BAAA,EAAQvB,QAAR;QACH;MACJ,CAJiB,CAAlB;IAKH;EACJ,CA5BD,EA4BG,CAACN,MAAD,EAASG,OAAT,EAAkBC,SAAlB,EAA6BC,MAA7B,EAAqCC,QAArC,CA5BH;;EA8BA,oBACI,6BAAC,8BAAD,CAAU,IAAV;IACI,KAAK,EAAE,CACHQ,aADG,EAEHP,KAFG;EADX,GAKQC,UALR,EADJ;AASH;;AAAA"}
1
+ {"version":3,"names":["defaultEnterDuration","defaultExitDuration","getDisappearingOffsetY","Dimensions","get","height","Slide","props","animatedY","animatedYProp","appear","enterDuration","exitDuration","onEnter","onEntered","onExit","onExited","style","otherProps","y","useSharedValue","animatedStyle","useAnimatedStyle","transform","translateY","value","useEffect","toValue","enterConfig","duration","easing","Easing","out","exp","withTiming","isFinished","runOnJS","exitConfig","in","ease"],"sources":["Slide.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { Dimensions } from 'react-native';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { Easing, runOnJS, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport type SlideProps from './SlideProps';\n\nconst defaultEnterDuration = 300;\nconst defaultExitDuration = 300;\n\nconst getDisappearingOffsetY = (): number => Dimensions.get('window').height;\n\nexport default function Slide(props: SlideProps) {\n const {\n animatedY: animatedYProp,\n appear,\n enterDuration = defaultEnterDuration,\n exitDuration = defaultExitDuration,\n onEnter,\n onEntered,\n onExit,\n onExited,\n style,\n ...otherProps\n } = props;\n\n const y = useSharedValue(getDisappearingOffsetY());\n const animatedY = animatedYProp || y;\n\n const animatedStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: animatedY.value }],\n }), []);\n\n useEffect(() => {\n if (appear) {\n onEnter?.();\n\n const toValue = 0;\n const enterConfig: Readonly<WithTimingConfig> = {\n duration: enterDuration,\n easing: Easing.out(Easing.exp),\n };\n\n animatedY.value = withTiming(toValue, enterConfig, isFinished => {\n if (isFinished && onEntered) {\n runOnJS(onEntered)();\n }\n });\n } else {\n onExit?.();\n\n const toValue = getDisappearingOffsetY();\n const exitConfig: Readonly<WithTimingConfig> = {\n duration: exitDuration,\n easing: Easing.in(Easing.ease),\n };\n\n animatedY.value = withTiming(toValue, exitConfig, isFinished => {\n if (isFinished && onExited) {\n runOnJS(onExited)();\n }\n });\n }\n }, [appear, onEnter, onEntered, onExit, onExited]);\n\n return (\n <Animated.View\n style={[\n animatedStyle,\n style,\n ]}\n {...otherProps}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;;;AAGA,MAAMA,oBAAoB,GAAG,GAA7B;AACA,MAAMC,mBAAmB,GAAG,GAA5B;;AAEA,MAAMC,sBAAsB,GAAG,MAAcC,uBAAA,CAAWC,GAAX,CAAe,QAAf,EAAyBC,MAAtE;;AAEe,SAASC,KAAT,CAAeC,KAAf,EAAkC;EAC7C,MAAM;IACFC,SAAS,EAAEC,aADT;IAEFC,MAFE;IAGFC,aAAa,GAAGX,oBAHd;IAIFY,YAAY,GAAGX,mBAJb;IAKFY,OALE;IAMFC,SANE;IAOFC,MAPE;IAQFC,QARE;IASFC,KATE;IAUF,GAAGC;EAVD,IAWFX,KAXJ;EAaA,MAAMY,CAAC,GAAG,IAAAC,qCAAA,EAAelB,sBAAsB,EAArC,CAAV;EACA,MAAMM,SAAS,GAAGC,aAAa,IAAIU,CAAnC;EAEA,MAAME,a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U,IAAV;IACI,KAAK,EAAE,CACHK,aADG,EAEHJ,KAFG;EADX,GAKQC,UALR,EADJ;AASH;;AAAA"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = Tab;
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
 
@@ -19,6 +19,10 @@ var _TabIndicator = _interopRequireDefault(require("./TabIndicator"));
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
+ 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); }
23
+
24
+ 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; }
25
+
22
26
  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); }
23
27
 
24
28
  const styles = _styles.StyleSheet.create({
@@ -42,9 +46,9 @@ function Tab(props) {
42
46
  const {
43
47
  badgeVisible = false,
44
48
  children,
45
- enableIndicator,
49
+ enableIndicator = false,
46
50
  icon: defaultIcon,
47
- selected,
51
+ selected = false,
48
52
  selectedIcon,
49
53
  variant = 'primary',
50
54
  style,
@@ -60,7 +64,7 @@ function Tab(props) {
60
64
  });
61
65
  const pressEffect = selected ? 'none' : 'opacity';
62
66
  const icon = selected ? selectedIcon || defaultIcon : defaultIcon;
63
- const iconElement = icon ? /*#__PURE__*/_react.default.cloneElement(icon, {
67
+ const iconElement = icon ? /*#__PURE__*/(0, _react.cloneElement)(icon, {
64
68
  fill: color
65
69
  }) : null;
66
70
  return /*#__PURE__*/_react.default.createElement(_TabBase.default, _extends({
@@ -73,7 +77,7 @@ function Tab(props) {
73
77
  }), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
74
78
  children: children,
75
79
  style: (0, _styles.css)(fontStyle)
76
- }), enableIndicator ? /*#__PURE__*/_react.default.createElement(_TabIndicator.default, null) : null);
80
+ }), enableIndicator && selected ? /*#__PURE__*/_react.default.createElement(_TabIndicator.default, null) : null);
77
81
  }
78
82
 
79
83
  ;