@fto-consult/expo-ui 6.26.5 → 6.26.8

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": "6.26.5",
3
+ "version": "6.26.8",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -75,7 +75,7 @@ const DatagridAccordionRow = React.forwardRef((props,ref)=>{
75
75
  const wrapStyle = React.useMemo(()=>{
76
76
  return getRowStyle({row:item,index,selected,numColumns,isAccordion:true,rowIndex:index});
77
77
  },[selected,numColumns]);
78
- const viewWrapperStyle = [];
78
+ const viewWrapperStyle = [selectable !== false && theme.styles.cursorPointer];
79
79
  if(selected) {
80
80
  const handleAvatarRowToggle = (event)=>{
81
81
  React.stopEventPropagation(event);
@@ -122,6 +122,7 @@ const DatagridAccordionRow = React.forwardRef((props,ref)=>{
122
122
  rowProps.style,
123
123
  numColumns > 1 && styles.multiColumns,
124
124
  selected && styles.selected,
125
+ selectable !== false && theme.styles.cursorPointer,
125
126
  //style,
126
127
  ]}
127
128
  ref = {React.useMergeRefs(ref,innerRef)}
@@ -230,6 +231,7 @@ const styles = StyleSheet.create({
230
231
  alignItems : 'center',
231
232
  justifyContent : 'center',
232
233
  paddingVertical : 10,
234
+ width : "100%",
233
235
  },
234
236
  right : {
235
237
  marginHorizontal : 0,
@@ -401,7 +401,7 @@ const DatagridFactory = (Factory)=>{
401
401
  const hasFootersFields = this.hasFootersFields();
402
402
  const datagridHeader = <View testID={testID+"_HeaderContainer"} pointerEvents={pointerEvents} style={[styles.datagridHeader]}>
403
403
  <ScrollView testID={testID+"_HeaderScrollView"} horizontal contentContainerStyle={StyleSheet.flatten([styles.contentContainerStyle,styles.minW100])}>
404
- <View testID={testID+"_HeaderContentCntainer"} style={[styles.table,styles.pullRight]}>
404
+ <View testID={testID+"_HeaderContentContainer"} style={[styles.table,styles.pullRight]}>
405
405
  {/*this.renderDataSourceSelector()*/}
406
406
  <View testID={testID+"_HeaderQueryLimit"} style={[styles.paginationItem]}>
407
407
  {this.renderQueryLimit(this.getStateDataSize().formatNumber())}
@@ -552,6 +552,7 @@ const DatagridFactory = (Factory)=>{
552
552
  items = {this.state.data}
553
553
  isLoading = {isLoading}
554
554
  ref = {this.listRef}
555
+ style = {styles.list}
555
556
  backToTopRef = {backToTopRef?(e)=>{
556
557
  return this.backToTopRef.current;
557
558
  }:false}
@@ -605,13 +606,15 @@ const styles = StyleSheet.create({
605
606
  alignItems : 'center',
606
607
  maxHeight : 60
607
608
  },
609
+ list : {
610
+ paddingHorizontal : 5,
611
+ },
608
612
  container : {
609
613
  position : 'relative',
610
614
  flexDirection :'column',
611
615
  justifyContent : 'flex-start',
612
616
  width : '100%',
613
617
  flex : 1,
614
- paddingHorizontal : isNativeMobile()? 5:1,
615
618
  },
616
619
  accordionHeader : {
617
620
  paddingTop : 0,
@@ -202,7 +202,13 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
202
202
  showError : false,
203
203
  swrOptions : getSWROptions(swrConfig.refreshTimeout)
204
204
  });
205
+ const dataRef = React.useRef(null);
206
+ const totalRef = React.useRef(0);
207
+ const loading = (isLoading || isValidating);
205
208
  const {data,total} = React.useMemo(()=>{
209
+ if(loading){
210
+ return {data:dataRef.current,total:totalRef.current};
211
+ }
206
212
  const {data,total} = (Array.isArray(result) ? {data:result,total:result.length} : isObj(result)? result : {data:[],total:0});
207
213
  const dd = Object.size(data);
208
214
  if(dd>total){
@@ -211,9 +217,10 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
211
217
  if(onFetchData && typeof onFetchData =='function'){
212
218
  onFetchData({allData:data,total,data,context:innerRef.current})
213
219
  }
220
+ dataRef.current = data;
221
+ totalRef.current = total;
214
222
  return {data,total};
215
- },[result])
216
- const loading = (isLoading || isValidating);
223
+ },[result,loading])
217
224
  React.useEffect(()=>{
218
225
  setTimeout(x=>{
219
226
  if(error && innerRef.current && innerRef.current.isLoading && innerRef.current.isLoading()){
@@ -13,7 +13,7 @@ import {Menu as BottomSheetMenu} from "$ecomponents/BottomSheet"
13
13
  import RenderType from "../RenderType";
14
14
  import Footer from "../Footer/Footer";
15
15
  import theme from "$theme";
16
- import Table from "$ecomponents/Table";
16
+ import Table,{styles as tableStyles} from "$ecomponents/Table";
17
17
  import DatagridProvider from "../hooks/Provider";
18
18
 
19
19
 
@@ -64,17 +64,25 @@ const DatagridFactory = (Factory)=>{
64
64
  return null;
65
65
  }
66
66
  renderFilterCell(props){
67
- const {columnField,style} = props;
67
+ const {columnField,style,...rest} = props;
68
68
  const filterC = this.currentFilteringColumns[columnField];
69
+ const rest2 = {};
70
+ ["defaultValue","action","operator"].map((i)=>{
71
+ if(i in rest){
72
+ rest2[i] = rest[i];
73
+ }
74
+ });
69
75
  if(isObj(filterC)){
70
- return <Filter
76
+ return <Filter
77
+ {...rest}
71
78
  {...filterC}
79
+ {...rest2}
72
80
  withLabel = {false}
73
- style = {[styles.filter,theme.styles.pv0,theme.styles.mv0]}
81
+ style = {[styles.filter,tableStyles.filter,theme.styles.pv0,theme.styles.mv0]}
74
82
  anchorProps ={{size:20}}
75
83
  mode = "flat"
76
84
  inputProps = {{
77
- style : [styles.filter],
85
+ style : [styles.filter,tableStyles.filter],
78
86
  mode : "flat",
79
87
  }}
80
88
  />
@@ -406,12 +414,9 @@ const styles = StyleSheet.create({
406
414
  filter : {
407
415
  marginHorizontal:0,
408
416
  paddingHorizontal:0,
409
- maxHeight : 40,
410
- height : 40,
411
417
  width : "100%",
412
418
  alignSelf : 'flex-start',
413
419
  flexGrow : 1,
414
- minHeight : 40,
415
420
  backgroundColor : 'transparent'
416
421
  },
417
422
  layoutContent : {
@@ -845,7 +845,7 @@ class DropdownComponent extends AppComponent {
845
845
  textInputProps.style.backgroundColor = backgroundColor;
846
846
  progressBarProps = defaultObj(progressBarProps);
847
847
 
848
- const loadingElement = !canHandle ? (<View testID={testID+"_DropdownActivityIndicatorContainer"} style = {[{paddingRight : 20}]}>
848
+ const loadingElement = !canHandle && !this.props.isFilter ? (<View testID={testID+"_DropdownActivityIndicatorContainer"} style = {[{paddingRight : 20}]}>
849
849
  <ActivityIndicator
850
850
  color={error?theme.colors.error:theme.colors.secondary}
851
851
  animating={true}
@@ -0,0 +1,9 @@
1
+ import {createContext,useContext,useRef,useMemo} from "react";
2
+
3
+ export const FiltersContext = createContext(null);
4
+
5
+ export const useFilters = x=>useContext(FiltersContext);
6
+
7
+ export const FiltersProvider = ({})=>{
8
+ const filtersValuesRef = useRef({});
9
+ }
@@ -187,17 +187,10 @@ export default class Filter extends AppComponent {
187
187
  value = undefined;
188
188
  }
189
189
  }
190
- const prev = JSON.stringify(defaultObj(this.previousRef.current)), current = {value,operator,action,ignoreCase};
191
- let tV = isArray(value) && value.length <= 0 ? undefined : value;
192
-
193
- this.isInitializedRef.current = this.props.dynamicRendered || this.isInitializedRef.current;
194
- if(prev == "{}" && (isNullOrEmpty(tV) || value === 0) && (!this.isInitializedRef.current) && (force !== true)) {
195
- return this;
196
- }
190
+ const prev = JSON.stringify(this.previousRef.current), current = {value,operator,action,ignoreCase};
197
191
  if(prev == JSON.stringify(current) && (force !== true)){
198
192
  return this;
199
193
  }
200
- this.isInitializedRef.current = true;
201
194
  this.previousRef.current = current;
202
195
  if(isFunction(this.props.onChange)){
203
196
  let selector = {};
@@ -415,6 +408,23 @@ export default class Filter extends AppComponent {
415
408
  }
416
409
  return value;
417
410
  }
411
+ UNSAFE_componentWillReceiveProps(nexProps){
412
+ const state = {};
413
+ const defaultValue = nexProps.defaultValue == null || nexProps.defaultValue =="" ? undefined : nexProps.defaultValue;
414
+ const stateValue = this.state.defaultValue == null || this.state.defaultValue ==""? undefined : this.state.defaultValue;
415
+ if('defaultValue' in nexProps && defaultValue != stateValue){
416
+ state.defaultValue = defaultValue;
417
+ }
418
+ if(isNonNullString(nexProps.operator) && nexProps.operator in this.state.operators){
419
+ state.operator = nexProps.operator;
420
+ }
421
+ if(isNonNullString(nexProps.action) in nexProps && nexProps.action in this.state.actions){
422
+ state.action = nexProps.action;
423
+ }
424
+ if(Object.size(state,true)){
425
+ this.setState(state,()=>{});
426
+ }
427
+ }
418
428
  render (){
419
429
  let {
420
430
  filter,
@@ -196,14 +196,6 @@ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,isStructData,ge
196
196
  }
197
197
  }
198
198
  }
199
- const prevIsUpdate = React.usePrevious(isUpdate);
200
- const prevDefaultValue = React.usePrevious(foreignKeyColumnValue);
201
- /*if(!isFilter){
202
- React.useEffect(()=>{
203
- if(prevIsUpdate === isUpdate && JSON.stringify(prevDefaultValue) === JSON.stringify(foreignKeyColumnValue)) return;
204
- context.refresh();
205
- },[isUpdate,foreignKeyColumnValue])
206
- }*/
207
199
  dropdownActions = isObj(dropdownActions)? {...dropdownActions} : isArray(dropdownActions)? [...dropdownActions] : []
208
200
  const isDropdonwsActionsArray = isArray(dropdownActions);
209
201
  const refreshItem = {
@@ -7,6 +7,7 @@ import KeyboardAvoidingView from "$ecomponents/KeyboardAvoidingView";
7
7
  import { StyleSheet } from "react-native";
8
8
  import APP from "$capp/instance";
9
9
  import PropTypes from "prop-types";
10
+ import View from "$ecomponents/View";
10
11
 
11
12
  /**** règles d'utilisation :
12
13
  1. les forms doivent toujours avoir un nom : chaine de caractère unique pour l'application et non null
@@ -105,9 +106,9 @@ export default class FormComponent extends React.AppComponent {
105
106
  ...rest
106
107
  } = this.props;
107
108
  testID = defaultStr(testID,"RN_FormComponent");
108
- return <KeyboardAvoidingView {...rest} testID={testID+"_FormKeyboardAvoidingView"} style={[styles.container,rest.style]}>
109
+ return <View {...rest} testID={testID+"_FormKeyboardAvoidingView"} style={[styles.container,rest.style]}>
109
110
  {this.props.children}
110
- </KeyboardAvoidingView>
111
+ </View>
111
112
  }
112
113
  }
113
114
  const isField = (Component)=>{
@@ -79,7 +79,6 @@ export const getFilterComponentProps = (_props)=>{
79
79
  filterType,
80
80
  getValidValue,
81
81
  validate,
82
- onValidate,
83
82
  onValidatorValid,///il s'agit de la fonction de rappel appelée immédiatement après que le validateur ait réuissie la validation
84
83
  onValidateField,
85
84
  onNoValidate,
@@ -0,0 +1,26 @@
1
+ import React from "$react";
2
+ import {useTable,useGetColumnProps} from "../hooks";
3
+ import {defaultObj,defaultVal} from "$cutils";
4
+ import styles from "../styles";
5
+ import HeaderCell from "./Cell";
6
+ import Label from "$ecomponents/Label";
7
+ import theme from "$theme";
8
+
9
+ export default function HeaderCellWrapper({columnField,isFilter,isFooter}){
10
+ const {render,sortedColumn,filtersValues,...props} = useGetColumnProps({columnField,isFilter,isFooter});
11
+ const columnDef = props.columnDef;
12
+ const rProps = isFilter ? sortedColumn : undefined;
13
+ const isHeader = !isFilter && !isFooter;
14
+ const width = props.width;
15
+ const {containerProps,...rest} = props;
16
+ return React.useMemo(()=>{
17
+ let content = typeof render ==='function' ? render(props) : isHeader ? defaultVal(columnDef?.text,columnDef?.label,columnField):null;
18
+ const wStyle = width && {width} || null;
19
+ if(isHeader){
20
+ content = <Label splitText numberOfLines={1} style={[theme.styles.w100,theme.styles.h100,styles.headerCellLabel,wStyle]} textBold primary>{content}</Label>
21
+ } else if(isFooter){
22
+ content = <Label primary textBold children={content}/>
23
+ }
24
+ return <HeaderCell {...containerProps} width={width} columnDef={columnDef} columnField={columnField} style={[styles.headerItem,styles.headerItemOrCell,styles.filterCell,containerProps.style,styles.cell,columnDef.style]} children={content}/>
25
+ },[columnField,width,rProps]);
26
+ }
@@ -0,0 +1,8 @@
1
+ if(isFilter){
2
+ console.log(forceRender,"is force render heeeeein manaa",rest.style);
3
+ return colsNames.map((columnField,index)=>{
4
+ const visible = columnsVisibilities[index];
5
+ if(!visible) return null;
6
+ return <CellWrapper isFilter key={columnField} columnField={columnField} columIndex={index}/>
7
+ })
8
+ }
@@ -2,7 +2,6 @@
2
2
  // Use of this source code is governed by a BSD-style
3
3
  // license that can be found in the LICENSE file.
4
4
 
5
- import Cell from "./Cell";
6
5
  import React from "$react";
7
6
  import { View } from "react-native";
8
7
  import PropTypes from "prop-types";
@@ -13,20 +12,20 @@ const isNative = isMobileNative();
13
12
  const Component = isNative ? View : "tr";
14
13
  import { useTable } from "../hooks";
15
14
  import styles from "../styles";
16
- import CellHeader from "./CellHeader";
15
+ import CellWrapper from "./CellWrapper";
17
16
 
18
17
  export default function RowHeaderComponent({isFilter,isFooter,isHeader,className,children:cChildren,...rest}){
19
- const {showHeaders,visibleColsNames,visibleColsNamesStr,headerContainerProps,footerContainerProps,filtersContainerProps,showFilters,footers,headers,filters,showFooters} = useTable();
18
+ const {showHeaders,visibleColsNames,visibleColsNamesStr,headerContainerProps,footerContainerProps,filtersContainerProps,showFilters,filters,showFooters} = useTable();
20
19
  const canV = showHeaders === false ? false : Array.isArray(children)? !!children.length : true;
21
20
  const visible = canV && (isHeader ? true : isFilter ? !!showFilters : isFooter ? !!showFooters: true);
22
21
  const containerProps = defaultObj( isHeader ? headerContainerProps : isFooter ? footerContainerProps : filtersContainerProps);
23
22
  const style = filters ? styles.filters : isFooter ? styles.footer : null;
24
- const children = React.useMemo(()=>{
25
- const contents = isFilter ? filters : isFooter ? footers : headers;
26
- return visibleColsNames.map((columnField,cIndex)=>{
27
- return contents[columnField] || null;
23
+ const children = React.useMemo(()=>{
24
+ return visibleColsNames.map((columnField,index)=>{
25
+ return <CellWrapper isFilter={isFilter} isFooter={isFooter} key={columnField} columnField={columnField} columIndex={index}/>
28
26
  });
29
27
  },[visibleColsNamesStr]);
28
+ if(!visible) return null;
30
29
  const rP = isNative ? rest : {className:classNames(className,"table-footer-or-header-row")}
31
30
  return <Component {...rP} {...containerProps} style={StyleSheet.flatten([styles.header,style,rest.style,containerProps.style,!visible && hStyle.hidden])}>
32
31
  {children}
@@ -37,12 +36,6 @@ RowHeaderComponent.propTypes = {
37
36
  visible : PropTypes.bool,
38
37
  }
39
38
 
40
- export {Cell};
41
-
42
- RowHeaderComponent.Cell = Cell;
43
- RowHeaderComponent.CellHeader = CellHeader;
44
-
45
- export {CellHeader};
46
39
 
47
40
  const hStyle = StyleSheet.create({
48
41
  hidden : {height:0,opacity:0,display:'none'}
@@ -1,19 +1,16 @@
1
- import React,{useMemo} from "$react";
2
- import {defaultStr,isObj,uniqid} from "$cutils";
1
+ import {useMemo,useRef,useStableMemo} from "$react";
2
+ import {defaultStr,isObj} from "$cutils";
3
3
  import {DEFAULT_COLUMN_WIDTH} from "./utils";
4
- import Label from "$ecomponents/Label";
5
- import HeaderCell from "./Header/Cell";
6
- import MainHeaderCell from "./Header/CellHeader";
7
- import styles from "./styles";
8
4
 
9
- export const usePrepareColumns = ({columns,forceRender,testID,renderFooterCell,renderHeaderCell,renderFilterCell,columnsWidths,headerCellContainerProps,colsWidths,columnProps,footers,footerCellContainerProps,filterCellContainerProps})=>{
5
+ export const usePrepareColumns = ({columns,testID,columnsWidths,headerCellContainerProps,colsWidths:cColsWidths,columnProps,footerCellContainerProps,filterCellContainerProps})=>{
6
+ const filtersValuesRef = useRef({});
10
7
  return useMemo(()=>{
11
8
  testID = defaultStr(testID,"RN_TableColumns")
12
- const cols = {},headers = {},footers = {},filters = {},visibleColsNames = [],columnsVisibilities=[],columnsNames = [],colsWidths={};
13
- let hasFooters = false;
9
+ const cols = {},visibleColsNames = [],columnsVisibilities=[],columnsNames = [],colsWidths={};
14
10
  columnProps = defaultObj(columnProps);
11
+ //const colsNames=[];
15
12
  let columnIndex = 0;
16
- const widths = defaultObj(columnsWidths,colsWidths);
13
+ const widths = defaultObj(columnsWidths,cColsWidths);
17
14
  headerCellContainerProps = defaultObj(headerCellContainerProps);
18
15
  footerCellContainerProps = defaultObj(footerCellContainerProps);
19
16
  filterCellContainerProps = defaultObj(filterCellContainerProps);
@@ -21,59 +18,62 @@ export const usePrepareColumns = ({columns,forceRender,testID,renderFooterCell,r
21
18
  Object.map(columns,(columnDef,field)=>{
22
19
  if(!isObj(columnDef)) return;
23
20
  const columnField = defaultStr(columnDef.field,field);
24
- let {visible,width,type,style} = columnDef;
21
+ let {visible,width,type} = columnDef;
25
22
  visible = typeof visible =='boolean'? visible : true;
26
23
  type = defaultStr(type,"text").toLowerCase().trim();
27
24
  width = colsWidths[columnField] = defaultDecimal(widths[columnField],width,DEFAULT_COLUMN_WIDTH);
28
- const colArgs = {width,type,columnDef,containerProps:{},columnField,index:columnIndex,columnIndex};
29
- const hContainerProps = defaultObj(colArgs.containerProps);
30
25
  totalWidths+=width;
31
- const rArgs = {columnDef,width};
32
- headers[columnField] = <MainHeaderCell colArgs={colArgs} {...rArgs} columnField={columnField} width={width} testID={testID+"_HeaderCell_"+columnField} {...headerCellContainerProps} {...hContainerProps} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,headerCellContainerProps.style,hContainerProps.style,style]}/>
33
- if(typeof renderFilterCell =='function'){
34
- const filterCell = renderFilterCell(colArgs);
35
- filters[columnField] = <HeaderCell {...rArgs} width={width} testID={testID+"_Filter_Cell_"+columnField} {...filterCellContainerProps} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,styles.filterCell,filterCellContainerProps.style,styles.cell,style]}>
36
- {React.isValidElement(filterCell)? filterCell : null}
37
- </HeaderCell>
26
+ columnsVisibilities.push(visible);
27
+ //colsNames.push(columnField);
28
+ if(visible){
29
+ visibleColsNames.push(columnField);
38
30
  }
39
- if(typeof renderFooterCell ==='function') {
40
- const footerProps = {...colArgs,containerProps:{}};
41
- let cellFooter = renderFooterCell(footerProps);
42
- let fContainerProps = {};
43
- if(!React.isValidElement(cellFooter,true) && isObj(cellFooter)){
44
- fContainerProps = isObj(cellFooter.containerProps)? cellFooter.containerProps : {};
45
- cellFooter = React.isValidElement(cellFooter.children)? cellFooter.children : React.isValidElement(cellFooter.content)? cellFooter.content : null;
46
- } else if(isObj(footerProps.containerProps)){
47
- fContainerProps = footerProps.containerProps;
48
- }
49
- cellFooter = React.isValidElement(cellFooter,true)? cellFooter : null;
50
- if(!hasFooters && cellFooter){
51
- hasFooters = true;
52
- }
53
- footers[columnField] = <HeaderCell {...rArgs} width={width} testID={testID+"_Footer_Cell_"+columnField} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,footerCellContainerProps.style,style]}>
54
- <Label primary children={cellFooter}/>
55
- </HeaderCell>
56
- }
57
- columnsVisibilities.push(visible);
58
- if(visible){
59
- visibleColsNames.push(columnField);
60
- }
61
- columnsNames.push(columnField);
62
- cols[columnField] = {
63
- ...columnDef,
64
- width,
65
- index : columnIndex,
66
- field : columnField,
67
- visible,
68
- columnField,
69
- };
70
- columnIndex++;
31
+ columnsNames.push(columnField);
32
+ cols[columnField] = {
33
+ ...columnDef,
34
+ width,
35
+ index : columnIndex,
36
+ field : columnField,
37
+ visible,
38
+ columnField,
39
+ };
40
+ columnIndex++;
71
41
  });
72
- return {columns:cols,columnsNames,headers,colsWidths,columnsVisibilities,totalWidths,totalColsWidths:totalWidths,visibleColsNamesStr:JSON.stringify(visibleColsNames),visibleColsNames,hasFooters,footers,filters};
73
- },[columns,footers,forceRender]);
42
+ return {columns:cols,columnsNames,filtersValues:filtersValuesRef.current,colsWidths,columnsVisibilities,totalWidths,totalColsWidths:totalWidths,visibleColsNamesStr:visibleColsNames.join(","),visibleColsNames};
43
+ },[columns]);
74
44
  }
45
+ import useTable from "./useTable";
75
46
 
47
+ export const useGetColumnProps = ({columnField,isFilter,isFooter})=>{
48
+ const {renderFilterCell,renderFooterCell,filtersValues,renderHeaderCell,sortedColumn,columns,filterCellContainerProps,footerCellContainerProps,headerCellContainerProps,testID,colsWidths} = useTable();
49
+ const columnDef = columns[columnField];
50
+ const props = isFilter ? {
51
+ containerProps : defaultObj(filterCellContainerProps),
52
+ render : renderFilterCell,
53
+ } : isFooter ? {
54
+ containerProps : defaultObj(footerCellContainerProps),
55
+ render : renderFooterCell,
56
+ } : {
57
+ containerProps : defaultObj(headerCellContainerProps),
58
+ render : renderHeaderCell
59
+ }
60
+ props.width = colsWidths[columnField];
61
+ props.columnField = columnField;
62
+ props.columnDef = columnDef;
63
+ props.type = defaultStr(columnDef?.type,"text").toLowerCase().trim();
64
+ props.sortedColumn = sortedColumn;
65
+ props.testID = `${testID}-HeaderCell${isFilter?"Filter":isFooter?"Footer":"Header"}_${columnField}`;
66
+ if(isFilter){
67
+ props.onValidate = ({action,defaultValue,operator})=>{
68
+ filtersValues[columnField] = {action,defaultValue,operator};
69
+ }
70
+ Object.map(filtersValues[columnField],(v,i)=>{
71
+ props[i] = v;
72
+ });
73
+ }
74
+ return props;
75
+ }
76
76
 
77
- export {default as useTable} from "./useTable";
77
+ export {useTable};
78
78
 
79
79
  export * from "./useTable";
@@ -60,7 +60,7 @@ const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRe
60
60
  footerScrollViewProps = defaultObj(footerScrollViewProps);
61
61
  const listRef = React.useRef(null),scrollViewRef = React.useRef(null),headerScrollViewRef = React.useRef(null);
62
62
  const layoutRef = React.useRef({});
63
- const {testID,withDatagridContext,filters,getRowByIndex,itemsChanged,hasFooters:stateHasFooters,bordered,totalWidths,keyExtractor,items,data} = useTable();
63
+ const {testID,withDatagridContext,getRowByIndex,itemsChanged,hasFooters:stateHasFooters,bordered,totalWidths,keyExtractor,items,data} = useTable();
64
64
  const hasData = !!Object.size(data,true);
65
65
  const emptyData = !hasData && renderListContent === false ?null : typeof renderEmpty =='function' ? renderEmpty() : null;
66
66
  const hasEmptyData = emptyData && React.isValidElement(emptyData);
@@ -70,7 +70,7 @@ const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRe
70
70
  const scrollContentContainerStyle = {flex:1,width:listWidth,minWidth:totalWidths,height:'100%'};
71
71
  const scrollEventThrottle = isMobileNative()?200:50;
72
72
  const scrollViewFlexGrow = {flexGrow:0};
73
- const maxScrollheight = 170;//footersContent.length && fFilters.length ? 170 : footersContent.length ?120 : fFilters.length ? 140 : 80;
73
+ const maxScrollheight = 170;
74
74
  const allScrollViewProps = {
75
75
  scrollEventThrottle,
76
76
  horizontal : true,
@@ -142,11 +142,13 @@ const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRe
142
142
  }
143
143
  }
144
144
  };
145
- const headerFootersFilters = <>
146
- <Header isHeader={true} testID={testID+"_Header"}/>
147
- <Header isFilter={true} testID={testID+"_Filters"} style={[styles.header,styles.footers,theme.styles.pt0,theme.styles.pb0,theme.styles.ml0,theme.styles.mr0]}/>
148
- <Header isFooter testID={testID+"_Footer"} style={[styles.header,styles.footers,theme.styles.pt0,theme.styles.pb0,theme.styles.ml0,theme.styles.mr0]}/>
149
- </>
145
+ const headerFootersFilters = React.useMemo(()=>{
146
+ return <>
147
+ <Header isHeader={true} testID={testID+"_TableHeader"}/>
148
+ <Header isFilter={true} testID={testID+"_TableFilters"} style={[styles.header,styles.filters,theme.styles.pt0,theme.styles.pb0,theme.styles.ml0,theme.styles.mr0]}/>
149
+ <Header isFooter testID={testID+"_TableFooter"} style={[styles.header,styles.footers,theme.styles.pt0,theme.styles.pb0,theme.styles.ml0,theme.styles.mr0]}/>
150
+ </>
151
+ },[])
150
152
  return <View testID= {testID+"_Container"} {...containerProps} onLayout={(e)=>{
151
153
  layoutRef.current = e.nativeEvent.layout;
152
154
  if(containerProps.onLayout){
@@ -285,9 +287,6 @@ const ColumnType = PropTypes.shape({
285
287
  label : PropTypes.text,
286
288
  text : PropTypes.string,
287
289
  });
288
- const RowType = PropTypes.shape({
289
-
290
- });
291
290
 
292
291
 
293
292
  TableComponent.popTypes = {
@@ -8,6 +8,7 @@ const styles = StyleSheet.create({
8
8
  contentContainer : {
9
9
  flex:1,
10
10
  },
11
+ headerCellLabel : {maxHeight:70},
11
12
  container : {
12
13
  width : '100%',
13
14
  minHeight : 300,
@@ -35,7 +36,7 @@ const styles = StyleSheet.create({
35
36
  minHeight : 40,
36
37
  },
37
38
  filters : {
38
- height : 50,
39
+ maxHeight : 50,
39
40
  },
40
41
  footers : {
41
42
  minHeight : 40,
@@ -45,9 +46,6 @@ const styles = StyleSheet.create({
45
46
  flexDirection : 'row',
46
47
  flexWrap : 'wrap',
47
48
  },
48
- footers : {
49
- minHeight : 40,
50
- },
51
49
  headerItemOrCell : {
52
50
  alignItems: 'flex-start',
53
51
  alignSelf : 'center',
@@ -65,8 +63,12 @@ const styles = StyleSheet.create({
65
63
  paddingVertical : 0,
66
64
  marginVertical : 0,
67
65
  marginHorizontal : 0,
66
+ maxHeight : 40,
68
67
  justifyContent : 'flex-start',
69
68
  },
69
+ filter : {
70
+ minHeight : 30,
71
+ },
70
72
  headerItem: {
71
73
  minHeight: 30,
72
74
  },
@@ -1,21 +0,0 @@
1
- import React from "$react";
2
- import Cell from "./Cell";
3
- import useTable from "../useTable";
4
- import Label from "$ecomponents/Label";
5
- import {defaultVal} from "$cutils";
6
- import theme from "$theme";
7
- import styles from "../styles";
8
-
9
- export default function TableCellMainHeaderComponent({columnField,columnDef,style,colArgs,...props}){
10
- const {sortedColumn,renderHeaderCell,colsWidths} = useTable();
11
- const width = colsWidths[columnField];
12
- const children = React.useMemo(()=>{
13
- const content = typeof renderHeaderCell =='function'? renderHeaderCell(colArgs) : defaultVal(columnDef.text,columnDef.label,columnField);
14
- if(!React.isValidElement(content,true)){
15
- console.error(content," is not valid element of header ",columnDef," it could not be render on table");
16
- return null;
17
- }
18
- return <Label splitText numberOfLines={1} style={[theme.styles.w100,theme.styles.h100,{maxHeight:70},width&&{width}]} textBold primary>{content}</Label>
19
- },[sortedColumn,columnField])
20
- return <Cell {...props} style={[styles.headerItem,style]} children={children}/>
21
- }