@fto-consult/expo-ui 5.11.2 → 5.11.4

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": "5.11.2",
3
+ "version": "5.11.4",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -61,7 +61,7 @@
61
61
  "@emotion/native": "^11.11.0",
62
62
  "@expo/html-elements": "^0.2.0",
63
63
  "@expo/vector-icons": "^13.0.0",
64
- "@fto-consult/common": "^3.17.1",
64
+ "@fto-consult/common": "^3.17.9",
65
65
  "@gorhom/portal": "^1.0.14",
66
66
  "@react-native-async-storage/async-storage": "^1.17.11",
67
67
  "@react-native-community/datetimepicker": "^6.7.3",
@@ -71,16 +71,16 @@
71
71
  "@react-navigation/native-stack": "^6.9.12",
72
72
  "@shopify/flash-list": "^1.4.0",
73
73
  "apexcharts": "^3.40.0",
74
- "expo": "^48.0.17",
75
- "expo-camera": "~13.2.1",
76
- "expo-clipboard": "~4.1.1",
77
- "expo-font": "~11.1.1",
78
- "expo-image-picker": "~14.1.1",
79
- "expo-linking": "~4.0.1",
80
- "expo-sqlite": "~11.1.1",
81
- "expo-status-bar": "~1.4.4",
82
- "expo-system-ui": "~2.2.1",
83
- "expo-web-browser": "~12.1.1",
74
+ "expo": "^48.0.19",
75
+ "expo-camera": "^13.2.1",
76
+ "expo-clipboard": "^4.1.2",
77
+ "expo-font": "^11.1.1",
78
+ "expo-image-picker": "^14.1.1",
79
+ "expo-linking": "^4.0.1",
80
+ "expo-sqlite": "^11.1.1",
81
+ "expo-status-bar": "^1.4.4",
82
+ "expo-system-ui": "^2.2.1",
83
+ "expo-web-browser": "^12.1.1",
84
84
  "file-saver": "^2.0.5",
85
85
  "fs-extra": "^11.1.1",
86
86
  "google-libphonenumber": "^3.2.32",
@@ -27,28 +27,26 @@ export const close = (props)=>{
27
27
  }
28
28
 
29
29
  const Provider = React.forwardRef((props,innerRef)=>{
30
- const {onDismiss} = props;
31
30
  const ref = innerRef || createProviderRef();
32
- const [state,setState] = React.useState({
33
- visible : false,
34
- });
31
+ const [visible,setVisible] = React.useState(false);
32
+ const [state,setState] = React.useState({});
35
33
  const context = {
36
34
  open : (props)=>{
37
- return setState({onDismiss:undefined,...defaultObj(props),visible:true})
35
+ if(!visible){
36
+ setVisible(true);
37
+ }
38
+ setState(defaultObj(props));
38
39
  },
39
- close : (props)=>{
40
- return setState({...state,...defaultObj(props),visible:false})
40
+ close : ()=>{
41
+ if(visible) return;
42
+ setVisible(false);
41
43
  }
42
44
  };
43
45
  React.setRef(ref,context);
44
- return <Menu {...props} {...state} sheet controlled onDismiss = {(e)=>{
45
- setState({...state,visible:false});
46
- if(typeof state.onDismiss =='function'){
47
- state.onDismiss({context,state})
48
- } else if(onDismiss){
49
- onDismiss({context,state});
46
+ return <Menu {...props} {...state} visible={visible} sheet controlled onDismiss = {(e)=>{
47
+ if(visible){
48
+ setVisible(false);
50
49
  }
51
-
52
50
  }}/>
53
51
  });
54
52
 
@@ -1590,7 +1590,7 @@ export default class CommonDatagridComponent extends AppComponent {
1590
1590
  checkedTooltip : "Les étiquettes de valeurs seront affichées sur le graphe",
1591
1591
  checkedValue : true,
1592
1592
  uncheckedValue : false,
1593
- defaultValue : this.isDashboard()? true : false,
1593
+ defaultValue : false,
1594
1594
  },
1595
1595
  abreviateValues : {
1596
1596
  type : "switch",
@@ -2227,7 +2227,7 @@ export default class CommonDatagridComponent extends AppComponent {
2227
2227
  const dataLabelFormatter = typeof chartProps.dataLabels?.formatter =="function"? chartProps.dataLabels.formatter : undefined;
2228
2228
  const chartOptions = {
2229
2229
  ...chartProps,
2230
- dataLabels : extendObj(true,{enabled:!this.isDashboard()},chartProps.dataLabels,{
2230
+ dataLabels : extendObj(true,{enabled:false},chartProps.dataLabels,{
2231
2231
  formatter : (value, { seriesIndex, dataPointIndex, w })=> {
2232
2232
  const serie = w.config.series[seriesIndex];
2233
2233
  const serieName = serie.name;
@@ -41,32 +41,28 @@ export const close = (props,innerProviderRef)=>{
41
41
  }
42
42
 
43
43
  const Provider = React.forwardRef((props,innerRef)=>{
44
- const {onDismiss,beforeOpen} = props;
45
44
  const ref = innerRef || createProviderRef();
46
- const [state,setState] = React.useState({
47
- visible : defaultBool(props.visible,false),
48
- });
45
+ const [visible,setVisible] = React.useState(defaultBool(props.visible,false));
46
+ const [state,setState] = React.useState({});
49
47
  const context = {
50
48
  open : (props)=>{
51
- if(state.visible) return;
52
- let bfOpen = typeof state.beforeOpen == 'function'? state.beforeOpen : typeof beforeOpen =='function'? beforeOpen : x=>true;
53
- if(bfOpen(state) === false) return;
54
- return setState({onDismiss:undefined,...defaultObj(props),visible:true})
49
+ if(visible) {
50
+ return;
51
+ }
52
+ if(!visible){
53
+ setVisible(true);
54
+ }
55
+ setState(defaultObj(props));
55
56
  },
56
- close : (props)=>{
57
- if(!state.visible) return;
58
- return setState({...state,...defaultObj(props),visible:false});
57
+ close : ()=>{
58
+ if(!visible) return;
59
+ setVisible(false);
59
60
  },
60
61
  };
61
62
  React.setRef(ref,context);
62
- return <Dialog {...props} {...state} controlled onDismiss = {(e)=>{
63
- if(state.visible){
64
- setState({...state,visible:false});
65
- }
66
- if(typeof state.onDismiss =='function'){
67
- state.onDismiss({context,state});
68
- } else if(onDismiss){
69
- onDismiss({context,state});
63
+ return <Dialog {...props} {...state} visible={visible} controlled onDismiss = {(e)=>{
64
+ if(visible){
65
+ setVisible(false);
70
66
  }
71
67
  }}/>
72
68
  });
@@ -258,7 +258,13 @@ export default class Field extends AppComponent {
258
258
  let fields = getFormFields(this.formName);
259
259
  let canEnable = true;
260
260
  for(var k in fields){
261
- if(!fields[k].isValid()){
261
+ if(k === this.getName()) continue;
262
+ const fK = fields[k];
263
+ const matchF = fK.getMatchField();
264
+ if(matchF && matchF.getName() === this.getName()){
265
+ fK.validate({value:fK.getValue()});
266
+ }
267
+ if(!fK.isValid()){
262
268
  canEnable = false;
263
269
  break;
264
270
  }
@@ -285,7 +291,27 @@ export default class Field extends AppComponent {
285
291
  });
286
292
  });
287
293
  }
294
+ getMatchField (){
295
+ const matchField = defaultStr(this.props.matchField).trim();
296
+ return matchField && this.getField(matchField) || null;
297
+ }
298
+ validateMatchField (value){
299
+ if(this.isFilter()) return true;
300
+ const matchedField = this.getMatchField();
301
+ if(matchedField){
302
+ value = value !== undefined ? value : this.getValue();
303
+ const matchedValue = matchedField.getValue();
304
+ if(!React.isEquals(matchedValue,value)){
305
+ return `le champ [${matchedField?.getLabel()}] doit avoir la même valeur que celle du champ [${this.getLabel()}].`;
306
+ }
307
+ }
308
+ return true;
309
+ }
288
310
  onValidatorValid(args){
311
+ const valMatchField = this.validateMatchField();
312
+ if(isNonNullString(valMatchField)){
313
+ return valMatchField;
314
+ }
289
315
  if(!this.isFilter()){
290
316
  const vRule =defaultStr(this.getValidRule()).toLowerCase();
291
317
  const value = typeof args.value == "undefined" || args.value == null ? "" : String(args.value).replaceAll("/","").replaceAll("\\",'').trim();
@@ -747,7 +773,7 @@ export default class Field extends AppComponent {
747
773
  return;
748
774
  }
749
775
  if(this.isFilter()) return
750
- const value = this.getValue();
776
+ if(this.getMatchField())
751
777
  if(isNonNullString(this.props.fieldToPopulateOnBlur) && isNonNullString(value)){
752
778
  const context = this.getField(this.props.fieldToPopulateOnBlur.trim());
753
779
  if(context && context.getValue){
@@ -1122,6 +1148,7 @@ Field.propTypes = {
1122
1148
  * Lorsqu'elle est définie alors le rendu lors du composant doit être de type filter
1123
1149
  */
1124
1150
  renderfilter : PropTypes.string,
1151
+ matchField : PropTypes.string,//si cette valeur est définie, alors le champ figurant dans la valeur doit avoir la même valeur que le champ courant
1125
1152
  /**** il s'agit d'un champ du même formulaire que la formField actuel, qui sera populated avec la valeur par défaut
1126
1153
  * de la formField cournat loreque la valeur du champ en question a une longueur très inférieure à celle de la valeur de la form courante.
1127
1154
  */
@@ -14,24 +14,25 @@ const FormDataDialogProvider = React.forwardRef((props,innerRef)=>{
14
14
  innerRef = innerRef || createProviderRef((eRef)=>{
15
15
  dialogProviderRef = eRef;
16
16
  });
17
- const [state,setState] = React.useState({
18
- visible : false,
19
- });
17
+ const [visible,setVisible] = React.useState(false);
18
+ const [state,setState] = React.useState({});
20
19
  const isMobile = isMobileOrTabletMedia();
21
20
  const formRef = React.useRef(null);
22
- const {closeAction,onDismiss} = props;
21
+ const {closeAction} = props;
23
22
  const context = {
24
23
  open : (props)=>{
25
- if(state.visible) return;
26
24
  let sData = {};
27
25
  if(formRef.current && formRef.current.formDataContext && formRef.current.formDataContext.getData){
28
26
  sData.data = formRef.current.formDataContext.getData();
29
27
  }
30
- return setState({...sData,onDismiss:undefined,...defaultObj(props),visible:true})
28
+ if(!visible){
29
+ setVisible(true);
30
+ }
31
+ setState({...sData,...defaultObj(props)});
31
32
  },
32
- close : (props)=>{
33
- if(!state.visible) return;
34
- setState({...state,...defaultObj(props),visible:false});
33
+ close : ()=>{
34
+ if(!visible) return;
35
+ setVisible(false);
35
36
  },
36
37
  };
37
38
  React.setRef(innerRef,context);
@@ -52,6 +53,7 @@ const FormDataDialogProvider = React.forwardRef((props,innerRef)=>{
52
53
  subtitle ={false}
53
54
  {...props}
54
55
  {...state}
56
+ visible = {visible}
55
57
  formProps = {formProps}
56
58
  isProvider
57
59
  ref={formRef}
@@ -82,13 +84,8 @@ const FormDataDialogProvider = React.forwardRef((props,innerRef)=>{
82
84
  dialogProps = {dialogProps}
83
85
  controlled={false}
84
86
  onDismiss = {(e)=>{
85
- if(state.visible){
86
- setState({...state,visible:false});
87
- }
88
- if(typeof state.onDismiss =='function'){
89
- state.onDismiss({context,state});
90
- } else if(onDismiss){
91
- onDismiss({context,state});
87
+ if(visible){
88
+ setVisible(false);
92
89
  }
93
90
  }}
94
91
  open = {context.open}
@@ -1,6 +1,6 @@
1
1
  import {getAppBarActionsProps} from "./utils";
2
2
  import React, {Component as AppComponent} from "$react";
3
- import {isNonNullString,defaultStr,defaultObj,extendObj,isObj,isFunction,defaultFunc,uniqid} from "$cutils";
3
+ import {isNonNullString,defaultStr,defaultNumber,defaultObj,extendObj,isObj,isFunction,defaultFunc,uniqid} from "$cutils";
4
4
  import {getForm,getFormField,Forms} from "../utils";
5
5
  import Divider from "$ecomponents/Divider";
6
6
  import Surface from "$ecomponents/Surface";
@@ -191,6 +191,7 @@ export default class FormDataComponent extends AppComponent{
191
191
  const archived = data.archived ? true : false;
192
192
  const responsive = typeof formProps.responsive =='boolean' ? formProps.responsive : this.props.responsive !== false ? true : false;
193
193
  const responsiveProps = extendObj({},this.props.responsiveProps,formProps.responsiveProps);
194
+ const windowWidth = defaultNumber(formProps.windowWidth,this.props.windowWidth) || undefined;
194
195
  Object.map(fields,(field,index,i)=>{//on ignore tous les champs supposés être à ignorer
195
196
  if(field === 'divider'){
196
197
  content.push(<Divider key = {index} style={theme.styles.w100}/>)
@@ -240,6 +241,7 @@ export default class FormDataComponent extends AppComponent{
240
241
  customResponsiveProps = defaultObj(customResponsiveProps);
241
242
  content.push(<Component
242
243
  data = {data}
244
+ windowWidth = {windowWidth}
243
245
  //withBottomSheet = {this.props.withBottomSheet}
244
246
  index = {index}
245
247
  disabled = {this.props.disabled || archived}
@@ -363,6 +365,7 @@ export default class FormDataComponent extends AppComponent{
363
365
  const cStyle = flattenStyle([styles.container,{backgroundColor:theme.surfaceBackgroundColor},containerProps.style]);
364
366
  formProps.style = flattenStyle([{backgroundColor:cStyle.backgroundColor},formProps.style]);
365
367
  formProps.fields = defaultObj(formProps.fields,fields);
368
+ formProps.windowWidth = defaultNumber(formProps.windowWidth,windowWidth) || undefined;
366
369
  const content = <Form
367
370
  {...formProps}
368
371
  name={this.getFormName()}
@@ -54,8 +54,8 @@ const styles = StyleSheet.create({
54
54
  paddingLeft : 20,
55
55
  },
56
56
  checkbox : {
57
- width : 20,
58
- height : 20,
57
+ //width : 20,
58
+ //height : 20,
59
59
  margin : 0,
60
60
  padding: 0,
61
61
  }
@@ -1,21 +0,0 @@
1
- {
2
- "name": "SMART-EEM",
3
- "version": "1.0.0",
4
- "id": "com.ftc.apps.device.smarteneo",
5
- "realeaseDateStr": "1er Juin 2021",
6
- "releaseDate": "2020-05-23",
7
- "devMail": "smart-eneo@gmail.com",
8
- "devWebsite": "http://fto-consulting.com/smart-eneo/",
9
- "copyRight": "FirsTo consulting@Août 2022",
10
- "apiVersion": "1.0",
11
- "includeCredentialsOnApiFetch": false,
12
- "checkNavigationPermsOnTableOrStructData": false,
13
- "theme": {
14
- "light": {
15
- "primary": "#00AB55",
16
- "secondary": "#354448"
17
- }
18
- },
19
- "netInfoReachabilityShortTimeout": 30000,
20
- "description": "Suivi des équipements Eneo"
21
- }