@fto-consult/expo-ui 5.4.0 → 5.5.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": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@emotion/native": "^11.10.0",
|
|
62
62
|
"@expo/html-elements": "^0.2.0",
|
|
63
63
|
"@expo/vector-icons": "^13.0.0",
|
|
64
|
-
"@fto-consult/common": "^3.3.
|
|
64
|
+
"@fto-consult/common": "^3.3.6",
|
|
65
65
|
"@gorhom/portal": "^1.0.14",
|
|
66
66
|
"@react-native-async-storage/async-storage": "^1.17.11",
|
|
67
67
|
"@react-native-community/datetimepicker": "^6.7.3",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"react-native-blob-util": "^0.17.0",
|
|
97
97
|
"react-native-gesture-handler": "~2.9.0",
|
|
98
98
|
"react-native-mime-types": "^2.3.0",
|
|
99
|
-
"react-native-paper": "^4.
|
|
100
|
-
"react-native-paper-dates": "^0.
|
|
99
|
+
"react-native-paper": "^5.4.1",
|
|
100
|
+
"react-native-paper-dates": "^0.15.1",
|
|
101
101
|
"react-native-reanimated": "~2.14.4",
|
|
102
102
|
"react-native-safe-area-context": "^4.5.0",
|
|
103
103
|
"react-native-screens": "~3.20.0",
|
|
@@ -11,17 +11,15 @@ const BottomSheetMenuComponent = React.forwardRef((props,ref)=>{
|
|
|
11
11
|
let {anchor,anchorProps,screenIndent,height:customHeight,bindResizeEvent,onDismiss,testID,visible:customVisible,controlled,mobile,animateOnClose,renderMenuContent,sheet,children,...rest} = props;
|
|
12
12
|
rest = defaultObj(rest);
|
|
13
13
|
const isControlled = controlled ? true : false;
|
|
14
|
-
const visibleRef = React.useRef(null);
|
|
15
14
|
const [state,setState] = React.useState({
|
|
16
15
|
visible : false,
|
|
17
16
|
height : undefined,
|
|
18
17
|
});
|
|
19
|
-
const visible =
|
|
20
|
-
visibleRef.current = null;
|
|
18
|
+
const visible = isControlled ? customVisible : state.visible;
|
|
21
19
|
let height = state.height;
|
|
22
20
|
const isMounted = React.useIsMounted();
|
|
23
21
|
const anchorRef = React.useRef(null);
|
|
24
|
-
const isMobile = x=> mobile || sheet === true || renderMenuContent === false ||
|
|
22
|
+
const isMobile = x=> mobile || sheet === true || renderMenuContent === false || isMob ? true : false;
|
|
25
23
|
let isMob = isMobile();
|
|
26
24
|
testID = defaultStr(testID,'RN_BottomSheetMenuComponent');
|
|
27
25
|
const innerRef = React.useRef(null);
|
|
@@ -32,9 +30,9 @@ const BottomSheetMenuComponent = React.forwardRef((props,ref)=>{
|
|
|
32
30
|
getContentHeight(anchorRef,({height})=>{
|
|
33
31
|
setState({...state,visible:true,height});
|
|
34
32
|
},screenIndent);
|
|
35
|
-
}, close = ()=>{
|
|
36
|
-
if(!isMobile()) return;
|
|
37
|
-
if(!isMounted() || !visible) return;
|
|
33
|
+
}, close = (force)=>{
|
|
34
|
+
if(force !== true && !isMobile()) return;
|
|
35
|
+
if(!isMounted() || (force !== true && !visible)) return;
|
|
38
36
|
if(isControlled){
|
|
39
37
|
if(onDismiss){
|
|
40
38
|
onDismiss({});
|
|
@@ -43,6 +41,7 @@ const BottomSheetMenuComponent = React.forwardRef((props,ref)=>{
|
|
|
43
41
|
}
|
|
44
42
|
setState({...state,visible:false})
|
|
45
43
|
}
|
|
44
|
+
const prevIsMob = React.usePrevious(isMob);
|
|
46
45
|
const Component = isMob ? BottomSheet : Menu;
|
|
47
46
|
anchorProps = defaultObj(anchorProps);
|
|
48
47
|
if(isMob){
|
|
@@ -67,6 +66,9 @@ const BottomSheetMenuComponent = React.forwardRef((props,ref)=>{
|
|
|
67
66
|
delete rest.visible;
|
|
68
67
|
height = undefined;
|
|
69
68
|
}
|
|
69
|
+
if(prevIsMob !== isMob){
|
|
70
|
+
rest.visible = visible;
|
|
71
|
+
}
|
|
70
72
|
if(!isControlled){
|
|
71
73
|
rest.onAnchorPress = ()=>{
|
|
72
74
|
open();
|
|
@@ -77,8 +79,7 @@ const BottomSheetMenuComponent = React.forwardRef((props,ref)=>{
|
|
|
77
79
|
React.useEffect(()=>{
|
|
78
80
|
const closeModal = ()=>{
|
|
79
81
|
if(!isMounted()) return;
|
|
80
|
-
|
|
81
|
-
setState({...state});
|
|
82
|
+
close(true);
|
|
82
83
|
}
|
|
83
84
|
if(bindResizeEvent !== false){
|
|
84
85
|
APP.on(APP.EVENTS.RESIZE_PAGE,closeModal);
|
|
@@ -47,18 +47,9 @@ class _Menu extends AppComponent {
|
|
|
47
47
|
statusBarHeight: APPROX_STATUSBAR_HEIGHT,
|
|
48
48
|
overlayAccessibilityLabel: 'Close menu',
|
|
49
49
|
};
|
|
50
|
-
|
|
51
|
-
static getDerivedStateFromProps1(nextProps, prevState) {
|
|
52
|
-
if (nextProps.visible && !prevState.rendered) {
|
|
53
|
-
return { rendered: true };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
50
|
constructor(props){
|
|
59
51
|
super(props);
|
|
60
52
|
extendObj(this.state,{
|
|
61
|
-
rendered: this.props.visible,
|
|
62
53
|
top: 0,
|
|
63
54
|
left: 0,
|
|
64
55
|
menuLayout: { width: 0, height: 0 },
|
|
@@ -78,17 +69,13 @@ class _Menu extends AppComponent {
|
|
|
78
69
|
componentWillUnmount() {
|
|
79
70
|
super.componentWillUnmount();
|
|
80
71
|
this.removeListeners();
|
|
72
|
+
this.menu = null;
|
|
73
|
+
this.anchor = null;
|
|
81
74
|
}
|
|
82
75
|
|
|
83
76
|
anchor = null;
|
|
84
|
-
menu = null;
|
|
85
77
|
backHandlerSubscription;
|
|
86
78
|
|
|
87
|
-
isCoordinate = (anchor) =>
|
|
88
|
-
!React.isValidElement(anchor) &&
|
|
89
|
-
typeof anchor?.x === 'number' &&
|
|
90
|
-
typeof anchor?.y === 'number';
|
|
91
|
-
|
|
92
79
|
measureMenuLayout = () =>
|
|
93
80
|
new Promise((resolve) => {
|
|
94
81
|
if (this.menu) {
|
|
@@ -100,12 +87,6 @@ class _Menu extends AppComponent {
|
|
|
100
87
|
|
|
101
88
|
measureAnchorLayout = () =>
|
|
102
89
|
new Promise((resolve) => {
|
|
103
|
-
const { anchor } = this.props;
|
|
104
|
-
if (this.isCoordinate(anchor)) {
|
|
105
|
-
resolve({ x: anchor.x, y: anchor.y, width: 0, height: 0 });
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
90
|
if (this.anchor) {
|
|
110
91
|
this.anchor.measureInWindow((x, y, width, height) => {
|
|
111
92
|
resolve({ x, y, width, height });
|
|
@@ -198,8 +179,8 @@ class _Menu extends AppComponent {
|
|
|
198
179
|
!windowLayout.height ||
|
|
199
180
|
!menuLayout.width ||
|
|
200
181
|
!menuLayout.height ||
|
|
201
|
-
(!anchorLayout.width
|
|
202
|
-
(!anchorLayout.height
|
|
182
|
+
(!anchorLayout.width) ||
|
|
183
|
+
(!anchorLayout.height)
|
|
203
184
|
) {
|
|
204
185
|
requestAnimationFrame(this.show);
|
|
205
186
|
return;
|
|
@@ -255,7 +236,7 @@ class _Menu extends AppComponent {
|
|
|
255
236
|
useNativeDriver: true,
|
|
256
237
|
}).start(({ finished }) => {
|
|
257
238
|
if (finished) {
|
|
258
|
-
this.setState({ menuLayout: { width: 0, height: 0 }
|
|
239
|
+
this.setState({ menuLayout: { width: 0, height: 0 }});
|
|
259
240
|
this.state.scaleAnimation.setValue({ x: 0, y: 0 });
|
|
260
241
|
this.focusFirstDOMNode(this.anchor);
|
|
261
242
|
}
|
|
@@ -283,8 +264,8 @@ class _Menu extends AppComponent {
|
|
|
283
264
|
opacityAnimation,
|
|
284
265
|
scaleAnimation,
|
|
285
266
|
} = this.state;
|
|
286
|
-
const rendered = visible;
|
|
287
267
|
const minWidth = defaultDecimal(customMinWidth);
|
|
268
|
+
const rendered = this.props.visible;
|
|
288
269
|
let { left, top } = this.state;
|
|
289
270
|
|
|
290
271
|
// I don't know why but on Android measure function is wrong by 24
|
|
@@ -458,7 +439,7 @@ class _Menu extends AppComponent {
|
|
|
458
439
|
|
|
459
440
|
//- (sameWidth ? anchorLayout.height : 0)
|
|
460
441
|
const positionStyle = {
|
|
461
|
-
top:
|
|
442
|
+
top: top + additionalVerticalValue,
|
|
462
443
|
...(I18nManager.isRTL ? { right: left } : { left }),
|
|
463
444
|
};
|
|
464
445
|
if(sameWidth){
|
|
@@ -474,8 +455,9 @@ class _Menu extends AppComponent {
|
|
|
474
455
|
positionStyle.top = SCREEN_INDENT;
|
|
475
456
|
}
|
|
476
457
|
const maxMenuHeight = windowLayout.height - top - SCREEN_INDENT;
|
|
477
|
-
const maxHeight = maxMenuHeight >=0 ? Math.max(Math.
|
|
458
|
+
const maxHeight = maxMenuHeight >=0 ? Math.max(Math.max(maxMenuHeight,menuLayout.height),150) : windowLayout.height - SCREEN_INDENT*2;
|
|
478
459
|
const contentContainerStyle = maxMenuHeight > SCREEN_INDENT ? {maxHeight} : undefined;
|
|
460
|
+
const hiddenStyle = !rendered ? {display:'none',width:0,opacity:0} : null;
|
|
479
461
|
return (
|
|
480
462
|
<View
|
|
481
463
|
testID = {testID}
|
|
@@ -485,17 +467,18 @@ class _Menu extends AppComponent {
|
|
|
485
467
|
collapsable={false}
|
|
486
468
|
style = {{backgroundColor:'transparent'}}
|
|
487
469
|
>
|
|
488
|
-
{
|
|
489
|
-
{
|
|
470
|
+
{anchor}
|
|
471
|
+
{true ? (
|
|
490
472
|
<Portal>
|
|
491
|
-
<TouchableWithoutFeedback
|
|
473
|
+
{rendered ? <TouchableWithoutFeedback
|
|
492
474
|
testID={testID+"_TouchableWithoutFeedBack"}
|
|
493
475
|
accessibilityLabel={overlayAccessibilityLabel}
|
|
494
476
|
accessibilityRole="button"
|
|
495
477
|
onPress={onDismiss}
|
|
478
|
+
style = {[hiddenStyle]}
|
|
496
479
|
>
|
|
497
480
|
<View style={[StyleSheet.absoluteFill,{flex:1,backgroundColor:'transparent'}]} testID={testID+"_Backdrop"} />
|
|
498
|
-
</TouchableWithoutFeedback
|
|
481
|
+
</TouchableWithoutFeedback>:null}
|
|
499
482
|
<View
|
|
500
483
|
testID = {testID+"_ContentContainer"}
|
|
501
484
|
ref={(ref) => {
|
|
@@ -503,11 +486,11 @@ class _Menu extends AppComponent {
|
|
|
503
486
|
}}
|
|
504
487
|
collapsable={false}
|
|
505
488
|
accessibilityViewIsModal={visible}
|
|
506
|
-
style={[styles.wrapper, positionStyle, style]}
|
|
489
|
+
style={[styles.wrapper, positionStyle, style,hiddenStyle]}
|
|
507
490
|
pointerEvents={visible ? 'box-none' : 'none'}
|
|
508
491
|
onAccessibilityEscape={onDismiss}
|
|
509
492
|
>
|
|
510
|
-
|
|
493
|
+
{rendered?<Animated.View style={{ transform: positionTransforms }} testID={testID+"_Animated"}>
|
|
511
494
|
<Surface
|
|
512
495
|
elevation = {5}
|
|
513
496
|
testID= {testID+"_Content"}
|
|
@@ -525,7 +508,7 @@ class _Menu extends AppComponent {
|
|
|
525
508
|
{((scrollableMenuHeight|| contentContainerStyle) && (<ScrollView contentContainerStyle={contentContainerStyle} testID={testID+"_ScrollView"}>{children}</ScrollView>
|
|
526
509
|
)) || children}
|
|
527
510
|
</Surface>
|
|
528
|
-
</Animated.View>
|
|
511
|
+
</Animated.View> : null}
|
|
529
512
|
</View>
|
|
530
513
|
</Portal>
|
|
531
514
|
) : null}
|
|
@@ -73,7 +73,7 @@ const MenuComponent = React.forwardRef((props,ref)=>{
|
|
|
73
73
|
console.error("unable to render menu, anchor not spécified for props",props);
|
|
74
74
|
}
|
|
75
75
|
const context = {openMenu,closeMenu,open:openMenu,close:closeMenu};
|
|
76
|
-
React.setRef(ref,context);
|
|
76
|
+
//React.setRef(ref,context);
|
|
77
77
|
if(typeof children =='function'){
|
|
78
78
|
children = children({openMenu,closeMenu,context});
|
|
79
79
|
}
|
|
@@ -81,8 +81,17 @@ const MenuComponent = React.forwardRef((props,ref)=>{
|
|
|
81
81
|
return ()=>{
|
|
82
82
|
React.setRef(ref,null);
|
|
83
83
|
}
|
|
84
|
-
},[])
|
|
85
|
-
return <Menu {...menuProps}
|
|
84
|
+
},[]);
|
|
85
|
+
return <Menu {...menuProps} ref={(el)=>{
|
|
86
|
+
if(el){
|
|
87
|
+
for(let i in context){
|
|
88
|
+
if(!(i in el)){
|
|
89
|
+
el[i] = context[i];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
React.setRef(ref,el);
|
|
94
|
+
}} testID={testID} visible={visible} onDismiss={closeMenu} anchor={anchor}>
|
|
86
95
|
{renderItems({...props,onPressItem,renderItem,openMenu,closeMenu})}
|
|
87
96
|
{React.isValidElement(children)? children: null}
|
|
88
97
|
</Menu>
|