@fto-consult/expo-ui 2.11.0 → 2.11.1

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": "2.11.0",
3
+ "version": "2.11.1",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,7 +1,6 @@
1
1
  import Fab from "$ecomponents/Fab";
2
2
  import {isObj,defaultStr,defaultVal,defaultObj} from "$utils";
3
3
  import React from "$react";
4
- import { StyleSheet } from 'react-native';
5
4
  import PropTypes from "prop-types";
6
5
 
7
6
  const SCREEN_INDENT = 20;
@@ -23,23 +22,21 @@ const BackToTopComponent = React.forwardRef((props,ref)=>{
23
22
  const isMounted = React.useIsMounted();
24
23
  const {onPress,accessibilityLabel,onBackToTop,onVisibilityChange,position,icon,...rProps} = props;
25
24
  const rest = defaultObj(rProps);
26
- const [state,setState] = React.useStateIfMounted({
27
- visible : false,
28
- });
25
+ const [visible,setVisible] = React.useState(false);
29
26
  const open = ()=>{
30
- if(!isMounted() || state.visible)return;
31
- setState({...state,visible:true});
27
+ if(!isMounted() || visible)return;
28
+ setVisible(true);
32
29
  }
33
30
  const close = ()=>{
34
- if(!isMounted() || !state.visible)return;
35
- setState({...state,visible:false});
31
+ if(!isMounted() || !visible)return;
32
+ setVisible(false);
36
33
  }
37
34
 
38
35
  const context = {open,close,
39
36
  toggleVisibility:(event)=>{
40
37
  if(!isMounted()) return;
41
38
  let v = toggleVisibility(event);
42
- if(typeof v =='boolean' && v !== state.visible){
39
+ if(typeof v =='boolean' && v !== visible){
43
40
  return v ? open() : close();
44
41
  }
45
42
  return undefined;
@@ -50,7 +47,7 @@ const BackToTopComponent = React.forwardRef((props,ref)=>{
50
47
  if(onVisibilityChange){
51
48
  onVisibilityChange({context,visible});
52
49
  }
53
- },[state.visible])
50
+ },[visible])
54
51
  const style = defaultStr(position).toLowerCase() =='right' ? {
55
52
  right: 0
56
53
  } : {left : 0};
@@ -58,7 +55,7 @@ const BackToTopComponent = React.forwardRef((props,ref)=>{
58
55
  React.useEffect(()=>{
59
56
  React.setRef(ref,context);
60
57
  },[])
61
- return !state.visible ? null : <Fab
58
+ return !visible ? null : <Fab
62
59
  {...rest}
63
60
  accessibilityLabel = {defaultStr(rest.accessibilityLabel,'Retour en haut')}
64
61
  onPress = {(e)=>{
@@ -20,7 +20,7 @@ import {defaultDecimal,extendObj} from "$utils";
20
20
  import theme,{StylePropTypes} from "$theme";
21
21
  import APP from "$app/instance";
22
22
  import MenuItem from "./Item";
23
- import {isWeb} from "$platform";
23
+ import { MIN_WIDTH } from './utils';
24
24
 
25
25
  const RESIZE_PAGE = APP.EVENTS.RESIZE_PAGE;
26
26
 
@@ -516,7 +516,8 @@ class _Menu extends AppComponent {
516
516
  shadowMenuContainerStyle,
517
517
  contentStyle,
518
518
  {backgroundColor : theme.colors.surface},
519
- sameWidth && anchorLayout.width ? {width:Math.max(anchorLayout.width,minWidth)} : undefined,
519
+ minWidth && {minWidth : Math.max(minWidth,MIN_WIDTH)},
520
+ sameWidth && anchorLayout.width ? {width:Math.max(anchorLayout.width,minWidth,MIN_WIDTH)} : undefined,
520
521
  ]
521
522
  }
522
523
  >
@@ -7,6 +7,7 @@ import Expandable from "$ecomponents/Expandable";
7
7
  import {cursorPointer} from "$theme";
8
8
  import Item from "./Item";
9
9
 
10
+ export const MIN_WIDTH = 150;
10
11
 
11
12
  export const renderItems = (props)=>{
12
13
  let _items = [];
@@ -20,6 +20,7 @@ const AbsoluteScrollView = React.forwardRef(({testID,contentProps,listRef,contai
20
20
  styles : {},
21
21
  visible : true,
22
22
  })
23
+ const [layoutVisible,_setLayoutVisible] = React.useState(true);
23
24
  const {styles,visible} = state,setStyles = (s)=>{
24
25
  if(isObj(s)){
25
26
  setState({...state,styles:{...styles,...s}});
@@ -31,9 +32,19 @@ const AbsoluteScrollView = React.forwardRef(({testID,contentProps,listRef,contai
31
32
  setState({...state,visible});
32
33
  }
33
34
  }
34
- }
35
+ },setVisible = (visible)=>{
36
+ if(typeof visible =='boolean' && visible !== state.visible){
37
+ setState({...state,visible});
38
+ }
39
+ },setLayoutVisible = (layoutVisible)=>{
40
+ if(typeof layoutVisible =='boolean' && layoutVisible !== state.layoutVisible){
41
+ _setLayoutVisible(layoutVisible);
42
+ }
43
+ }
35
44
  React.setRef(ref,{
36
45
  setStyles,
46
+ setVisible,
47
+ setLayoutVisible,
37
48
  checkVisibility : (args)=>{
38
49
  args = defaultObj(args);
39
50
  if(isObj(args.contentOffset) && isObj(args.contentSize)){
@@ -56,7 +67,7 @@ const AbsoluteScrollView = React.forwardRef(({testID,contentProps,listRef,contai
56
67
  toggleVisible();
57
68
  },[styles])
58
69
  return <Portal>
59
- {<View testID={testID+"_Containter"} {...containerProps} style={[mainStyles.container,containerProps.style,styles.container,{left:win.width-10},!visible &&{display:'none',width:0,opacity:0}]}>
70
+ {<View testID={testID+"_Containter"} {...containerProps} style={[mainStyles.container,containerProps.style,styles.container,{left:win.width-10},(!visible || !layoutVisible) &&{display:'none',width:0,opacity:0}]}>
60
71
  <ScrollView
61
72
  {...props}
62
73
  ref = {scrollViewRef}
@@ -5,7 +5,7 @@ import PropTypes from "prop-types";
5
5
  export const DEFAULT_COLUMN_WIDTH = 60;
6
6
  import React from "$react";
7
7
  import Label from "$ecomponents/Label";
8
- import { StyleSheet,View as RNView,ScrollView,Dimensions} from "react-native";
8
+ import { StyleSheet,View as RNView,ScrollView,NativeModules,Dimensions} from "react-native";
9
9
  import { getRowStyle } from "$ecomponents/Datagrid/utils";
10
10
  import {isMobileNative} from "$cplatform";
11
11
  import theme from "$theme";
@@ -213,6 +213,16 @@ const TableComponent = React.forwardRef(({containerProps,renderEmpty,isRowSelect
213
213
  React.setRef(tableRef,context);
214
214
  const cStyle = {width:listWidth}
215
215
  const absoluteScrollViewRef = React.useRef(null);
216
+ const scrollViewLayoutRef = React.useRef({});
217
+ const toggleAbsoluteScrollVisible = ()=>{
218
+ const ref = scrollViewLayoutRef.current;
219
+ if(isObj(ref.layout) && isObj(ref.content)){
220
+ const layoutVisible = Math.abs(ref.content.width - ref.layout.width)<=50 ? false : true;
221
+ if(absoluteScrollViewRef.current && absoluteScrollViewRef.current.setLayoutVisible){
222
+ absoluteScrollViewRef.current.setLayoutVisible(layoutVisible);
223
+ }
224
+ }
225
+ }
216
226
  return <View testID= {testID+"_Container"} {...containerProps} style={[styles.container,{alignItems:'stretch'},containerProps.style]}>
217
227
  <RNView style={[cStyle]} testID={testID+"_Headers_ScrollViewContainer"}>
218
228
  <ScrollView
@@ -234,12 +244,23 @@ const TableComponent = React.forwardRef(({containerProps,renderEmpty,isRowSelect
234
244
  {hasEmptyData ? <View testID={testID+"_Empty"} style={styles.hasNotData}>
235
245
  {emptyData}
236
246
  </View> : <ScrollView {...scrollViewProps} scrollEventThrottle = {scrollEventThrottle} horizontal contentContainerStyle={[scrollContentContainerStyle,scrollViewProps.contentContainerStyle]} showsVerticalScrollIndicator={false}
237
- onScroll = {getOnScrollCb([headerScrollViewRef,footerScrollViewRef],null,(args)=>{
238
- const nativeEvent = args.nativeEvent;
239
- if(absoluteScrollViewRef.current && absoluteScrollViewRef.current.checkVisibility){
240
- absoluteScrollViewRef.current.checkVisibility(nativeEvent);
241
- }
242
- })} ref={scrollViewRef} testID={testID+"_ScrollView"}>
247
+ onScroll = {getOnScrollCb([headerScrollViewRef,footerScrollViewRef],null,(args)=>{
248
+ const nativeEvent = args.nativeEvent;
249
+ if(absoluteScrollViewRef.current && absoluteScrollViewRef.current.checkVisibility){
250
+ absoluteScrollViewRef.current.checkVisibility(nativeEvent);
251
+ }
252
+ })}
253
+ onLayout={({nativeEvent:{layout}}) => {
254
+ scrollViewLayoutRef.current.layout = layout;
255
+ toggleAbsoluteScrollVisible();
256
+ }}
257
+ ref={scrollViewRef}
258
+ testID={testID+"_ScrollView"}
259
+ onContentSizeChange = {(width,height)=>{
260
+ scrollViewLayoutRef.current.content = {width,height};
261
+ toggleAbsoluteScrollVisible();
262
+ }}
263
+ >
243
264
  <FlashList
244
265
  containerProps = {{style:[cStyle]}}
245
266
  //prepareItems = {Array.isArray(items)? false : undefined}
@@ -353,7 +374,7 @@ const styles = StyleSheet.create({
353
374
  minHeight : 300,
354
375
  paddingBottom : 50,
355
376
  paddingLeft : 10,
356
- paddingRight : 10,
377
+ paddingRight : 0,
357
378
  flex : 1,
358
379
  position : 'relative',
359
380
  },