@fto-consult/expo-ui 6.27.0 → 6.27.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": "6.27.0",
3
+ "version": "6.27.1",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -43,10 +43,15 @@ const Provider = React.forwardRef((props,innerRef)=>{
43
43
  }
44
44
  };
45
45
  React.setRef(ref,context);
46
- return <Menu {...props} {...state} visible={visible} sheet controlled onDismiss = {(e)=>{
46
+ return <Menu {...props} {...state} visible={visible} sheet controlled onDismiss = {(...args)=>{
47
47
  if(visible){
48
48
  setVisible(false);
49
49
  }
50
+ if(typeof state.onDismiss =='function'){
51
+ state.onDismiss(...args)
52
+ } else if(typeof props.onDismiss =='function'){
53
+ props.onDismiss(...args);
54
+ }
50
55
  }}/>
51
56
  });
52
57
 
@@ -6,7 +6,6 @@ import Label from "$ecomponents/Label";
6
6
  import PropTypes from "prop-types";
7
7
  import React from "$react";
8
8
  import theme from "$theme"
9
- import {isMobileNative} from "$cplatform";
10
9
  import {styles as rStyles,getRowStyle} from "../utils";
11
10
  import Swipeable from 'react-native-gesture-handler/Swipeable';
12
11
  import { useIsRowSelected,useDatagrid} from "../hooks";
@@ -30,7 +29,7 @@ const DatagridAccordionRow = React.forwardRef((props,ref)=>{
30
29
  callArgs,
31
30
  } = props;
32
31
  const {context} = useDatagrid();
33
- let {wrapperStyle,title,right,rightProps,description,avatarContent,rowProps} = props;
32
+ let {title,right,rightProps,description,avatarContent,rowProps} = props;
34
33
  rightProps = defaultObj(rightProps);
35
34
  if(!isObj(item)) {
36
35
  return null;
@@ -108,6 +107,11 @@ const DatagridAccordionRow = React.forwardRef((props,ref)=>{
108
107
  }
109
108
  right = typeof right === 'function'? right ({color:theme.colors.primaryOnSurface,selectable:true,style:[rStyles.lineHeight,styles.right]}) : right;
110
109
  const swipeableRef = React.useRef(null);
110
+ React.useEffect(()=>{
111
+ return ()=>{
112
+ React.setRef(swipeableRef,null);
113
+ }
114
+ },[])
111
115
  return <Pressable
112
116
  disabled = {selectable===false?true : false}
113
117
  {...rowProps}
@@ -125,7 +129,15 @@ const DatagridAccordionRow = React.forwardRef((props,ref)=>{
125
129
  selectable !== false && theme.styles.cursorPointer,
126
130
  //style,
127
131
  ]}
128
- ref = {React.useMergeRefs(ref,innerRef)}
132
+ ref = {(el)=>{
133
+ if(el){
134
+ el.toggleExpand = (expand)=>{
135
+ setExpanded(typeof expand =='boolean'? expand : !expanded);
136
+ }
137
+ }
138
+ React.setRef(ref,el);
139
+ React.setRef(innerRef,el);
140
+ }}
129
141
  >
130
142
  <Swipeable
131
143
  ref = {swipeableRef}
@@ -168,7 +180,9 @@ const DatagridAccordionRow = React.forwardRef((props,ref)=>{
168
180
  style={[styles.renderedContent,viewWrapperStyle]}
169
181
  testID={testID+'_ContentContainer'}
170
182
  >
171
- {avatarContent}
183
+ {hasAvatar?<View testID={testID+"_AvatarContentContainer"} style={[styles.avatarContent]}>
184
+ {avatarContent}
185
+ </View> : avatarContent}
172
186
  <View testID={testID+"_Content"} style={[styles.content,styles.wrap]}>
173
187
  {title}
174
188
  {description}
@@ -201,9 +201,9 @@ const DatagridFactory = (Factory)=>{
201
201
  numColumns = {numColumns}
202
202
  key = {index}
203
203
  ref = {(el)=>{
204
- if(isObj(this.renderingItemsProps) && isObj(this.renderingItemsProps[rowKey]) ){
205
- this.renderingItemsProps[rowKey].ref = el;
206
- }
204
+ this.renderingItemsProps = defaultObj(this.renderingItemsProps);
205
+ this.renderingItemsProps[rowKey] = defaultObj(this.renderingItemsProps[rowKey]);
206
+ this.renderingItemsProps[rowKey].ref = el;
207
207
  }}
208
208
  style = {style}
209
209
  callArgs = {this.getItemCallArgs({item,index})}
@@ -263,9 +263,14 @@ const DatagridFactory = (Factory)=>{
263
263
  /*** affiche les infos de l'item */
264
264
  onToggleExpandItem({item,index,rowIndex,rowKey,...rest}){
265
265
  if(!isObj(this.bottomSheetContext) || typeof this.bottomSheetContext.open !=='function') return;
266
+ if(!isObj(this.renderingItemsProps) || !isObj(this.renderingItemsProps[rowKey])) return;
266
267
  const callArgs = this.getItemCallArgs({item,index})
267
268
  return this.bottomSheetContext.open({
268
269
  ...rest,
270
+ onDismiss : ()=>{
271
+ const ref = this.renderingItemsProps[rowKey].ref;
272
+ ref?.toggleExpand && ref?.toggleExpand(false);
273
+ },
269
274
  children : <View style={[styles.expandedItemContent]} testID={'RN_DatagridAccordionExpanded'}>
270
275
  {Object.mapToArray(this.state.columns,(columnDef,columnField,index)=>{
271
276
  callArgs.columnDef = columnDef;
@@ -552,7 +557,7 @@ const DatagridFactory = (Factory)=>{
552
557
  items = {this.state.data}
553
558
  isLoading = {isLoading}
554
559
  ref = {this.listRef}
555
- style = {styles.list}
560
+ style = {[styles.list,rest.style]}
556
561
  backToTopRef = {backToTopRef?(e)=>{
557
562
  return this.backToTopRef.current;
558
563
  }:false}
@@ -607,7 +612,7 @@ const styles = StyleSheet.create({
607
612
  maxHeight : 60
608
613
  },
609
614
  list : {
610
- paddingHorizontal : 5,
615
+ paddingHorizontal : isNativeMobile()?10:0,
611
616
  },
612
617
  container : {
613
618
  position : 'relative',
@@ -628,7 +633,7 @@ const styles = StyleSheet.create({
628
633
  flexDirection:'row',
629
634
  alignItems : 'center',
630
635
  flex:1,
631
- paddingHorizontal : 10,
636
+ paddingHorizontal : 0,
632
637
  },
633
638
  pullRight : {
634
639
  flexDirection : 'row',
@@ -458,7 +458,6 @@ const styles = {
458
458
  left: 0,
459
459
  width:vertical ? width : width * count,
460
460
  flexDirection: vertical ? 'column' : 'row',
461
- height : '100%',
462
461
  }),typeof height ==='number'? (vertical ? height * count : height) : undefiend,autoHeight),
463
462
  scrollViewContentContainer : {
464
463
  paddingBottom : 40,