@fountain-ui/core 2.0.0-beta.12 → 2.0.0-beta.15
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.
- package/build/commonjs/ButtonBase/ButtonBase.js +57 -52
- package/build/commonjs/ButtonBase/ButtonBase.js.map +1 -1
- package/build/commonjs/CircularProgress/CircularProgress.js +21 -19
- package/build/commonjs/CircularProgress/CircularProgress.js.map +1 -1
- package/build/commonjs/ImageCore/ImageCoreNative.js +24 -26
- package/build/commonjs/ImageCore/ImageCoreNative.js.map +1 -1
- package/build/commonjs/Tab/Tab.js +9 -5
- package/build/commonjs/Tab/Tab.js.map +1 -1
- package/build/commonjs/Tabs/IndexAwareTab.js +28 -0
- package/build/commonjs/Tabs/IndexAwareTab.js.map +1 -0
- package/build/commonjs/Tabs/TabIndicator.js +27 -13
- package/build/commonjs/Tabs/TabIndicator.js.map +1 -1
- package/build/commonjs/Tabs/TabIndicatorProps.js.map +1 -1
- package/build/commonjs/Tabs/Tabs.js +43 -62
- package/build/commonjs/Tabs/Tabs.js.map +1 -1
- package/build/commonjs/Tabs/TabsProps.js.map +1 -1
- package/build/commonjs/Tabs/index.js.map +1 -1
- package/build/commonjs/Tabs/useScrollViewReaction.js +65 -0
- package/build/commonjs/Tabs/useScrollViewReaction.js.map +1 -0
- package/build/commonjs/Tooltip/Tooltip.js +14 -18
- package/build/commonjs/Tooltip/Tooltip.js.map +1 -1
- package/build/commonjs/animated/AnimatedPressable.js +2 -3
- package/build/commonjs/animated/AnimatedPressable.js.map +1 -1
- package/build/commonjs/hooks/useThrottle.js +3 -7
- package/build/commonjs/hooks/useThrottle.js.map +1 -1
- package/build/commonjs/hooks/useValidWindowDimensions/index.ios.js +14 -7
- package/build/commonjs/hooks/useValidWindowDimensions/index.ios.js.map +1 -1
- package/build/commonjs/internal/hooks/useHeight.js +2 -6
- package/build/commonjs/internal/hooks/useHeight.js.map +1 -1
- package/build/module/ButtonBase/ButtonBase.js +55 -48
- package/build/module/ButtonBase/ButtonBase.js.map +1 -1
- package/build/module/CircularProgress/CircularProgress.js +21 -18
- package/build/module/CircularProgress/CircularProgress.js.map +1 -1
- package/build/module/ImageCore/ImageCoreNative.js +20 -23
- package/build/module/ImageCore/ImageCoreNative.js.map +1 -1
- package/build/module/Tab/Tab.js +5 -5
- package/build/module/Tab/Tab.js.map +1 -1
- package/build/module/Tabs/IndexAwareTab.js +18 -0
- package/build/module/Tabs/IndexAwareTab.js.map +1 -0
- package/build/module/Tabs/TabIndicator.js +26 -14
- package/build/module/Tabs/TabIndicator.js.map +1 -1
- package/build/module/Tabs/TabIndicatorProps.js.map +1 -1
- package/build/module/Tabs/Tabs.js +42 -60
- package/build/module/Tabs/Tabs.js.map +1 -1
- package/build/module/Tabs/TabsProps.js.map +1 -1
- package/build/module/Tabs/index.js.map +1 -1
- package/build/module/Tabs/useScrollViewReaction.js +54 -0
- package/build/module/Tabs/useScrollViewReaction.js.map +1 -0
- package/build/module/Tooltip/Tooltip.js +11 -11
- package/build/module/Tooltip/Tooltip.js.map +1 -1
- package/build/module/animated/AnimatedPressable.js +2 -3
- package/build/module/animated/AnimatedPressable.js.map +1 -1
- package/build/module/hooks/useThrottle.js +3 -3
- package/build/module/hooks/useThrottle.js.map +1 -1
- package/build/module/hooks/useValidWindowDimensions/index.ios.js +15 -9
- package/build/module/hooks/useValidWindowDimensions/index.ios.js.map +1 -1
- package/build/module/internal/hooks/useHeight.js +2 -2
- package/build/module/internal/hooks/useHeight.js.map +1 -1
- package/build/typescript/CircularProgress/CircularProgress.d.ts +1 -1
- package/build/typescript/Tabs/IndexAwareTab.d.ts +9 -0
- package/build/typescript/Tabs/TabIndicatorProps.d.ts +2 -2
- package/build/typescript/Tabs/Tabs.d.ts +4 -1
- package/build/typescript/Tabs/TabsProps.d.ts +22 -9
- package/build/typescript/Tabs/index.d.ts +1 -1
- package/build/typescript/Tabs/useScrollViewReaction.d.ts +9 -0
- package/build/typescript/animated/AnimatedPressable.d.ts +2 -2
- package/build/typescript/hooks/useValidWindowDimensions/index.ios.d.ts +2 -1
- package/package.json +2 -2
- package/src/ButtonBase/ButtonBase.tsx +69 -43
- package/src/CircularProgress/CircularProgress.tsx +34 -27
- package/src/ImageCore/ImageCoreNative.tsx +17 -19
- package/src/Tab/Tab.tsx +5 -5
- package/src/Tabs/IndexAwareTab.tsx +30 -0
- package/src/Tabs/TabIndicator.tsx +26 -14
- package/src/Tabs/TabIndicatorProps.ts +2 -2
- package/src/Tabs/Tabs.tsx +50 -62
- package/src/Tabs/TabsProps.ts +25 -9
- package/src/Tabs/index.ts +1 -1
- package/src/Tabs/useScrollViewReaction.ts +63 -0
- package/src/Tooltip/Tooltip.tsx +12 -12
- package/src/animated/AnimatedPressable.tsx +1 -2
- package/src/hooks/useThrottle.ts +3 -3
- package/src/hooks/useValidWindowDimensions/index.ios.ts +16 -10
- package/src/internal/hooks/useHeight.ts +2 -2
- package/build/commonjs/ButtonBase/ButtonBase.ios.js +0 -101
- package/build/commonjs/ButtonBase/ButtonBase.ios.js.map +0 -1
- package/build/commonjs/ButtonBase/useDisabledReaction/index.js +0 -21
- package/build/commonjs/ButtonBase/useDisabledReaction/index.js.map +0 -1
- package/build/commonjs/ButtonBase/useDisabledReaction/index.native.js +0 -9
- package/build/commonjs/ButtonBase/useDisabledReaction/index.native.js.map +0 -1
- package/build/commonjs/ImageCore/ImageCoreNative.ios.js +0 -60
- package/build/commonjs/ImageCore/ImageCoreNative.ios.js.map +0 -1
- package/build/commonjs/Tabs/useTabsWidth.js +0 -26
- package/build/commonjs/Tabs/useTabsWidth.js.map +0 -1
- package/build/module/ButtonBase/ButtonBase.ios.js +0 -82
- package/build/module/ButtonBase/ButtonBase.ios.js.map +0 -1
- package/build/module/ButtonBase/useDisabledReaction/index.js +0 -12
- package/build/module/ButtonBase/useDisabledReaction/index.js.map +0 -1
- package/build/module/ButtonBase/useDisabledReaction/index.native.js +0 -2
- package/build/module/ButtonBase/useDisabledReaction/index.native.js.map +0 -1
- package/build/module/ImageCore/ImageCoreNative.ios.js +0 -45
- package/build/module/ImageCore/ImageCoreNative.ios.js.map +0 -1
- package/build/module/Tabs/useTabsWidth.js +0 -18
- package/build/module/Tabs/useTabsWidth.js.map +0 -1
- package/build/typescript/ButtonBase/ButtonBase.ios.d.ts +0 -2
- package/build/typescript/ButtonBase/useDisabledReaction/index.d.ts +0 -2
- package/build/typescript/ButtonBase/useDisabledReaction/index.native.d.ts +0 -2
- package/build/typescript/ImageCore/ImageCoreNative.ios.d.ts +0 -2
- package/build/typescript/Tabs/useTabsWidth.d.ts +0 -2
- package/src/ButtonBase/ButtonBase.ios.tsx +0 -95
- package/src/ButtonBase/useDisabledReaction/index.native.ts +0 -4
- package/src/ButtonBase/useDisabledReaction/index.ts +0 -17
- package/src/ImageCore/ImageCoreNative.ios.tsx +0 -46
- package/src/Tabs/useTabsWidth.ts +0 -20
|
@@ -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 =
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
|
|
11
|
-
var
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
32
|
+
const SCALE_EFFECT_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,59 @@ function ButtonBase(props) {
|
|
|
57
54
|
periodMillis: disableThrottle ? 0 : throttleMillis,
|
|
58
55
|
callback: onPress
|
|
59
56
|
});
|
|
60
|
-
const opacity = (0,
|
|
61
|
-
const scale = (0,
|
|
62
|
-
|
|
63
|
-
opacity:
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
95
|
+
const pressDelay = pressEffect === 'scale' ? SCALE_EFFECT_PRESS_IN_DELAY : 0;
|
|
92
96
|
return /*#__PURE__*/_react.default.createElement(_animated.AnimatedPressable, _extends({
|
|
93
97
|
disabled: disabled,
|
|
94
98
|
onPress: handlePress,
|
|
95
|
-
onPressIn:
|
|
96
|
-
onPressOut:
|
|
97
|
-
style: [animatedStyle,
|
|
99
|
+
onPressIn: handlePressIn,
|
|
100
|
+
onPressOut: handlePressOut,
|
|
101
|
+
style: [animatedStyle, styleProp],
|
|
102
|
+
unstable_pressDelay: pressDelay
|
|
98
103
|
}, otherProps), typeof children !== 'function' ? _ref => {
|
|
99
104
|
let {
|
|
100
105
|
hovered
|
|
101
106
|
} = _ref;
|
|
102
107
|
|
|
103
108
|
if (hovered !== undefined && !disabled) {
|
|
104
|
-
|
|
109
|
+
startPressAnimation(hovered, true);
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
return children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ORIGINAL_OPACITY","DISABLED_OPACITY","ACTIVE_OPACITY","ORIGINAL_SCALE","MINIFIED_SCALE","
|
|
1
|
+
{"version":3,"names":["ORIGINAL_OPACITY","DISABLED_OPACITY","ACTIVE_OPACITY","ORIGINAL_SCALE","MINIFIED_SCALE","SCALE_EFFECT_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","pressDelay","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 SCALE_EFFECT_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 const pressDelay = pressEffect === 'scale'\n ? SCALE_EFFECT_PRESS_IN_DELAY\n : 0;\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={pressDelay}\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":"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"}
|
|
@@ -7,22 +7,16 @@ exports.default = CircularProgress;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _reactNative = require("react-native");
|
|
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
|
-
const
|
|
21
|
-
|
|
22
|
-
easing: _reactNativeReanimated.Easing.linear
|
|
23
|
-
};
|
|
24
|
-
const MIN_ROTATE = 0;
|
|
25
|
-
const MAX_ROTATE = 360;
|
|
18
|
+
const MIN_ROTATE_DEGREE = 0;
|
|
19
|
+
const MAX_ROTATE_DEGREE = 360;
|
|
26
20
|
|
|
27
21
|
const useStyles = function () {
|
|
28
22
|
return {
|
|
@@ -35,22 +29,30 @@ const useStyles = function () {
|
|
|
35
29
|
|
|
36
30
|
function CircularProgress(props) {
|
|
37
31
|
const {
|
|
38
|
-
style
|
|
32
|
+
style: styleProp
|
|
39
33
|
} = props;
|
|
40
34
|
const styles = useStyles();
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const spinStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
35
|
+
const rotate = (0, _react.useRef)(new _reactNative.Animated.Value(MIN_ROTATE_DEGREE)).current;
|
|
36
|
+
const animatedStyle = {
|
|
44
37
|
transform: [{
|
|
45
|
-
rotate:
|
|
38
|
+
rotate: rotate.interpolate({
|
|
39
|
+
inputRange: [MIN_ROTATE_DEGREE, MAX_ROTATE_DEGREE],
|
|
40
|
+
outputRange: [`${MIN_ROTATE_DEGREE}deg`, `${MAX_ROTATE_DEGREE}deg`]
|
|
41
|
+
})
|
|
46
42
|
}]
|
|
47
|
-
}
|
|
43
|
+
};
|
|
48
44
|
(0, _react.useEffect)(() => {
|
|
49
|
-
|
|
45
|
+
_reactNative.Animated.loop(_reactNative.Animated.timing(rotate, {
|
|
46
|
+
toValue: MAX_ROTATE_DEGREE,
|
|
47
|
+
duration: 900,
|
|
48
|
+
easing: _reactNative.Easing.linear,
|
|
49
|
+
useNativeDriver: true
|
|
50
|
+
})).start();
|
|
50
51
|
}, []);
|
|
51
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
|
|
53
|
+
children: /*#__PURE__*/_react.default.createElement(_icons.CircularProgress, null),
|
|
54
|
+
style: [animatedStyle, styles.root, styleProp]
|
|
55
|
+
});
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["MIN_ROTATE_DEGREE","MAX_ROTATE_DEGREE","useStyles","root","alignItems","justifyContent","CircularProgress","props","style","styleProp","styles","rotate","useRef","Animated","Value","current","animatedStyle","transform","interpolate","inputRange","outputRange","useEffect","loop","timing","toValue","duration","easing","Easing","linear","useNativeDriver","start"],"sources":["CircularProgress.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated, Easing } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { CircularProgress as CircularProgressIcon } from '../internal/icons';\nimport { OverridableComponentProps } from '../types';\n\ntype CircularProgressStyles = NamedStylesStringUnion<'root'>;\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 = useRef(new Animated.Value(MIN_ROTATE_DEGREE)).current;\n\n const animatedStyle = {\n transform: [{\n rotate: rotate.interpolate({\n inputRange: [MIN_ROTATE_DEGREE, MAX_ROTATE_DEGREE],\n outputRange: [`${MIN_ROTATE_DEGREE}deg`, `${MAX_ROTATE_DEGREE}deg`],\n }),\n }],\n };\n\n useEffect(() => {\n Animated.loop(\n Animated.timing(\n rotate,\n {\n toValue: MAX_ROTATE_DEGREE,\n duration: 900,\n easing: Easing.linear,\n useNativeDriver: true,\n },\n ),\n ).start();\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;;AAEA;;AAEA;;;;;;AAKA,MAAMA,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,aAAA,EAAO,IAAIC,qBAAA,CAASC,KAAb,CAAmBd,iBAAnB,CAAP,EAA8Ce,OAA7D;EAEA,MAAMC,aAAa,GAAG;IAClBC,SAAS,EAAE,CAAC;MACRN,MAAM,EAAEA,MAAM,CAACO,WAAP,CAAmB;QACvBC,UAAU,EAAE,CAACnB,iBAAD,EAAoBC,iBAApB,CADW;QAEvBmB,WAAW,EAAE,CAAE,GAAEpB,iBAAkB,KAAtB,EAA6B,GAAEC,iBAAkB,KAAjD;MAFU,CAAnB;IADA,CAAD;EADO,CAAtB;EASA,IAAAoB,gBAAA,EAAU,MAAM;IACZR,qBAAA,CAASS,IAAT,CACIT,qBAAA,CAASU,MAAT,CACIZ,MADJ,EAEI;MACIa,OAAO,EAAEvB,iBADb;MAEIwB,QAAQ,EAAE,GAFd;MAGIC,MAAM,EAAEC,mBAAA,CAAOC,MAHnB;MAIIC,eAAe,EAAE;IAJrB,CAFJ,CADJ,EAUEC,KAVF;EAWH,CAZD,EAYG,EAZH;EAcA,oBACI,6BAAC,qBAAD,CAAU,IAAV;IACI,QAAQ,eAAE,6BAAC,uBAAD,OADd;IAEI,KAAK,EAAE,CACHd,aADG,EAEHN,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 =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
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 =
|
|
21
|
+
const AnimatedFastImage = _reactNative.Animated.createAnimatedComponent(_reactNativeFastImage.default);
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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: [
|
|
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","
|
|
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 = Tab;
|
|
7
7
|
|
|
8
|
-
var _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.
|
|
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
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["styles","StyleSheet","create","root","Platform","OS","minWidth","primary","minHeight","secondary","bottomNavigation","Tab","props","badgeVisible","children","enableIndicator","icon","defaultIcon","selected","selectedIcon","variant","style","otherProps","theme","useTheme","vertical","color","palette","text","hint","tabBaseStyle","css","fontStyle","createFontStyle","selector","typo","h2","button2","flag","pressEffect","iconElement","
|
|
1
|
+
{"version":3,"names":["styles","StyleSheet","create","root","Platform","OS","minWidth","primary","minHeight","secondary","bottomNavigation","Tab","props","badgeVisible","children","enableIndicator","icon","defaultIcon","selected","selectedIcon","variant","style","otherProps","theme","useTheme","vertical","color","palette","text","hint","tabBaseStyle","css","fontStyle","createFontStyle","selector","typo","h2","button2","flag","pressEffect","iconElement","cloneElement","fill"],"sources":["Tab.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { Platform, Text } from 'react-native';\nimport Badge from '../Badge';\nimport TabBase from '../TabBase';\nimport type TabProps from './TabProps';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport TabIndicator from './TabIndicator';\n\nconst styles = StyleSheet.create({\n root: {\n // TODO: Remove redundant platform checking\n ...(Platform.OS === 'web' ? { minWidth: 'auto' } : {}),\n },\n primary: {\n minHeight: 48,\n },\n secondary: {\n minHeight: 48,\n },\n bottomNavigation: {\n minHeight: 56,\n },\n});\n\nexport default function Tab(props: TabProps) {\n const {\n badgeVisible = false,\n children,\n enableIndicator = false,\n icon: defaultIcon,\n selected = false,\n selectedIcon,\n variant = 'primary',\n style,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const vertical = variant === 'bottom-navigation';\n\n const color = selected ? theme.palette.text.primary : theme.palette.text.hint;\n\n const tabBaseStyle = css([\n styles.root,\n variant === 'primary'\n ? styles.primary\n : (variant === 'secondary' ? styles.secondary : styles.bottomNavigation),\n style,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => variant === 'primary'\n ? typo.h2\n : (variant === 'secondary' ? typo.button2 : typo.flag),\n color,\n });\n\n const pressEffect = selected ? 'none' : 'opacity';\n\n const icon = selected ? (selectedIcon || defaultIcon) : defaultIcon;\n const iconElement = icon ? cloneElement(icon, { fill: color }) : null;\n\n return (\n <TabBase\n pressEffect={pressEffect}\n style={tabBaseStyle}\n vertical={vertical}\n {...otherProps}\n >\n <Badge\n children={iconElement}\n invisible={!badgeVisible}\n />\n\n <Text\n children={children}\n style={css(fontStyle)}\n />\n\n {(enableIndicator && selected) ? <TabIndicator/> : null}\n </TabBase>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,MAAMA,MAAM,GAAGC,kBAAA,CAAWC,MAAX,CAAkB;EAC7BC,IAAI,EAAE,EACF;IACA,IAAIC,qBAAA,CAASC,EAAT,KAAgB,KAAhB,GAAwB;MAAEC,QAAQ,EAAE;IAAZ,CAAxB,GAA+C,EAAnD;EAFE,CADuB;EAK7BC,OAAO,EAAE;IACLC,SAAS,EAAE;EADN,CALoB;EAQ7BC,SAAS,EAAE;IACPD,SAAS,EAAE;EADJ,CARkB;EAW7BE,gBAAgB,EAAE;IACdF,SAAS,EAAE;EADG;AAXW,CAAlB,CAAf;;AAgBe,SAASG,GAAT,CAAaC,KAAb,EAA8B;EACzC,MAAM;IACFC,YAAY,GAAG,KADb;IAEFC,QAFE;IAGFC,eAAe,GAAG,KAHhB;IAIFC,IAAI,EAAEC,WAJJ;IAKFC,QAAQ,GAAG,KALT;IAMFC,YANE;IAOFC,OAAO,GAAG,SAPR;IAQFC,KARE;IASF,GAAGC;EATD,IAUFV,KAVJ;EAYA,MAAMW,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,MAAMC,QAAQ,GAAGL,OAAO,KAAK,mBAA7B;EAEA,MAAMM,KAAK,GAAGR,QAAQ,GAAGK,KAAK,CAACI,OAAN,CAAcC,IAAd,CAAmBrB,OAAtB,GAAgCgB,KAAK,CAACI,OAAN,CAAcC,IAAd,CAAmBC,IAAzE;EAEA,MAAMC,YAAY,GAAG,IAAAC,WAAA,EAAI,CACrB/B,MAAM,CAACG,IADc,EAErBiB,OAAO,KAAK,SAAZ,GACMpB,MAAM,CAACO,OADb,GAEOa,OAAO,KAAK,WAAZ,GAA0BpB,MAAM,CAACS,SAAjC,GAA6CT,MAAM,CAACU,gBAJtC,EAKrBW,KALqB,CAAJ,CAArB;EAQA,MAAMW,SAAS,GAAG,IAAAC,uBAAA,EAAgBV,KAAhB,EAAuB;IACrCW,QAAQ,EAAGC,IAAD,IAAUf,OAAO,KAAK,SAAZ,GACde,IAAI,CAACC,EADS,GAEbhB,OAAO,KAAK,WAAZ,GAA0Be,IAAI,CAACE,OAA/B,GAAyCF,IAAI,CAACG,IAHhB;IAIrCZ;EAJqC,CAAvB,CAAlB;EAOA,MAAMa,WAAW,GAAGrB,QAAQ,GAAG,MAAH,GAAY,SAAxC;EAEA,MAAMF,IAAI,GAAGE,QAAQ,GAAIC,YAAY,IAAIF,WAApB,GAAmCA,WAAxD;EACA,MAAMuB,WAAW,GAAGxB,IAAI,gBAAG,IAAAyB,mBAAA,EAAazB,IAAb,EAAmB;IAAE0B,IAAI,EAAEhB;EAAR,CAAnB,CAAH,GAAyC,IAAjE;EAEA,oBACI,6BAAC,gBAAD;IACI,WAAW,EAAEa,WADjB;IAEI,KAAK,EAAET,YAFX;IAGI,QAAQ,EAAEL;EAHd,GAIQH,UAJR,gBAMI,6BAAC,cAAD;IACI,QAAQ,EAAEkB,WADd;IAEI,SAAS,EAAE,CAAC3B;EAFhB,EANJ,eAWI,6BAAC,iBAAD;IACI,QAAQ,EAAEC,QADd;IAEI,KAAK,EAAE,IAAAiB,WAAA,EAAIC,SAAJ;EAFX,EAXJ,EAgBMjB,eAAe,IAAIG,QAApB,gBAAgC,6BAAC,qBAAD,OAAhC,GAAkD,IAhBvD,CADJ;AAoBH;;AAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = IndexAwareTab;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
11
|
+
|
|
12
|
+
function IndexAwareTab(props) {
|
|
13
|
+
const {
|
|
14
|
+
children,
|
|
15
|
+
index,
|
|
16
|
+
sharedIndex
|
|
17
|
+
} = props;
|
|
18
|
+
const [selected, setSelected] = (0, _react.useState)(index === sharedIndex.value);
|
|
19
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => index === sharedIndex.value, result => {
|
|
20
|
+
(0, _reactNativeReanimated.runOnJS)(setSelected)(result);
|
|
21
|
+
}, [index]);
|
|
22
|
+
return /*#__PURE__*/(0, _react.cloneElement)(children, {
|
|
23
|
+
selected
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
;
|
|
28
|
+
//# sourceMappingURL=IndexAwareTab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["IndexAwareTab","props","children","index","sharedIndex","selected","setSelected","useState","value","useAnimatedReaction","result","runOnJS","cloneElement"],"sources":["IndexAwareTab.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { cloneElement, useState } from 'react';\nimport type { SharedValue } from 'react-native-reanimated';\nimport { runOnJS, useAnimatedReaction } from 'react-native-reanimated';\n\nexport interface IndexAwareTabProps {\n children: ReactElement;\n index: number;\n sharedIndex: SharedValue<number>;\n}\n\nexport default function IndexAwareTab(props: IndexAwareTabProps) {\n const {\n children,\n index,\n sharedIndex,\n } = props;\n\n const [selected, setSelected] = useState(index === sharedIndex.value);\n\n useAnimatedReaction(\n () => index === sharedIndex.value,\n (result) => {\n runOnJS(setSelected)(result);\n },\n [index],\n );\n\n return cloneElement(children, { selected });\n};\n"],"mappings":";;;;;;;AACA;;AAEA;;AAQe,SAASA,aAAT,CAAuBC,KAAvB,EAAkD;EAC7D,MAAM;IACFC,QADE;IAEFC,KAFE;IAGFC;EAHE,IAIFH,KAJJ;EAMA,MAAM,CAACI,QAAD,EAAWC,WAAX,IAA0B,IAAAC,eAAA,EAASJ,KAAK,KAAKC,WAAW,CAACI,KAA/B,CAAhC;EAEA,IAAAC,0CAAA,EACI,MAAMN,KAAK,KAAKC,WAAW,CAACI,KADhC,EAEKE,MAAD,IAAY;IACR,IAAAC,8BAAA,EAAQL,WAAR,EAAqBI,MAArB;EACH,CAJL,EAKI,CAACP,KAAD,CALJ;EAQA,oBAAO,IAAAS,mBAAA,EAAaV,QAAb,EAAuB;IAAEG;EAAF,CAAvB,CAAP;AACH;;AAAA"}
|
|
@@ -21,13 +21,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
21
21
|
|
|
22
22
|
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
23
|
|
|
24
|
+
const INDICATOR_WIDTH = 10;
|
|
25
|
+
const INDICATOR_HEIGHT = 4;
|
|
26
|
+
const SCROLLABLE_TABS_INSET = 12 * 2;
|
|
27
|
+
|
|
24
28
|
const useStyles = function () {
|
|
25
29
|
const theme = (0, _styles.useTheme)();
|
|
26
30
|
return {
|
|
27
31
|
root: {
|
|
28
32
|
backgroundColor: theme.palette.secondary.main,
|
|
33
|
+
left: 0,
|
|
29
34
|
bottom: 0,
|
|
30
|
-
|
|
35
|
+
width: INDICATOR_WIDTH,
|
|
36
|
+
height: INDICATOR_HEIGHT,
|
|
31
37
|
position: 'absolute'
|
|
32
38
|
},
|
|
33
39
|
disabled: {
|
|
@@ -36,29 +42,37 @@ const useStyles = function () {
|
|
|
36
42
|
};
|
|
37
43
|
};
|
|
38
44
|
|
|
45
|
+
const ANIMATION_CONFIG = {
|
|
46
|
+
duration: 300,
|
|
47
|
+
easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.exp)
|
|
48
|
+
};
|
|
49
|
+
|
|
39
50
|
function TabIndicator(props) {
|
|
40
51
|
const {
|
|
41
52
|
coordinates,
|
|
42
53
|
disabled,
|
|
43
54
|
scrollable,
|
|
44
|
-
|
|
55
|
+
sharedIndex,
|
|
45
56
|
style,
|
|
46
57
|
...otherProps
|
|
47
58
|
} = props;
|
|
48
59
|
const styles = useStyles();
|
|
49
60
|
const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
61
|
+
const index = sharedIndex.value;
|
|
62
|
+
const {
|
|
63
|
+
x1,
|
|
64
|
+
x2
|
|
65
|
+
} = coordinates[index] ?? _TabCoordinate.defaultCoordinate;
|
|
66
|
+
const tabWidth = x2 - x1;
|
|
67
|
+
const translateX = x1 + (tabWidth - INDICATOR_WIDTH) / 2;
|
|
68
|
+
const inset = scrollable ? SCROLLABLE_TABS_INSET : 0;
|
|
69
|
+
const scaleX = (tabWidth - inset) / INDICATOR_WIDTH;
|
|
59
70
|
return {
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
transform: [{
|
|
72
|
+
translateX: (0, _reactNativeReanimated.withTiming)(translateX, ANIMATION_CONFIG)
|
|
73
|
+
}, {
|
|
74
|
+
scaleX: (0, _reactNativeReanimated.withTiming)(scaleX, ANIMATION_CONFIG)
|
|
75
|
+
}]
|
|
62
76
|
};
|
|
63
77
|
}, [coordinates, scrollable]);
|
|
64
78
|
return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, _extends({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useStyles","theme","useTheme","root","backgroundColor","palette","secondary","main","bottom","height","position","disabled","
|
|
1
|
+
{"version":3,"names":["INDICATOR_WIDTH","INDICATOR_HEIGHT","SCROLLABLE_TABS_INSET","useStyles","theme","useTheme","root","backgroundColor","palette","secondary","main","left","bottom","width","height","position","disabled","ANIMATION_CONFIG","duration","easing","Easing","out","exp","TabIndicator","props","coordinates","scrollable","sharedIndex","style","otherProps","styles","animatedStyle","useAnimatedStyle","index","value","x1","x2","defaultCoordinate","tabWidth","translateX","inset","scaleX","transform","withTiming","undefined"],"sources":["TabIndicator.tsx"],"sourcesContent":["import React from 'react';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { Easing, useAnimatedStyle, withTiming } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport type TabIndicatorProps from './TabIndicatorProps';\nimport { defaultCoordinate } from './TabCoordinate';\n\ntype TabIndicatorStyles = NamedStylesStringUnion<'root' | 'disabled'>;\n\nconst INDICATOR_WIDTH = 10;\nconst INDICATOR_HEIGHT = 4;\n\nconst SCROLLABLE_TABS_INSET = 12 * 2;\n\nconst useStyles: UseStyles<TabIndicatorStyles> = function (): TabIndicatorStyles {\n const theme = useTheme();\n\n return {\n root: {\n backgroundColor: theme.palette.secondary.main,\n left: 0,\n bottom: 0,\n width: INDICATOR_WIDTH,\n height: INDICATOR_HEIGHT,\n position: 'absolute',\n },\n disabled: {\n height: 0,\n },\n };\n};\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = {\n duration: 300,\n easing: Easing.out(Easing.exp),\n};\n\nexport default function TabIndicator(props: TabIndicatorProps) {\n const {\n coordinates,\n disabled,\n scrollable,\n sharedIndex,\n style,\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const animatedStyle = useAnimatedStyle(() => {\n const index = sharedIndex.value;\n\n const { x1, x2 } = coordinates[index] ?? defaultCoordinate;\n\n const tabWidth = x2 - x1;\n\n const translateX = x1 + (tabWidth - INDICATOR_WIDTH) / 2;\n\n const inset = scrollable ? SCROLLABLE_TABS_INSET : 0;\n const scaleX = (tabWidth - inset) / INDICATOR_WIDTH;\n\n return {\n transform: [\n { translateX: withTiming(translateX, ANIMATION_CONFIG) },\n { scaleX: withTiming(scaleX, ANIMATION_CONFIG) },\n ],\n };\n }, [coordinates, scrollable]);\n\n return (\n <Animated.View\n style={[\n styles.root,\n disabled ? styles.disabled : undefined,\n animatedStyle,\n style,\n ]}\n {...otherProps}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAEA;;;;;;;;;;AAIA,MAAMA,eAAe,GAAG,EAAxB;AACA,MAAMC,gBAAgB,GAAG,CAAzB;AAEA,MAAMC,qBAAqB,GAAG,KAAK,CAAnC;;AAEA,MAAMC,SAAwC,GAAG,YAAgC;EAC7E,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,eAAe,EAAEH,KAAK,CAACI,OAAN,CAAcC,SAAd,CAAwBC,IADvC;MAEFC,IAAI,EAAE,CAFJ;MAGFC,MAAM,EAAE,CAHN;MAIFC,KAAK,EAAEb,eAJL;MAKFc,MAAM,EAAEb,gBALN;MAMFc,QAAQ,EAAE;IANR,CADH;IASHC,QAAQ,EAAE;MACNF,MAAM,EAAE;IADF;EATP,CAAP;AAaH,CAhBD;;AAkBA,MAAMG,gBAA4C,GAAG;EACjDC,QAAQ,EAAE,GADuC;EAEjDC,MAAM,EAAEC,6BAAA,CAAOC,GAAP,CAAWD,6BAAA,CAAOE,GAAlB;AAFyC,CAArD;;AAKe,SAASC,YAAT,CAAsBC,KAAtB,EAAgD;EAC3D,MAAM;IACFC,WADE;IAEFT,QAFE;IAGFU,UAHE;IAIFC,WAJE;IAKFC,KALE;IAMF,GAAGC;EAND,IAOFL,KAPJ;EASA,MAAMM,MAAM,GAAG3B,SAAS,EAAxB;EAEA,MAAM4B,aAAa,GAAG,IAAAC,uCAAA,EAAiB,MAAM;IACzC,MAAMC,KAAK,GAAGN,WAAW,CAACO,KAA1B;IAEA,MAAM;MAAEC,EAAF;MAAMC;IAAN,IAAaX,WAAW,CAACQ,KAAD,CAAX,IAAsBI,gCAAzC;IAEA,MAAMC,QAAQ,GAAGF,EAAE,GAAGD,EAAtB;IAEA,MAAMI,UAAU,GAAGJ,EAAE,GAAG,CAACG,QAAQ,GAAGtC,eAAZ,IAA+B,CAAvD;IAEA,MAAMwC,KAAK,GAAGd,UAAU,GAAGxB,qBAAH,GAA2B,CAAnD;IACA,MAAMuC,MAAM,GAAG,CAACH,QAAQ,GAAGE,KAAZ,IAAqBxC,eAApC;IAEA,OAAO;MACH0C,SAAS,EAAE,CACP;QAAEH,UAAU,EAAE,IAAAI,iCAAA,EAAWJ,UAAX,EAAuBtB,gBAAvB;MAAd,CADO,EAEP;QAAEwB,MAAM,EAAE,IAAAE,iCAAA,EAAWF,MAAX,EAAmBxB,gBAAnB;MAAV,CAFO;IADR,CAAP;EAMH,CAlBqB,EAkBnB,CAACQ,WAAD,EAAcC,UAAd,CAlBmB,CAAtB;EAoBA,oBACI,6BAAC,8BAAD,CAAU,IAAV;IACI,KAAK,EAAE,CACHI,MAAM,CAACxB,IADJ,EAEHU,QAAQ,GAAGc,MAAM,CAACd,QAAV,GAAqB4B,SAF1B,EAGHb,aAHG,EAIHH,KAJG;EADX,GAOQC,UAPR,EADJ;AAWH;;AAAA"}
|