@fto-consult/expo-ui 1.1.1 → 1.1.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
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 '$eauth';
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
@@ -28,20 +28,22 @@ export default function LoginComponent(props){
28
28
  testID = defaultStr(testID,"RN_Auth.LoginComponent");
29
29
  formName = React.useRef(uniqid(defaultStr(formName,"login-formname"))).current;
30
30
  const nextButtonRef = React.useRef(null);
31
+ const previousButtonRef = React.useRef(null);
31
32
  const dialogProviderRef = React.useRef(null);
32
33
  const backgroundColor = theme.colors.surface;
33
34
  const Wrapper = withPortal ? Screen : View;
35
+ const _getForm = x=> getForm(formName);
34
36
 
35
37
  const auth = useAuth();
36
38
  const notifyUser = (message)=> notify.error({message,position:'top'})
37
39
  const [state,setState] = React.useState({
38
40
  step : defaultNumber(step,1),
41
+ data : defaultObj(props.data),
39
42
  });
40
- const _getForm = x=> getForm(formName);
41
43
  const getData = ()=>{
42
44
  const form = _getForm();
43
45
  if(form && form.getData){
44
- return form.getData();
46
+ return extendObj(state.data,form.getData());
45
47
  }
46
48
  return defaultObj(props.data);
47
49
  }
@@ -72,13 +74,14 @@ export default function LoginComponent(props){
72
74
  }
73
75
  },[withPortal])
74
76
  const getProps = typeof getLoginProps =='function'? getLoginProps : x=>null;
75
- const {header,children,data:loginData,validate,keyboardEvents,onSuccess:onLoginSuccess,canSubmit:canSubmitForm,onStepChange,...loginProps} = defaultObj(getProps({
77
+ const {header,children,data:loginData,canGoToNext,keyboardEvents,onSuccess:onLoginSuccess,canSubmit:canSubmitForm,onStepChange,...loginProps} = defaultObj(getProps({
76
78
  ...state,
77
- data : getData(),
78
- state,
79
+ getForm,
80
+ getData,
81
+ focusField,
79
82
  formName,
80
- setState,
81
83
  nextButtonRef,
84
+ previousButtonRef,
82
85
  }));
83
86
  React.useEffect(()=>{
84
87
  Preloader.closeAll();
@@ -87,7 +90,7 @@ export default function LoginComponent(props){
87
90
  React.useEffect(()=>{
88
91
  /*** lorsque le state du composant change */
89
92
  if(typeof onStepChange =='function'){
90
- return onStepChange({...state,previousStep:prevStep,focusField,nextButtonRef,data:getData()})
93
+ return onStepChange({...state,previousStep:prevStep,focusField,nextButtonRef})
91
94
  }
92
95
  },[state.step]);
93
96
  /****la fonction à utiliser pour vérifier si l'on peut envoyer les données pour connextion
@@ -96,16 +99,15 @@ export default function LoginComponent(props){
96
99
  const canSubmit = typeof canSubmitForm =='function'? canSubmitForm : ({step})=>step >= 2;
97
100
  const goToNext = ()=>{
98
101
  let step = state.step;
99
- let data = getData();
100
- data.code = defaultStr(data.code, state.code);
102
+ const data = getData();
101
103
  const form = _getForm();
102
104
  if(!form){
103
105
  notifyUser("Impossible de valider le formulaire car celui-ci semble invalide")
104
106
  return;
105
107
  }
106
- const args = {data,form,step,nextButtonRef};
107
- if(typeof validate =='function'){
108
- const s = validate(args);
108
+ const args = {data,form,step,nextButtonRef,previousButtonRef};
109
+ if(typeof canGoToNext =='function'){
110
+ const s = canGoToNext(args);
109
111
  if(s === false) return;
110
112
  if(isNonNullString(s)){
111
113
  notifyUser(s);
@@ -155,7 +157,7 @@ export default function LoginComponent(props){
155
157
  }
156
158
  }
157
159
  }}
158
- data = {extendObj(props.data,loginData)}
160
+ data = {extendObj(state.data,loginData)}
159
161
  >
160
162
  <View testID={testID+"_ButtonsContainer"} style={[styles.buttonWrapper]}>
161
163
  <Button
@@ -167,12 +169,12 @@ export default function LoginComponent(props){
167
169
  onPress = {goToNext}
168
170
  icon = {state.step == 1? 'arrow-right':'login'}
169
171
  surface
170
- disabled = {!isNonNullString(state.code)}
171
172
  >
172
173
  {state.step == 1? 'Suivant' : 'Connexion' }
173
174
  </Button>
174
175
  {state.step>=2 ? <Button
175
176
  onPress = {goToFirstStep}
177
+ ref = {previousButtonRef}
176
178
  mode = "contained"
177
179
  rounded
178
180
  raised
@@ -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,