@fto-consult/expo-ui 6.69.0 → 6.70.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.
@@ -55,8 +55,8 @@ export default function AppMainEntry(){
55
55
  return Promise.resolve("app is initialized");
56
56
  }}
57
57
  /*** if you need to wrap main application content with some custom react Provider*/
58
- render = {function({render,appConfig}){
59
- return render;
58
+ children = {function({children,appConfig}){
59
+ return children;
60
60
  }}
61
61
  ///fonction de rappel appelée avant d'exit l'application, doit retourner une promesse que lorsque résolue, exit l'application
62
62
  beforeExit = {()=>Promise.resolve(true)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "6.69.0",
3
+ "version": "6.70.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "main",
6
6
  "scripts": {
package/src/App.js CHANGED
@@ -13,8 +13,8 @@ import App from "./AppEntry";
13
13
  * }
14
14
  */
15
15
 
16
- export default function ExpoUIAppEntryProvider({render,children,init,...rest}){
16
+ export default function ExpoUIAppEntryProvider({children,init,...rest}){
17
17
  return <Provider {...rest}>
18
- <App init={init} children={children} render={render}/>
18
+ <App init={init} children={children}/>
19
19
  </Provider>
20
20
  }
@@ -62,7 +62,7 @@ const NAVIGATION_PERSISTENCE_KEY = 'NAVIGATION_STATE';
62
62
  * initialRouteName : la route initiale par défaut
63
63
  * getStartedRouteName : la route par défaut de getStarted lorsque l'application est en mode getStarted, c'est à dire lorsque la fonction init renvoie une erreur (reject)
64
64
  */
65
- function App({init:initApp,initialRouteName:appInitialRouteName,render}) {
65
+ function App({init:initApp,initialRouteName:appInitialRouteName,children}) {
66
66
  AppStateService.init();
67
67
  const {FontsIconsFilter,beforeExit,preferences:appPreferences,navigation,getStartedRouteName} = useContext();
68
68
  const {containerProps} = navigation;
@@ -289,7 +289,7 @@ function App({init:initApp,initialRouteName:appInitialRouteName,render}) {
289
289
  }}
290
290
  />
291
291
  </NavigationContainer> : null;
292
- const content = isLoaded ? typeof render == 'function'? render({children:child,appConfig,config:appConfig}) : child : null;
292
+ const content = isLoaded ? typeof children == 'function'? children({children:child,appConfig,config:appConfig}) : child : null;
293
293
  return <SafeAreaProvider>
294
294
  <GestureHandlerRootView testID={"RN_MainAppGestureHanleRootView"} style={styles.gesture}>
295
295
  <AppEntryRootView>
@@ -193,15 +193,27 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
193
193
  opts.showError = false;
194
194
  }
195
195
  if(typeof fetcher =='function'){
196
- return fetcher(url,opts);
196
+ return fetcher(url,opts).then((r)=>{
197
+ showProgressRef.current = false;
198
+ return r;
199
+ }).catch((r)=>{
200
+ showProgressRef.current = false;
201
+ return r;
202
+ });
197
203
  }
198
- return apiFetch(url,opts);
204
+ return apiFetch(url,opts).then((r)=>{
205
+ showProgressRef.current = false;
206
+ return r;
207
+ }).catch((r)=>{
208
+ showProgressRef.current = false;
209
+ return r;
210
+ });
199
211
  },
200
212
  swrOptions : getSWROptions(swrConfig.refreshTimeout)
201
213
  });
202
214
  const dataRef = React.useRef(null);
203
215
  const totalRef = React.useRef(0);
204
- const loading = (customIsLoading === true || isLoading || isValidating);
216
+ const loading = (customIsLoading === true || isLoading || (isValidating && showProgressRef.current));
205
217
  const {data,total} = React.useMemo(()=>{
206
218
  if((loading && customIsLoading !== false) || !isObjOrArray(result)){
207
219
  return {data:dataRef.current,total:totalRef.current};
@@ -228,7 +240,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
228
240
  },500);
229
241
  },[error]);
230
242
  const doRefresh = (showProgress)=>{
231
- showProgressRef.current = showProgress ? typeof showProgress ==='boolean' : isLoading;
243
+ showProgressRef.current = showProgress ? typeof showProgress ==='boolean' : showProgressRef.current;
232
244
  refresh();
233
245
  }
234
246
  const canPaginate = ()=>{
@@ -391,7 +403,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
391
403
  handleQueryLimit = {false}
392
404
  handlePagination = {false}
393
405
  autoSort = {canSortRemotely()? false : true}
394
- isLoading = {loading /*&& !error*/ && showProgressRef.current && true || false}
406
+ isLoading = {loading && showProgressRef.current || false}
395
407
  beforeFetchData = {(args)=>{
396
408
  if(typeof beforeFetchData =="function" && beforeFetchData(args)==false) return;
397
409
  let {fetchOptions:opts,force} = args;
@@ -57,6 +57,7 @@ Object.map(Utils,(v,i)=>{
57
57
  },
58
58
  customFormFields{Object}, //les composant personalisés des forms fields
59
59
  tableLinkPropsMutator : ({object})=><{object}>, la fonction permettant de muter les props du composant TableLink,
60
+ fabPropsMutator : ({object})=><{object}>, la fonction permettant de muter les props du composant Fab, affiché dans les écrans par défaut,
60
61
  TableDataScreen | TableDataScreenItem : {ReactComponent}, le composant TableDataScreenItem, à utiliser pour le rendu des écrans
61
62
  TableDataScreenList | TableDataListScreen {ReactComponent}, le composant TableDataList à utiliser pour le rendu des écrans listants les éléments du table data
62
63
  },
@@ -7,26 +7,28 @@ import {navigateToTableData} from "$enavigation/utils";
7
7
  import PropTypes from "prop-types";
8
8
  import theme from "$theme";
9
9
  import {isLoggedIn as isAuthLoggedIn} from "$cauth/utils/session";
10
+ import useExpoUI from "$econtext/hooks";
11
+ import Auth from "$cauth";
10
12
 
11
13
  export * from "./utils";
12
14
 
13
- const FabLayoutComponent = React.forwardRef(({style,screenName,tables,...props},ref)=>{
15
+ const FabLayoutComponent = React.forwardRef((p,ref)=>{
16
+ const {components:{fabPropsMutator},tablesData} = useExpoUI();
17
+ const {style,actions:fabActions,...props} = typeof fabPropsMutator == 'function'? extendObj({},p,fabPropsMutator({...p,isLoggedIn})) : p;
14
18
  const [isLoggedIn,setIsLoggedIn] = React.useState(isAuthLoggedIn());
15
19
  const isMounted = React.useIsMounted();
20
+ const tables = isObjOrArray(fabActions)? fabActions : tablesData;
16
21
  const actions = React.useMemo(()=>{
22
+ if(Array.isArray(fabActions)) return fabActions;
17
23
  if(!isLoggedIn) return null;
18
24
  const a = [];
19
25
  Object.map(tables,(table,i,index)=>{
20
- if(!isObj(table) || table.showInFab === false) return;
26
+ if(!isObj(table) || table.showInFab === false || typeof table.showInFab =="function" && table.showInFab() === false) return;
21
27
  const icon = defaultStr(table.addIcon,"material-add");
22
28
  const text = defaultStr(table.text,table.label);
23
29
  const addText = defaultStr(table.newElementLabel,"Nouveau");
24
30
  const tableName = defaultStr(table.table,table.tableName);
25
- let auth = true;
26
- if(typeof Auth !=='undefined' && Auth && Auth.isTableDataAllowed){
27
- auth = Auth.isTableDataAllowed({table:tableName,action:'create'});
28
- }
29
- if(!table || !icon || !text || !auth) return;
31
+ if(!table || !icon || !text || !Auth.isTableDataAllowed({table:tableName,action:'create'})) return;
30
32
  let fabProps = typeof table.getFabProps ==='function'? table.getFabProps({tableName}) : defaultObj(table.fabProps);;
31
33
  if(fabProps === false) return;
32
34
  fabProps = defaultObj(fabProps);
@@ -48,7 +50,8 @@ const FabLayoutComponent = React.forwardRef(({style,screenName,tables,...props},
48
50
  })
49
51
  })
50
52
  return a.length ? a : null;
51
- },[isLoggedIn]);
53
+ },[isLoggedIn,fabActions,tables]);
54
+
52
55
  React.useEffect(()=>{
53
56
  const onLogin = ()=>{
54
57
  if(!isMounted())return;
@@ -66,7 +69,6 @@ const FabLayoutComponent = React.forwardRef(({style,screenName,tables,...props},
66
69
  },[])
67
70
  return actions ? <Fab.Group
68
71
  {...props}
69
- screenName = {screenName}
70
72
  ref = {ref}
71
73
  style={[styles.fab,style]}
72
74
  actions = {actions}
@@ -86,9 +88,7 @@ const styles = StyleSheet.create({
86
88
  FabLayoutComponent.displayName = "FabLayoutComponent";
87
89
 
88
90
  FabLayoutComponent.propTypes = {
89
- tables : PropTypes.oneOfType([
90
- PropTypes.objectOf(PropTypes.object),
91
- PropTypes.arrayOf(PropTypes.object)
92
- ]),
91
+ ...Fab.propTypes,
92
+ actions : PropTypes.array, //les actions du fab layout
93
93
  screenName : PropTypes.string,
94
94
  }
@@ -19,9 +19,6 @@ export default function MainScreenComponent({profilAvatarProps,withDrawer,allowD
19
19
  withDrawer = false;
20
20
  }
21
21
  const withProfilAvatarOnAppBar = cWithPorilAvatarOnAppbar !== false && withDrawer && !theme.showProfilAvatarOnDrawer ? true : false;
22
- if(authRequired === false){
23
- props.withFab = false;
24
- }
25
22
  return <Container authProps={authProps} required={authRequired}>
26
23
  <ScreenWithoutAuthContainer
27
24
  {...props}