@fto-consult/expo-ui 2.34.2 → 2.34.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": "2.34.2",
3
+ "version": "2.34.4",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/App.js CHANGED
@@ -107,7 +107,7 @@ export default function getIndex(options){
107
107
  const date = screensRef.current[screen];
108
108
  const diff = new Date().getTime() - date.getTime();
109
109
  const timeout = defaultNumber(appConfig.get("swrRefreshTimeout"),SWR_REFRESH_TIMEOUT)
110
- //console.log(diff,"is diff and ",date.toFormat("HH:MM:ss"),screensRef,screen);
110
+ screensRef.current[screen] = new Date();
111
111
  return diff >= timeout ? true : false;
112
112
  },
113
113
  initFocus(callback) {
@@ -155,7 +155,7 @@ export const footerFieldName = "dgrid-fters-fields";
155
155
 
156
156
 
157
157
  /*****
158
- * Pour spécifier qu'un champ du datagrid n'existe pas en bd il s'uffit de suffixer le nom du champ par le suffix : "FoundInDB" et de renseigner false comme valeur
158
+ * Pour spécifier qu'un champ du datagrid n'existe pas en bd il s'ufit de suffixer le nom du champ par le suffix : "FoundInDB" et de renseigner false comme valeur
159
159
  de l'objet rowData de cette propriété
160
160
  */
161
161
  export default class CommonDatagridComponent extends AppComponent {
@@ -719,7 +719,7 @@ export default class CommonDatagridComponent extends AppComponent {
719
719
  if(header.type.contains("date")){
720
720
  this.dateFields[header.field] = header;
721
721
  }
722
- /**** pour ignorer une colonne du datagrid, il suffit de passer le paramètre datagrid à false */
722
+ /**** pour ignorer une colonne du datagrid, il sufit de passer le paramètre datagrid à false */
723
723
  if(!isNonNullString(header.field) || header.datagrid === false) {
724
724
  return;
725
725
  }
@@ -2094,6 +2094,10 @@ export default class CommonDatagridComponent extends AppComponent {
2094
2094
  let totalWidths = 0;
2095
2095
  let columnIndex = 0,visibleColumnIndex=0;
2096
2096
  this.sectionListColumnsSize.current = 0;
2097
+ /*** la props widht de la colonne peut être en pourcentage
2098
+ * l'on peut également définir la valeur minWidth en entier qui représentera la longuer minimale du champ
2099
+ * la props fitWidth permet de dire que le champ devra occuper l'espace restant sur la page
2100
+ */
2097
2101
  Object.map(columns,(header,headerIndex) => {
2098
2102
  let {
2099
2103
  field,
@@ -2115,6 +2119,9 @@ export default class CommonDatagridComponent extends AppComponent {
2115
2119
 
2116
2120
  const type = defaultStr(header.jsType,header.type,"text").toLowerCase();
2117
2121
  sortType = defaultStr(sortType,type).toLowerCase();
2122
+ if(typeof width =='string' && width.contains("%")){
2123
+ width = ((parseFloat(width.replaceAll(" ","").split('%')[0].trim())|0)*windowWidth)/100;
2124
+ }
2118
2125
  width = defaultDecimal(width);
2119
2126
  if(width <COLUMN_WIDTH/2){
2120
2127
  width = COLUMN_WIDTH;
@@ -2129,6 +2136,9 @@ export default class CommonDatagridComponent extends AppComponent {
2129
2136
  } else if(type =="select_country" || type =='selectcountry'){
2130
2137
  width = Math.max(width,90);
2131
2138
  }
2139
+ if(typeof restCol.minWidth =='number'){
2140
+ width = Math.max(width,minWidth);
2141
+ }
2132
2142
  totalWidths +=width;
2133
2143
  widths[header.field] = width;
2134
2144
  const colProps = {id,key}
@@ -2139,6 +2149,7 @@ export default class CommonDatagridComponent extends AppComponent {
2139
2149
  }
2140
2150
  const title = header.text = header.text || header.label || header.title||header.field
2141
2151
  visibleColumnsNames[header.field] = visible ? true : false;
2152
+
2142
2153
  visibleColumns.push({
2143
2154
  onPress : ()=>{
2144
2155
  setTimeout(() => {
@@ -49,7 +49,7 @@ export const setSessionData = (key,value)=>{
49
49
 
50
50
 
51
51
 
52
- export const timeout = 5000*60//*60;
52
+ export const timeout = 5000*60;//5 minutes
53
53
  /***@see : https://swr.vercel.app/docs/api */
54
54
 
55
55
  export const getSWROptions = ()=>{
@@ -170,11 +170,13 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
170
170
  const canHandleLimit = handleQueryLimit !== false ? true : false;
171
171
  const limitRef = React.useRef(!canHandleLimit ?0 : defaultNumber(getSessionData("limit"),500));
172
172
  const isInitializedRef = React.useRef(false);
173
- testID = defaultStr(testID,"RNSWRDatagridComponent")
174
- const {error, isValidating,isLoading,refresh} = useSWR(fetchPath,{
173
+ testID = defaultStr(testID,"RNSWRDatagridComponent");
174
+ const isLoadingRef = React.useRef(true);
175
+ const {error, isValidating,isLoading:customIsLoading,refresh} = useSWR(fetchPath,{
175
176
  fetcher : (url,opts)=>{
176
177
  if(!isInitializedRef.current) {
177
178
  isFetchingRef.current = false;
179
+ isLoadingRef.current = false;
178
180
  return;
179
181
  }
180
182
  opts = extendObj({},opts,fetchOptionsRef.current);
@@ -206,6 +208,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
206
208
  url = setQueryParams(url,opts.queryParams);
207
209
  return fetcher(url,opts).then(fetchCB).finally(()=>{
208
210
  isFetchingRef.current = false;
211
+ isLoadingRef.current = false;
209
212
  });
210
213
  }
211
214
  const {url:fUrl,fetcher:cFetcher,...rest} = getFetcherOptions(url,opts);
@@ -219,22 +222,21 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
219
222
  ...defaultObj(appConfig.swr),
220
223
  },
221
224
  });
225
+ const isLoading = isLoadingRef.current && customIsLoading || false;
222
226
  React.useEffect(()=>{
223
227
  innerRef.current && innerRef.current.setIsLoading && innerRef.current.setIsLoading(isLoading);
224
228
  },[isLoading])
225
229
  React.useEffect(()=>{
226
230
  const cb = refreshCBRef.current;
227
231
  refreshCBRef.current = null;
228
- if(!isValidating && !isLoading && typeof cb =='function'){
232
+ if(!isValidating && !customIsLoading && typeof cb =='function'){
229
233
  cb();
230
234
  }
231
- },[isValidating,isLoading])
235
+ },[isValidating,customIsLoading])
232
236
  const doRefresh = (showProgress)=>{
233
237
  showProgressRef.current = showProgress ? typeof showProgress ==='boolean' : false;
234
238
  if(isFetchingRef.current) return;
235
- refreshCBRef.current = ()=>{
236
- //showProgressRef.current = false;
237
- };
239
+ isLoadingRef.current = true;
238
240
  refresh();
239
241
  }
240
242
  const canPaginate = ()=>{
@@ -272,7 +274,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
272
274
  ///si le nombre total d'élements est inférieur au nombre limite alors le trie peut être fait localement
273
275
  return totalRef.current > limitRef.current && true || false;
274
276
  }
275
- const loading = (isLoading|| isValidating);
277
+ const loading = (isLoadingRef.current && (isLoading|| isValidating));
276
278
  const pointerEvents = loading ?"node" : "auto";
277
279
  const itLimits = [{
278
280
  text : "Limite nbre elts par page",
@@ -34,6 +34,15 @@ const TableDataSelectField = React.forwardRef((_props,ref)=>{
34
34
  }
35
35
  fKeyTable = defaultObj(fKeyTable);
36
36
  foreignKeyTable = defaultStr(fKeyTable.tableName,fKeyTable.table,foreignKeyTable).trim().toUpperCase();
37
+ const sortColumn = defaultStr(fKeyTable.defaultSortColumn);
38
+ const sortDir = defaultStr(fKeyTable.defaultSortOrder).toLowerCase().trim();
39
+ const sort = {};
40
+ if(sortColumn){
41
+ sort.column = sortColumn;
42
+ if(sortDir =='asc' || sortDir =='desc'){
43
+ sort.dir = sortDir;
44
+ }
45
+ }
37
46
  const isMounted = React.useIsMounted();
38
47
  const showAdd = isFilter || !foreignKeyTable ? false : React.useRef(Auth.isTableDataAllowed({foreignKeyTable,action:'create'}) ? defaultVal(props.showAdd,props.showAddBtn,true) : false).current;
39
48
  const [state,setState] = React.useState({
@@ -44,6 +53,9 @@ const TableDataSelectField = React.forwardRef((_props,ref)=>{
44
53
  const cFetch = typeof customFetchItem =='function' && customFetchItem;
45
54
  const fetchItems = (opts)=>{
46
55
  opts.showError = false;
56
+ if(sortColumn){
57
+ opts.sort = sort;
58
+ }
47
59
  if(cFetch) return cFetch(queryPath,opts);
48
60
  if(queryPath){
49
61
  return fetch(queryPath,opts);
@@ -109,6 +109,7 @@ export const getFilterComponentProps = (_props)=>{
109
109
  } else if(isNonNullString(props.foreignKeyColumn) && isNonNullString(props.foreignKeyTable)) {
110
110
  component = Fields.SelectTableData;
111
111
  props.multiple = true;
112
+ type = "select";
112
113
  }else {
113
114
  const tt = type.replaceAll("_","").toLowerCase();
114
115
  if(React.isComponent(componentTypes[tt])){