@fto-consult/expo-ui 2.11.0 → 2.11.2

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.2",
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)=>{
@@ -1510,7 +1510,7 @@ export default class CommonDatagridComponent extends AppComponent {
1510
1510
  }
1511
1511
  UNSAFE_componentWillReceiveProps(nextProps){
1512
1512
  if(!isObjOrArray(nextProps.data) || nextProps.data == this.props.data || stableHash(nextProps.data) == stableHash(this.props.data)) {
1513
- if(nextProps.isLoading !== this.props.isLoading && typeof nextProps.isLoading =='boolean'){
1513
+ if( typeof this.props.isLoading=='boolean' && nextProps.isLoading !== this.props.isLoading && typeof nextProps.isLoading =='boolean'){
1514
1514
  this.setIsLoading(nextProps.isLoading)
1515
1515
  }
1516
1516
  return;
@@ -1536,6 +1536,7 @@ export default class CommonDatagridComponent extends AppComponent {
1536
1536
  renderHeaderCell({columnDef,columnField}){
1537
1537
  if(this.isSelectableColumn(columnDef,columnField)){
1538
1538
  return <Checkbox
1539
+ testID = "RN_SelectColumnHeaderCell"
1539
1540
  checked ={this.isAllRowsSelected()?true:false}
1540
1541
  key = {this.getSelectableColumName()}
1541
1542
  secondaryOnCheck
@@ -404,7 +404,7 @@ const styles = StyleSheet.create({
404
404
  selectableColumn : {
405
405
  width : SELECTABLE_COLUMN_WIDTH,
406
406
  //justifyContent:'center',
407
- alignItems : 'flex-start',
407
+ alignItems : 'center',
408
408
  paddingVertical : 0,
409
409
  marginVertical : 0,
410
410
  paddingHorizontal : 0,
@@ -65,27 +65,27 @@ export const getImputedBackgroundStyle = (rowData)=>{
65
65
 
66
66
 
67
67
  export const ROW_APPROVED_STYLE = {
68
- borderRightColor : APPROVED_COLOR,
69
- borderRightWidth : 4,
70
- marginRight : MARGIN_HORIZONTAL
68
+ //borderRightColor : APPROVED_COLOR,
69
+ //borderRightWidth : 4,
70
+ //marginRight : MARGIN_HORIZONTAL
71
71
  }
72
72
 
73
73
  export const ROW_ARCHIVED_STYLE = {
74
- borderBottomColor : ARCHIVED_COLOR,
75
- borderBottomWidth :4,
74
+ //borderBottomColor : ARCHIVED_COLOR,
75
+ //borderBottomWidth :4,
76
76
  //marginBottom : MARGIN_VERTICAL,
77
77
  }
78
78
 
79
79
  export const ROW_PAID_STYLE = {
80
- borderLeftColor : PAID_COLOR,
81
- borderLeftWidth : 5,
82
- marginLeft : MARGIN_HORIZONTAL
80
+ //borderLeftColor : PAID_COLOR,
81
+ //borderLeftWidth : 5,
82
+ //marginLeft : MARGIN_HORIZONTAL
83
83
  }
84
84
 
85
85
  export const ROW_IMPUTED_STYLE = {
86
- borderLeftColor : IMPUTED_COLOR,
87
- borderLeftWidth : 5,
88
- marginLeft : MARGIN_HORIZONTAL
86
+ //borderLeftColor : IMPUTED_COLOR,
87
+ //borderLeftWidth : 5,
88
+ //marginLeft : MARGIN_HORIZONTAL
89
89
  }
90
90
 
91
91
  export const ROW_ODD_STYLE = {
@@ -110,7 +110,7 @@ export const ROW_BORDER_STYLE = {
110
110
  borderRightColor : ROW_BORDER_COLOR,
111
111
  borderRightWidth : 0,
112
112
  borderTopColor : ROW_BORDER_COLOR,
113
- borderTopWidth : 0,
113
+ borderTopWidth : 0
114
114
  }
115
115
 
116
116
 
@@ -166,7 +166,7 @@ export const getRowStyle = ({row,bordered,numColumns,rowData,isAccordion,isTable
166
166
  if(rowIndex !== undefined){
167
167
  style.push(rowIndex%2===0?styles.even : theme.isDark()?styles.oddDark : styles.odd)
168
168
  }
169
- if(selected){
169
+ if(false && selected){
170
170
  style.push(styles.selected,{borderBottomWidth:1,borderBottomColor:theme.colors.primary})
171
171
  }
172
172
  if(paid || row.paid){
@@ -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
  },