@fto-consult/expo-ui 1.1.0 → 1.1.2
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/package.json +1 -1
- package/src/App.js +1 -1
- package/src/auth/Login.js +18 -16
- package/src/components/TextField/index.js +1 -0
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -12,7 +12,7 @@ import DialogProvider from "$ecomponents/Dialog/Provider";
|
|
|
12
12
|
import { DialogProvider as FormDataDialogProvider } from '$eform/FormData';
|
|
13
13
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
14
14
|
import { PreferencesContext } from './Preferences';
|
|
15
|
-
import {AuthProvider} from '$
|
|
15
|
+
import {AuthProvider} from '$cauth';
|
|
16
16
|
import {PortalProvider } from '$ecomponents/Portal';
|
|
17
17
|
import ErrorBoundary from "$ecomponents/ErrorBoundary";
|
|
18
18
|
import ErrorBoundaryProvider from "$ecomponents/ErrorBoundary/Provider";
|
package/src/auth/Login.js
CHANGED
|
@@ -59,14 +59,7 @@ export default function LoginComponent(props){
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
Preloader.closeAll();
|
|
64
|
-
},[]);
|
|
65
|
-
React.useEffect(()=>{
|
|
66
|
-
if(typeof loginProps.focusField =='function'){
|
|
67
|
-
return loginProps.focusField({...state,focusField,nextButtonRef,data:getData()})
|
|
68
|
-
}
|
|
69
|
-
},[state.step]);
|
|
62
|
+
|
|
70
63
|
if(withPortal){
|
|
71
64
|
appBarProps = defaultObj(appBarProps);
|
|
72
65
|
appBarProps.backAction = false;
|
|
@@ -79,19 +72,28 @@ export default function LoginComponent(props){
|
|
|
79
72
|
}
|
|
80
73
|
},[withPortal])
|
|
81
74
|
const getProps = typeof getLoginProps =='function'? getLoginProps : x=>null;
|
|
82
|
-
const {header,children,...loginProps} = defaultObj(getProps({
|
|
75
|
+
const {header,children,data:loginData,validate,keyboardEvents,onSuccess:onLoginSuccess,canSubmit:canSubmitForm,onStepChange,...loginProps} = defaultObj(getProps({
|
|
83
76
|
...state,
|
|
84
77
|
data : getData(),
|
|
85
|
-
focusField,
|
|
86
78
|
state,
|
|
87
79
|
formName,
|
|
88
80
|
setState,
|
|
89
81
|
nextButtonRef,
|
|
90
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]);
|
|
91
93
|
/****la fonction à utiliser pour vérifier si l'on peut envoyer les données pour connextion
|
|
92
94
|
* par défaut, on envoie les données lorssqu'on est à l'étappe 2
|
|
93
95
|
* **/
|
|
94
|
-
const canSubmit = typeof
|
|
96
|
+
const canSubmit = typeof canSubmitForm =='function'? canSubmitForm : ({step})=>step >= 2;
|
|
95
97
|
const goToNext = ()=>{
|
|
96
98
|
let step = state.step;
|
|
97
99
|
let data = getData();
|
|
@@ -102,8 +104,8 @@ export default function LoginComponent(props){
|
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
104
106
|
const args = {data,form,step,nextButtonRef};
|
|
105
|
-
if(typeof
|
|
106
|
-
const s =
|
|
107
|
+
if(typeof validate =='function'){
|
|
108
|
+
const s = validate(args);
|
|
107
109
|
if(s === false) return;
|
|
108
110
|
if(isNonNullString(s)){
|
|
109
111
|
notifyUser(s);
|
|
@@ -113,7 +115,7 @@ export default function LoginComponent(props){
|
|
|
113
115
|
if(canSubmit(args) && step > 1){
|
|
114
116
|
Preloader.open("vérification ...");
|
|
115
117
|
return auth.signIn(data).then((a)=>{
|
|
116
|
-
if(typeof
|
|
118
|
+
if(typeof onLoginSuccess =='function' && onLoginSuccess(a)=== false) return;
|
|
117
119
|
if(isFunction(onSuccess)){
|
|
118
120
|
onSuccess(true);
|
|
119
121
|
} else {
|
|
@@ -147,13 +149,13 @@ export default function LoginComponent(props){
|
|
|
147
149
|
{...loginProps}
|
|
148
150
|
formProps = {{
|
|
149
151
|
keyboardEvents : {
|
|
150
|
-
...defaultObj(
|
|
152
|
+
...defaultObj(keyboardEvents),
|
|
151
153
|
enter : ({formInstance})=>{
|
|
152
154
|
goToNext();
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
157
|
}}
|
|
156
|
-
data = {extendObj(props.data,
|
|
158
|
+
data = {extendObj(props.data,loginData)}
|
|
157
159
|
>
|
|
158
160
|
<View testID={testID+"_ButtonsContainer"} style={[styles.buttonWrapper]}>
|
|
159
161
|
<Button
|
|
@@ -300,6 +300,7 @@ const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
|
|
|
300
300
|
ellipsizeMode : "head",
|
|
301
301
|
testID : testID+"_Input",
|
|
302
302
|
keyboardAppearance : theme.isDark()? 'dark': 'default',
|
|
303
|
+
caretHidden : false,
|
|
303
304
|
...props,
|
|
304
305
|
innerRef,
|
|
305
306
|
placeholder : (isFocused || isShadowMode || isNormalMode) && labelText ? "":placeholder,
|