@fountain-ui/core 3.0.0-alpha.10 → 3.0.0-alpha.12
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/AppBar/AppBar.js +6 -1
- package/build/commonjs/AppBar/AppBar.js.map +1 -1
- package/build/commonjs/Badge/Badge.js +4 -3
- package/build/commonjs/Badge/Badge.js.map +1 -1
- package/build/commonjs/Badge/BadgeProps.js.map +1 -1
- package/build/commonjs/ButtonBase/index.js +2 -2
- package/build/commonjs/ButtonBase/index.js.map +1 -1
- package/build/commonjs/Chip/Chip.js +21 -14
- package/build/commonjs/Chip/Chip.js.map +1 -1
- package/build/commonjs/Chip/ChipProps.js +3 -1
- package/build/commonjs/Chip/ChipProps.js.map +1 -1
- package/build/commonjs/Chip/index.js +6 -0
- package/build/commonjs/Chip/index.js.map +1 -1
- package/build/commonjs/Chip/useChipStyle.js +29 -19
- package/build/commonjs/Chip/useChipStyle.js.map +1 -1
- package/build/commonjs/Dialog/Dialog.js +7 -8
- package/build/commonjs/Dialog/Dialog.js.map +1 -1
- package/build/commonjs/Dialog/DialogProps.js +1 -1
- package/build/commonjs/Dialog/DialogProps.js.map +1 -1
- package/build/commonjs/Dialog/useDialogSectionStyle.js +6 -4
- package/build/commonjs/Dialog/useDialogSectionStyle.js.map +1 -1
- package/build/commonjs/Dialog/useDialogStyle.js +9 -8
- package/build/commonjs/Dialog/useDialogStyle.js.map +1 -1
- package/build/commonjs/DialogTitle/DialogLargeTitle.js +80 -0
- package/build/commonjs/DialogTitle/DialogLargeTitle.js.map +1 -0
- package/build/commonjs/DialogTitle/DialogTitle.js +8 -4
- package/build/commonjs/DialogTitle/DialogTitle.js.map +1 -1
- package/build/commonjs/Divider/Divider.js +17 -9
- package/build/commonjs/Divider/Divider.js.map +1 -1
- package/build/commonjs/Divider/DividerProps.js +1 -1
- package/build/commonjs/Divider/DividerProps.js.map +1 -1
- package/build/commonjs/ListItem/ListItem.js +3 -13
- package/build/commonjs/ListItem/ListItem.js.map +1 -1
- package/build/commonjs/Pagination/Pagination.js +2 -0
- package/build/commonjs/Pagination/Pagination.js.map +1 -1
- package/build/commonjs/Pagination/PaginationProps.js +3 -1
- package/build/commonjs/Pagination/PaginationProps.js.map +1 -1
- package/build/commonjs/Pagination/index.js +6 -0
- package/build/commonjs/Pagination/index.js.map +1 -1
- package/build/commonjs/PaginationItem/PaginationItem.js +32 -22
- package/build/commonjs/PaginationItem/PaginationItem.js.map +1 -1
- package/build/commonjs/PaginationItem/PaginationItemProps.js.map +1 -1
- package/build/commonjs/Tab/Tab.js +11 -3
- package/build/commonjs/Tab/Tab.js.map +1 -1
- package/build/commonjs/Tabs/useTabsStyle.js +7 -4
- package/build/commonjs/Tabs/useTabsStyle.js.map +1 -1
- package/build/commonjs/Toolbar/BackButton/BackButton.js +47 -0
- package/build/commonjs/Toolbar/BackButton/BackButton.js.map +1 -0
- package/build/commonjs/Toolbar/BackButton/BackButtonProps.js +2 -0
- package/build/commonjs/Toolbar/BackButton/BackButtonProps.js.map +1 -0
- package/build/commonjs/Toolbar/BackButton/index.js +16 -0
- package/build/commonjs/Toolbar/BackButton/index.js.map +1 -0
- package/build/commonjs/Toolbar/Toolbar.js +8 -4
- package/build/commonjs/Toolbar/Toolbar.js.map +1 -1
- package/build/commonjs/internal/icons/ChevronLeft.js +4 -2
- package/build/commonjs/internal/icons/ChevronLeft.js.map +1 -1
- package/build/commonjs/internal/icons/ChevronRight.js +4 -2
- package/build/commonjs/internal/icons/ChevronRight.js.map +1 -1
- package/build/commonjs/internal/icons/Close.js +4 -2
- package/build/commonjs/internal/icons/Close.js.map +1 -1
- package/build/module/AppBar/AppBar.js +5 -1
- package/build/module/AppBar/AppBar.js.map +1 -1
- package/build/module/Badge/Badge.js +4 -3
- package/build/module/Badge/Badge.js.map +1 -1
- package/build/module/Badge/BadgeProps.js.map +1 -1
- package/build/module/ButtonBase/index.js +1 -1
- package/build/module/ButtonBase/index.js.map +1 -1
- package/build/module/Chip/Chip.js +17 -13
- package/build/module/Chip/Chip.js.map +1 -1
- package/build/module/Chip/ChipProps.js +1 -0
- package/build/module/Chip/ChipProps.js.map +1 -1
- package/build/module/Chip/index.js +1 -1
- package/build/module/Chip/index.js.map +1 -1
- package/build/module/Chip/useChipStyle.js +29 -19
- package/build/module/Chip/useChipStyle.js.map +1 -1
- package/build/module/Dialog/Dialog.js +7 -8
- package/build/module/Dialog/Dialog.js.map +1 -1
- package/build/module/Dialog/DialogProps.js +1 -1
- package/build/module/Dialog/DialogProps.js.map +1 -1
- package/build/module/Dialog/useDialogSectionStyle.js +6 -4
- package/build/module/Dialog/useDialogSectionStyle.js.map +1 -1
- package/build/module/Dialog/useDialogStyle.js +9 -8
- package/build/module/Dialog/useDialogStyle.js.map +1 -1
- package/build/module/DialogTitle/DialogLargeTitle.js +65 -0
- package/build/module/DialogTitle/DialogLargeTitle.js.map +1 -0
- package/build/module/DialogTitle/DialogTitle.js +6 -3
- package/build/module/DialogTitle/DialogTitle.js.map +1 -1
- package/build/module/Divider/Divider.js +7 -0
- package/build/module/Divider/Divider.js.map +1 -1
- package/build/module/Divider/DividerProps.js +1 -1
- package/build/module/Divider/DividerProps.js.map +1 -1
- package/build/module/ListItem/ListItem.js +3 -13
- package/build/module/ListItem/ListItem.js.map +1 -1
- package/build/module/Pagination/Pagination.js +2 -0
- package/build/module/Pagination/Pagination.js.map +1 -1
- package/build/module/Pagination/PaginationProps.js +1 -0
- package/build/module/Pagination/PaginationProps.js.map +1 -1
- package/build/module/Pagination/index.js +1 -1
- package/build/module/Pagination/index.js.map +1 -1
- package/build/module/PaginationItem/PaginationItem.js +28 -21
- package/build/module/PaginationItem/PaginationItem.js.map +1 -1
- package/build/module/PaginationItem/PaginationItemProps.js.map +1 -1
- package/build/module/Tab/Tab.js +11 -3
- package/build/module/Tab/Tab.js.map +1 -1
- package/build/module/Tabs/useTabsStyle.js +6 -4
- package/build/module/Tabs/useTabsStyle.js.map +1 -1
- package/build/module/Toolbar/BackButton/BackButton.js +32 -0
- package/build/module/Toolbar/BackButton/BackButton.js.map +1 -0
- package/build/module/Toolbar/BackButton/BackButtonProps.js +2 -0
- package/build/module/Toolbar/BackButton/BackButtonProps.js.map +1 -0
- package/build/module/Toolbar/BackButton/index.js +2 -0
- package/build/module/Toolbar/BackButton/index.js.map +1 -0
- package/build/module/Toolbar/Toolbar.js +7 -3
- package/build/module/Toolbar/Toolbar.js.map +1 -1
- package/build/module/internal/icons/ChevronLeft.js +4 -2
- package/build/module/internal/icons/ChevronLeft.js.map +1 -1
- package/build/module/internal/icons/ChevronRight.js +4 -2
- package/build/module/internal/icons/ChevronRight.js.map +1 -1
- package/build/module/internal/icons/Close.js +4 -2
- package/build/module/internal/icons/Close.js.map +1 -1
- package/build/typescript/Badge/BadgeProps.d.ts +10 -5
- package/build/typescript/ButtonBase/index.d.ts +1 -1
- package/build/typescript/Chip/ChipProps.d.ts +11 -4
- package/build/typescript/Chip/index.d.ts +1 -1
- package/build/typescript/Chip/useChipStyle.d.ts +4 -3
- package/build/typescript/Dialog/DialogProps.d.ts +1 -6
- package/build/typescript/Dialog/useDialogStyle.d.ts +1 -1
- package/build/typescript/DialogTitle/DialogLargeTitle.d.ts +9 -0
- package/build/typescript/DialogTitle/DialogTitle.d.ts +6 -1
- package/build/typescript/Divider/DividerProps.d.ts +1 -1
- package/build/typescript/Pagination/PaginationProps.d.ts +12 -0
- package/build/typescript/Pagination/index.d.ts +2 -2
- package/build/typescript/PaginationItem/PaginationItemProps.d.ts +6 -0
- package/build/typescript/Toolbar/BackButton/BackButton.d.ts +3 -0
- package/build/typescript/Toolbar/BackButton/BackButtonProps.d.ts +4 -0
- package/build/typescript/Toolbar/BackButton/index.d.ts +2 -0
- package/build/typescript/Toolbar/Toolbar.d.ts +6 -1
- package/package.json +3 -3
- package/src/AppBar/AppBar.tsx +4 -0
- package/src/Badge/Badge.tsx +4 -3
- package/src/Badge/BadgeProps.ts +12 -6
- package/src/ButtonBase/index.ts +1 -1
- package/src/Chip/Chip.tsx +20 -13
- package/src/Chip/ChipProps.ts +13 -4
- package/src/Chip/index.ts +1 -1
- package/src/Chip/useChipStyle.ts +34 -17
- package/src/Dialog/Dialog.tsx +7 -8
- package/src/Dialog/DialogProps.ts +1 -7
- package/src/Dialog/useDialogSectionStyle.ts +6 -4
- package/src/Dialog/useDialogStyle.ts +9 -7
- package/src/DialogTitle/DialogLargeTitle.tsx +95 -0
- package/src/DialogTitle/DialogTitle.tsx +6 -1
- package/src/Divider/Divider.tsx +5 -0
- package/src/Divider/DividerProps.ts +1 -1
- package/src/ListItem/ListItem.tsx +3 -13
- package/src/Pagination/Pagination.tsx +3 -2
- package/src/Pagination/PaginationProps.ts +15 -0
- package/src/Pagination/index.ts +2 -2
- package/src/PaginationItem/PaginationItem.tsx +31 -24
- package/src/PaginationItem/PaginationItemProps.ts +7 -0
- package/src/Tab/Tab.tsx +20 -6
- package/src/Tabs/useTabsStyle.ts +7 -4
- package/src/Toolbar/BackButton/BackButton.tsx +42 -0
- package/src/Toolbar/BackButton/BackButtonProps.ts +4 -0
- package/src/Toolbar/BackButton/index.ts +2 -0
- package/src/Toolbar/Toolbar.tsx +6 -1
- package/src/internal/icons/ChevronLeft.tsx +4 -1
- package/src/internal/icons/ChevronRight.tsx +4 -1
- package/src/internal/icons/Close.tsx +4 -1
- package/build/commonjs/ButtonBase/LegacyButtonBase.js +0 -126
- package/build/commonjs/ButtonBase/LegacyButtonBase.js.map +0 -1
- package/build/module/ButtonBase/LegacyButtonBase.js +0 -106
- package/build/module/ButtonBase/LegacyButtonBase.js.map +0 -1
- package/build/typescript/ButtonBase/LegacyButtonBase.d.ts +0 -5
- package/src/ButtonBase/LegacyButtonBase.tsx +0 -135
|
@@ -4,7 +4,10 @@ import { createSvgIcon } from '../../utils';
|
|
|
4
4
|
|
|
5
5
|
export default createSvgIcon(
|
|
6
6
|
<Path
|
|
7
|
-
|
|
7
|
+
fillRule="evenodd"
|
|
8
|
+
clipRule="evenodd"
|
|
9
|
+
d="M0 12C3.16267e-09 11.7348 0.105357 11.4804 0.292893 11.2929L6.29289 5.29289C6.68342 4.90237 7.31658 4.90237 7.70711 5.29289C8.09763 5.68342 8.09763 6.31658 7.70711 6.70711L2.41421 12L7.70711 17.2929C8.09763 17.6834 8.09763 18.3166 7.70711 18.7071C7.31658 19.0976 6.68342 19.0976 6.29289 18.7071L0.292893 12.7071C0.105357 12.5196 -3.16267e-09 12.2652 0 12Z"
|
|
8
10
|
/>,
|
|
9
11
|
'ChevronLeft',
|
|
12
|
+
'0 0 8 24',
|
|
10
13
|
);
|
|
@@ -4,7 +4,10 @@ import { createSvgIcon } from '../../utils';
|
|
|
4
4
|
|
|
5
5
|
export default createSvgIcon(
|
|
6
6
|
<Path
|
|
7
|
-
|
|
7
|
+
fillRule="evenodd"
|
|
8
|
+
clipRule="evenodd"
|
|
9
|
+
d="M8 12C8 12.2652 7.89464 12.5196 7.70711 12.7071L1.70711 18.7071C1.31658 19.0976 0.683417 19.0976 0.292892 18.7071C-0.0976309 18.3166 -0.0976309 17.6834 0.292893 17.2929L5.58579 12L0.292894 6.70711C-0.0976304 6.31658 -0.0976304 5.68342 0.292895 5.29289C0.683418 4.90237 1.31658 4.90237 1.70711 5.29289L7.70711 11.2929C7.89464 11.4804 8 11.7348 8 12Z"
|
|
8
10
|
/>,
|
|
9
11
|
'ChevronRight',
|
|
12
|
+
'0 0 8 24',
|
|
10
13
|
);
|
|
@@ -4,7 +4,10 @@ import { createSvgIcon } from '../../utils';
|
|
|
4
4
|
|
|
5
5
|
export default createSvgIcon(
|
|
6
6
|
<Path
|
|
7
|
-
|
|
7
|
+
fillRule="evenodd"
|
|
8
|
+
clipRule="evenodd"
|
|
9
|
+
d="M0.292893 5.29289C0.683417 4.90237 1.31658 4.90237 1.70711 5.29289L7 10.5858L12.2929 5.29289C12.6834 4.90237 13.3166 4.90237 13.7071 5.29289C14.0976 5.68342 14.0976 6.31658 13.7071 6.70711L8.41421 12L13.7071 17.2929C14.0976 17.6834 14.0976 18.3166 13.7071 18.7071C13.3166 19.0976 12.6834 19.0976 12.2929 18.7071L7 13.4142L1.70711 18.7071C1.31658 19.0976 0.683417 19.0976 0.292893 18.7071C-0.0976311 18.3166 -0.0976311 17.6834 0.292893 17.2929L5.58579 12L0.292893 6.70711C-0.0976311 6.31658 -0.0976311 5.68342 0.292893 5.29289Z"
|
|
8
10
|
/>,
|
|
9
11
|
'Close',
|
|
12
|
+
'0 0 14 24',
|
|
10
13
|
);
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ORIGINAL_OPACITY = exports.DISABLED_OPACITY = void 0;
|
|
7
|
-
exports.default = ButtonBase;
|
|
8
|
-
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
|
|
11
|
-
var _reactNative = require("react-native");
|
|
12
|
-
|
|
13
|
-
var _hooks = require("../hooks");
|
|
14
|
-
|
|
15
|
-
var _utils = require("../utils");
|
|
16
|
-
|
|
17
|
-
var _animated = require("../animated");
|
|
18
|
-
|
|
19
|
-
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); }
|
|
20
|
-
|
|
21
|
-
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
|
-
|
|
23
|
-
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
|
-
|
|
25
|
-
const ORIGINAL_OPACITY = 1;
|
|
26
|
-
exports.ORIGINAL_OPACITY = ORIGINAL_OPACITY;
|
|
27
|
-
const DISABLED_OPACITY = .3;
|
|
28
|
-
exports.DISABLED_OPACITY = DISABLED_OPACITY;
|
|
29
|
-
const ACTIVE_OPACITY = .65;
|
|
30
|
-
const ORIGINAL_SCALE = 1;
|
|
31
|
-
const MINIFIED_SCALE = .96; // at "node_modules/react-native/Libraries/Pressability.js"
|
|
32
|
-
// const DEFAULT_MIN_PRESS_DURATION = 130;
|
|
33
|
-
|
|
34
|
-
const SCALE_EFFECT_PRESS_IN_DELAY = 130;
|
|
35
|
-
const OPACITY_EFFECT_PRESS_IN_DELAY = 0;
|
|
36
|
-
|
|
37
|
-
const startTimingAnimationWithDefaults = (value, toValue) => {
|
|
38
|
-
_reactNative.Animated.timing(value, {
|
|
39
|
-
toValue,
|
|
40
|
-
duration: 150,
|
|
41
|
-
useNativeDriver: _utils.isNotAndroid12
|
|
42
|
-
}).start();
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const getOpacityByDisabled = disabled => disabled ? DISABLED_OPACITY : ORIGINAL_OPACITY;
|
|
46
|
-
|
|
47
|
-
function ButtonBase(props) {
|
|
48
|
-
const {
|
|
49
|
-
children,
|
|
50
|
-
disabled = false,
|
|
51
|
-
disableThrottle = false,
|
|
52
|
-
onPress,
|
|
53
|
-
onPressOut,
|
|
54
|
-
pressEffect = 'opacity',
|
|
55
|
-
pressDelay: pressDelayOrNil,
|
|
56
|
-
style: styleProp,
|
|
57
|
-
throttleMillis = 650,
|
|
58
|
-
...otherProps
|
|
59
|
-
} = props;
|
|
60
|
-
const handlePress = (0, _hooks.useThrottle)({
|
|
61
|
-
periodMillis: disableThrottle ? 0 : throttleMillis,
|
|
62
|
-
callback: onPress
|
|
63
|
-
});
|
|
64
|
-
const opacity = (0, _hooks.useAnimatedValue)(getOpacityByDisabled(disabled));
|
|
65
|
-
const scale = (0, _hooks.useAnimatedValue)(ORIGINAL_SCALE);
|
|
66
|
-
(0, _react.useEffect)(() => {
|
|
67
|
-
opacity.setValue(getOpacityByDisabled(disabled));
|
|
68
|
-
}, [disabled, pressEffect]);
|
|
69
|
-
const startScaleAnimation = (0, _react.useCallback)((pressIn, isHover) => {
|
|
70
|
-
if (!isHover) {
|
|
71
|
-
startTimingAnimationWithDefaults(scale, pressIn ? MINIFIED_SCALE : ORIGINAL_SCALE);
|
|
72
|
-
}
|
|
73
|
-
}, []);
|
|
74
|
-
const startOpacityAnimation = (0, _react.useCallback)(pressIn => {
|
|
75
|
-
if (pressIn) {
|
|
76
|
-
opacity.setValue(ACTIVE_OPACITY);
|
|
77
|
-
} else {
|
|
78
|
-
startTimingAnimationWithDefaults(opacity, ORIGINAL_OPACITY);
|
|
79
|
-
}
|
|
80
|
-
}, []);
|
|
81
|
-
const startPressAnimation = (0, _react.useCallback)(function (pressIn) {
|
|
82
|
-
let isHover = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
83
|
-
|
|
84
|
-
if (pressEffect === 'scale') {
|
|
85
|
-
startScaleAnimation(pressIn, isHover);
|
|
86
|
-
} else if (pressEffect === 'opacity') {
|
|
87
|
-
startOpacityAnimation(pressIn, isHover);
|
|
88
|
-
}
|
|
89
|
-
}, [pressEffect]);
|
|
90
|
-
const handlePressIn = (0, _react.useCallback)(() => {
|
|
91
|
-
startPressAnimation(true, false);
|
|
92
|
-
}, [startPressAnimation]);
|
|
93
|
-
const handlePressOut = (0, _react.useCallback)(() => {
|
|
94
|
-
onPressOut && onPressOut();
|
|
95
|
-
startPressAnimation(false, false);
|
|
96
|
-
}, [startPressAnimation, onPressOut]);
|
|
97
|
-
const animatedStyle = {
|
|
98
|
-
opacity,
|
|
99
|
-
transform: [{
|
|
100
|
-
scale
|
|
101
|
-
}]
|
|
102
|
-
};
|
|
103
|
-
const defaultPressDelay = pressEffect === 'scale' ? SCALE_EFFECT_PRESS_IN_DELAY : OPACITY_EFFECT_PRESS_IN_DELAY;
|
|
104
|
-
const pressDelay = pressDelayOrNil ?? defaultPressDelay;
|
|
105
|
-
return /*#__PURE__*/_react.default.createElement(_animated.AnimatedPressable, _extends({
|
|
106
|
-
disabled: disabled,
|
|
107
|
-
onPress: handlePress,
|
|
108
|
-
onPressIn: handlePressIn,
|
|
109
|
-
onPressOut: handlePressOut,
|
|
110
|
-
style: [animatedStyle, styleProp],
|
|
111
|
-
unstable_pressDelay: pressDelay
|
|
112
|
-
}, otherProps), typeof children !== 'function' ? _ref => {
|
|
113
|
-
let {
|
|
114
|
-
hovered
|
|
115
|
-
} = _ref;
|
|
116
|
-
|
|
117
|
-
if (hovered !== undefined && !disabled) {
|
|
118
|
-
startPressAnimation(hovered, true);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return children;
|
|
122
|
-
} : children);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
;
|
|
126
|
-
//# sourceMappingURL=LegacyButtonBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ORIGINAL_OPACITY","DISABLED_OPACITY","ACTIVE_OPACITY","ORIGINAL_SCALE","MINIFIED_SCALE","SCALE_EFFECT_PRESS_IN_DELAY","OPACITY_EFFECT_PRESS_IN_DELAY","startTimingAnimationWithDefaults","value","toValue","Animated","timing","duration","useNativeDriver","isNotAndroid12","start","getOpacityByDisabled","disabled","ButtonBase","props","children","disableThrottle","onPress","onPressOut","pressEffect","pressDelay","pressDelayOrNil","style","styleProp","throttleMillis","otherProps","handlePress","useThrottle","periodMillis","callback","opacity","useAnimatedValue","scale","useEffect","setValue","startScaleAnimation","useCallback","pressIn","isHover","startOpacityAnimation","startPressAnimation","handlePressIn","handlePressOut","animatedStyle","transform","defaultPressDelay","hovered","undefined"],"sources":["LegacyButtonBase.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from 'react';\nimport { Animated } from 'react-native';\nimport { useAnimatedValue, useThrottle } from '../hooks';\nimport { isNotAndroid12 } from '../utils';\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;\nconst OPACITY_EFFECT_PRESS_IN_DELAY = 0;\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: isNotAndroid12,\n }).start();\n};\n\nconst getOpacityByDisabled = (disabled: boolean) => disabled ? DISABLED_OPACITY : ORIGINAL_OPACITY;\n\nexport default function ButtonBase(props: ButtonBaseProps) {\n const {\n children,\n disabled = false,\n disableThrottle = false,\n onPress,\n onPressOut,\n pressEffect = 'opacity',\n pressDelay: pressDelayOrNil,\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 = useAnimatedValue(getOpacityByDisabled(disabled));\n const scale = useAnimatedValue(ORIGINAL_SCALE);\n\n useEffect(() => {\n opacity.setValue(getOpacityByDisabled(disabled));\n }, [disabled, pressEffect]);\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 onPressOut && onPressOut();\n\n startPressAnimation(false, false);\n }, [startPressAnimation, onPressOut]);\n\n const animatedStyle = {\n opacity,\n transform: [{ scale }],\n };\n\n const defaultPressDelay = pressEffect === 'scale'\n ? SCALE_EFFECT_PRESS_IN_DELAY\n : OPACITY_EFFECT_PRESS_IN_DELAY;\n const pressDelay = pressDelayOrNil ?? defaultPressDelay;\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":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAOO,MAAMA,g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;MAAEZ;IAAF,CAAD;EAFO,CAAtB;EAKA,MAAMa,iBAAiB,GAAG1B,WAAW,KAAK,OAAhB,GACpBnB,2BADoB,GAEpBC,6BAFN;EAGA,MAAMmB,UAAU,GAAGC,eAAe,IAAIwB,iBAAtC;EAEA,oBACI,6BAAC,2BAAD;IACI,QAAQ,EAAEjC,QADd;IAEI,OAAO,EAAEc,WAFb;IAGI,SAAS,EAAEe,aAHf;IAII,UAAU,EAAEC,cAJhB;IAKI,KAAK,EAAE,CACHC,aADG,EAEHpB,SAFG,CALX;IASI,mBAAmB,EAAEH;EATzB,GAUQK,UAVR,GAYK,OAAOV,QAAP,KAAoB,UAApB,GACG,QAAiB;IAAA,IAAhB;MAAE+B;IAAF,CAAgB;;IACb,IAAIA,OAAO,KAAKC,SAAZ,IAAyB,CAACnC,QAA9B,EAAwC;MACpC4B,mBAAmB,CAACM,OAAD,EAAU,IAAV,CAAnB;IACH;;IAED,OAAO/B,QAAP;EACH,CAPJ,GAQGA,QApBR,CADJ;AAwBH;;AAAA"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
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); }
|
|
2
|
-
|
|
3
|
-
import React, { useCallback, useEffect } from 'react';
|
|
4
|
-
import { Animated } from 'react-native';
|
|
5
|
-
import { useAnimatedValue, useThrottle } from '../hooks';
|
|
6
|
-
import { isNotAndroid12 } from '../utils';
|
|
7
|
-
import { AnimatedPressable } from '../animated';
|
|
8
|
-
export const ORIGINAL_OPACITY = 1;
|
|
9
|
-
export const DISABLED_OPACITY = .3;
|
|
10
|
-
const ACTIVE_OPACITY = .65;
|
|
11
|
-
const ORIGINAL_SCALE = 1;
|
|
12
|
-
const MINIFIED_SCALE = .96; // at "node_modules/react-native/Libraries/Pressability.js"
|
|
13
|
-
// const DEFAULT_MIN_PRESS_DURATION = 130;
|
|
14
|
-
|
|
15
|
-
const SCALE_EFFECT_PRESS_IN_DELAY = 130;
|
|
16
|
-
const OPACITY_EFFECT_PRESS_IN_DELAY = 0;
|
|
17
|
-
|
|
18
|
-
const startTimingAnimationWithDefaults = (value, toValue) => {
|
|
19
|
-
Animated.timing(value, {
|
|
20
|
-
toValue,
|
|
21
|
-
duration: 150,
|
|
22
|
-
useNativeDriver: isNotAndroid12
|
|
23
|
-
}).start();
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const getOpacityByDisabled = disabled => disabled ? DISABLED_OPACITY : ORIGINAL_OPACITY;
|
|
27
|
-
|
|
28
|
-
export default function ButtonBase(props) {
|
|
29
|
-
const {
|
|
30
|
-
children,
|
|
31
|
-
disabled = false,
|
|
32
|
-
disableThrottle = false,
|
|
33
|
-
onPress,
|
|
34
|
-
onPressOut,
|
|
35
|
-
pressEffect = 'opacity',
|
|
36
|
-
pressDelay: pressDelayOrNil,
|
|
37
|
-
style: styleProp,
|
|
38
|
-
throttleMillis = 650,
|
|
39
|
-
...otherProps
|
|
40
|
-
} = props;
|
|
41
|
-
const handlePress = useThrottle({
|
|
42
|
-
periodMillis: disableThrottle ? 0 : throttleMillis,
|
|
43
|
-
callback: onPress
|
|
44
|
-
});
|
|
45
|
-
const opacity = useAnimatedValue(getOpacityByDisabled(disabled));
|
|
46
|
-
const scale = useAnimatedValue(ORIGINAL_SCALE);
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
opacity.setValue(getOpacityByDisabled(disabled));
|
|
49
|
-
}, [disabled, pressEffect]);
|
|
50
|
-
const startScaleAnimation = useCallback((pressIn, isHover) => {
|
|
51
|
-
if (!isHover) {
|
|
52
|
-
startTimingAnimationWithDefaults(scale, pressIn ? MINIFIED_SCALE : ORIGINAL_SCALE);
|
|
53
|
-
}
|
|
54
|
-
}, []);
|
|
55
|
-
const startOpacityAnimation = useCallback(pressIn => {
|
|
56
|
-
if (pressIn) {
|
|
57
|
-
opacity.setValue(ACTIVE_OPACITY);
|
|
58
|
-
} else {
|
|
59
|
-
startTimingAnimationWithDefaults(opacity, ORIGINAL_OPACITY);
|
|
60
|
-
}
|
|
61
|
-
}, []);
|
|
62
|
-
const startPressAnimation = useCallback(function (pressIn) {
|
|
63
|
-
let isHover = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
64
|
-
|
|
65
|
-
if (pressEffect === 'scale') {
|
|
66
|
-
startScaleAnimation(pressIn, isHover);
|
|
67
|
-
} else if (pressEffect === 'opacity') {
|
|
68
|
-
startOpacityAnimation(pressIn, isHover);
|
|
69
|
-
}
|
|
70
|
-
}, [pressEffect]);
|
|
71
|
-
const handlePressIn = useCallback(() => {
|
|
72
|
-
startPressAnimation(true, false);
|
|
73
|
-
}, [startPressAnimation]);
|
|
74
|
-
const handlePressOut = useCallback(() => {
|
|
75
|
-
onPressOut && onPressOut();
|
|
76
|
-
startPressAnimation(false, false);
|
|
77
|
-
}, [startPressAnimation, onPressOut]);
|
|
78
|
-
const animatedStyle = {
|
|
79
|
-
opacity,
|
|
80
|
-
transform: [{
|
|
81
|
-
scale
|
|
82
|
-
}]
|
|
83
|
-
};
|
|
84
|
-
const defaultPressDelay = pressEffect === 'scale' ? SCALE_EFFECT_PRESS_IN_DELAY : OPACITY_EFFECT_PRESS_IN_DELAY;
|
|
85
|
-
const pressDelay = pressDelayOrNil ?? defaultPressDelay;
|
|
86
|
-
return /*#__PURE__*/React.createElement(AnimatedPressable, _extends({
|
|
87
|
-
disabled: disabled,
|
|
88
|
-
onPress: handlePress,
|
|
89
|
-
onPressIn: handlePressIn,
|
|
90
|
-
onPressOut: handlePressOut,
|
|
91
|
-
style: [animatedStyle, styleProp],
|
|
92
|
-
unstable_pressDelay: pressDelay
|
|
93
|
-
}, otherProps), typeof children !== 'function' ? _ref => {
|
|
94
|
-
let {
|
|
95
|
-
hovered
|
|
96
|
-
} = _ref;
|
|
97
|
-
|
|
98
|
-
if (hovered !== undefined && !disabled) {
|
|
99
|
-
startPressAnimation(hovered, true);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return children;
|
|
103
|
-
} : children);
|
|
104
|
-
}
|
|
105
|
-
;
|
|
106
|
-
//# sourceMappingURL=LegacyButtonBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","Animated","useAnimatedValue","useThrottle","isNotAndroid12","AnimatedPressable","ORIGINAL_OPACITY","DISABLED_OPACITY","ACTIVE_OPACITY","ORIGINAL_SCALE","MINIFIED_SCALE","SCALE_EFFECT_PRESS_IN_DELAY","OPACITY_EFFECT_PRESS_IN_DELAY","startTimingAnimationWithDefaults","value","toValue","timing","duration","useNativeDriver","start","getOpacityByDisabled","disabled","ButtonBase","props","children","disableThrottle","onPress","onPressOut","pressEffect","pressDelay","pressDelayOrNil","style","styleProp","throttleMillis","otherProps","handlePress","periodMillis","callback","opacity","scale","setValue","startScaleAnimation","pressIn","isHover","startOpacityAnimation","startPressAnimation","handlePressIn","handlePressOut","animatedStyle","transform","defaultPressDelay","hovered","undefined"],"sources":["LegacyButtonBase.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from 'react';\nimport { Animated } from 'react-native';\nimport { useAnimatedValue, useThrottle } from '../hooks';\nimport { isNotAndroid12 } from '../utils';\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;\nconst OPACITY_EFFECT_PRESS_IN_DELAY = 0;\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: isNotAndroid12,\n }).start();\n};\n\nconst getOpacityByDisabled = (disabled: boolean) => disabled ? DISABLED_OPACITY : ORIGINAL_OPACITY;\n\nexport default function ButtonBase(props: ButtonBaseProps) {\n const {\n children,\n disabled = false,\n disableThrottle = false,\n onPress,\n onPressOut,\n pressEffect = 'opacity',\n pressDelay: pressDelayOrNil,\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 = useAnimatedValue(getOpacityByDisabled(disabled));\n const scale = useAnimatedValue(ORIGINAL_SCALE);\n\n useEffect(() => {\n opacity.setValue(getOpacityByDisabled(disabled));\n }, [disabled, pressEffect]);\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 onPressOut && onPressOut();\n\n startPressAnimation(false, false);\n }, [startPressAnimation, onPressOut]);\n\n const animatedStyle = {\n opacity,\n transform: [{ scale }],\n };\n\n const defaultPressDelay = pressEffect === 'scale'\n ? SCALE_EFFECT_PRESS_IN_DELAY\n : OPACITY_EFFECT_PRESS_IN_DELAY;\n const pressDelay = pressDelayOrNil ?? defaultPressDelay;\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":";;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,QAA8C,OAA9C;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,gBAAT,EAA2BC,WAA3B,QAA8C,UAA9C;AACA,SAASC,cAAT,QAA+B,UAA/B;AACA,SAASC,iBAAT,QAAkC,aAAlC;AAOA,OAAO,MAAMC,gBAAgB,GAAG,CAAzB;AACP,OAAO,MAAMC,gBAAgB,GAAG,EAAzB;AACP,MAAMC,cAAc,GAAG,GAAvB;AAEA,MAAMC,cAAc,GAAG,CAAvB;AACA,MAAMC,cAAc,GAAG,GAAvB,C,CAEA;AACA;;AACA,MAAMC,2BAA2B,GAAG,GAApC;AACA,MAAMC,6BAA6B,GAAG,CAAtC;;AAKA,MAAMC,gCAAgC,GAAG,CACrCC,KADqC,EAErCC,OAFqC,KAGpC;EACDd,QAAQ,CAACe,MAAT,CAAgBF,KAAhB,EAAuB;IACnBC,OADmB;IAEnBE,QAAQ,EAAE,GAFS;IAGnBC,eAAe,EAAEd;EAHE,CAAvB,EAIGe,KAJH;AAKH,CATD;;AAWA,MAAMC,oBAAoB,GAAIC,QAAD,IAAuBA,QAAQ,GAAGd,gBAAH,GAAsBD,gBAAlF;;AAEA,eAAe,SAASgB,UAAT,CAAoBC,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,GAQGA,QApBR,CADJ;AAwBH;AAAA"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect } from 'react';
|
|
2
|
-
import { Animated } from 'react-native';
|
|
3
|
-
import { useAnimatedValue, useThrottle } from '../hooks';
|
|
4
|
-
import { isNotAndroid12 } from '../utils';
|
|
5
|
-
import { AnimatedPressable } from '../animated';
|
|
6
|
-
import type ButtonBaseProps from './ButtonBaseProps';
|
|
7
|
-
|
|
8
|
-
interface StartPressAnimation {
|
|
9
|
-
(pressIn: boolean, isHover: boolean): void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const ORIGINAL_OPACITY = 1;
|
|
13
|
-
export const DISABLED_OPACITY = .3;
|
|
14
|
-
const ACTIVE_OPACITY = .65;
|
|
15
|
-
|
|
16
|
-
const ORIGINAL_SCALE = 1;
|
|
17
|
-
const MINIFIED_SCALE = .96;
|
|
18
|
-
|
|
19
|
-
// at "node_modules/react-native/Libraries/Pressability.js"
|
|
20
|
-
// const DEFAULT_MIN_PRESS_DURATION = 130;
|
|
21
|
-
const SCALE_EFFECT_PRESS_IN_DELAY = 130;
|
|
22
|
-
const OPACITY_EFFECT_PRESS_IN_DELAY = 0;
|
|
23
|
-
|
|
24
|
-
type TimingAnimationValue = Animated.Value | Animated.ValueXY;
|
|
25
|
-
type TimingAnimationToValue = Animated.TimingAnimationConfig['toValue'];
|
|
26
|
-
|
|
27
|
-
const startTimingAnimationWithDefaults = (
|
|
28
|
-
value: TimingAnimationValue,
|
|
29
|
-
toValue: TimingAnimationToValue,
|
|
30
|
-
) => {
|
|
31
|
-
Animated.timing(value, {
|
|
32
|
-
toValue,
|
|
33
|
-
duration: 150,
|
|
34
|
-
useNativeDriver: isNotAndroid12,
|
|
35
|
-
}).start();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const getOpacityByDisabled = (disabled: boolean) => disabled ? DISABLED_OPACITY : ORIGINAL_OPACITY;
|
|
39
|
-
|
|
40
|
-
export default function ButtonBase(props: ButtonBaseProps) {
|
|
41
|
-
const {
|
|
42
|
-
children,
|
|
43
|
-
disabled = false,
|
|
44
|
-
disableThrottle = false,
|
|
45
|
-
onPress,
|
|
46
|
-
onPressOut,
|
|
47
|
-
pressEffect = 'opacity',
|
|
48
|
-
pressDelay: pressDelayOrNil,
|
|
49
|
-
style: styleProp,
|
|
50
|
-
throttleMillis = 650,
|
|
51
|
-
...otherProps
|
|
52
|
-
} = props;
|
|
53
|
-
|
|
54
|
-
const handlePress = useThrottle({
|
|
55
|
-
periodMillis: disableThrottle ? 0 : throttleMillis,
|
|
56
|
-
callback: onPress,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const opacity = useAnimatedValue(getOpacityByDisabled(disabled));
|
|
60
|
-
const scale = useAnimatedValue(ORIGINAL_SCALE);
|
|
61
|
-
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
opacity.setValue(getOpacityByDisabled(disabled));
|
|
64
|
-
}, [disabled, pressEffect]);
|
|
65
|
-
|
|
66
|
-
const startScaleAnimation = useCallback<StartPressAnimation>((pressIn, isHover) => {
|
|
67
|
-
if (!isHover) {
|
|
68
|
-
startTimingAnimationWithDefaults(
|
|
69
|
-
scale,
|
|
70
|
-
pressIn ? MINIFIED_SCALE : ORIGINAL_SCALE,
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
}, []);
|
|
74
|
-
|
|
75
|
-
const startOpacityAnimation = useCallback<StartPressAnimation>((pressIn) => {
|
|
76
|
-
if (pressIn) {
|
|
77
|
-
opacity.setValue(ACTIVE_OPACITY);
|
|
78
|
-
} else {
|
|
79
|
-
startTimingAnimationWithDefaults(opacity, ORIGINAL_OPACITY);
|
|
80
|
-
}
|
|
81
|
-
}, []);
|
|
82
|
-
|
|
83
|
-
const startPressAnimation = useCallback<StartPressAnimation>((pressIn, isHover = false) => {
|
|
84
|
-
if (pressEffect === 'scale') {
|
|
85
|
-
startScaleAnimation(pressIn, isHover);
|
|
86
|
-
} else if (pressEffect === 'opacity') {
|
|
87
|
-
startOpacityAnimation(pressIn, isHover);
|
|
88
|
-
}
|
|
89
|
-
}, [pressEffect]);
|
|
90
|
-
|
|
91
|
-
const handlePressIn = useCallback(() => {
|
|
92
|
-
startPressAnimation(true, false);
|
|
93
|
-
}, [startPressAnimation]);
|
|
94
|
-
|
|
95
|
-
const handlePressOut = useCallback(() => {
|
|
96
|
-
onPressOut && onPressOut();
|
|
97
|
-
|
|
98
|
-
startPressAnimation(false, false);
|
|
99
|
-
}, [startPressAnimation, onPressOut]);
|
|
100
|
-
|
|
101
|
-
const animatedStyle = {
|
|
102
|
-
opacity,
|
|
103
|
-
transform: [{ scale }],
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const defaultPressDelay = pressEffect === 'scale'
|
|
107
|
-
? SCALE_EFFECT_PRESS_IN_DELAY
|
|
108
|
-
: OPACITY_EFFECT_PRESS_IN_DELAY;
|
|
109
|
-
const pressDelay = pressDelayOrNil ?? defaultPressDelay;
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<AnimatedPressable
|
|
113
|
-
disabled={disabled}
|
|
114
|
-
onPress={handlePress}
|
|
115
|
-
onPressIn={handlePressIn}
|
|
116
|
-
onPressOut={handlePressOut}
|
|
117
|
-
style={[
|
|
118
|
-
animatedStyle,
|
|
119
|
-
styleProp,
|
|
120
|
-
]}
|
|
121
|
-
unstable_pressDelay={pressDelay}
|
|
122
|
-
{...otherProps}
|
|
123
|
-
>
|
|
124
|
-
{typeof children !== 'function' ? (
|
|
125
|
-
({ hovered }) => {
|
|
126
|
-
if (hovered !== undefined && !disabled) {
|
|
127
|
-
startPressAnimation(hovered, true);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return children;
|
|
131
|
-
}
|
|
132
|
-
) : children}
|
|
133
|
-
</AnimatedPressable>
|
|
134
|
-
);
|
|
135
|
-
};
|