@fto-consult/expo-ui 2.17.0 → 2.18.1
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 +1 -1
- package/src/components/Chart/index.js +1 -0
- package/src/components/Countries/resources/countries-normalized.json +1987 -1987
- package/src/components/Countries/resources/countries-with-not-extra.json +1211 -1211
- package/src/components/Countries/resources/countries.sql +243 -243
- package/src/components/Datagrid/Accordion/index.js +3 -2
- package/src/components/Datagrid/Common/Common.js +225 -66
- package/src/components/Datagrid/Footer/index.js +26 -23
- package/src/components/Datagrid/RenderTypes/index.web.js +2 -2
- package/src/components/Datagrid/SWRDatagrid.js +18 -10
- package/src/components/Datagrid/Table/index.js +7 -5
- package/src/components/Table/index.js +2 -1
|
@@ -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
|
|
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
|
-
|
|
146
|
-
|
|
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
|
|
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(!
|
|
214
|
+
if(!canPaginate()) return false;
|
|
207
215
|
return Math.ceil(totalRef.current / limitRef.current);;
|
|
208
216
|
};
|
|
209
217
|
const getNextPage = ()=>{
|
|
210
|
-
if(!
|
|
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(!
|
|
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(!
|
|
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(!
|
|
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,
|
|
@@ -175,14 +175,14 @@ const DatagridFactory = (Factory)=>{
|
|
|
175
175
|
restItems = [
|
|
176
176
|
...this.renderCustomMenu(),
|
|
177
177
|
...(selectableMultiple ? [{
|
|
178
|
-
label : "
|
|
178
|
+
label : "Sélectionner "+max.formatNumber(),
|
|
179
179
|
icon : "select-all",
|
|
180
180
|
onPress : (x,event)=>{
|
|
181
181
|
this.handleAllRowsToggle(true);
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
184
|
{
|
|
185
|
-
label : "Tout
|
|
185
|
+
label : "Tout désélectionner",
|
|
186
186
|
onPress : (x,event)=>{
|
|
187
187
|
this.handleAllRowsToggle(false);
|
|
188
188
|
},
|
|
@@ -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]}>
|
|
@@ -278,6 +279,7 @@ const DatagridFactory = (Factory)=>{
|
|
|
278
279
|
] : visibleColumns}
|
|
279
280
|
|
|
280
281
|
/>
|
|
282
|
+
{this.renderSectionListMenu()}
|
|
281
283
|
<View testID={testID+"_HeaderPagination"} style = {styles.paginationItem}>
|
|
282
284
|
<BottomSheetMenu
|
|
283
285
|
testID={testID+"_HeaderMenus"}
|
|
@@ -306,16 +308,16 @@ const DatagridFactory = (Factory)=>{
|
|
|
306
308
|
</View>
|
|
307
309
|
</ScrollView>
|
|
308
310
|
</View> : null;
|
|
309
|
-
return <View style={[styles.container]} pointerEvents={pointerEvents}>
|
|
311
|
+
return <View style={[styles.container,{maxHeight:height-100}]} pointerEvents={pointerEvents}>
|
|
310
312
|
<View ref={this.layoutRef}>
|
|
311
|
-
<DatagridActions
|
|
313
|
+
{this.props.showActions !== false ? <DatagridActions
|
|
312
314
|
pointerEvents = {pointerEvents}
|
|
313
315
|
title = {title}
|
|
314
316
|
context = {this}
|
|
315
317
|
selectedRows = {Object.assign({},this.selectedRows)}
|
|
316
318
|
selectedRowsActions = {this.renderSelectedRowsActions.bind(this)}
|
|
317
319
|
actions = {actions}
|
|
318
|
-
/>
|
|
320
|
+
/> : null}
|
|
319
321
|
{rPagination}
|
|
320
322
|
{_progressBar}
|
|
321
323
|
</View>
|