@fto-consult/expo-ui 2.9.6 → 2.10.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.
- package/package.json +2 -2
- package/src/App.js +82 -32
- package/src/components/Datagrid/Accordion/index.js +1 -1
- package/src/components/Datagrid/Common/Common.js +120 -23
- package/src/components/Datagrid/Common/ProgressBar.js +58 -0
- package/src/components/Datagrid/Common/TableData.js +15 -70
- package/src/components/Datagrid/IndexComponent.js +45 -0
- package/src/components/Datagrid/RenderTypes/index.web.js +5 -2
- package/src/components/Datagrid/Table/index.js +11 -12
- package/src/components/Datagrid/index.js +4 -40
- package/src/components/Menu/Item.js +2 -1
- package/src/layouts/Fab/index.js +0 -1
- package/src/components/Datagrid/Table/Datatable.js +0 -232
- package/src/components/Datagrid/Table/renderTable.js +0 -664
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { fixedIcon,virtualIcon } from "./utils"
|
|
2
2
|
export default {
|
|
3
3
|
fixed : {
|
|
4
|
-
code:'fixed',icon:fixedIcon,
|
|
4
|
+
code:'fixed',icon:fixedIcon,
|
|
5
|
+
label:'Tableau virtuel optimisé',
|
|
6
|
+
desktop:true,
|
|
5
7
|
title : "Les éléments de liste s'affichent dans un tableau virtuel optimisé",
|
|
6
8
|
},
|
|
7
|
-
virtual : {code:'virtual',icon:virtualIcon,
|
|
9
|
+
virtual : {code:'virtual',icon:virtualIcon,
|
|
10
|
+
label:'Tableau virtuel',
|
|
8
11
|
title : "Les éléments de liste s'affichent dans un tableau virtuel", desktop:true
|
|
9
12
|
}
|
|
10
13
|
}
|
|
@@ -113,30 +113,29 @@ const DatagridFactory = (Factory)=>{
|
|
|
113
113
|
render(){
|
|
114
114
|
let {title,testID,actions,selectableMultiple,sortable,exportable,
|
|
115
115
|
selectable,pagin,showPagination,
|
|
116
|
-
sessionName,onMount,onUnmount,onFetchData,
|
|
116
|
+
sessionName,onMount,onUnmount,onFetchData,dataSourceSelector,dataSourceSelectorProps,queryLimit,
|
|
117
117
|
filters,
|
|
118
118
|
accordion, //pour le rendu du header en accordion
|
|
119
119
|
...rest
|
|
120
120
|
} = this.props;
|
|
121
121
|
testID = defaultStr(testID,'RN_DatagridTableComponent');
|
|
122
122
|
rest = defaultObj(rest);
|
|
123
|
-
let
|
|
124
|
-
if(
|
|
125
|
-
|
|
126
|
-
} else if(
|
|
127
|
-
|
|
123
|
+
let showDataSourceSelector = false;
|
|
124
|
+
if(dataSourceSelector === true){
|
|
125
|
+
showDataSourceSelector = true;
|
|
126
|
+
} else if(dataSourceSelector ===false){
|
|
127
|
+
showDataSourceSelector = false;
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
let _dbSelector = undefined;/* showDBSelector ? <div>
|
|
129
|
+
dataSourceSelectorProps = defaultObj(dataSourceSelectorProps);
|
|
130
|
+
let _dataSourceSelector = undefined;/* showDataSourceSelector ? <div>
|
|
132
131
|
<DBSelector
|
|
133
|
-
{...
|
|
132
|
+
{...dataSourceSelectorProps}
|
|
134
133
|
onChange = {this.onChangeDatabases.bind(this)}
|
|
135
134
|
/>
|
|
136
135
|
</div> : null;*/
|
|
137
136
|
if(!title){
|
|
138
|
-
title =
|
|
139
|
-
|
|
137
|
+
title = _dataSourceSelector;
|
|
138
|
+
_dataSourceSelector = null;
|
|
140
139
|
}
|
|
141
140
|
exportable = defaultBool(exportable,true);
|
|
142
141
|
sortable = defaultVal(sortable,true);
|
|
@@ -1,43 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {isFunction} from "$utils";
|
|
5
|
-
import React from "$react";
|
|
6
|
-
import {getRenderType} from "./utils";
|
|
1
|
+
// Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
7
4
|
|
|
8
5
|
export * from "./Common";
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
const DatagridMainComponent = React.forwardRef((props,ref)=>{
|
|
12
|
-
const isDesk = isDesktopMedia();
|
|
13
|
-
const isMob = isMobileMedia();
|
|
14
|
-
const [isTableData] = React.useState(defaultStr(props.tableName,props.table) || typeof props.fetchData ==='function' || props.isTableData?true : false);
|
|
15
|
-
const TableComponent = isTableData ? DatagridTableData : Table;
|
|
16
|
-
const AccordionComponent = isTableData ? TableDataAccordion : Accordion;
|
|
17
|
-
let Component = TableComponent;
|
|
18
|
-
const canRenderAccordion = (isFunction(props.accordion) || (isObj(props.accordionProps) && isFunction(props.accordionProps.accordion)) || props.accordion === true);
|
|
19
|
-
let renderType = defaultStr(getRenderType(),isDesk? "fixed":'accordion').trim().toLowerCase()
|
|
20
|
-
if(renderType == 'accordion' && canRenderAccordion){
|
|
21
|
-
Component = AccordionComponent;
|
|
22
|
-
} else if(renderType =='table'){
|
|
23
|
-
Component = TableComponent;
|
|
24
|
-
} else if(isMob && canRenderAccordion){
|
|
25
|
-
Component = AccordionComponent;
|
|
26
|
-
}
|
|
27
|
-
return <Component
|
|
28
|
-
{...props}
|
|
29
|
-
ref = {ref}
|
|
30
|
-
/>;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export default DatagridMainComponent;
|
|
34
|
-
|
|
35
|
-
DatagridMainComponent.displayName = "DatagridMainComponent";
|
|
36
|
-
|
|
37
|
-
DatagridMainComponent.propTypes = {
|
|
38
|
-
...DatagridTableData.propTypes
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
DatagridMainComponent.getDBName = DatagridTableData.getDBName;
|
|
42
|
-
|
|
43
|
-
DatagridMainComponent.LinesProgressBar = DatagridMainComponent.LineProgressBar = DatagridTableData.LineProgressBar;
|
|
7
|
+
export {default} from "./IndexComponent";
|
|
@@ -35,7 +35,7 @@ const MenuItemComponent = React.forwardRef(({
|
|
|
35
35
|
accessibilityLabel,
|
|
36
36
|
...rest
|
|
37
37
|
},ref) => {
|
|
38
|
-
title = defaultVal(
|
|
38
|
+
title = defaultVal(label,text,title);
|
|
39
39
|
const disabledColor = color(theme.dark ? white : black)
|
|
40
40
|
.alpha(0.32)
|
|
41
41
|
.rgb()
|
|
@@ -66,6 +66,7 @@ const MenuItemComponent = React.forwardRef(({
|
|
|
66
66
|
return (
|
|
67
67
|
<Tooltip
|
|
68
68
|
{...defaultObj(rest)}
|
|
69
|
+
tooltip = {defaultVal(rest.tooltip,title,label,text)}
|
|
69
70
|
Component = {TouchableRipple}
|
|
70
71
|
style={[styles.container, style,maxWidthStyle,disabledStyle]}
|
|
71
72
|
onPress={onPress}
|
package/src/layouts/Fab/index.js
CHANGED
|
@@ -16,7 +16,6 @@ const FABContainer = React.forwardRef((props,ref)=>{
|
|
|
16
16
|
ref = ref || createFabRef(screenName);
|
|
17
17
|
React.useEffect(()=>{
|
|
18
18
|
const onFocusFab = ({sanitizedName})=>{
|
|
19
|
-
console.log(sanitizedName," is dddddd focused")
|
|
20
19
|
const isFocused = sanitizedName === sScreenName;
|
|
21
20
|
if(isFocused && ref.current && ref.current.show){
|
|
22
21
|
ref.current.show();
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import View from "$ecomponents/View";
|
|
2
|
-
import React from '$react'
|
|
3
|
-
import {
|
|
4
|
-
StyleSheet,
|
|
5
|
-
} from 'react-native'
|
|
6
|
-
import ScrollView from "$ecomponents/ScrollView";
|
|
7
|
-
import PropTypes from 'prop-types'
|
|
8
|
-
import {isObj,defaultDecimal,defaultStr,isDecimal} from "$utils";
|
|
9
|
-
import Label from "$ecomponents/Label";
|
|
10
|
-
|
|
11
|
-
const DEFAULT_HEIGHT = 240;
|
|
12
|
-
export const DEFAULT_COLUMN_WIDTH = 60;
|
|
13
|
-
|
|
14
|
-
import { ROW_BORDER_COLOR,ROW_BORDER_WIDTH } from '../utils';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const DatatableComponent = (props)=>{
|
|
18
|
-
let {renderCell,cellContainerProps,hasFooters,footerContainerProps,showFilters,showFooter,footerCellContainerProps,headerCellContainerProps,renderFooterCell,rowContainerProps,containerProps,getRowKey,renderHeaderCell,data,columns,headerContainerProps,colsWidths,columnProps,columnsWidths,contentContainerStyle,renderRow} = props;
|
|
19
|
-
|
|
20
|
-
const hStyle = {borderBottomColor:ROW_BORDER_COLOR,borderBottomWidth:ROW_BORDER_WIDTH};
|
|
21
|
-
const [state,setState] = React.useStateIfMounted({
|
|
22
|
-
headers : [],
|
|
23
|
-
footersCells : [],
|
|
24
|
-
hasFooters : defaultBool(hasFooters),
|
|
25
|
-
tableRows : []
|
|
26
|
-
});
|
|
27
|
-
const prevData = React.usePrevious(data);
|
|
28
|
-
const prevColumns = React.usePrevious(columns);
|
|
29
|
-
const prevShowFilters = React.usePrevious(showFilters);
|
|
30
|
-
|
|
31
|
-
containerProps = defaultObj(containerProps);
|
|
32
|
-
headerContainerProps = defaultObj(headerContainerProps);
|
|
33
|
-
footerCellContainerProps = defaultObj(footerCellContainerProps);
|
|
34
|
-
footerContainerProps = defaultObj(footerContainerProps);
|
|
35
|
-
|
|
36
|
-
const prepareState = React.useCallback(()=>{
|
|
37
|
-
const headers = [],footersCells = [],tableRows = [],cols = {};
|
|
38
|
-
const widths = defaultObj(colsWidths,columnsWidths);
|
|
39
|
-
getRowKey = typeof getRowKey =='function'? getRowKey : (r,index)=>index;
|
|
40
|
-
columnProps = defaultObj(columnProps);
|
|
41
|
-
let columnIndex = 0;
|
|
42
|
-
cellContainerProps = defaultObj(cellContainerProps);
|
|
43
|
-
headerCellContainerProps = defaultObj(headerCellContainerProps);
|
|
44
|
-
let hasFooterFields = false;
|
|
45
|
-
Object.map(columns,(columnDef,columnField)=>{
|
|
46
|
-
if(!isObj(columnDef) || columnDef.visible === false) return;
|
|
47
|
-
let {visible,width,type,...colProps} = columnDef;
|
|
48
|
-
type = defaultStr(type,"text").toLowerCase().trim();
|
|
49
|
-
colProps = defaultObj(colProps);
|
|
50
|
-
width = defaultDecimal(widths[columnField],columnDef.width,DEFAULT_COLUMN_WIDTH);
|
|
51
|
-
widths[columnField] = width;
|
|
52
|
-
const style = {width};
|
|
53
|
-
const colArgs = { width,Headers:headers,...colProps,containerProps:{},style,columnDef,columnField,columnIndex};
|
|
54
|
-
let headerContent = typeof renderHeaderCell ==='function' ? renderHeaderCell (colArgs) :
|
|
55
|
-
defaultVal(columnDef.Label,columnDef.text);
|
|
56
|
-
cols[columnField] = columnDef;
|
|
57
|
-
columnIndex++;
|
|
58
|
-
headers.push(
|
|
59
|
-
<View {...headerCellContainerProps} {...colArgs.containerProps} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,headerCellContainerProps.style,colArgs.containerProps.style,style]}>
|
|
60
|
-
<Label>{headerContent}</Label>
|
|
61
|
-
</View>
|
|
62
|
-
)
|
|
63
|
-
if(typeof renderFooterCell ==='function') {
|
|
64
|
-
const footerProps = {...colArgs,containerProps:{}};
|
|
65
|
-
const cellFooter = renderFooterCell(footerProps);
|
|
66
|
-
const hsFooter = React.isValidElement(cellFooter);
|
|
67
|
-
if(!hasFooterFields && hsFooter){
|
|
68
|
-
hasFooterFields = hsFooter;
|
|
69
|
-
}
|
|
70
|
-
footersCells.push(<View key={columnField} style={[styles.headerItem,styles.headerItemOrCell,footerCellContainerProps.style,footerProps.containerProps.style,style]}>
|
|
71
|
-
{hsFooter? cellFooter : null}
|
|
72
|
-
</View>)
|
|
73
|
-
};
|
|
74
|
-
});
|
|
75
|
-
const nState = {headers,footersCells,hasFooters}
|
|
76
|
-
if(prevData !== data || prevColumns !== columns){
|
|
77
|
-
const _renderCell = (args) => {
|
|
78
|
-
const {rowIndex,columnField,rowData} = args;
|
|
79
|
-
args.containerProps = defaultObj(args.containerProps);
|
|
80
|
-
let style = {width: widths[columnField]};
|
|
81
|
-
args.style = style;
|
|
82
|
-
let ctx = rowData[columnField];
|
|
83
|
-
if(typeof args.customRenderCell =='function'){
|
|
84
|
-
ctx = args.customRenderCell(args);
|
|
85
|
-
} else if(typeof renderCell ==='function'){
|
|
86
|
-
ctx = renderCell(args);
|
|
87
|
-
}
|
|
88
|
-
if(typeof ctx =='number'){
|
|
89
|
-
if(typeof columnDef.format ==='money'){
|
|
90
|
-
ctx = ctx.formatMoney();
|
|
91
|
-
} else ctx = ctx.formatNumber();
|
|
92
|
-
}
|
|
93
|
-
return (
|
|
94
|
-
<View {...cellContainerProps} {...args.containerProps} key={rowIndex+columnField} style={[styles.cell,styles.headerItemOrCell,cellContainerProps.style,args.containerProps.style, style]}>
|
|
95
|
-
<Label>{ctx}</Label>
|
|
96
|
-
</View>
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
Object.map(data,(row,index,_index)=>{
|
|
100
|
-
const key = getRowKey(row,index);
|
|
101
|
-
if(!isObj(row) || (typeof key !=='string' && typeof key !=='number')) return;
|
|
102
|
-
const rowIndex = typeof index ==='number'? index : _index;
|
|
103
|
-
let rows = [];
|
|
104
|
-
|
|
105
|
-
Object.map(cols,(columnDef,columnField)=>{
|
|
106
|
-
rows.push(_renderCell({rowData:row,row,rowIndex,allData:data,index,rowKey:key,columns:cols,widths,containerProps:{},columnDef,columnField}));
|
|
107
|
-
});
|
|
108
|
-
const containerProps = typeof rowContainerProps =='function'? defaultObj(rowContainerProps({
|
|
109
|
-
columns : cols,rowIndex,allData:data,rowData : row,row,rowKey:key,index,
|
|
110
|
-
})) : isObj(rowContainerProps)? rowContainerProps : {};
|
|
111
|
-
if((Array.isArray(rows) && rows.length === headers.length)){
|
|
112
|
-
tableRows.push(
|
|
113
|
-
<View {...containerProps} key={key} style={[containerProps.style,styles.row]}>
|
|
114
|
-
{rows}
|
|
115
|
-
</View>
|
|
116
|
-
)
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
nState.tableRows = tableRows;
|
|
120
|
-
}
|
|
121
|
-
return nState;
|
|
122
|
-
},[data,columns])
|
|
123
|
-
React.useEffect(()=>{
|
|
124
|
-
if(data === prevData && columns === prevColumns && prevShowFilters === showFilters) return;
|
|
125
|
-
setState({...state,...prepareState()});
|
|
126
|
-
},[data,columns,showFooter,showFilters])
|
|
127
|
-
const {tableRows,headers,footersCells} = state;
|
|
128
|
-
const hasFootersFields = state.hasFooters && showFooter && footersCells.length ? true : false;
|
|
129
|
-
return (
|
|
130
|
-
<ScrollView
|
|
131
|
-
contentContainerStyle={[contentContainerStyle]}
|
|
132
|
-
horizontal
|
|
133
|
-
bounces={false}
|
|
134
|
-
>
|
|
135
|
-
<View {...containerProps} style={[styles.container,containerProps.style]}>
|
|
136
|
-
<View {...headerContainerProps} style={[headerContainerProps.style,!hasFootersFields ? hStyle:null,styles.header]}>
|
|
137
|
-
{headers}
|
|
138
|
-
</View>
|
|
139
|
-
{hasFootersFields ? <View {...footerContainerProps} style={[footerContainerProps.style,hStyle,styles.header]}>
|
|
140
|
-
{footersCells}
|
|
141
|
-
</View> : null}
|
|
142
|
-
<ScrollView
|
|
143
|
-
vertical
|
|
144
|
-
bounces={false}
|
|
145
|
-
style={styles.dataView}
|
|
146
|
-
contentContainerStyle={styles.dataViewContent} >
|
|
147
|
-
<View>
|
|
148
|
-
{tableRows}
|
|
149
|
-
</View>
|
|
150
|
-
</ScrollView>
|
|
151
|
-
</View>
|
|
152
|
-
</ScrollView>
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
DatatableComponent.propTypes = {
|
|
158
|
-
containerProps : PropTypes.object,
|
|
159
|
-
renderHeaderCell : PropTypes.func,
|
|
160
|
-
hasFooters : PropTypes.bool,
|
|
161
|
-
renderRow : PropTypes.func,
|
|
162
|
-
renderCell : PropTypes.func,
|
|
163
|
-
renderFooterCell : PropTypes.func,///la fonction appelée pour le rendu des entêtes du footer
|
|
164
|
-
footerCellContainerProps : PropTypes.object,
|
|
165
|
-
footerContainerProps : PropTypes.object,
|
|
166
|
-
showFooter : PropTypes.bool,
|
|
167
|
-
cellContainerProps : PropTypes.object,
|
|
168
|
-
headerCellContainerProps : PropTypes.object,//les props du container des entêtes du tableau
|
|
169
|
-
rowContainerProps : PropTypes.oneOfType([
|
|
170
|
-
PropTypes.object,
|
|
171
|
-
PropTypes.func,
|
|
172
|
-
]),///les props du container des lignes
|
|
173
|
-
columns: PropTypes.oneOfType([
|
|
174
|
-
PropTypes.arrayOf(PropTypes.object),
|
|
175
|
-
PropTypes.objectOf(PropTypes.object)
|
|
176
|
-
]).isRequired,
|
|
177
|
-
columnWidth: PropTypes.number,
|
|
178
|
-
data : PropTypes.oneOfType([
|
|
179
|
-
PropTypes.objectOf(PropTypes.object),
|
|
180
|
-
PropTypes.arrayOf(PropTypes.object)
|
|
181
|
-
]),
|
|
182
|
-
height: PropTypes.oneOfType([
|
|
183
|
-
PropTypes.string,
|
|
184
|
-
PropTypes.number,
|
|
185
|
-
]),
|
|
186
|
-
headerContainerProps : PropTypes.object,
|
|
187
|
-
rowContainerProps : PropTypes.oneOfType([
|
|
188
|
-
PropTypes.func,
|
|
189
|
-
PropTypes.object
|
|
190
|
-
]),
|
|
191
|
-
cellContainerProps : PropTypes.oneOfType([
|
|
192
|
-
PropTypes.func,
|
|
193
|
-
PropTypes.object
|
|
194
|
-
]),
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const styles = StyleSheet.create({
|
|
198
|
-
container : {
|
|
199
|
-
paddingRight :2,
|
|
200
|
-
},
|
|
201
|
-
header: {
|
|
202
|
-
flexDirection: 'row',
|
|
203
|
-
paddingVertical : 1,
|
|
204
|
-
alignItems : 'center'
|
|
205
|
-
},
|
|
206
|
-
headerItemOrCell : {
|
|
207
|
-
alignItems: 'flex-start',
|
|
208
|
-
justifyContent: 'center',
|
|
209
|
-
textAlign : 'left',
|
|
210
|
-
//flex: 1,
|
|
211
|
-
flexWrap : 'wrap',
|
|
212
|
-
marginHorizontal : 7,
|
|
213
|
-
},
|
|
214
|
-
headerItem: {
|
|
215
|
-
minHeight: 30,
|
|
216
|
-
},
|
|
217
|
-
dataView: {
|
|
218
|
-
flexGrow: 1,
|
|
219
|
-
},
|
|
220
|
-
dataViewContent: {
|
|
221
|
-
minHeight : '100%',
|
|
222
|
-
paddingBottom : 30,
|
|
223
|
-
},
|
|
224
|
-
row: {
|
|
225
|
-
flexDirection: 'row',
|
|
226
|
-
},
|
|
227
|
-
cell: {
|
|
228
|
-
minHeight: 25,
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
export default DatatableComponent;
|