@fto-consult/expo-ui 1.0.37 → 1.1.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.
@@ -53,6 +53,9 @@ module.exports = (opts)=>{
53
53
  if(r["$navigation"] == r["$cnavigation"]){
54
54
  r["$navigation"] = r["$enavigation"];
55
55
  }
56
+ if(r["$loginComponent"] == r["$cloginComponent"]){
57
+ r["$loginComponent"] = path.resolve(expo,"auth","Login");
58
+ }
56
59
  if(typeof opts.mutator =='function'){
57
60
  opts.mutator(r);
58
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "1.0.37",
3
+ "version": "1.1.1",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -60,7 +60,7 @@
60
60
  "@emotion/native": "^11.10.0",
61
61
  "@expo/metro-config": "^0.4.0",
62
62
  "@expo/webpack-config": "^0.17.2",
63
- "@fto-consult/common": "^1.1.11",
63
+ "@fto-consult/common": "^1.1.13",
64
64
  "@gorhom/portal": "^1.0.14",
65
65
  "@react-native-async-storage/async-storage": "~1.17.3",
66
66
  "@react-native-community/netinfo": "9.3.0",
package/src/auth/Login.js CHANGED
@@ -18,6 +18,7 @@ import {Provider as DialogProvider} from "$ecomponents/Dialog";
18
18
  import Screen from "$escreen";
19
19
  import {getTitle} from "$escreens/Auth/utils";
20
20
  import {isWeb} from "$cplatform";
21
+ import getLoginProps from "$getLoginProps";
21
22
 
22
23
  const WIDTH = 400;
23
24
 
@@ -58,14 +59,7 @@ export default function LoginComponent(props){
58
59
  }
59
60
  }
60
61
 
61
- React.useEffect(()=>{
62
- Preloader.closeAll();
63
- },[]);
64
- React.useEffect(()=>{
65
- if(typeof formProps.focusField =='function'){
66
- return formProps.focusField({...state,focusField,nextButtonRef,data:getData()})
67
- }
68
- },[state.step]);
62
+
69
63
  if(withPortal){
70
64
  appBarProps = defaultObj(appBarProps);
71
65
  appBarProps.backAction = false;
@@ -77,18 +71,29 @@ export default function LoginComponent(props){
77
71
  },1000)
78
72
  }
79
73
  },[withPortal])
80
- const formProps = defaultObj(LoginComponent.getProps(LoginComponent.getProps({
74
+ const getProps = typeof getLoginProps =='function'? getLoginProps : x=>null;
75
+ const {header,children,data:loginData,validate,keyboardEvents,onSuccess:onLoginSuccess,canSubmit:canSubmitForm,onStepChange,...loginProps} = defaultObj(getProps({
81
76
  ...state,
82
77
  data : getData(),
83
- focusField,
84
78
  state,
79
+ formName,
85
80
  setState,
86
81
  nextButtonRef,
87
- })));
82
+ }));
83
+ React.useEffect(()=>{
84
+ Preloader.closeAll();
85
+ },[]);
86
+ const prevStep = React.usePrevious(state.step);
87
+ React.useEffect(()=>{
88
+ /*** lorsque le state du composant change */
89
+ if(typeof onStepChange =='function'){
90
+ return onStepChange({...state,previousStep:prevStep,focusField,nextButtonRef,data:getData()})
91
+ }
92
+ },[state.step]);
88
93
  /****la fonction à utiliser pour vérifier si l'on peut envoyer les données pour connextion
89
94
  * par défaut, on envoie les données lorssqu'on est à l'étappe 2
90
95
  * **/
91
- const canSubmit = typeof formProps.canSubmit =='function'? formProps.canSubmit : ({step})=>step >= 2;
96
+ const canSubmit = typeof canSubmitForm =='function'? canSubmitForm : ({step})=>step >= 2;
92
97
  const goToNext = ()=>{
93
98
  let step = state.step;
94
99
  let data = getData();
@@ -99,8 +104,8 @@ export default function LoginComponent(props){
99
104
  return;
100
105
  }
101
106
  const args = {data,form,step,nextButtonRef};
102
- if(typeof formProps.validate =='function'){
103
- const s = formProps.validate(args);
107
+ if(typeof validate =='function'){
108
+ const s = validate(args);
104
109
  if(s === false) return;
105
110
  if(isNonNullString(s)){
106
111
  notifyUser(s);
@@ -110,7 +115,7 @@ export default function LoginComponent(props){
110
115
  if(canSubmit(args) && step > 1){
111
116
  Preloader.open("vérification ...");
112
117
  return auth.signIn(data).then((a)=>{
113
- if(typeof formProps.onSuccess =='function' && formProps.onSuccess(a)=== false) return;
118
+ if(typeof onLoginSuccess =='function' && onLoginSuccess(a)=== false) return;
114
119
  if(isFunction(onSuccess)){
115
120
  onSuccess(true);
116
121
  } else {
@@ -138,18 +143,19 @@ export default function LoginComponent(props){
138
143
  header = {<View style = {[styles.header]}>
139
144
  <Avatar testID={testID+"_Avatar"} size={50} secondary icon = 'lock'/>
140
145
  <Label testID={testID+"_HeaderText"} bool style={{color:theme.colors.primaryOnSurface,fontSize:18,paddingTop:10}}>Connectez vous SVP</Label>
146
+ {React.isValidElement(header)? header : null}
141
147
  </View>}
142
148
  responsive = {false}
143
- {...formProps}
149
+ {...loginProps}
144
150
  formProps = {{
145
151
  keyboardEvents : {
146
- ...defaultObj(formProps.keyboardEvents),
152
+ ...defaultObj(keyboardEvents),
147
153
  enter : ({formInstance})=>{
148
154
  goToNext();
149
155
  }
150
156
  }
151
157
  }}
152
- data = {extendObj(props.data,formProps.data)}
158
+ data = {extendObj(props.data,loginData)}
153
159
  >
154
160
  <View testID={testID+"_ButtonsContainer"} style={[styles.buttonWrapper]}>
155
161
  <Button
@@ -179,20 +185,12 @@ export default function LoginComponent(props){
179
185
  </Button> : null}
180
186
  </View>
181
187
  </FormData>
188
+ {React.isValidElement(children) ? children : null}
182
189
  </Surface>
183
190
  </Surface>
184
191
  </Wrapper>;
185
192
  }
186
193
 
187
- /**** cette fonction est utilisée, pour modifier dynamiquement les champs et les props de connexion au formulaire */
188
- LoginComponent.getProps = ({data,step,state,nextButtonRef})=>{
189
- return {
190
- ///les champ à utiliser pour l'authentification de l'utilisateur
191
- fields : {
192
-
193
- }
194
- }
195
- }
196
194
 
197
195
  const updateMediaQueryStyle = ()=>{
198
196
  const isSmallPhone = Dimensions.isSmallPhoneMedia(),isTablet = Dimensions.isTabletMedia(),
package/src/auth/index.js DELETED
@@ -1,9 +0,0 @@
1
- import AuthGuard from "$cauth/AuthGuard";
2
- import Login from "./Login";
3
- AuthGuard.Login = Login;
4
-
5
- export * from "$cauth";
6
-
7
- export {default} from "$cauth";
8
-
9
- export {Login};