@fto-consult/expo-ui 8.82.9 → 8.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fto-consult/expo-ui",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.83.0",
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
5
|
"react-native-paper-doc": "https://github.com/callstack/react-native-paper/tree/main/docs/docs/guides",
|
6
6
|
"scripts": {
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { Pressable } from "react-native";
|
2
|
+
import { forwardRef,useRef } from "react";
|
3
|
+
import PropTypes from "prop-types";
|
4
|
+
|
5
|
+
const PressableComponent = forwardRef(({onPress,pressDelay,onDoublePress,disabled,readOnly,...props},ref)=>{
|
6
|
+
const lastPressRef = useRef=(0);
|
7
|
+
pressDelay = typeof pressDelay =="number" && pressDelay > 10 ? pressDelay : 400;
|
8
|
+
return <Pressable
|
9
|
+
{...props}
|
10
|
+
onPress = {disabled !== true && readOnly !== true ? (...rest)=>{
|
11
|
+
const delta = new Date().getTime() - lastPressRef.current;
|
12
|
+
lastPressRef.current = new Date().getTime();
|
13
|
+
if(delta < pressDelay && typeof onDoublePress ==="function") {
|
14
|
+
// double tap happend
|
15
|
+
onDoublePress(...rest);
|
16
|
+
}
|
17
|
+
if(typeof onPress =="function"){
|
18
|
+
onPress(...rest);
|
19
|
+
}
|
20
|
+
}: onPress}
|
21
|
+
/>
|
22
|
+
});
|
23
|
+
|
24
|
+
PressableComponent.displayName = "PressableComponent";
|
25
|
+
|
26
|
+
PressableComponent.propTypes = {
|
27
|
+
...Object.assign({},Pressable.propTypes),
|
28
|
+
pressDelay : PropTypes.number, //le délai d'attente de l'action press, par défaut 400 milli secondes
|
29
|
+
onDoublePress : PropTypes.func,
|
30
|
+
}
|