@fto-consult/expo-ui 6.69.1 → 6.70.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.
@@ -35,6 +35,16 @@ export default function AppMainEntry(){
35
35
  profilePropsMutator : ({fields,...props})=>({fields,...props}),//la fonction permettant de muter les champs liés à l'écran de mise à jour d'un profil utilisateur
36
36
  }}
37
37
  components = {{
38
+ /**
39
+ * ///le composant permettant de faire office de provider principal de l'application,
40
+ //ce composatnn permet de wrapper le contenu principal de l'application, les utilitaires de navigation, de la boîte de dialogue et bien d'autre ne doivent pas être utilisé
41
+ il peut être utilisé pour par exemple wrapper le contenu au travaer d'un store redux et bien d'autre
42
+ * @param {*} param0
43
+ * @returns
44
+ */
45
+ MainProvider : function({children,...props}){
46
+ return children;
47
+ },
38
48
  /*** logo : ReactNode|ReactElement | ReactComponent | object {
39
49
  image{ReactComponent} :,text {ReactComponent}
40
50
  },*/
@@ -55,8 +65,8 @@ export default function AppMainEntry(){
55
65
  return Promise.resolve("app is initialized");
56
66
  }}
57
67
  /*** if you need to wrap main application content with some custom react Provider*/
58
- render = {function({render,appConfig}){
59
- return render;
68
+ children = {function({children,appConfig}){
69
+ return children;
60
70
  }}
61
71
  ///fonction de rappel appelée avant d'exit l'application, doit retourner une promesse que lorsque résolue, exit l'application
62
72
  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.1",
3
+ "version": "6.70.1",
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
  }
@@ -1,16 +1,20 @@
1
1
  import {View,StyleSheet} from "react-native";
2
2
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
3
- export default function AppEntryRootView(props){
3
+ import React from "$react";
4
+ export default function AppEntryRootView({MainProvider,...props}){
5
+ const Wrapper = React.isComponent(MainProvider)? MainProvider : React.Fragment;
4
6
  const insets = useSafeAreaInsets();
5
- return <View
6
- testID="RN_MainAppEntryRootView"
7
- {...props}
8
- style = {StyleSheet.flatten([
9
- {
10
- paddingBottom: insets.bottom,
11
- paddingLeft: insets.left,
12
- paddingRight: insets.right,
13
- },
14
- props.style,{flex:1}])}
15
- />
7
+ return <Wrapper>
8
+ <View
9
+ testID="RN_MainAppEntryRootView"
10
+ {...props}
11
+ style = {StyleSheet.flatten([
12
+ {
13
+ paddingBottom: insets.bottom,
14
+ paddingLeft: insets.left,
15
+ paddingRight: insets.right,
16
+ },
17
+ props.style,{flex:1}])}
18
+ />
19
+ </Wrapper>
16
20
  }
@@ -62,9 +62,9 @@ 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
- const {FontsIconsFilter,beforeExit,preferences:appPreferences,navigation,getStartedRouteName} = useContext();
67
+ const {FontsIconsFilter,beforeExit,AppWrapper,preferences:appPreferences,navigation,getStartedRouteName,components:{MainProvider}} = useContext();
68
68
  const {containerProps} = navigation;
69
69
  const [initialState, setInitialState] = React.useState(undefined);
70
70
  const appReadyRef = React.useRef(true);
@@ -289,10 +289,10 @@ 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
- <AppEntryRootView>
295
+ <AppEntryRootView MainProvider={MainProvider}>
296
296
  <PaperProvider
297
297
  theme={theme}
298
298
  settings={{
@@ -48,6 +48,7 @@ Object.map(Utils,(v,i)=>{
48
48
  handleHelpScreen : {boolean}, //si l'écran d'aide sera pris en compte, l'écran d'aide ainsi que les écrans des termes d'utilisations et autres
49
49
  convertFiltersToSQL : {boolean}, si les filtres de datagrid ou filtres seront convertis au format SQL
50
50
  components : {
51
+ MainProvider : {ReactComponent}, //le composant qui permet de wrapper le contenu de l'application expo. Nb, ce composant ne peut utiliser ni les routes, nis les DialogProvider,
51
52
  logo : ReactNode | ReactComponent | object {
52
53
  image{ReactComponent} :,
53
54
  text {ReactComponent}
@@ -57,9 +58,11 @@ Object.map(Utils,(v,i)=>{
57
58
  },
58
59
  customFormFields{Object}, //les composant personalisés des forms fields
59
60
  tableLinkPropsMutator : ({object})=><{object}>, la fonction permettant de muter les props du composant TableLink,
61
+ fabPropsMutator : ({object})=><{object}>, la fonction permettant de muter les props du composant Fab, affiché dans les écrans par défaut,
60
62
  TableDataScreen | TableDataScreenItem : {ReactComponent}, le composant TableDataScreenItem, à utiliser pour le rendu des écrans
61
63
  TableDataScreenList | TableDataListScreen {ReactComponent}, le composant TableDataList à utiliser pour le rendu des écrans listants les éléments du table data
62
64
  },
65
+
63
66
  navigation : {
64
67
  screens : {Array}, les écrans de navigation,
65
68
  screenOptions : {object}, les options du composant Stack.Navigator, voir https://reactnavigation.org/docs/native-stack-navigator/
@@ -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}