@fto-consult/expo-ui 2.16.11 → 2.18.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.
@@ -13,7 +13,7 @@ import Image from "$ecomponents/Image";
13
13
  import Icon,{COPY_ICON} from "$ecomponents/Icon";
14
14
  import filterUtils from "$cfilters";
15
15
  import Hashtag from "$ecomponents/Hashtag";
16
- import {sortBy,isDecimal,extendObj,isObjOrArray,isOb,defaultNumber,defaultStr,isFunction,defaultBool,defaultArray,defaultObj,isNonNullString,defaultDecimal} from "$utils";
16
+ import {sortBy,isDecimal,extendObj,isObjOrArray,isObj,defaultNumber,defaultStr,isFunction,defaultBool,defaultArray,defaultObj,isNonNullString,defaultDecimal} from "$utils";
17
17
  import {Datagrid as DatagridContentLoader} from "$ecomponents/ContentLoader";
18
18
  import React from "$react";
19
19
  import DateLib from "$lib/date";
@@ -35,6 +35,7 @@ import stableHash from "stable-hash";
35
35
  import DatagridProgressBar from "./ProgressBar";
36
36
  import {Flag} from "$ecomponents/Countries"
37
37
  import View from "$ecomponents/View";
38
+ import {Menu} from "$ecomponents/BottomSheet";
38
39
 
39
40
  export const arrayValueSeparator = ", ";
40
41
 
@@ -68,7 +69,7 @@ export default class CommonDatagridComponent extends AppComponent {
68
69
  data = (data && typeof data == 'object')? Object.toArray(data):[];
69
70
  let sRows = {}
70
71
  Object.map(selectedRows,(row,i)=>{
71
- if(isObj(row)){
72
+ if(this.canSelectRow(row)){
72
73
  sRows[this.getRowKey(row,i)] = {...row};
73
74
  }
74
75
  });
@@ -107,7 +108,14 @@ export default class CommonDatagridComponent extends AppComponent {
107
108
  isLoadingRef : {
108
109
  value : {current:false}
109
110
  },
110
- currentFilteringColumns : {value:{}}
111
+ currentFilteringColumns : {value:{}},
112
+ emptySectionListHeaderValue : {value : uniqid("empty-section-list-header-val").toUpperCase()},
113
+ getSectionListHeaderProp : {value : typeof this.props.getSectionListHeader =='function'? this.props.getSectionListHeader : undefined},
114
+ sectionListData : {value : {}},//l'ensemble des données de sectionList
115
+ hasFoundSectionData : {value : {current: false}},
116
+ sectionListHeaderFooters : {value : {}},
117
+ sectionListDataSize : {value : {current : 0}},
118
+ sectionListColumnsSize : {value : {current:0}}, //la taille du nombre d'éléments de section dans les colonnes
111
119
  })
112
120
  this.isLoading = this.isLoading.bind(this);
113
121
  this.getProgressBar = this.getProgressBar.bind(this);
@@ -137,7 +145,8 @@ export default class CommonDatagridComponent extends AppComponent {
137
145
  })
138
146
  this.state.filteredColumns = defaultObj(this.getSessionData("filteredColumns"+this.getSessionNameKey()),this.props.filters);
139
147
  this.filtersSelectors = {selector:this.getFilters()};
140
- this.prepareColumns();
148
+ const {sectionListColumns} = this.prepareColumns();
149
+ this.state.sectionListColumns = sectionListColumns;
141
150
  if(this.canHandleColumnResize()){
142
151
  this.state.columnsWidths = this.preparedColumns.widths;
143
152
  }
@@ -186,6 +195,27 @@ export default class CommonDatagridComponent extends AppComponent {
186
195
  this.currentDataSources = Object.toArray(this.currentDataSources);
187
196
  }
188
197
  }
198
+ /*** si une ligne peut être selectionable */
199
+ canSelectRow(row){
200
+ return isObj(row) && row.isSectionListHeader !== true ? true : false;
201
+ }
202
+ prepareSectionListColumns(props){
203
+ props = defaultObj(props,this.props);
204
+ const l = {};
205
+ (Array.isArray(props.sectionListColumns) ? props.sectionListColumns : []).map((col)=>{
206
+ if(isNonNullString(col)){
207
+ l[col.trim()] = {};
208
+ }
209
+ })
210
+ return l;
211
+ }
212
+ /*** récupère la liste des colonnes à utiliser pour le rendu des sectionList, ces colonnes doivent figurer dans la liste des colonnes du tableu */
213
+ getSectionListColumns(){
214
+ if(!isObj(this.state.sectionListColumns)){
215
+ return this.prepareSectionListColumns();
216
+ }
217
+ return this.state.sectionListColumns;
218
+ }
189
219
  bindResizeEvents(){
190
220
  return false;
191
221
  }
@@ -367,6 +397,7 @@ export default class CommonDatagridComponent extends AppComponent {
367
397
  }
368
398
  /**** fonction appelée lorsque l'on clique sur la checkbox permettant de sélectionner la ligne */
369
399
  handleRowToggle ({row,rowIndex,rowData,rowKey,index, selected,cb,callback},cb2){
400
+ if(!this.canSelectRow(row)) return ;
370
401
  if(typeof rowKey !=='string' && typeof rowKey !=='number') return;
371
402
  let selectableMultiple = defaultVal(this.props.selectableMultiple,true);
372
403
  rowIndex = defaultNumber(rowIndex,index);
@@ -477,6 +508,9 @@ export default class CommonDatagridComponent extends AppComponent {
477
508
  isSelectableColumn(columnDef,columnField){
478
509
  return isObj(columnDef) && defaultStr(columnDef.field,columnField) === this.getSelectableColumName();
479
510
  }
511
+ isIndexColumn(columnDef,columnField){
512
+ return isObj(columnDef) && defaultStr(columnDef.field,columnField) === this.getIndexColumnName();
513
+ }
480
514
  initColumnsCallback(){}
481
515
  initColumns (columns){
482
516
  this.state.columns = {};
@@ -516,7 +550,7 @@ export default class CommonDatagridComponent extends AppComponent {
516
550
  const headerCol = Object.clone(headerCol1);
517
551
  if(isAccordion && headerCol.accordion === false) return null;
518
552
  let header = {...headerCol};
519
- header.field = header.field || headerIndex
553
+ header.field = defaultStr(header.field, headerIndex)
520
554
  /**** pour ignorer une colonne du datagrid, il suffit de passer le paramètre datagrid à false */
521
555
  if(!isNonNullString(header.field) || header.datagrid === false) {
522
556
  return;
@@ -726,7 +760,7 @@ export default class CommonDatagridComponent extends AppComponent {
726
760
  if(typeof this.props.onSort =='function' && this.props.onSort({...sort,context:this,sort,data:this.INITIAL_STATE.data,fields:this.state.columns,columns:this.state.columns}) === false){
727
761
  return;
728
762
  }
729
- this.prepareData({data:this.state.data,updateFooters:false},(state)=>{
763
+ this.prepareData({data:this.INITIAL_STATE.data,updateFooters:false},(state)=>{
730
764
  this.setState(state);
731
765
  });
732
766
  }
@@ -946,13 +980,80 @@ export default class CommonDatagridComponent extends AppComponent {
946
980
  }
947
981
  return null;
948
982
  }
983
+ toggleColumnInSectionList(columnName){
984
+ if(!isNonNullString(columnName) || !isObj(this.state.columns[columnName])) return;
985
+ if(!isObj(this.state.sectionListColumns) || !Array.isArray(this.preparedColumns?.sectionListColumnsMenuItems))return;
986
+ const menuItems = this.preparedColumns?.sectionListColumnsMenuItems;
987
+ if(!menuItems.length) return;
988
+ const sectionListColumns = {...this.state.sectionListColumns};
989
+ if(isObj(sectionListColumns[columnName])){
990
+ delete sectionListColumns[columnName];
991
+ } else {
992
+ sectionListColumns[columnName] = {};
993
+ }
994
+ const {sectionListColumns:pSListColumns} = this.prepareColumns({sectionListColumns});
995
+ this.setIsLoading(true,()=>{
996
+ this.prepareData({data:this.INITIAL_STATE.data,sectionListColumns:pSListColumns},(state)=>{
997
+ this.setState({...state,sectionListColumns:pSListColumns},()=>{
998
+ this.setIsLoading(false);
999
+ });
1000
+ });
1001
+ })
1002
+ }
1003
+ removeAllColumnsInSectionList(){
1004
+ const {sectionListColumns} = this.prepareColumns({sectionListColumns:{}});
1005
+ this.setIsLoading(true,()=>{
1006
+ this.prepareData({data:this.INITIAL_STATE.data,sectionListColumns},(state)=>{
1007
+ this.setState({...state,sectionListColumns},()=>{
1008
+ this.setIsLoading(false);
1009
+ });
1010
+ });
1011
+ })
1012
+ }
1013
+ /*** permet d'effectuer le rendu des colonnes groupable dans le menu item */
1014
+ renderSectionListMenu(){
1015
+ const m = Array.isArray(this.preparedColumns?.sectionListColumnsMenuItems)? this.preparedColumns?.sectionListColumnsMenuItems : [];
1016
+ if(!m.length){
1017
+ return null;
1018
+ }
1019
+ const isMobile = isMobileOrTabletMedia();
1020
+ return <Menu
1021
+ title = {"Grouper les données du tableau"}
1022
+ testID = {"RN_DatagridSectionListMenu"}
1023
+ anchor = {(props)=>{
1024
+ return <Icon {...props} name='format-list-group' title={"Grouper les éléments du tableau"}></Icon>
1025
+ }}
1026
+ items = {[
1027
+ !isMobile && {
1028
+ text : "Grouper par",
1029
+ icon : "group",
1030
+ closeOnPress : false,
1031
+ divider : true,
1032
+ },
1033
+ this.sectionListColumnsSize.current && {
1034
+ text : "Supprimer les groupes",
1035
+ icon: "ungroup",
1036
+ divider : true,
1037
+ onPress : ()=>{
1038
+ setTimeout(()=>{
1039
+ this.removeAllColumnsInSectionList();
1040
+ },300)
1041
+ }
1042
+ },
1043
+ ...m,
1044
+ ]}
1045
+ />
1046
+ }
949
1047
  prepareColumns (args){
950
1048
  this.beforePrepareColumns();
951
1049
  args = defaultObj(args);
1050
+ const sectionListColumns = {};
1051
+ const sListColumns = isObj(args.sectionListColumns) ? args.sectionListColumns : this.getSectionListColumns();
952
1052
  const filteredColumns = isObjOrArray(args.filteredColumns)?args.filteredColumns : isObjOrArray(this.state.filteredColumns) ? this.state.filteredColumns : {};
953
1053
  const columns = args.columns || this.state.columns;
954
1054
  const currentSortedColumn = isObj(args.sortedColumn) && args.sortedColumn.column? args.sortedColumn : defaultObj(this.sortRef.current);
955
1055
  const visibleColumns = [],headerFilters = [],visibleColumnsNames={};
1056
+ const sectionListColumnsMenuItems = [];
956
1057
  const sortable = defaultBool(this.props.sortable,true);
957
1058
  const sortedColumns = {};
958
1059
  let sortedColumnsLength = 0;
@@ -965,6 +1066,7 @@ export default class CommonDatagridComponent extends AppComponent {
965
1066
  const widths = {};
966
1067
  let totalWidths = 0;
967
1068
  let columnIndex = 0,visibleColumnIndex=0;
1069
+ this.sectionListColumnsSize.current = 0;
968
1070
  Object.map(columns,(header,headerIndex) => {
969
1071
  let {
970
1072
  field,
@@ -1011,11 +1113,17 @@ export default class CommonDatagridComponent extends AppComponent {
1011
1113
  const title = header.text = header.text || header.label || header.title||header.field
1012
1114
  visibleColumnsNames[header.field] = visible ? true : false;
1013
1115
  visibleColumns.push({
1014
- onPress : ()=>{this.toggleColumnVisibility(header.field);return false},
1116
+ onPress : ()=>{
1117
+ setTimeout(() => {
1118
+ this.toggleColumnVisibility(header.field);
1119
+ },300);
1120
+ return false;
1121
+ },
1015
1122
  title : title,
1016
1123
  icon : visible?CHECKED_ICON_NAME : null,
1017
1124
  });
1018
1125
  restCol.field = header.field;
1126
+
1019
1127
  restCol.label = defaultStr(header.text,header.label) ;
1020
1128
  restCol.type = type;
1021
1129
  if(!restCol.label){
@@ -1037,6 +1145,7 @@ export default class CommonDatagridComponent extends AppComponent {
1037
1145
  sortedColumns[field] = restCol.label;
1038
1146
  sortedColumnsLength++;
1039
1147
  }
1148
+
1040
1149
  colFilter = colFilter && filters !== false ? true : false;
1041
1150
  const sortedProps = isColumnSorted ? {...sortedColumn} : {};
1042
1151
  let filterProps = {};
@@ -1093,6 +1202,30 @@ export default class CommonDatagridComponent extends AppComponent {
1093
1202
  key : header.field,
1094
1203
  filter :colFilter,
1095
1204
  },headerFilters)
1205
+
1206
+ if(this.props.groupable !== false && header.groupable !== false && !this.isSelectableColumn(header,header.field) && !this.isIndexColumn(header,header.field)){
1207
+ const isInSectionListHeader = isObj(sListColumns[field]);
1208
+ if(isInSectionListHeader){
1209
+ sectionListColumns[field] = {
1210
+ ...header,
1211
+ width,
1212
+ type,
1213
+ ...sListColumns[field],
1214
+ };///les colonnes de sections
1215
+ this.sectionListColumnsSize.current++;
1216
+ }
1217
+ sectionListColumnsMenuItems.push({
1218
+ field,
1219
+ onPress : ()=>{
1220
+ setTimeout(()=>{
1221
+ this.toggleColumnInSectionList(field);
1222
+ },300)
1223
+ return false;
1224
+ },
1225
+ title : title,
1226
+ icon : isInSectionListHeader?CHECKED_ICON_NAME : null,
1227
+ });
1228
+ }
1096
1229
  columnIndex++;
1097
1230
  visibleColumnIndex++;
1098
1231
 
@@ -1106,6 +1239,8 @@ export default class CommonDatagridComponent extends AppComponent {
1106
1239
  this.preparedColumns.filteredColumns = filteredColumns;
1107
1240
  this.preparedColumns.widths = widths;
1108
1241
  this.preparedColumns.totalWidths = totalWidths;
1242
+ this.preparedColumns.sectionListColumns = sectionListColumns;
1243
+ this.preparedColumns.sectionListColumnsMenuItems = sectionListColumnsMenuItems;
1109
1244
  return this.preparedColumns;
1110
1245
  }
1111
1246
  getPaginatedSelectedRows(data){
@@ -1118,49 +1253,128 @@ export default class CommonDatagridComponent extends AppComponent {
1118
1253
  getFooterValues(){
1119
1254
  return defaultObj(this.___evaluatedFootersValues);
1120
1255
  }
1256
+
1257
+ /**** s'il s'agit d'une section list */
1258
+ isSectionList(sectionListColumns){
1259
+ sectionListColumns = isObj(sectionListColumns) ? sectionListColumns : this.state.sectionListColumns;
1260
+ return !this.isPivotDatagrid() && isObj(sectionListColumns) && Object.size(sectionListColumns,true) ? true : false;
1261
+ }
1262
+ /**** si le datagrid admet les sectionDatas */
1263
+ hasSectionListData(){
1264
+ return this.hasFoundSectionData.current;
1265
+ }
1266
+ /*** vérifie si l'on a la colonne passée en paramètre */
1267
+ hasColumn(column){
1268
+ column = isObj(column)? defaultStr(column.field) : defaultStr(column);
1269
+ if(!column) return false;
1270
+ return isObj(this.state.columns) && this.state.columns[column]&& true || false;
1271
+ }
1272
+ formatSectionListHeader(sectionListHeader){
1273
+ if(!isNonNullString(sectionListHeader)) return "";
1274
+ if(this.props.sectoonListHeaderUpperCase !== false){
1275
+ sectionListHeader = sectionListHeader.toUpperCase();
1276
+ }
1277
+ return sectionListHeader.trim();
1278
+ }
1279
+ getSectionListDataSize(){
1280
+ return defaultNumber(this.sectionListDataSize.current)
1281
+ }
1121
1282
  prepareData(args,cb){
1122
- let {pagination,data,force,updateFooters} = defaultObj(args);
1283
+ let {pagination,data,force,sectionListColumns,updateFooters} = defaultObj(args);
1123
1284
  cb = typeof cb ==='function'? cb : typeof args.cb == 'function'? args.cb : undefined;
1285
+ sectionListColumns = isObj(sectionListColumns) ? sectionListColumns : this.state.sectionListColumns;
1124
1286
  let isArr = Array.isArray(data);
1125
1287
  //let push = (d,index) => isArr ? newData.push(d) : newData[index] = d;
1126
1288
  const hasLocalFilter = this.props.filters !== false && this.hasLocalFilters;
1127
1289
  let footersColumns = this.getFooterFields(),hasFooterFields = Object.size(footersColumns,true);
1128
1290
  const canUpdateFooters = !!(updateFooters !== false && hasFooterFields);
1129
- if(hasLocalFilter || !isArr || canUpdateFooters) {
1291
+ this.hasFoundSectionData.current = false;
1292
+ this.sectionListDataSize.current = 0;
1293
+ const isSList = this.isSectionList(sectionListColumns);
1294
+ if(hasLocalFilter || !isArr || canUpdateFooters || isSList) {
1130
1295
  if(canUpdateFooters){
1131
1296
  this.___evaluatedFootersValues = {}
1132
1297
  }
1133
1298
  const newData = [];
1134
- Object.map(data,(d,i)=>{
1299
+ const columns = sectionListColumns;
1300
+ const sectionListColumnsSize = this.sectionListColumnsSize.current;
1301
+ const hasSectionColumns = this.sectionListColumnsSize.current > 0;
1302
+ if(isSList){
1303
+ Object.map(this.sectionListData,(v,i)=>{
1304
+ delete this.sectionListData[i];
1305
+ });
1306
+ //on réinnitialise tous les footes
1307
+ Object.map(this.sectionListHeaderFooters,(v,i)=>{
1308
+ delete this.sectionListHeaderFooters[i];
1309
+ })
1310
+ }
1311
+ let currentSectionListFooter = null;
1312
+ const sectionListData = this.sectionListData;//l'ensemble des données de sectionList
1313
+ Object.map(data,(d,i,rowIndex)=>{
1135
1314
  if(!isObj(d) || (hasLocalFilter && this.doLocalFilter({rowData:d,rowIndex:i}) === false)){
1136
1315
  return;
1137
1316
  }
1317
+ if(hasSectionColumns){
1318
+ let sHeader = this.getSectionListHeader({data:d,columnsLength : sectionListColumnsSize,fieldsSize:sectionListColumnsSize,sectionListColumnsLength:sectionListColumnsSize,sectionListColumnsSize,allData:data,rowData:d,index:i,rowIndex,context:this,columns,fields:columns});
1319
+ if(sHeader === false) return;//on omet la donnée si la fonction de récupération de son header retourne false
1320
+ if(!isNonNullString(sHeader)){
1321
+ if(this.props.ignoreEmptySectionListHeader !== false){
1322
+ sHeader = this.emptySectionListHeaderValue;
1323
+ } else return;
1324
+ }
1325
+ let r = this.formatSectionListHeader(sHeader);
1326
+ if(!Array.isArray(sectionListData[r])){
1327
+ sectionListData[r] = [];
1328
+ this.sectionListDataSize.current++;
1329
+ }
1330
+ sectionListData[r].push(d);
1331
+ if(canUpdateFooters){
1332
+ this.sectionListHeaderFooters[r] = defaultObj(this.sectionListHeaderFooters[r]);
1333
+ currentSectionListFooter = this.sectionListHeaderFooters[r];
1334
+ }
1335
+ this.hasFoundSectionData.current = true;
1336
+ }
1138
1337
  if(canUpdateFooters){
1338
+ const result = [this.___evaluatedFootersValues]
1339
+ if(currentSectionListFooter){
1340
+ result.push(currentSectionListFooter);
1341
+ }
1139
1342
  Object.map(footersColumns,(columnDef,field)=>{
1140
- evalSingleValue({data:d,columnDef,field,result:this.___evaluatedFootersValues,displayLabel:false})
1343
+ evalSingleValue({data:d,columnDef,field,result,displayLabel:false})
1141
1344
  });
1142
1345
  }
1143
1346
  newData.push(d);
1144
1347
  //push(d,i);
1145
1348
  });
1146
1349
  data = newData;
1147
- }
1350
+ }
1148
1351
  if(this.canAutoSort() && isNonNullString(this.sortRef.current.column)){
1149
1352
  if(isObj(this.state.columns) && this.state.columns[this.sortRef.current.column]){
1150
1353
  let field = this.state.columns[this.sortRef.current.column];
1151
- const cfg = Object.assign({},this.sortRef.current);
1152
- cfg.getItem = (item,columnName,{getItem})=>{
1354
+ const sortConfig = Object.assign({},this.sortRef.current);
1355
+ sortConfig.getItem = (item,columnName,{getItem})=>{
1153
1356
  if(isObj(item) && (field.type =='decimal' || field.type =="number")){
1154
1357
  const v = item[columnName];
1155
1358
  return isDecimal(v)? v : isNonNullString(v)? parseDecimal(v) : 0;
1156
1359
  }
1157
1360
  return getItem(item,columnName);
1158
1361
  }
1159
- data = sortBy(data,cfg);//on trie tout d'abord les données
1362
+ data = sortBy(data,sortConfig);//on trie tout d'abord les données
1160
1363
  }
1161
1364
  }
1162
1365
  this.INITIAL_STATE.data = data;
1163
- if(this.canPaginateData()){
1366
+ if(this.hasFoundSectionData.current){
1367
+ data = [];
1368
+ for(let i in this.sectionListData){
1369
+ //this.sectionListData[i] = sortConfig ? sortBy(this.sectionListData[i],sortConfig):this.sectionListData[i];
1370
+ //const v = i;// === this.emptySectionListHeaderValue ? "" : i;
1371
+ data.push({isSectionListHeader:true,sectionListHeaderKey:i});
1372
+ this.sectionListData[i].map((d)=>{
1373
+ data.push(d);
1374
+ })
1375
+ }
1376
+ }
1377
+ if(!this.hasSectionListData() && this.canPaginateData()){
1164
1378
  pagination = this.initPagination(pagination);
1165
1379
  pagination.rows = data.length;
1166
1380
  this._pagination = pagination;
@@ -1175,6 +1389,64 @@ export default class CommonDatagridComponent extends AppComponent {
1175
1389
  }
1176
1390
  return state;
1177
1391
  }
1392
+ getSectionListHeader(args){
1393
+ if(this.getSectionListHeaderProp){
1394
+ return this.getSectionListHeaderProp(args);
1395
+ }
1396
+ const {fields,sectionListColumnsSize,data} = args;
1397
+ const d = [];
1398
+ Object.map(fields,(field,i)=>{
1399
+ const txt = this.renderRowCell({
1400
+ ...args,
1401
+ columnDef : field,
1402
+ renderRowCell : false,
1403
+ isSectionListHeader : true,
1404
+ columnField : defaultStr(field.field,i),
1405
+ });
1406
+ if(!isNonNullString(txt) && typeof txt !=='number') return;
1407
+ if(sectionListColumnsSize == 1){
1408
+ d.push(txt);
1409
+ } else {
1410
+ d.push("{0} : {1}".sprintf(defaultStr(field.label,field.txt),txt))
1411
+ }
1412
+ });
1413
+ return d.length ? d.join(arrayValueSeparator) : undefined;
1414
+ }
1415
+ /*** retourne le type d'item à rendre à la fonction flashlist
1416
+ * @see : https://shopify.github.io/flash-list/docs/guides/section-list
1417
+ */
1418
+ getFlashListItemType(item){
1419
+ return typeof item === "string" || isObj(item) && item.isSectionListHeader === true ? "sectionHeader" : "row";;
1420
+ }
1421
+ /****permet de faire le rendu flashlist */
1422
+ renderFlashListItem(args){
1423
+ if(!this.hasSectionListData()) return null;
1424
+ args = defaultObj(args);
1425
+ let {item,rowProps,rowStyle} = args;
1426
+ if(!isObj(item) || item.isSectionListHeader !== true || !isNonNullString(item.sectionListHeaderKey)) return null;
1427
+ args.isAccordion = this.isAccordion();
1428
+ args.columns = this.preparedColumns.visibleColumns;
1429
+ args.columnsNames = this.preparedColumns.visibleColumnsNames;
1430
+ const key = item.sectionListHeaderKey;
1431
+ const label = key === this.emptySectionListHeaderValue ? defaultStr(this.props.sectionListHeaderEmptyValue,"N/A") : key;
1432
+ const style = typeof this.props.getSectionListHeaderStyle =='function' ? this.props.getSectionListHeaderStyle(args) : null;
1433
+ const cStyle = typeof this.props.getSectionListHeaderContentContainerStyle =="function" ?this.props.getSectionListHeaderContentContainerStyle(args) : undefined;
1434
+ const lStyle = typeof this.props.getSectionListHeaderLabelStyle =='function' ? this.props.getSectionListHeaderLabelStyle(args) : null;
1435
+
1436
+ rowProps = defaultObj(rowProps);
1437
+ const testID = rowProps.testID = defaultStr(args.testID,"RN_DatagridSectionListHeader")+"_"+defaultVal(args.rowIndex,args.index)
1438
+ if(Array.isArray(rowStyle)){
1439
+ if(style){
1440
+ rowStyle.push(style);
1441
+ }
1442
+ }
1443
+ if(isObj(this.sectionListHeaderFooters[key])){
1444
+ console.log(this.sectionListHeaderFooters[key]," is value of keyeees");
1445
+ }
1446
+ return <View testID={testID+"_ContentContainer"} style={[theme.styles.w100,theme.styles,theme.styles.justifyContentCenter,theme.styles.pt1,theme.styles.pb1,theme.styles.alignItemsCenter,theme.styles.ml1,theme.styles.mr1,cStyle]}>
1447
+ <Label testID={testID+"_Label"} splitText numberOfLines={3} textBold style={[theme.styles.w100,lStyle]}>{label}</Label>
1448
+ </View>
1449
+ }
1178
1450
  isRowSelected(rowKey,rowIndex){
1179
1451
  if(isObj(rowKey)){
1180
1452
  rowKey = this.getRowKey(rowKey,rowIndex);
@@ -1195,7 +1467,7 @@ export default class CommonDatagridComponent extends AppComponent {
1195
1467
  }
1196
1468
  });
1197
1469
  Object.map(rows,(row,i)=>{
1198
- if(isObj(row)) {
1470
+ if(this.canSelectRow(row)) {
1199
1471
  const rowKey = this.getRowKey(row,i);
1200
1472
  this.selectedRowsCount++;
1201
1473
  this.selectedRows[rowKey] = row;
@@ -1477,7 +1749,7 @@ export default class CommonDatagridComponent extends AppComponent {
1477
1749
  if(this.state.data && typeof this.state.data.length ==='number'){
1478
1750
  max = max ? Math.min(max,this.state.data.length,max) : this.state.data.length;
1479
1751
  }
1480
- return max;
1752
+ return Math.max(max-this.getSectionListDataSize(),0);
1481
1753
  }
1482
1754
  canSetIsLoading(){
1483
1755
  return isObj(this.progressBarRef.current) && typeof this.progressBarRef.current.setIsLoading =='function' ? true : false;
@@ -1626,6 +1898,10 @@ export default class CommonDatagridComponent extends AppComponent {
1626
1898
  }
1627
1899
  canScrollTo(){
1628
1900
  return this.state.data.length? true :false;
1901
+ }
1902
+ /**** permet d'afficher le menu item lié aux champs triables */
1903
+ getSortableMenuMenuItem(){
1904
+
1629
1905
  }
1630
1906
  renderSelectableCheckboxCell(props){
1631
1907
  const {containerProps} = props;
@@ -1652,14 +1928,16 @@ export default class CommonDatagridComponent extends AppComponent {
1652
1928
  différent du td d'un table et ne doit pas être un TableColumn de md
1653
1929
  */
1654
1930
  renderRowCell (arg){
1655
- let {rowData,rowKey,handleSelectableColumn,rowIndex,index,rowCounterIndex,columnDef,columnField} = arg;
1931
+ let {rowData,renderRowCell:customRenderRowCell,isSectionListHeader,rowKey,handleSelectableColumn,rowIndex,index,rowCounterIndex,columnDef,columnField} = arg;
1932
+ const renderText = isSectionListHeader === true || customRenderRowCell === false ? true : false;
1656
1933
  rowIndex = isDecimal(rowIndex)? rowIndex : isDecimal(index)? index : undefined;
1657
1934
  rowCounterIndex = isDecimal(rowCounterIndex) ? rowCounterIndex : isDecimal(rowIndex)? rowIndex+1 : defaultDecimal(rowCounterIndex);
1658
- if(!isObj(rowData)) return {render:null,extra:{}};
1935
+ if(!isObj(rowData)) return renderText ? null : {render:null,extra:{}};
1659
1936
  let _render = null;
1660
1937
  columnDef = defaultObj(columnDef);
1661
1938
  let _type = defaultStr(columnDef.jsType,columnDef.type).trim().toLowerCase();
1662
1939
  if(this.isSelectableColumn(columnDef,columnField)){
1940
+ if(renderText) return null;
1663
1941
  rowKey = rowKey ? rowKey : this.getRowKey(rowData,rowIndex);
1664
1942
  return {render :handleSelectableColumn === false ? null : this.renderSelectableCheckboxCell({
1665
1943
  ...arg,
@@ -1671,7 +1949,8 @@ export default class CommonDatagridComponent extends AppComponent {
1671
1949
  this.handleRowToggle({row:rowData,rowData,rowIndex,rowKey,selected:checked})
1672
1950
  }
1673
1951
  }),style:{},extra:{style:{}}};
1674
- } else if(columnField == this.getIndexColumnName()){
1952
+ } else if((columnField == this.getIndexColumnName())){
1953
+ if(renderText) return null;
1675
1954
  return {render : rowCounterIndex.formatNumber(),style:{},extra:{}};
1676
1955
  }
1677
1956
  let renderProps = undefined;
@@ -1679,7 +1958,7 @@ export default class CommonDatagridComponent extends AppComponent {
1679
1958
  renderProps = columnDef.datagrid.renderProps;
1680
1959
  }
1681
1960
  const style = Object.assign({},StyleSheet.flatten(columnDef.style));
1682
- if(columnDef.visible === false){
1961
+ if(!renderText && columnDef.visible === false){
1683
1962
  style.display = "none";
1684
1963
  }
1685
1964
  let extra = {style},renderArgs = arg;
@@ -1694,7 +1973,7 @@ export default class CommonDatagridComponent extends AppComponent {
1694
1973
  _render = defaultDecimal(columnDef.multiplicater({...renderArgs,value:rowData[columnField]}),rowData[columnField]);
1695
1974
  } else {
1696
1975
  _render = defaultValue;
1697
- if(defaultStr(columnDef.format).toLowerCase() === 'hashtag'){
1976
+ if(!renderText && defaultStr(columnDef.format).toLowerCase() === 'hashtag'){
1698
1977
  _render = <Hashtag>{_render}</Hashtag>
1699
1978
  } else if(typeof columnDef.render === "function"){
1700
1979
  _render = columnDef.render.call(this,renderArgs);
@@ -1714,11 +1993,11 @@ export default class CommonDatagridComponent extends AppComponent {
1714
1993
  _render = checkedLabel;
1715
1994
  } else _render = uncheckedLabel;
1716
1995
  }
1717
- else if(_type =='select_country' || _type =='selectcountry'){
1996
+ else if(!renderText && (_type =='select_country' || _type =='selectcountry')){
1718
1997
  _render = <Flag withCode {...columnDef} length={undefined} width={undefined} height={undefined} code={defaultValue}/>
1719
1998
  }
1720
1999
  ///le lien vers le table data se fait via la colonne ayant la propriété foreignKeyTable de type chaine de caractère non nulle
1721
- else if(isNonNullString(columnDef.foreignKeyTable) || columnDef.primaryKey === true || arrayValueExists(['id','piece'],_type)){
2000
+ else if(!renderText && (isNonNullString(columnDef.foreignKeyTable) || columnDef.primaryKey === true || arrayValueExists(['id','piece'],_type))){
1722
2001
  const id = rowData[columnField]?.toString();
1723
2002
  if(isNonNullString(id)){
1724
2003
  _render = <TableLink
@@ -1772,6 +2051,7 @@ export default class CommonDatagridComponent extends AppComponent {
1772
2051
  }
1773
2052
  }
1774
2053
  } else if(_type == 'image'){
2054
+ if(renderText) return null;
1775
2055
  columnDef = defaultObj(columnDef)
1776
2056
  columnDef = {...columnDef,...defaultObj(columnDef.datagrid)};
1777
2057
  columnDef.size = defaultDecimal(columnDef.size,50);
@@ -1825,7 +2105,7 @@ export default class CommonDatagridComponent extends AppComponent {
1825
2105
  _render = _render.formatNumber();
1826
2106
  //}
1827
2107
  }
1828
- if(_render && isObj(renderProps)){
2108
+ if(!renderText && _render && isObj(renderProps)){
1829
2109
  let Component = defaultVal(renderProps.Component,Label);
1830
2110
  delete renderProps.Component;
1831
2111
  _render = <Component {...renderProps}>{_render}</Component>
@@ -1833,9 +2113,13 @@ export default class CommonDatagridComponent extends AppComponent {
1833
2113
  if(typeof _render =='boolean'){
1834
2114
  _render = _render ? "Oui" : "Non";
1835
2115
  }
1836
- if(typeof _render ==='string' || typeof _render =='number'){
2116
+ if(renderText){
2117
+ return React.getTextContent(_render);
2118
+ }
2119
+ if((typeof _render ==='string' || typeof _render =='number')){
1837
2120
  _render = <Label selectable>{_render}</Label>
1838
2121
  }
2122
+
1839
2123
  _render = React.isValidElement(_render)|| Array.isArray(_render)?_render:null;
1840
2124
  return {render:_render,style,extra,key};
1841
2125
  }
@@ -1986,7 +2270,7 @@ CommonDatagridComponent.propTypes = {
1986
2270
  * si c'est un objet, alors il peut être de la forme :
1987
2271
  * {
1988
2272
  * title : PropTypes.node , //le titre du header
1989
- * avatar : PropTypes.string(dataUrl,src,other) || PropType.node, ///l'avatar,
2273
+ * avatar : PropTypes.string(dataUrl,src,other) || PropTypes.node, ///l'avatar,
1990
2274
  * rowClassName : la class à appliquer à la ligne
1991
2275
  * rowProps : les props à appliquer à la ligne de la liste
1992
2276
  * headerClassName : la class à appliquer au header de la ligne
@@ -2007,6 +2291,22 @@ CommonDatagridComponent.propTypes = {
2007
2291
  PropTypes.arrayOf(PropTypes.object),
2008
2292
  PropTypes.objectOf(PropTypes.object),
2009
2293
  ]),
2294
+ sectionListHeaderEmptyValue : PropTypes.string, //la valeur vide par défaut à afficher dans les entêtes du table
2295
+ ignoreCaseOnSectionListHeader : PropTypes.bool,//si l'on ignorera la casse dans le sectionlISThEADER
2296
+ sectoonListHeaderUpperCase : PropTypes.bool, //si le sectionListHeader sera en majuscule
2297
+ getSectionListHeaderLabelStyle : PropTypes.func,//la fonction permettant de récupérer les styles à appliquer sur le composant label de la section header
2298
+ getSectionListHeaderContentContainerStyle : PropTypes.func, //retourne les styles à appliquer sur le contentContainer de la sectionListHeader
2299
+ getSectionListHeaderStyle : PropTypes.func, // la fonction permettant de récupérer les propriétés particulières à appliquer au style passé en paramètre
2300
+ /*** spécifie si le datagrid est groupable et si l'on utilisera les sectionList du composant FLashList pour le rendu du tableau
2301
+ * si une colonne n'est pas groupable alors elle ne peut pas apparaître dans les sectionList
2302
+ */
2303
+ groupable : PropTypes.bool,
2304
+ /*la fonction permettant de récupérer l'entête de la sectionList pour la données passée en paramètre
2305
+ @param {object : {data:{object},context:{this},allData:[]}}
2306
+ @return {string}
2307
+ */
2308
+ getSectionListHeader : PropTypes.func,
2309
+ ignoreEmptySectionListHeader : PropTypes.bool, // si l'on ignorera les sectionList data dont l'entête, le sectionListHeader est empty
2010
2310
  /**** la fonction permettant de faire le rendu dun contenu paginé, personalisé */
2011
2311
  renderCustomPagination : PropTypes.func,
2012
2312
  getActionsArgs : PropTypes.func,//fonction permettant de récupérer les props supplémentaires à passer aux actions du datagrid