@fto-consult/expo-ui 1.0.37 → 1.1.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.
- package/babel.config.alias.js +3 -0
- package/package.json +2 -2
- package/src/auth/Login.js +16 -20
- package/src/auth/index.js +0 -9
package/babel.config.alias.js
CHANGED
|
@@ -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
|
|
3
|
+
"version": "1.1.0",
|
|
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.
|
|
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
|
|
|
@@ -62,8 +63,8 @@ export default function LoginComponent(props){
|
|
|
62
63
|
Preloader.closeAll();
|
|
63
64
|
},[]);
|
|
64
65
|
React.useEffect(()=>{
|
|
65
|
-
if(typeof
|
|
66
|
-
return
|
|
66
|
+
if(typeof loginProps.focusField =='function'){
|
|
67
|
+
return loginProps.focusField({...state,focusField,nextButtonRef,data:getData()})
|
|
67
68
|
}
|
|
68
69
|
},[state.step]);
|
|
69
70
|
if(withPortal){
|
|
@@ -77,18 +78,20 @@ export default function LoginComponent(props){
|
|
|
77
78
|
},1000)
|
|
78
79
|
}
|
|
79
80
|
},[withPortal])
|
|
80
|
-
const
|
|
81
|
+
const getProps = typeof getLoginProps =='function'? getLoginProps : x=>null;
|
|
82
|
+
const {header,children,...loginProps} = defaultObj(getProps({
|
|
81
83
|
...state,
|
|
82
84
|
data : getData(),
|
|
83
85
|
focusField,
|
|
84
86
|
state,
|
|
87
|
+
formName,
|
|
85
88
|
setState,
|
|
86
89
|
nextButtonRef,
|
|
87
|
-
}))
|
|
90
|
+
}));
|
|
88
91
|
/****la fonction à utiliser pour vérifier si l'on peut envoyer les données pour connextion
|
|
89
92
|
* par défaut, on envoie les données lorssqu'on est à l'étappe 2
|
|
90
93
|
* **/
|
|
91
|
-
const canSubmit = typeof
|
|
94
|
+
const canSubmit = typeof loginProps.canSubmit =='function'? loginProps.canSubmit : ({step})=>step >= 2;
|
|
92
95
|
const goToNext = ()=>{
|
|
93
96
|
let step = state.step;
|
|
94
97
|
let data = getData();
|
|
@@ -99,8 +102,8 @@ export default function LoginComponent(props){
|
|
|
99
102
|
return;
|
|
100
103
|
}
|
|
101
104
|
const args = {data,form,step,nextButtonRef};
|
|
102
|
-
if(typeof
|
|
103
|
-
const s =
|
|
105
|
+
if(typeof loginProps.validate =='function'){
|
|
106
|
+
const s = loginProps.validate(args);
|
|
104
107
|
if(s === false) return;
|
|
105
108
|
if(isNonNullString(s)){
|
|
106
109
|
notifyUser(s);
|
|
@@ -110,7 +113,7 @@ export default function LoginComponent(props){
|
|
|
110
113
|
if(canSubmit(args) && step > 1){
|
|
111
114
|
Preloader.open("vérification ...");
|
|
112
115
|
return auth.signIn(data).then((a)=>{
|
|
113
|
-
if(typeof
|
|
116
|
+
if(typeof loginProps.onSuccess =='function' && loginProps.onSuccess(a)=== false) return;
|
|
114
117
|
if(isFunction(onSuccess)){
|
|
115
118
|
onSuccess(true);
|
|
116
119
|
} else {
|
|
@@ -138,18 +141,19 @@ export default function LoginComponent(props){
|
|
|
138
141
|
header = {<View style = {[styles.header]}>
|
|
139
142
|
<Avatar testID={testID+"_Avatar"} size={50} secondary icon = 'lock'/>
|
|
140
143
|
<Label testID={testID+"_HeaderText"} bool style={{color:theme.colors.primaryOnSurface,fontSize:18,paddingTop:10}}>Connectez vous SVP</Label>
|
|
144
|
+
{React.isValidElement(header)? header : null}
|
|
141
145
|
</View>}
|
|
142
146
|
responsive = {false}
|
|
143
|
-
{...
|
|
147
|
+
{...loginProps}
|
|
144
148
|
formProps = {{
|
|
145
149
|
keyboardEvents : {
|
|
146
|
-
...defaultObj(
|
|
150
|
+
...defaultObj(loginProps.keyboardEvents),
|
|
147
151
|
enter : ({formInstance})=>{
|
|
148
152
|
goToNext();
|
|
149
153
|
}
|
|
150
154
|
}
|
|
151
155
|
}}
|
|
152
|
-
data = {extendObj(props.data,
|
|
156
|
+
data = {extendObj(props.data,loginProps.data)}
|
|
153
157
|
>
|
|
154
158
|
<View testID={testID+"_ButtonsContainer"} style={[styles.buttonWrapper]}>
|
|
155
159
|
<Button
|
|
@@ -179,20 +183,12 @@ export default function LoginComponent(props){
|
|
|
179
183
|
</Button> : null}
|
|
180
184
|
</View>
|
|
181
185
|
</FormData>
|
|
186
|
+
{React.isValidElement(children) ? children : null}
|
|
182
187
|
</Surface>
|
|
183
188
|
</Surface>
|
|
184
189
|
</Wrapper>;
|
|
185
190
|
}
|
|
186
191
|
|
|
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
192
|
|
|
197
193
|
const updateMediaQueryStyle = ()=>{
|
|
198
194
|
const isSmallPhone = Dimensions.isSmallPhoneMedia(),isTablet = Dimensions.isTabletMedia(),
|