@fto-consult/expo-ui 5.11.5 → 5.11.6

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": "5.11.5",
3
+ "version": "5.11.6",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -592,7 +592,7 @@ export default class CommonDatagridComponent extends AppComponent {
592
592
  }
593
593
  /**** fonction appelée lorsque l'on clique sur la checkbox permettant de sélectionner la ligne */
594
594
  handleRowToggle ({rowIndex,rowKey,index, selected,cb,callback},cb2){
595
- if((typeof rowKey !=='string' && typeof rowKey !=='number')) return false;
595
+ if(!this.isValidRowKey(rowKey)) return false;
596
596
  const row = this.getRowByKey(rowKey);
597
597
  if(!isObj(row) || !this.canSelectRow(row)) return false;
598
598
  let selectableMultiple = this.isSelectableMultiple();
@@ -796,6 +796,7 @@ export default class CommonDatagridComponent extends AppComponent {
796
796
  const r = isObj(selected)? selected : {};
797
797
  const ret = {
798
798
  ...dataSourceArgs,
799
+ rowsByKeys : this.rowsByKeys,
799
800
  showConfirm,
800
801
  Preloader,
801
802
  notify,
@@ -2689,6 +2690,9 @@ export default class CommonDatagridComponent extends AppComponent {
2689
2690
  getSectionListDataSize(){
2690
2691
  return defaultNumber(this.sectionListDataSize.current)
2691
2692
  }
2693
+ isValidRowKey(rowKey){
2694
+ return !!(isNonNullString(rowKey) || typeof rowKey =='number');
2695
+ }
2692
2696
  prepareData(args,cb){
2693
2697
  let {pagination,config,aggregatorFunction:customAggregatorFunction,displayOnlySectionListHeaders:cdisplayOnlySectionListHeaders,data,force,sectionListColumns,sectionListCollapsedStates,updateFooters} = defaultObj(args);
2694
2698
  cb = typeof cb ==='function'? cb : typeof args.cb == 'function'? args.cb : undefined;
@@ -2706,7 +2710,6 @@ export default class CommonDatagridComponent extends AppComponent {
2706
2710
  this.sectionListDataSize.current = 0;
2707
2711
  this.rowsByKeys = {};
2708
2712
  const isSList = this.isSectionList(sectionListColumns);
2709
- this.rowsByKeys = {};
2710
2713
  const sortingField = isNonNullString(this.sortRef.current.column) && isObj(this.state.columns) && this.state.columns[this.sortRef.current.column] || {};
2711
2714
  const hasSortField = Object.size(sortingField,true);
2712
2715
  if(this.canAutoSort() && isNonNullString(this.sortRef.current.column) && hasSortField){
@@ -2746,6 +2749,9 @@ export default class CommonDatagridComponent extends AppComponent {
2746
2749
  if(!isObj(d) || (hasLocalFilter && this.doLocalFilter({rowData:d,rowIndex:i}) === false)){
2747
2750
  return;
2748
2751
  }
2752
+ const rKey = this.getRowKey(d,i);
2753
+ if(!this.isValidRowKey(rKey)) return;
2754
+ this.rowsByKeys[rKey] = d;
2749
2755
  if(hasSectionColumns && this.renderSectionListIsAllowed){
2750
2756
  let sHeader = this.getSectionListHeader({config,data:d,columnsLength : sectionListColumnsSize,fieldsSize:sectionListColumnsSize,sectionListColumnsLength:sectionListColumnsSize,sectionListColumnsSize,allData:data,rowData:d,index:i,rowIndex,context:this,columns,fields:columns});
2751
2757
  if(sHeader === false) return;//on omet la donnée si la fonction de récupération de son header retourne false
@@ -2791,7 +2797,17 @@ export default class CommonDatagridComponent extends AppComponent {
2791
2797
  })
2792
2798
  }
2793
2799
  data = newData;
2794
- }
2800
+ } else {
2801
+ const newData = [];
2802
+ Object.map(data,(d,i,rowIndex)=>{
2803
+ if(!isObj(d)) return;
2804
+ const rowKey = this.getRowKey(d,i,rowIndex);
2805
+ if(!this.isValidRowKey(rowKey)) return;
2806
+ this.rowsByKeys[rowKey] = d;
2807
+ newData.push(d);
2808
+ });
2809
+ data = newData;
2810
+ }
2795
2811
  this.INITIAL_STATE.data = data;
2796
2812
  if(this.hasFoundSectionData.current){
2797
2813
  data = [];
@@ -2950,8 +2966,7 @@ export default class CommonDatagridComponent extends AppComponent {
2950
2966
  if(isObj(rowKey)){
2951
2967
  rowKey = this.getRowKey(rowKey,rowIndex);
2952
2968
  }
2953
- if(typeof rowKey !=='string' && typeof rowKey !=='number') return false;
2954
- if(!isObj(this.selectedRowsRefs[rowKey])) return false;
2969
+ if(!this.isValidRowKey(rowKey) || !isObj(this.selectedRowsRefs[rowKey])) return false;
2955
2970
  return !!(isObj(this.selectedRows[rowKey]) && this.selectedRowsRefs[rowKey].checked);
2956
2971
  }
2957
2972
  /*** permet de définir les lignes sélectionnées du datagrid */
@@ -2968,6 +2983,7 @@ export default class CommonDatagridComponent extends AppComponent {
2968
2983
  Object.map(rows,(row,i)=>{
2969
2984
  if(this.canSelectRow(row)) {
2970
2985
  const rowKey = this.getRowKey(row,i);
2986
+ this.rowsByKeys[rowKey] = row;
2971
2987
  this.selectedRowsCount++;
2972
2988
  this.selectedRows[rowKey] = row;
2973
2989
  const sRowRef = this.selectedRowsRefs[rowKey];
@@ -3734,7 +3750,7 @@ export default class CommonDatagridComponent extends AppComponent {
3734
3750
  return this.renderSelectFieldCell(args);
3735
3751
  }
3736
3752
  getRowByKey(rowKey){
3737
- return this.rowsByKeys[rowKey] || null;
3753
+ return (this.isValidRowKey(rowKey)) && isObj(this.rowsByKeys[rowKey]) && this.rowsByKeys[rowKey] || null;
3738
3754
  }
3739
3755
  /*** retourne le rendu d'une cellule de la ligne du tableau
3740
3756
  @parm, rowData, object, la ligne à afficher le rendu du contenu
@@ -3753,8 +3769,7 @@ export default class CommonDatagridComponent extends AppComponent {
3753
3769
  const renderText = isSectionListHeader === true || customRenderRowCell === false ? true : false;
3754
3770
  if(!isObj(rowData)) return renderText ? null : {render:null,extra:{}};
3755
3771
  rowIndex = isDecimal(rowIndex)? rowIndex : isDecimal(index)? index : undefined;
3756
- rowKey = rowKey || typeof rowKey =='number' ? rowKey : this.getRowKey(rowData,rowIndex);
3757
- this.rowsByKeys[rowKey] = rowData;
3772
+ rowKey = this.isValidRowKey(rowKey) ? rowKey : this.getRowKey(rowData,rowIndex);
3758
3773
  rowCounterIndex = isDecimal(rowCounterIndex) ? rowCounterIndex : isDecimal(rowIndex)? rowIndex+1 : defaultDecimal(rowCounterIndex);
3759
3774
  if(this.isSelectableColumn(columnDef,columnField)){
3760
3775
  if(renderText) return null;