@fto-consult/expo-ui 2.37.8 → 2.38.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.
Files changed (41) hide show
  1. package/metro.config.js +1 -0
  2. package/package.json +7 -6
  3. package/src/components/AutoResizer/index.js +104 -0
  4. package/src/components/Chart/appexChart/index.native.js +1 -1
  5. package/src/components/Chart/index.js +2 -1
  6. package/src/components/Datagrid/Accordion/Filters.js +0 -1
  7. package/src/components/Datagrid/Accordion/index.js +8 -13
  8. package/src/components/Datagrid/Common/Common.js +135 -51
  9. package/src/components/Datagrid/Common/utils.js +4 -1
  10. package/src/components/Datagrid/IndexComponent.js +1 -4
  11. package/src/components/Datagrid/SWRDatagrid.js +2 -16
  12. package/src/components/Datagrid/Table/index.js +10 -39
  13. package/src/components/Dialog/Dialog.js +0 -1
  14. package/src/components/Form/FormData/Dialog.js +1 -6
  15. package/src/components/Form/FormData/FormData.js +1 -2
  16. package/src/components/Form/FormData/FormDataActions.js +6 -9
  17. package/src/components/Hashtag/index.js +2 -2
  18. package/src/components/List/Common.js +0 -1
  19. package/src/components/Table/AbsoluteScrollView.js +3 -2
  20. package/src/components/Table/Cell.js +24 -0
  21. package/src/components/Table/Header.js +25 -0
  22. package/src/components/Table/List.js +196 -0
  23. package/src/components/Table/List.native.js +5 -0
  24. package/src/components/{Datagrid/Common → Table}/ProgressBar.js +0 -0
  25. package/src/components/Table/Row.js +21 -0
  26. package/src/components/Table/Test.js +0 -0
  27. package/src/components/Table/index.js +218 -202
  28. package/src/layouts/Screen/FormData/FormData.js +6 -15
  29. package/src/layouts/Screen/FormData/List.js +7 -8
  30. package/src/layouts/Screen/ScreenWithOrWithoutAuthContainer.js +4 -4
  31. package/src/layouts/Screen/TableData.js +6 -13
  32. package/src/media/file-system/utils/write.js +1 -1
  33. package/src/screens/Auth/Profile.js +2 -3
  34. package/src/screens/Auth/SignIn.js +1 -3
  35. package/src/screens/Help/PrivacyPolicy/index.js +1 -3
  36. package/src/screens/Help/TermsOfUses/index.js +1 -3
  37. package/src/screens/ScreenWrapper.js +82 -0
  38. package/src/screens/index.js +10 -68
  39. package/src/screens/utils.js +2 -0
  40. package/webpack.config.js +9 -1
  41. package/src/components/Datagrid/Table/Cell.js +0 -45
@@ -5,7 +5,7 @@ import PropTypes from "prop-types";
5
5
  import {defaultObj,defaultStr,defaultNumber,defaultBool} from "$utils";
6
6
  import ScrollView from '$ecomponents/ScrollView';
7
7
  import View from "$ecomponents/View";
8
- import { useNavigation,getScreenProps } from '$cnavigation';
8
+ import { useNavigation} from '$cnavigation';
9
9
  import Fab from "$elayouts/Fab";
10
10
  import APP from "$capp";
11
11
  import AppBar,{createAppBarRef} from "$elayouts/AppBar";
@@ -57,7 +57,7 @@ export default function MainScreenScreenWithOrWithoutAuthContainer(props) {
57
57
  renderChildren,
58
58
  renderProfilAvatar,
59
59
  ...rest
60
- } = getScreenProps(props);
60
+ } = props;
61
61
  const insets = useSafeAreaInsets();
62
62
  testID = defaultStr(testID,"RN_MainScreenScreenWithOrWithoutAuthContainer")
63
63
  containerProps = defaultObj(containerProps);
@@ -75,8 +75,8 @@ export default function MainScreenScreenWithOrWithoutAuthContainer(props) {
75
75
  ];
76
76
  options = defaultObj(options);
77
77
  appBarProps = defaultObj(appBarProps)
78
- title = defaultVal(title,appBarProps.title,options.title);
79
- subtitle = defaultVal(appBarProps.subtitle,options.subtitle,subtitle);
78
+ title = defaultVal(title,appBarProps.title);
79
+ subtitle = defaultVal(subtitle,appBarProps.subtitle);
80
80
  const appBarRef = createAppBarRef();
81
81
  const navigation = useNavigation();
82
82
  authProps = Object.assign({},authProps),
@@ -16,7 +16,7 @@ import {isMobileOrTabletMedia} from "$platform/dimensions";
16
16
  import Tab from "$ecomponents/Tab";
17
17
  import Surface from "$ecomponents/Surface";
18
18
  import View from "$ecomponents/View";
19
- import {getScreenProps,goBack as navGoBack} from "$cnavigation";
19
+ import {goBack as navGoBack} from "$cnavigation";
20
20
  import {renderTabsContent,renderActions} from "./utils";
21
21
  import theme from "$theme";
22
22
  import cActions from "$cactions";
@@ -72,7 +72,7 @@ export const isDocEditing = (data,fields,checkPrimaryKey)=>{
72
72
  export default class TableDataScreenComponent extends FormDataScreen{
73
73
  constructor(props){
74
74
  super(props);
75
- const mainProps = getScreenProps(props);
75
+ const mainProps = props;
76
76
  extendObj(this.state,this.prepareStateData(mainProps));
77
77
  const table = defaultObj(mainProps.table);
78
78
  const fields = {},primaryKeyFields = {};
@@ -239,7 +239,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
239
239
  newElementLabel,
240
240
  prepareField,
241
241
  ...rest
242
- } = getScreenProps(props);
242
+ } = props;
243
243
  const table = this.table;
244
244
  const {datas,currentIndex,data} = this.state;
245
245
  const tableName = this.tableName;
@@ -353,7 +353,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
353
353
  return rActionsArg;
354
354
  }
355
355
  renderTabs(args){
356
- const tabs = this.getMainProps().tabs;
356
+ const tabs = this.props.tabs;
357
357
  if(typeof tabs =='function'){
358
358
  return tabs(args);
359
359
  }
@@ -566,10 +566,9 @@ export default class TableDataScreenComponent extends FormDataScreen{
566
566
  return this.hidePreloaderTimeout;
567
567
  }
568
568
  UNSAFE_componentWillReceiveProps(nextProps){
569
- const props = getScreenProps(nextProps);
570
- const {data,datas}= props;
569
+ const {data,datas}= nextProps;
571
570
  if(stableHash({data,datas}) != stableHash({data:this.state.data,datas:this.state.datas})){
572
- this.setState(this.prepareStateData(props));
571
+ this.setState(this.prepareStateData(nextProps));
573
572
  }
574
573
  return;
575
574
  }
@@ -809,12 +808,6 @@ export default class TableDataScreenComponent extends FormDataScreen{
809
808
  getAppBarTitle (){
810
809
  return defaultStr(this.titleProp,this.table.text,this.table.label);
811
810
  }
812
- getMainProps(){
813
- if(isObj(this.INITIAL_STATE.props) && Object.size(this.INITIAL_STATE.props,true)) {
814
- this.INITIAL_STATE.props
815
- }
816
- return getScreenProps(this.props);
817
- }
818
811
  getAppBarProps(a){
819
812
  const r = super.getAppBarProps(a);
820
813
  r.title = this.getAppBarTitle();
@@ -3,7 +3,7 @@
3
3
  // license that can be found in the LICENSE file.
4
4
  import {defaultStr,base64toBlob,dataURLToBlob,getTypeFromDataURL,isNonNullString,getFileName,getFileExtension,defaultNumber,defaultBool,dataURLToBase64,isBlob,isBase64,isDataURL} from "$utils";
5
5
  const FileSaver = require('file-saver');
6
- const mime = require('mime-types')
6
+ const mime = require('react-native-mime-types')
7
7
  const XLSX = require("xlsx");
8
8
  import Preloader from "$preloader";
9
9
 
@@ -1,7 +1,7 @@
1
1
  import FormDataScreen from "$elayouts/Screen/FormData";
2
2
  import {defaultStr,defaultObj,isObjOrArray,isObj} from "$utils";
3
3
  import Auth from "$auth";
4
- import {getScreenProps,navigate} from "$cnavigation";
4
+ import {navigate} from "$cnavigation";
5
5
  import SelectTheme from "$themeSelectorComponent";
6
6
  import Preloader from "$epreloader";
7
7
  import {SignIn2SignOut} from "$cauth";
@@ -10,8 +10,7 @@ import avatarProps from "$eauth/avatarProps";
10
10
 
11
11
  import {screenName} from "./utils";
12
12
 
13
- export default function UserProfileScreen(prs){
14
- const props = getScreenProps(prs);
13
+ export default function UserProfileScreen(props){
15
14
  const user = defaultObj(props.user,Auth.getLoggedUser());
16
15
  const testID = defaultStr(props.testID,"RN_UserProfile_FormData");
17
16
  const themeRef = React.useRef(defaultObj(user.theme));
@@ -2,12 +2,10 @@
2
2
  import {SIGN_IN} from "$cauth/routes"
3
3
  import Screen from "$escreen";
4
4
  import Login from "$eauth/Login";
5
- import {getScreenProps} from "$cnavigation";
6
5
  import {getTitle} from "./utils";
7
6
 
8
7
 
9
- function AuthSignInScreen(_props){
10
- const props = getScreenProps(_props);
8
+ function AuthSignInScreen(props){
11
9
  const title = getTitle();
12
10
  return <Screen
13
11
  title = {title}
@@ -3,11 +3,9 @@ import title from "./title"
3
3
  import Screen from "$screen";
4
4
  import Link from "./Link";
5
5
  import Content from "$PrivacyPolicy";
6
- import {getScreenProps} from "$cnavigation";
7
6
  import React from "$react";
8
7
 
9
- export default function PrivacyPolicy(p){
10
- const props = getScreenProps(p);
8
+ export default function PrivacyPolicy(props){
11
9
  return <Screen
12
10
  {...props}
13
11
  withDrawer = {false}
@@ -3,12 +3,10 @@ import title from "./title";
3
3
  import Screen from "$screen";
4
4
  import Link from "./Link";
5
5
  import Content from "$TermsOfUses";
6
- import {getScreenProps} from "$cnavigation";
7
6
  import {extendObj} from "$utils";
8
7
  import React from "$react";
9
8
 
10
- export default function TermsOfUses(p){
11
- const props = getScreenProps(p);
9
+ export default function TermsOfUses(props){
12
10
  return <Screen
13
11
  {...props}
14
12
  withDrawer = {false}
@@ -0,0 +1,82 @@
1
+ // Copyright 2023 @fto-consult/Boris Fouomene. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+ import React from "$react";
5
+ import { BackHandler } from "react-native";
6
+ import APP from "$capp";
7
+ import {useDrawer} from "$ecomponents/Drawer";
8
+ import {navigationRef,getScreenProps,setRoute,setActiveNavigation,setScreenOptions,goBack} from "$cnavigation";
9
+ import { SCREEN_OPTIONS } from "./utils";
10
+
11
+ export default function ScreenWrapperNavComponent(_props){
12
+ const {navigation,route,...props} = getScreenProps(_props);
13
+ const sanitizedName = route.name;
14
+ const options = defaultObj(SCREEN_OPTIONS[sanitizedName]);
15
+ const {screenName,Screen,authRequired,isModal,...rest} = options;
16
+ const {drawerRef} = useDrawer()
17
+ setActiveNavigation(navigation);
18
+ setRoute(route);
19
+ React.useEffect(()=>{
20
+ const unsubscribe = navigation.addListener('focus', (a) => {
21
+ APP.trigger(APP.EVENTS.SCREEN_FOCUS,{
22
+ screenName,
23
+ sanitizedName,
24
+ options,
25
+ })
26
+ });
27
+ const unsubscribeBlur = navigation.addListener('blur', (a) => {
28
+ APP.trigger(APP.EVENTS.SCREEN_BLUR,{
29
+ screenName,
30
+ sanitizedName,
31
+ options,
32
+ })
33
+ });
34
+ const backAction = (a) => {
35
+ if(drawerRef && drawerRef.current.canToggle() && drawerRef.current.isOpen()){
36
+ drawerRef.current.closeDrawer();
37
+ return true;
38
+ }
39
+ let isGoingBack = false;
40
+ if(navigationRef.canGoBack()){
41
+ if(isGoingBack) return true;
42
+ isGoingBack = true;
43
+ const opts = navigationRef.getCurrentOptions();
44
+ const aProps = defaultObj(opts.appBarProps);
45
+ goBack({...opts,...aProps,...defaultObj(aProps.appBarProps)});
46
+ isGoingBack = false;
47
+ return true;
48
+ }
49
+ APP.trigger(APP.EVENTS.BACK_BUTTON,{groupName,route:navigationRef.getCurrentRoute(),screenName:sanitizedName,source:'screen'});
50
+ return true;
51
+ };
52
+ const subscription = BackHandler.addEventListener('hardwareBackPress', backAction);
53
+ return ()=>{
54
+ if(unsubscribe){
55
+ unsubscribe();
56
+ }
57
+ if(unsubscribeBlur){
58
+ unsubscribeBlur();
59
+ }
60
+ if(subscription?.remove)subscription.remove();
61
+ return BackHandler.removeEventListener('hardwareBackPress', backAction);
62
+ }
63
+ },[]);
64
+ setScreenOptions(options);
65
+ const allowDrawer = typeof options.allowDrawer ==='boolean'? options.allowDrawer : typeof Screen.allowDrawer =='boolean'? Screen.allowDrawer : Screen.isModalScreen == true ? false : true;
66
+ return <Screen
67
+ {...rest}
68
+ key = {sanitizedName}
69
+ authRequired={authRequired||allowDrawer}
70
+ backAction={isModal}
71
+ modal={isModal}
72
+ navigation = {navigation}
73
+ route = {route}
74
+ allowDrawer={allowDrawer}
75
+ withDrawer = {allowDrawer !== false ? true : false}
76
+ {...props}
77
+ title = {defaultVal(props.title,options.title,rest.title)}
78
+ subtitle = {defaultVal(props.subtitle,options.subtitle,rest.subtitle)}
79
+ screenName={sanitizedName}
80
+ options={options}
81
+ />
82
+ }
@@ -2,15 +2,11 @@ import {defaultBool,defaultArray,defaultVal,isObj,isNonNullString,defaultObj,isA
2
2
  import {sanitizeName,GROUP_NAMES} from "./utils";
3
3
  import mainScreens from "$mainScreens"
4
4
  import React from "$react";
5
- import { BackHandler } from "react-native";
6
- import APP from "$capp";
7
- import {useDrawer} from "$ecomponents/Drawer";
8
- import {navigationRef,getScreenProps,setRoute,setActiveNavigation,setScreenOptions,goBack} from "$cnavigation";
5
+ import ScreenWrapper from "./ScreenWrapper";
6
+ import { SCREEN_OPTIONS } from "./utils";
9
7
 
10
8
  export * from "./utils";
11
9
 
12
- export const SCREEN_OPTIONS = {};
13
-
14
10
 
15
11
  export const handleScreen = ({Screen,Factory,ModalFactory,result,useTheme,filter,index})=>{
16
12
  result = defaultObj(result);
@@ -33,9 +29,9 @@ export const handleScreen = ({Screen,Factory,ModalFactory,result,useTheme,filter
33
29
  screenName = defaultStr(screenName,Screen.screenName);
34
30
  if(isNonNullString(screenName)){
35
31
  let name = screenName;
36
- let sanitizedName = sanitizeName(screenName);
32
+ const sanitizedName = sanitizeName(screenName);
37
33
  let extra = filter({Screen,name,sanitizedName}),
38
- authRequired = !!Screen.authRequired;
34
+ authRequired = typeof Screen.authRequired =="boolean"? Screen.authRequired : true;
39
35
  if(extra ===false){
40
36
  return null;
41
37
  }
@@ -62,6 +58,9 @@ export const handleScreen = ({Screen,Factory,ModalFactory,result,useTheme,filter
62
58
  screensGroups[groupName] = defaultArray(screensGroups[groupName]);
63
59
  screensGroups[groupName].push(<ScreenComponent key={sanitizedName} name={sanitizedName} options={args=>{
64
60
  const options = typeof Screen.options === 'function'? Screen.options(args) : typeof screenOptions ==='function'? screenOptions(args) : defaultObj(Screen.options,screenOptions);
61
+ options.screenName = screenName;
62
+ options.Screen = Screen;
63
+ options.authRequired = authRequired;
65
64
  SCREEN_OPTIONS[sanitizedName] = options;
66
65
  options.withAppBar = Screen.isModalScreen ? true : false;
67
66
  if(options.headerShown === false || Screen.headerShown === false){
@@ -69,67 +68,10 @@ export const handleScreen = ({Screen,Factory,ModalFactory,result,useTheme,filter
69
68
  }
70
69
  options.elevation = typeof options.elevation =='number'? options.elevation : typeof Screen.elevation =='number'? Screen.elevation : undefined;
71
70
  options.back = args.navigation.canGoBack();
72
- const {title,subtitle} = getScreenProps(args);
73
- options.title = defaultVal(options.title,title);
74
- options.subtitle = defaultVal(options.subtitle,subtitle);
71
+ options.extra = defaultObj(extra);
72
+ options.isModal = Screen.isModalScreen;
75
73
  return options;
76
- }}>
77
- {props =>{
78
- const options = defaultObj(SCREEN_OPTIONS[sanitizedName]);
79
- const {drawerRef} = useDrawer()
80
- const {navigation,route} = props;
81
- setActiveNavigation(navigation);
82
- setRoute(route);
83
- React.useEffect(()=>{
84
- const unsubscribe = navigation.addListener('focus', (a) => {
85
- APP.trigger(APP.EVENTS.SCREEN_FOCUS,{
86
- screenName,
87
- sanitizedName,
88
- options,
89
- })
90
- });
91
- const unsubscribeBlur = navigation.addListener('blur', (a) => {
92
- APP.trigger(APP.EVENTS.SCREEN_BLUR,{
93
- screenName,
94
- sanitizedName,
95
- options,
96
- })
97
- });
98
- const backAction = (a) => {
99
- if(drawerRef && drawerRef.current.canToggle() && drawerRef.current.isOpen()){
100
- drawerRef.current.closeDrawer();
101
- return true;
102
- }
103
- let isGoingBack = false;
104
- if(navigationRef.canGoBack()){
105
- if(isGoingBack) return true;
106
- isGoingBack = true;
107
- const opts = navigationRef.getCurrentOptions();
108
- const aProps = defaultObj(opts.appBarProps);
109
- goBack({...opts,...aProps,...defaultObj(aProps.appBarProps)});
110
- isGoingBack = false;
111
- return true;
112
- }
113
- APP.trigger(APP.EVENTS.BACK_BUTTON,{groupName,route:navigationRef.getCurrentRoute(),screenName:sanitizedName,source:'screen'});
114
- return true;
115
- };
116
- const subscription = BackHandler.addEventListener('hardwareBackPress', backAction);
117
- return ()=>{
118
- if(unsubscribe){
119
- unsubscribe();
120
- }
121
- if(unsubscribeBlur){
122
- unsubscribeBlur();
123
- }
124
- if(subscription?.remove)subscription.remove();
125
- return BackHandler.removeEventListener('hardwareBackPress', backAction);
126
- }
127
- },[]);
128
- setScreenOptions(options);
129
- const allowDrawer = typeof options.allowDrawer ==='boolean'? options.allowDrawer : typeof Screen.allowDrawer =='boolean'? Screen.allowDrawer : Screen.isModalScreen == true ? false : true;
130
- return <Screen authRequired={authRequired||allowDrawer} backAction={Screen.isModalScreen} modal={Screen.isModalScreen} allowDrawer={allowDrawer} withDrawer = {allowDrawer !== false ? true : false} {...props} screenName={sanitizedName} extra ={defaultObj(extra)} options={options} />
131
- }}
132
- </ScreenComponent>)
74
+ }} component = {ScreenWrapper}/>);
133
75
  } else {
134
76
  console.error("Aucun nom définit pour l'écran ",Screen,index,". cet écran ne pourra pas être pris en compte dans l'application et peut provoquer des bugs.")
135
77
  }
@@ -11,3 +11,5 @@ export const GROUP_NAMES = {
11
11
  START : "INSTALL", //install est un alias à start
12
12
  DEFAULT : "PRIVATE",
13
13
  }
14
+
15
+ export const SCREEN_OPTIONS = {};
package/webpack.config.js CHANGED
@@ -18,7 +18,15 @@ module.exports = async function(env, argv,opts) {
18
18
  },
19
19
  },
20
20
  argv
21
- );
21
+ );
22
+ config.module.rules.push(
23
+ {
24
+ test: /.mjs$/,
25
+ include: /node_modules/,
26
+ include: /node_modules/,
27
+ type: "javascript/auto",
28
+ use: {loader: 'babel-loader'}
29
+ });
22
30
  //config.resolve.alias['moduleA'] = 'moduleB';
23
31
  config.mode = config.mode =="development" || config.mode =='production' ? config.mode : "development";
24
32
  // Maybe you want to turn off compression in dev mode.
@@ -1,45 +0,0 @@
1
- import * as React from 'react';
2
- import { StyleSheet, StylePropTypes, ViewStyle } from 'react-native';
3
- import {Text,TouchableRipple} from "react-native-paper";
4
- import Label from "$ecomponents/Label";
5
- import PropTypes from "prop-types";
6
- import {styleTypeProps} from "$theme";
7
-
8
- const DataTableCell = ({ children, style, numeric, ...rest }) => (
9
- <TouchableRipple
10
- {...rest}
11
- style={[styles.container, numeric && styles.right, style]}
12
- >
13
- <Text numberOfLines={1}>{children}</Text>
14
- </TouchableRipple>
15
- );
16
-
17
- DataTableCell.displayName = 'DataTable.Cell';
18
-
19
- const styles = StyleSheet.create({
20
- container: {
21
- flex: 1,
22
- flexDirection: 'row',
23
- alignItems: 'center',
24
- },
25
-
26
- right: {
27
- justifyContent: 'flex-end',
28
- },
29
- });
30
-
31
- export default DataTableCell;
32
-
33
-
34
- DataTableCell.propTypes = {
35
- children: PropTypes.node,
36
- /**
37
- * Align the text to the right. Generally monetary or number fields are aligned to right.
38
- */
39
- numeric : PropTypes.bool,
40
- /**
41
- * Function to execute on press.
42
- */
43
- onPress : PropTypes.func,
44
- style : styleTypeProps,
45
- }