@fto-consult/expo-ui 2.18.0 → 2.18.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.
@@ -5,7 +5,7 @@ import memoize from "$react/memoize";
5
5
  export {default as FooterItem} from "./Footer";
6
6
  import {parseDecimal} from "$utils";
7
7
 
8
- export const evalSingleValue = ({data,columnDef,field,result,displayLabel,onlyVisible})=>{
8
+ export const evalSingleValue = ({data,columnDef,field,result,withLabel,displayLabel,onlyVisible})=>{
9
9
  data = data || {}
10
10
  if(!isNonNullString(field) || !isObj(columnDef)) return result;
11
11
  onlyVisible = defaultBool(onlyVisible,true);
@@ -22,7 +22,7 @@ export const evalSingleValue = ({data,columnDef,field,result,displayLabel,onlyVi
22
22
  currentResult = defaultObj(currentResult);
23
23
  if(!isObj(currentResult[field])){
24
24
  let label = defaultStr(columnDef.label,columnDef.text);
25
- if(!label && displayLabel !== false) return currentResult;
25
+ if(!label && displayLabel !== false && withLabel !== false) return currentResult;
26
26
  currentResult[field] = {
27
27
  label,
28
28
  visible : columnDef.visible,
@@ -39,12 +39,12 @@ export const evalSingleValue = ({data,columnDef,field,result,displayLabel,onlyVi
39
39
  })
40
40
  return result;
41
41
  }
42
- export const evalValues = memoize(({data,columns,onlyVisible,displayLabel})=>{
42
+ export const evalValues = memoize(({data,columns,onlyVisible,withLabel,displayLabel})=>{
43
43
  let result = {};
44
44
  Object.map(data,(rowData,i)=>{
45
45
  if(!isObj(rowData)) return result;
46
46
  Object.map(columns,(columnDef,field)=>{
47
- result = evalSingleValue({data:rowData,columnDef,field,result,displayLabel,onlyVisible})
47
+ result = evalSingleValue({data:rowData,columnDef,field,result,withLabel,displayLabel,onlyVisible})
48
48
  })
49
49
  })
50
50
  return result;
@@ -94,4 +94,6 @@ export default function DGGridFooters (props){
94
94
  }
95
95
  })}
96
96
  </Component>
97
- }
97
+ }
98
+
99
+ export {_Footer as Footer};
@@ -83,6 +83,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
83
83
  ListFooterComponent,
84
84
  testID,
85
85
  autoSort,
86
+ handleQueryLimit,
86
87
  ...rest
87
88
  } = props;
88
89
  rest = defaultObj(rest);
@@ -130,7 +131,8 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
130
131
  const totalRef = React.useRef(0);
131
132
  const isFetchingRef = React.useRef(false);
132
133
  const pageRef = React.useRef(1);
133
- const limitRef = React.useRef(defaultNumber(getSessionData("limit"),500));
134
+ const canHandleLimit = handleQueryLimit !== false ? true : false;
135
+ const limitRef = React.useRef(!canHandleLimit ?0 : defaultNumber(getSessionData("limit"),500));
134
136
  const isInitializedRef = React.useRef(false);
135
137
  testID = defaultStr(testID,"RNSWRDatagridComponent")
136
138
  const {error, isValidating,isLoading,refresh} = useSWR(fetchPath,{
@@ -142,8 +144,14 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
142
144
  opts = extendObj({},opts,fetchOptionsRef.current);
143
145
  opts.queryParams = defaultObj(opts.queryParams);
144
146
  opts.queryParams.withTotal = true;
145
- opts.queryParams.limit = limitRef.current;
146
- opts.queryParams.page = pageRef.current -1;
147
+ if(canHandleLimit){
148
+ opts.queryParams.limit = limitRef.current;
149
+ opts.queryParams.page = pageRef.current -1;
150
+ } else {
151
+ delete opts.queryParams.limit;
152
+ delete opts.queryParams.page;
153
+ delete opts.queryParams.offset;
154
+ }
147
155
  if(isObj(opts.sort)){
148
156
  opts.queryParams.sort = opts.sort;
149
157
  }
@@ -197,17 +205,17 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
197
205
  };
198
206
  refresh();
199
207
  }
200
- const canPagninate = ()=>{
201
- if(typeof totalRef.current !=='number' || typeof pageRef.current !='number' || typeof limitRef.current !='number') return false;
208
+ const canPaginate = ()=>{
209
+ if(canHandleLimit && typeof totalRef.current !=='number' || typeof pageRef.current !='number' || typeof limitRef.current !='number') return false;
202
210
  if(limitRef.current <= 0) return false;
203
211
  return true;
204
212
  }
205
213
  const getTotalPages = ()=>{
206
- if(!canPagninate()) return false;
214
+ if(!canPaginate()) return false;
207
215
  return Math.ceil(totalRef.current / limitRef.current);;
208
216
  };
209
217
  const getNextPage = ()=>{
210
- if(!canPagninate()) return false;
218
+ if(!canPaginate()) return false;
211
219
  const totalPages = getTotalPages();
212
220
  let nPage = pageRef.current+1;
213
221
  if(nPage > totalPages){
@@ -218,7 +226,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
218
226
  }
219
227
  return nPage;
220
228
  },getPrevPage = ()=>{
221
- if(!canPagninate()) return false;
229
+ if(!canPaginate()) return false;
222
230
  let pPage = pageRef.current - 1;
223
231
  if(pPage < firstPage){
224
232
  pPage = firstPage;
@@ -228,7 +236,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
228
236
  }
229
237
  return pPage;
230
238
  }, canSortRemotely = ()=>{
231
- if(!canPagninate() || autoSort === true) return false;
239
+ if(!canPaginate() || autoSort === true) return false;
232
240
  ///si le nombre total d'élements est inférieur au nombre limite alors le trie peut être fait localement
233
241
  return totalRef.current > limitRef.current && true || false;
234
242
  }
@@ -260,7 +268,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
260
268
  return false;
261
269
  }}
262
270
  renderCustomPagination = {({context})=>{
263
- if(!canPagninate()) return null;
271
+ if(!canPaginate()) return null;
264
272
  const page = pageRef.current, totalPages = getTotalPages(), prevPage = getPrevPage(),nextPage = getNextPage();
265
273
  const iconProp = {
266
274
  size : 25,
@@ -112,7 +112,8 @@ const DatagridFactory = (Factory)=>{
112
112
  }
113
113
  }
114
114
  render(){
115
- let {title,testID,actions,selectableMultiple,
115
+ let {title,testID,actions,
116
+ selectableMultiple,
116
117
  sortable,
117
118
  autoSort,
118
119
  exportable,
@@ -144,7 +145,7 @@ const DatagridFactory = (Factory)=>{
144
145
  exportable = defaultBool(exportable,true);
145
146
  let isMobile = isMobileOrTabletMedia();
146
147
  selectable = defaultVal(selectable,true);
147
- selectableMultiple = defaultBool(selectableMultiple,true);
148
+ selectableMultiple = this.isSelectableMultiple();
148
149
  pagin = defaultVal(pagin,true)
149
150
  showPagination = defaultVal(showPagination,true);
150
151
 
@@ -167,10 +168,9 @@ const DatagridFactory = (Factory)=>{
167
168
  let _progressBar = this.getProgressBar();
168
169
  const pointerEvents = isLoading? "none":"auto";
169
170
 
170
- let selectAllRowsToggleTitle = isAllRowsSelected?"Tout Déselec":"Tout Select"
171
171
  let restItems = [];
172
172
  let max = this.getMaxSelectableRows();
173
- if(selectableMultiple && max && defaultBool(this.props.selectableMultiple,true)){
173
+ if(selectableMultiple && max){
174
174
  max = max.formatNumber();
175
175
  restItems = [
176
176
  ...this.renderCustomMenu(),
@@ -190,6 +190,7 @@ const DatagridFactory = (Factory)=>{
190
190
  }] : [])
191
191
  ]
192
192
  }
193
+ const {width,height} = Dimensions.get("window");
193
194
  const rPagination = showPagination ? <View style={[styles.paginationContainer]}>
194
195
  <ScrollView horizontal showsHorizontalScrollIndicator={!isLoading} style={styles.paginationContainerStyle} contentContainerStyle={styles.minW100}>
195
196
  <View style={[styles.paginationContent]}>
@@ -307,16 +308,16 @@ const DatagridFactory = (Factory)=>{
307
308
  </View>
308
309
  </ScrollView>
309
310
  </View> : null;
310
- return <View style={[styles.container]} pointerEvents={pointerEvents}>
311
+ return <View style={[styles.container,{maxHeight:height-100}]} pointerEvents={pointerEvents}>
311
312
  <View ref={this.layoutRef}>
312
- <DatagridActions
313
+ {this.props.showActions !== false ? <DatagridActions
313
314
  pointerEvents = {pointerEvents}
314
315
  title = {title}
315
316
  context = {this}
316
317
  selectedRows = {Object.assign({},this.selectedRows)}
317
318
  selectedRowsActions = {this.renderSelectedRowsActions.bind(this)}
318
319
  actions = {actions}
319
- />
320
+ /> : null}
320
321
  {rPagination}
321
322
  {_progressBar}
322
323
  </View>
@@ -364,7 +364,8 @@ const ColumnType = PropTypes.shape({
364
364
  const RowType = PropTypes.shape({
365
365
 
366
366
  });
367
- const styles = StyleSheet.create({
367
+
368
+ export const styles = StyleSheet.create({
368
369
  datagrid : {
369
370
  flex:1,
370
371
  },