@fto-consult/expo-ui 6.26.4 → 6.26.7
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/Datagrid/Accordion/Row.js +4 -4
- package/src/components/Datagrid/Common/Common.js +1 -1
- package/src/components/Datagrid/SWRDatagrid.js +9 -2
- package/src/components/Datagrid/Table/index.js +13 -8
- package/src/components/Dropdown/index.js +1 -1
- package/src/components/Filter/context.js +9 -0
- package/src/components/Filter/index.js +18 -8
- package/src/components/Form/Fields/SelectTableData/Component.js +0 -8
- package/src/components/Form/FormData/componentsTypes.js +0 -1
- package/src/components/Table/Header/CellWrapper.js +26 -0
- package/src/components/Table/Header/filters.old.js +8 -0
- package/src/components/Table/Header/index.js +6 -13
- package/src/components/Table/hooks.js +55 -55
- package/src/components/Table/index.js +9 -10
- package/src/components/Table/styles.js +6 -4
- package/src/components/Table/Header/CellHeader.js +0 -21
package/package.json
CHANGED
|
@@ -127,10 +127,10 @@ const DatagridAccordionRow = React.forwardRef((props,ref)=>{
|
|
|
127
127
|
ref = {React.useMergeRefs(ref,innerRef)}
|
|
128
128
|
>
|
|
129
129
|
<Swipeable
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
ref = {swipeableRef}
|
|
131
|
+
testID={testID+'_ContentContainerSwipeable'}
|
|
132
|
+
friction={2}
|
|
133
|
+
containerStyle = {{overflow:'hidden'}}
|
|
134
134
|
leftThreshold={80}
|
|
135
135
|
enableTrackpadTwoFingerGesture
|
|
136
136
|
renderLeftActions={selectable === false? undefined : (_progress,dragX) => {
|
|
@@ -3743,7 +3743,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
3743
3743
|
getRowKeyByIndex(rowIndex){
|
|
3744
3744
|
if(typeof rowIndex !='number') return undefined;
|
|
3745
3745
|
const idx = this.getRowsKeysIndexes();
|
|
3746
|
-
if(rowIndex < idx.length
|
|
3746
|
+
if(rowIndex < idx.length && rowIndex>=0){
|
|
3747
3747
|
return idx[rowIndex];
|
|
3748
3748
|
}
|
|
3749
3749
|
return undefined;
|
|
@@ -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(
|
|
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 = {
|
|
@@ -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
|
|
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,
|
|
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
|
-
|
|
26
|
-
|
|
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
|
|
2
|
-
import {defaultStr,isObj
|
|
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,
|
|
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 = {},
|
|
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,
|
|
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
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
if(
|
|
34
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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,
|
|
73
|
-
},[columns
|
|
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 {
|
|
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,
|
|
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
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
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
|
-
}
|