@fto-consult/expo-ui 3.3.4 → 3.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "3.3.4",
3
+ "version": "3.4.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,8 @@ import TableLink from "$TableLink";
11
11
  import {Flag} from "$ecomponents/Countries";
12
12
  import { StyleSheet } from "react-native";
13
13
  import {isDesktopMedia} from "$dimensions";
14
-
14
+ import {View} from "react-native";
15
+ import theme from "$theme";
15
16
  export const renderRowCell = (arg)=>{
16
17
  let {rowData,getRowKey,context,formatValue:customFormatValue,renderRowCell:customRenderRowCell,abreviateValues,isSectionListHeader,rowIndex,index,rowCounterIndex,columnDef,columnField} = arg;
17
18
  context = context || this;
@@ -24,10 +25,6 @@ export const renderRowCell = (arg)=>{
24
25
  getRowKey = typeof getRowKey =='function'? getRowKey : React.getKey;
25
26
  columnDef = defaultObj(columnDef);
26
27
  let _type = defaultStr(columnDef.jsType,columnDef.type).trim().toLowerCase().replaceAll("_","");
27
- let renderProps = undefined;
28
- if(isObj(columnDef.datagrid)){
29
- renderProps = columnDef.datagrid.renderProps;
30
- }
31
28
  const style = Object.assign({},StyleSheet.flatten(columnDef.style));
32
29
  if(!renderText && columnDef.visible === false){
33
30
  style.display = "none";
@@ -70,16 +67,47 @@ export const renderRowCell = (arg)=>{
70
67
  else if(!renderText && (isNonNullString(columnDef.foreignKeyTable) || columnDef.primaryKey === true || arrayValueExists(['id','piece'],_type))){
71
68
  const id = rowData[columnField]?.toString();
72
69
  if(isNonNullString(id)){
73
- _render = <TableLink
74
- id = {id}
75
- foreignKeyTable = {defaultStr(columnDef.foreignKeyTable,columnDef.table,columnDef.tableName)}
76
- foreignKeyColumn = {defaultStr(columnDef.foreignKeyColumn,columnDef.field)}
77
- {...columnDef}
78
- data = {rowData}
79
- columnField = {columnField}
80
- >
81
- {renderSelectFieldCell({columnDef,columnField,rowData})}
82
- </TableLink>
70
+ const rProps = {
71
+ foreignKeyTable : defaultStr(columnDef.foreignKeyTable,columnDef.table,columnDef.tableName),
72
+ foreignKeyColumn : defaultStr(columnDef.foreignKeyColumn,columnDef.field),
73
+ ...columnDef,
74
+ multiple : undefined,
75
+ readOnly : undefined,
76
+ disabled : undefined,
77
+ editable : undefined,
78
+ data : rowData,
79
+ columnField,
80
+ }
81
+ const sepp = ",";
82
+ if(columnDef.multiple && id.contains(sepp)){
83
+ let hasC = false,sep2 ="";
84
+ _render = <View style={[style,theme.styles.row,theme.styles.flexWrap]} testID={"RN_RowCell_"+columnDef.field+"multiple_"}>
85
+ {id.split(sepp).map((idd,index)=>{
86
+ if(!isNonNullString(idd)) return null;
87
+ idd = idd.trim();
88
+ if(!idd) return null;
89
+ if(hasC){
90
+ sep2=", ";
91
+ }
92
+ hasC = true;
93
+ return <TableLink
94
+ key = {index}
95
+ {...rProps}
96
+ id = {idd}
97
+ >
98
+ {sep2+idd}
99
+ </TableLink>
100
+ })}
101
+ </View>
102
+
103
+ } else {
104
+ _render = <TableLink
105
+ {...rProps}
106
+ id = {id}
107
+ >
108
+ {renderSelectFieldCell({columnDef,rowCellValue:id,columnField,rowData})}
109
+ </TableLink>
110
+ }
83
111
  }
84
112
  } else if((_type.contains('select'))){
85
113
  _render= renderSelectFieldCell({columnDef,columnField,rowData,data:rowData})
@@ -119,18 +147,10 @@ export const renderRowCell = (arg)=>{
119
147
  }
120
148
  _render = __r;
121
149
  }
122
- if(isFunction(renderProps)){
123
- renderProps = renderProps.call(context,renderArgs);
124
- }
125
150
  if(canFormatValue){
126
151
  const formatter = typeof columnDef.formatValue =='function'? columnDef.formatValue : undefined;
127
152
  _render = formatValue(_render,columnDef.format,abreviateValues,formatter);
128
153
  }
129
- if(!renderText && _render && isObj(renderProps)){
130
- let Component = defaultVal(renderProps.Component,Label);
131
- delete renderProps.Component;
132
- _render = <Component {...renderProps}>{_render}</Component>
133
- }
134
154
  if(renderText){
135
155
  if(typeof _render =='number' || typeof _render =='boolean' || typeof _render =="string"){
136
156
  return _render;
@@ -144,8 +164,8 @@ export const renderRowCell = (arg)=>{
144
164
  return {render:_render,style,extra,key};
145
165
  }
146
166
 
147
- export const renderSelectFieldCell= ({rowData,columnDef,columnField})=>{
148
- let v1 = rowData[columnField],_render = v1;
167
+ export const renderSelectFieldCell= ({rowData,rowCellValue,columnDef,columnField})=>{
168
+ let v1 = rowCellValue || rowData[columnField],_render = v1;
149
169
  if(isObjOrArray(columnDef.items)){
150
170
  if(columnDef.multiple){
151
171
  v1 = Object.toArray(v1);
@@ -181,6 +201,17 @@ export const renderSelectFieldCell= ({rowData,columnDef,columnField})=>{
181
201
  }
182
202
  }
183
203
  }
204
+ if(Array.isArray(_render) || isObj(_render)){
205
+ let rr = "",sep = "";
206
+ Object.map(_render,(r)=>{
207
+ const t = React.getTextContent(r);
208
+ if(isNonNullString(t)){
209
+ rr+=(sep)+t;
210
+ sep = arrayValueSeparator;
211
+ }
212
+ })
213
+ return rr;
214
+ }
184
215
  return _render
185
216
  }
186
217
 
@@ -52,7 +52,7 @@ export const getSWROptions = ()=>{
52
52
  const delay = defaultNumber(appConfig.get("swrRefreshTimeout"),timeout);
53
53
  return {
54
54
  dedupingInterval : delay,
55
- errorRetryInterval : delay*2,
55
+ errorRetryInterval : Math.max(delay*2,timeout),
56
56
  errorRetryCount : 5,
57
57
  revalidateOnMount : false,//enable or disable automatic revalidation when component is mounted
58
58
  revalidateOnFocus : true, //automatically revalidate when window gets focused (details)
@@ -1,8 +1,8 @@
1
1
  import {Colors} from "$theme";
2
2
  import React from 'react';
3
3
  import View from "$ecomponents/View";
4
- import {StyleSheet,TouchableWithoutFeedback} from 'react-native';
5
- import ScrollView from "$ecomponents/ScrollView";
4
+ import {StyleSheet,ScrollView,TouchableWithoutFeedback} from 'react-native';
5
+ //import ScrollView from "$ecomponents/ScrollView";
6
6
  import Label from "$ecomponents/Label";
7
7
  import Icon from "$ecomponents/Icon"
8
8
  import {defaultObj,isNonNullString,defaultStr} from "$utils";