@fto-consult/expo-ui 6.25.1 → 6.25.3
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/app.config.json +1 -1
- package/package.json +2 -1
- package/src/components/Datagrid/Common/Common.js +156 -130
- package/src/components/Dialog/DialogContent.js +2 -2
- package/src/components/Dropdown/index.js +1 -2
- package/src/components/Label/index.js +12 -4
- package/src/components/List/hooks.js +8 -11
- package/src/components/Table/Header/Cell/index.native.js +2 -1
- package/src/components/Table/Header/CellHeader.js +21 -0
- package/src/components/Table/Header/index.js +23 -8
- package/src/components/Table/Row/Cell/Content.js +2 -2
- package/src/components/Table/Row/Cell/Content.native.js +5 -4
- package/src/components/Table/Row/Cell/index.js +3 -3
- package/src/components/Table/Row/RowWrapper.native.js +10 -2
- package/src/components/Table/Row/index.js +4 -3
- package/src/components/Table/hooks.js +15 -20
- package/src/components/Table/index.js +9 -35
- package/src/components/Table/styles.js +10 -3
- package/src/components/Table/useTable.js +7 -0
- package/src/print/createPDF/index.js +20 -0
- package/src/print/formatText.js +84 -0
- package/src/print/index.js +13 -0
- package/src/print/pdf/formats/defaultFormats.js +28 -0
- package/src/print/pdf/formats/defaultPageFormat.js +1 -0
- package/src/print/pdf/formats/defaultPageOrientation.js +1 -0
- package/src/print/pdf/formats/fields.js +139 -0
- package/src/print/pdf/formats/formats.js +8 -0
- package/src/print/pdf/formats/index.js +10 -0
- package/src/print/pdf/formats/renderItem.js +8 -0
- package/src/print/pdf/index.js +2 -0
- package/src/print/pdf/paperSizes/all.js +1948 -0
- package/src/print/pdf/paperSizes/index.js +4 -0
- package/src/print/pdf/paperSizes/iso.js +493 -0
- package/src/print/qrCode.js +44 -0
- package/src/print/svg/index.js +25 -0
- package/src/print/toPdfMakeObj.js +51 -0
- package/src/print/utils.js +1840 -0
- package/src/screens/Help/openLibraries.js +1 -1
package/app.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fto-consult/expo-ui",
|
|
3
|
-
"version": "6.25.
|
|
3
|
+
"version": "6.25.3",
|
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"fs-extra": "^11.1.1",
|
|
93
93
|
"google-libphonenumber": "^3.2.33",
|
|
94
94
|
"htmlparser2-without-node-native": "^3.9.2",
|
|
95
|
+
"pdfmake": "^0.2.7",
|
|
95
96
|
"process": "^0.11.10",
|
|
96
97
|
"prop-types": "^15.8.1",
|
|
97
98
|
"react": "^18.2.0",
|
|
@@ -961,7 +961,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
961
961
|
this.setState(state);
|
|
962
962
|
});
|
|
963
963
|
};
|
|
964
|
-
const max = isMobileOrTabletMedia()?
|
|
964
|
+
const max = isMobileOrTabletMedia()? 200 : 5000;
|
|
965
965
|
if(this.INITIAL_STATE.data.length > max){
|
|
966
966
|
return this.setIsLoading(true,call,true);
|
|
967
967
|
}
|
|
@@ -1706,6 +1706,15 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1706
1706
|
label : "Exporter les entêtes des groupes",
|
|
1707
1707
|
defaultValue :1,
|
|
1708
1708
|
},
|
|
1709
|
+
fields : {
|
|
1710
|
+
text : "Champs à exporter",
|
|
1711
|
+
items : this.state.columns,
|
|
1712
|
+
type : "select",
|
|
1713
|
+
itemValue : ({item,index})=>index,
|
|
1714
|
+
filter : ({item,index})=> isObj(item) && item.exportable !== false,
|
|
1715
|
+
renderItem : ({item,index})=> item?.label || item?.text || index,
|
|
1716
|
+
multiple : true,
|
|
1717
|
+
},
|
|
1709
1718
|
/*abreviateValues : {
|
|
1710
1719
|
text : "Abréger les valeurs numériques",
|
|
1711
1720
|
type : "switch",
|
|
@@ -1718,147 +1727,164 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1718
1727
|
},
|
|
1719
1728
|
}
|
|
1720
1729
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
const skey = "export-to-excel";
|
|
1730
|
+
SetExportOptions({excel}){
|
|
1731
|
+
const skey = excel ? "export-to-excel":"export-to-other";
|
|
1724
1732
|
const isOnlytotal = this.state.displayOnlySectionListHeaders;
|
|
1725
|
-
|
|
1733
|
+
const displayOnlyHeader = this.canDisplayOnlySectionListHeaders() && isOnlytotal;
|
|
1726
1734
|
const sData = defaultObj(this.getSessionData(skey));
|
|
1727
|
-
return
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1735
|
+
return new Promise((resolve,reject)=>{
|
|
1736
|
+
return DialogProvider.open({
|
|
1737
|
+
title : `Paramètre d'export ${excel?"excel":"pdf"}`,
|
|
1738
|
+
data : sData,
|
|
1739
|
+
fields : {
|
|
1740
|
+
...this.getExportableFields(),
|
|
1741
|
+
sheetName : excel && {
|
|
1742
|
+
label : 'Nom de la feuille excel',
|
|
1743
|
+
format : "hashtag",
|
|
1744
|
+
required : true,
|
|
1745
|
+
},
|
|
1746
|
+
exportOnlyTotal : displayOnlyHeader && {
|
|
1747
|
+
label : "Exporter uniquemnt les totaux",
|
|
1748
|
+
defaultValue : 0,
|
|
1749
|
+
type : "switch",
|
|
1750
|
+
},
|
|
1751
|
+
aggregatedValues : displayOnlyHeader ? {
|
|
1752
|
+
label : "Exporter uniquement les totaux aggrégées",
|
|
1753
|
+
defaultValue : 0,
|
|
1754
|
+
type : "switch",
|
|
1755
|
+
} : null,
|
|
1736
1756
|
},
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1757
|
+
actions : [{text:'Exporter',icon : "check"}],
|
|
1758
|
+
onSuccess: (args)=>{
|
|
1759
|
+
args.sessionKeyName = skey;
|
|
1760
|
+
args.displayOnlyHeader = displayOnlyHeader;
|
|
1761
|
+
args.isOnlytotal = isOnlytotal;
|
|
1762
|
+
args.sessionData = sData;
|
|
1763
|
+
DialogProvider.close();
|
|
1764
|
+
resolve(args);
|
|
1765
|
+
return args;
|
|
1741
1766
|
},
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1767
|
+
onCancel : reject,
|
|
1768
|
+
})
|
|
1769
|
+
})
|
|
1770
|
+
}
|
|
1771
|
+
/***@see : https://docs.sheetjs.com/docs/api/utilities */
|
|
1772
|
+
exportToExcel(){
|
|
1773
|
+
return this.SetExportOptions({excel:true}).then(({sessionKeyName,isOnlytotal,displayOnlyHeader,data:config})=>{
|
|
1774
|
+
this.setSessionData(sessionKeyName,config);
|
|
1775
|
+
config.fileName = sprintf(config.fileName);
|
|
1776
|
+
config.sheetName = sanitizeSheetName(config.sheetName);
|
|
1777
|
+
const data = [];
|
|
1778
|
+
let totalColumns = 0;
|
|
1779
|
+
const cols = {};
|
|
1780
|
+
Preloader.open("préparation des données...");
|
|
1781
|
+
const footers = this.getFooters();
|
|
1782
|
+
const hasFields = !!config.fields.length;
|
|
1783
|
+
const fields = config.fields;
|
|
1784
|
+
if(displayOnlyHeader && config.aggregatedValues){
|
|
1785
|
+
const fValues = this.getFooterValues();
|
|
1786
|
+
const headers = ["Fonction d'agrégation"];
|
|
1787
|
+
const aggregatorFunctions = this.aggregatorFunctions;
|
|
1788
|
+
Object.map(footers,(f,i)=>{
|
|
1789
|
+
if(hasFields && !fields.includes(i)) return;
|
|
1790
|
+
const col = this.state.columns[i];
|
|
1791
|
+
if(!col || col.visible === false) return;
|
|
1792
|
+
headers.push(defaultStr(col.label,col.text));
|
|
1793
|
+
cols[i] = col;
|
|
1794
|
+
});
|
|
1795
|
+
data.push(headers);
|
|
1796
|
+
Object.map(aggregatorFunctions,(ag,i)=>{
|
|
1797
|
+
const d = [defaultStr(ag.label,ag.text,i)];
|
|
1798
|
+
Object.map(fValues,(footer,field)=>{
|
|
1799
|
+
if(!cols[field]) return;
|
|
1800
|
+
d.push(defaultNumber(footer[i]))
|
|
1768
1801
|
});
|
|
1769
|
-
data.push(
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
dd.push(null);
|
|
1817
|
-
}
|
|
1818
|
-
});
|
|
1819
|
-
if(canExportOnlyTotal){
|
|
1820
|
-
dd.unshift(val);
|
|
1821
|
-
data.push(dd);
|
|
1822
|
-
} else {
|
|
1823
|
-
data.push(d);
|
|
1824
|
-
data.push(dd);
|
|
1825
|
-
}
|
|
1802
|
+
data.push(d);
|
|
1803
|
+
})
|
|
1804
|
+
} else {
|
|
1805
|
+
const headers = [];
|
|
1806
|
+
const hFooters = defaultObj(this.sectionListHeaderFooters);
|
|
1807
|
+
const agFunc = this.state.aggregatorFunction;
|
|
1808
|
+
const canExportOnlyTotal = isOnlytotal || (config.exportOnlyTotal && displayOnlyHeader);
|
|
1809
|
+
if(canExportOnlyTotal){
|
|
1810
|
+
headers.push("");
|
|
1811
|
+
}
|
|
1812
|
+
Object.map(this.state.columns,(col,i)=>{
|
|
1813
|
+
if(hasFields && !fields.includes(i)) return;
|
|
1814
|
+
if(!isObj(col) || col.visible === false || this.isSelectableColumn(col,i) || i === this.getIndexColumnName()) return;
|
|
1815
|
+
if(canExportOnlyTotal && !(i in footers)) return;
|
|
1816
|
+
cols[i] = col;
|
|
1817
|
+
headers.push(defaultStr(col.label,col.text));
|
|
1818
|
+
totalColumns++;
|
|
1819
|
+
})
|
|
1820
|
+
data.push(headers);
|
|
1821
|
+
Object.map(this.state.data,(dat,index)=>{
|
|
1822
|
+
///si l'on a a faire à une colonne de type entete
|
|
1823
|
+
const d = [];
|
|
1824
|
+
if(dat.isSectionListHeader){
|
|
1825
|
+
if(!config.displayTotals && !canExportOnlyTotal) return;
|
|
1826
|
+
const {sectionListHeaderKey:key} = dat;
|
|
1827
|
+
const val = key === this.emptySectionListHeaderValue ? this.getEmptySectionListHeaderValue() : key;
|
|
1828
|
+
d.push(val);
|
|
1829
|
+
if(!canExportOnlyTotal){
|
|
1830
|
+
for(let i = 1;i<totalColumns;i++){
|
|
1831
|
+
d.push(null);
|
|
1832
|
+
}
|
|
1833
|
+
data.push(d);
|
|
1834
|
+
} else {
|
|
1835
|
+
const hF = hFooters[key];
|
|
1836
|
+
if(isObj(hF) && isNonNullString(agFunc)){
|
|
1837
|
+
const dd = [];
|
|
1838
|
+
Object.map(cols,(col,i)=>{
|
|
1839
|
+
if(i in hF){
|
|
1840
|
+
const ff = hF[i];
|
|
1841
|
+
dd.push(defaultNumber(ff[agFunc]));
|
|
1842
|
+
} else {
|
|
1843
|
+
dd.push(null);
|
|
1844
|
+
}
|
|
1845
|
+
});
|
|
1846
|
+
if(canExportOnlyTotal){
|
|
1847
|
+
dd.unshift(val);
|
|
1848
|
+
data.push(dd);
|
|
1826
1849
|
} else {
|
|
1827
1850
|
data.push(d);
|
|
1851
|
+
data.push(dd);
|
|
1828
1852
|
}
|
|
1853
|
+
} else {
|
|
1854
|
+
data.push(d);
|
|
1829
1855
|
}
|
|
1830
|
-
} else if(!canExportOnlyTotal) {
|
|
1831
|
-
Object.map(cols,(col,i)=>{
|
|
1832
|
-
const isDateField = defaultStr(col.type).toLowerCase().contains("date");
|
|
1833
|
-
d.push(this.renderRowCell({
|
|
1834
|
-
data : dat,
|
|
1835
|
-
rowData : dat,
|
|
1836
|
-
rowCounterIndex : index,
|
|
1837
|
-
rowIndex : index,
|
|
1838
|
-
formatValue : false,
|
|
1839
|
-
renderRowCell : false,
|
|
1840
|
-
columnField : defaultStr(col.field,i),
|
|
1841
|
-
columnDef :{
|
|
1842
|
-
...col,
|
|
1843
|
-
...(isDateField?{format:config.dateFormat}:{})
|
|
1844
|
-
}
|
|
1845
|
-
}));
|
|
1846
|
-
})
|
|
1847
|
-
data.push(d);
|
|
1848
1856
|
}
|
|
1849
|
-
})
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
+
} else if(!canExportOnlyTotal) {
|
|
1858
|
+
Object.map(cols,(col,i)=>{
|
|
1859
|
+
const isDateField = defaultStr(col.type).toLowerCase().contains("date");
|
|
1860
|
+
d.push(this.renderRowCell({
|
|
1861
|
+
data : dat,
|
|
1862
|
+
rowData : dat,
|
|
1863
|
+
rowCounterIndex : index,
|
|
1864
|
+
rowIndex : index,
|
|
1865
|
+
formatValue : false,
|
|
1866
|
+
renderRowCell : false,
|
|
1867
|
+
columnField : defaultStr(col.field,i),
|
|
1868
|
+
columnDef :{
|
|
1869
|
+
...col,
|
|
1870
|
+
...(isDateField?{format:config.dateFormat}:{})
|
|
1871
|
+
}
|
|
1872
|
+
}));
|
|
1873
|
+
})
|
|
1874
|
+
data.push(d);
|
|
1857
1875
|
}
|
|
1858
|
-
|
|
1859
|
-
Preloader.close();
|
|
1860
|
-
})
|
|
1876
|
+
});
|
|
1861
1877
|
}
|
|
1878
|
+
const wb = XLSX.utils.book_new();
|
|
1879
|
+
const ws = XLSX.utils.aoa_to_sheet(data);
|
|
1880
|
+
XLSX.utils.book_append_sheet(wb, ws, config.sheetName);
|
|
1881
|
+
FileSystem.writeExcel({...config,workbook:wb}).then(({path})=>{
|
|
1882
|
+
if(isNonNullString(path)){
|
|
1883
|
+
notify.success("Fichier enregistré dans le répertoire {0}".sprintf(path))
|
|
1884
|
+
}
|
|
1885
|
+
}).finally(()=>{
|
|
1886
|
+
Preloader.close();
|
|
1887
|
+
})
|
|
1862
1888
|
})
|
|
1863
1889
|
}
|
|
1864
1890
|
exportToPdf(){
|
|
@@ -2,10 +2,10 @@ import KeyboardAvoidingView from "../KeyboardAvoidingView";
|
|
|
2
2
|
import React from "$react";
|
|
3
3
|
import { useWindowDimensions } from "react-native";
|
|
4
4
|
|
|
5
|
-
const DialogContentComponent = ({isPreloader,isFullScreen,...props})=>{
|
|
5
|
+
const DialogContentComponent = ({isPreloader,title,children,isFullScreen,...props})=>{
|
|
6
6
|
const isFull = isFullScreen();
|
|
7
7
|
//useWindowDimensions();
|
|
8
|
-
const content = React.useMemo(()=>
|
|
8
|
+
const content = React.useMemo(()=>children,[isPreloader,title,children]);
|
|
9
9
|
return isPreloader || !isFull ? content : <KeyboardAvoidingView>{content}</KeyboardAvoidingView>
|
|
10
10
|
}
|
|
11
11
|
export default DialogContentComponent;
|
|
@@ -967,7 +967,6 @@ class DropdownComponent extends AppComponent {
|
|
|
967
967
|
const renderingItems = this.getItems();
|
|
968
968
|
const isDisabled = readOnly || disabled?true:false;
|
|
969
969
|
const isBigList = this.isBigList;
|
|
970
|
-
const ListComponent = isBigList ? BigList : List;
|
|
971
970
|
const autoFocus = canAutoFocusSearchField({visible,items:renderingItems});
|
|
972
971
|
dialogProps = defaultObj(dialogProps);
|
|
973
972
|
if(this.props.name =="RG_Compta"){
|
|
@@ -1063,7 +1062,7 @@ class DropdownComponent extends AppComponent {
|
|
|
1063
1062
|
{isMob && helperText ? <View testID = {testID+"_HelperText"} style={[styles.helperText]}>
|
|
1064
1063
|
{helperText}
|
|
1065
1064
|
</View>: null}
|
|
1066
|
-
<
|
|
1065
|
+
<BigList
|
|
1067
1066
|
testID = {testID+"_List"}
|
|
1068
1067
|
{...listProps}
|
|
1069
1068
|
ref = {this.listRef}
|
|
@@ -10,7 +10,7 @@ const defaultSelectable = canTextBeSelectable();
|
|
|
10
10
|
|
|
11
11
|
export const EllipsizeMode = {'head':'head','middle':'middle', 'tail':'tail' , 'clip':'clip'}
|
|
12
12
|
|
|
13
|
-
const LabelComponent = React.forwardRef(({ children,role,color,upperCase,fontSize,testID,wrap,id,wrapText,error,underlined,splitText,secondary,primary,bold,textBold,disabled,text,style,...rest},ref)=> {
|
|
13
|
+
const LabelComponent = React.forwardRef(({ children,selectable,role,color,upperCase,fontSize,testID,wrap,id,wrapText,error,underlined,splitText,secondary,primary,bold,textBold,disabled,text,style,...rest},ref)=> {
|
|
14
14
|
children = defaultVal(children,text);
|
|
15
15
|
let isText = false;
|
|
16
16
|
if(!React.isValidElement(children) && Array.isArray(children) && children.length){
|
|
@@ -58,6 +58,8 @@ const LabelComponent = React.forwardRef(({ children,role,color,upperCase,fontSiz
|
|
|
58
58
|
if(disabled){
|
|
59
59
|
r1.pointerEvents = "none";
|
|
60
60
|
}
|
|
61
|
+
selectable = !!(selectable || defaultSelectable);
|
|
62
|
+
r2.userSelect = selectable?"none":"all";
|
|
61
63
|
if(isNonNullString(children) || isText || typeof children ==='number'){
|
|
62
64
|
if(!isText){
|
|
63
65
|
children +="";
|
|
@@ -68,7 +70,10 @@ const LabelComponent = React.forwardRef(({ children,role,color,upperCase,fontSiz
|
|
|
68
70
|
if(fontSize){
|
|
69
71
|
r1.fontSize = fontSize;
|
|
70
72
|
}
|
|
71
|
-
|
|
73
|
+
if(selectable){
|
|
74
|
+
r2.userSelect = "text";
|
|
75
|
+
}
|
|
76
|
+
return (<Text allowFontScaling = {true} ref = {ref}
|
|
72
77
|
{...rest} {...restProps} testID={testID} disabled={disabled}
|
|
73
78
|
role={typeof role =='string' && role && supportedRoles.includes(role.trim()) && role.trim() || undefined}
|
|
74
79
|
style={[styles.label,splitText?styles.wrap:null,splitText?styles.w100:null,bold?styles.bold:null,r2,style,r1,styles.webFontFamilly]}>{children}</Text>)
|
|
@@ -92,7 +97,7 @@ const LabelComponent = React.forwardRef(({ children,role,color,upperCase,fontSiz
|
|
|
92
97
|
}
|
|
93
98
|
return children;
|
|
94
99
|
}
|
|
95
|
-
return <View ref = {ref}
|
|
100
|
+
return <View ref = {ref} {...rest} {...restProps} testID = {testID} style={viewStyle} disabled={disabled}>{children}</View>
|
|
96
101
|
}
|
|
97
102
|
return null;
|
|
98
103
|
})
|
|
@@ -114,7 +119,10 @@ LabelComponentExported.propTypes = {
|
|
|
114
119
|
color : PropTypes.string,
|
|
115
120
|
selectable : PropTypes.bool, //si le texte est sélectionnable
|
|
116
121
|
underlined : PropTypes.bool,//si le style underlined sera appliqué au label
|
|
117
|
-
splitText : PropTypes.bool,///si le texte lorsqu'il est long sera
|
|
122
|
+
splitText : PropTypes.bool,///si le texte lorsqu'il est long sera splité,
|
|
123
|
+
/*useSelect : PropTypes.oneOfType([
|
|
124
|
+
'auto', 'text', 'none', 'contain', 'all'
|
|
125
|
+
])*/
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
export default LabelComponentExported;
|
|
@@ -10,17 +10,14 @@ export const useList = ({items,filter,prepareItems,...props})=>{
|
|
|
10
10
|
const context = contextRef.current;
|
|
11
11
|
context.itemsRefs = Array.isArray(context.itemsRefs) && context.itemsRefs || [];
|
|
12
12
|
context.prepareItems = defaultFunc((prepareItems === false ? (items)=> items:null),prepareItems,customPrepareItems);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const canPrepareItems = prepareItems === false ? false : true;
|
|
14
|
+
context.items = contextRef.items = React.useMemo(()=>{
|
|
15
|
+
const r = context.prepareItems(items,filter);
|
|
16
|
+
if(!Array.isArray(r)){
|
|
17
|
+
console.error(r," is not valid list data array",items,props);
|
|
18
|
+
return [];
|
|
17
19
|
}
|
|
18
|
-
return
|
|
19
|
-
},[items]);
|
|
20
|
-
context.items = contextRef.items = prepareItems === false ? items : getItems();
|
|
21
|
-
if(!Array.isArray(context.items)){
|
|
22
|
-
console.error(context.items," is not valid list data array",items,props);
|
|
23
|
-
context.items = [];
|
|
24
|
-
}
|
|
20
|
+
return r;
|
|
21
|
+
},[items,canPrepareItems]);
|
|
25
22
|
return context;
|
|
26
23
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import View from "$ecomponents/View";
|
|
2
2
|
import React from "$react";
|
|
3
|
+
import styles from "../../styles";
|
|
3
4
|
const TableHeaderCellComponent = React.forwardRef(({width,style,...props},ref)=>{
|
|
4
|
-
return <View ref={ref} {...props} style={[style,width && {width}]}/>
|
|
5
|
+
return <View ref={ref} {...props} style={[styles.cell,style,width && {width}]}/>
|
|
5
6
|
});
|
|
6
7
|
TableHeaderCellComponent.displayName = "TableTableHeaderCellComponent";
|
|
7
8
|
export default TableHeaderCellComponent;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -8,19 +8,27 @@ import { View } from "react-native";
|
|
|
8
8
|
import PropTypes from "prop-types";
|
|
9
9
|
import { StyleSheet } from "react-native";
|
|
10
10
|
import {isMobileNative} from "$cplatform";
|
|
11
|
-
import {classNames} from "$cutils";
|
|
11
|
+
import {classNames,defaultObj} from "$cutils";
|
|
12
12
|
const isNative = isMobileNative();
|
|
13
13
|
const Component = isNative ? View : "tr";
|
|
14
|
-
import
|
|
14
|
+
import { useTable } from "../hooks";
|
|
15
|
+
import styles from "../styles";
|
|
16
|
+
import CellHeader from "./CellHeader";
|
|
15
17
|
|
|
16
|
-
export default function RowHeaderComponent({
|
|
18
|
+
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();
|
|
20
|
+
const canV = showHeaders === false ? false : Array.isArray(children)? !!children.length : true;
|
|
21
|
+
const visible = canV && (isHeader ? true : isFilter ? !!showFilters : isFooter ? !!showFooters: true);
|
|
22
|
+
const containerProps = defaultObj( isHeader ? headerContainerProps : isFooter ? footerContainerProps : filtersContainerProps);
|
|
23
|
+
const style = filters ? styles.filters : isFooter ? styles.footer : null;
|
|
17
24
|
const children = React.useMemo(()=>{
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
const contents = isFilter ? filters : isFooter ? footers : headers;
|
|
26
|
+
return visibleColsNames.map((columnField,cIndex)=>{
|
|
27
|
+
return contents[columnField] || null;
|
|
28
|
+
});
|
|
29
|
+
},[visibleColsNamesStr]);
|
|
20
30
|
const rP = isNative ? rest : {className:classNames(className,"table-footer-or-header-row")}
|
|
21
|
-
|
|
22
|
-
//const backgroundColor = theme.isDark()? theme.Colors.lighten(theme.surfaceBackgroundColor):theme.Colors.darken(theme.surfaceBackgroundColor);
|
|
23
|
-
return <Component {...rP} style={StyleSheet.flatten([rest.style,!visible && {height:0,opacity:0,display:'none'}])}>
|
|
31
|
+
return <Component {...rP} {...containerProps} style={StyleSheet.flatten([styles.header,style,rest.style,containerProps.style,!visible && hStyle.hidden])}>
|
|
24
32
|
{children}
|
|
25
33
|
</Component>
|
|
26
34
|
}
|
|
@@ -32,3 +40,10 @@ RowHeaderComponent.propTypes = {
|
|
|
32
40
|
export {Cell};
|
|
33
41
|
|
|
34
42
|
RowHeaderComponent.Cell = Cell;
|
|
43
|
+
RowHeaderComponent.CellHeader = CellHeader;
|
|
44
|
+
|
|
45
|
+
export {CellHeader};
|
|
46
|
+
|
|
47
|
+
const hStyle = StyleSheet.create({
|
|
48
|
+
hidden : {height:0,opacity:0,display:'none'}
|
|
49
|
+
});
|
|
@@ -6,8 +6,8 @@ import {classNames} from "$cutils";
|
|
|
6
6
|
import { StyleSheet } from "react-native";
|
|
7
7
|
import Label from "$ecomponents/Label";
|
|
8
8
|
|
|
9
|
-
function TableCellContentComponent({children,style,...rest}){
|
|
10
|
-
return (<td {
|
|
9
|
+
function TableCellContentComponent({children,columnDef,testID,columnField,style,...rest}){
|
|
10
|
+
return (<td data-test-id={testID||"RN_TableCellComoponent"} className={classNames(rest.className,"table-row-cell")} style={StyleSheet.flatten([style])}>
|
|
11
11
|
{children}
|
|
12
12
|
</td>);
|
|
13
13
|
}
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
// license that can be found in the LICENSE file.
|
|
4
4
|
import React from "react";
|
|
5
5
|
import View from "$ecomponents/View";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import {useTable} from "../../hooks";
|
|
7
|
+
function TableCellContentComponent({children,columnField,style,colSpan,...rest}){
|
|
8
|
+
const {colsWidths} = useTable();
|
|
9
|
+
const width = columnField ? colsWidths[columnField] : 0;
|
|
10
|
+
return (<View testID={"RN_TableRowCellContentComponent"} {...rest} style={[style,width && {width}]}>
|
|
10
11
|
{children}
|
|
11
12
|
</View>);
|
|
12
13
|
}
|
|
@@ -4,7 +4,7 @@ import { useTable } from "../../hooks";
|
|
|
4
4
|
import {defaultObj} from "$cutils";
|
|
5
5
|
import Label from "$ecomponents/Label";
|
|
6
6
|
import styles from "../../styles";
|
|
7
|
-
const TableRowCellComponent = React.forwardRef(({children,columnDef,rowData,colSpan,isSectionListHeader,rowIndex,style,...rest},ref)=>{
|
|
7
|
+
const TableRowCellComponent = React.forwardRef(({children,columnDef,columnField,rowData,colSpan,isSectionListHeader,rowIndex,style,...rest},ref)=>{
|
|
8
8
|
if(isSectionListHeader){
|
|
9
9
|
return <CellContent colSpan={colSpan} ref={ref} style={[styles.sectionListHeader,style]} >
|
|
10
10
|
{children}
|
|
@@ -12,14 +12,14 @@ const TableRowCellComponent = React.forwardRef(({children,columnDef,rowData,colS
|
|
|
12
12
|
}
|
|
13
13
|
const {renderCell} = useTable();
|
|
14
14
|
const {content,containerProps} = React.useMemo(()=>{
|
|
15
|
-
const rArgs = {...rest,columnDef,rowData,rowIndex,containerProps : {}};
|
|
15
|
+
const rArgs = {...rest,columnDef,columnField,rowData,rowIndex,containerProps : {}};
|
|
16
16
|
const r = typeof renderCell =='function' && renderCell (rArgs) || children;
|
|
17
17
|
return {
|
|
18
18
|
content : r && React.isValidElement(r,true)? r : children,
|
|
19
19
|
containerProps : defaultObj(rArgs.containerProps)
|
|
20
20
|
}
|
|
21
21
|
},[children]);
|
|
22
|
-
return (<CellContent ref={ref} {...containerProps} style={[style,containerProps.style]} >
|
|
22
|
+
return (<CellContent ref={ref} {...containerProps} columnField={columnField} style={[style,containerProps.style]} >
|
|
23
23
|
{columnDef.isSelectableColumnName ? content : <Label testID="RN_TableRowCell" style={[styles.cell]}>{content}</Label>}
|
|
24
24
|
</CellContent>);
|
|
25
25
|
});
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { forwardRef } from "react";
|
|
1
|
+
import { forwardRef,useMemo } from "react";
|
|
2
2
|
import View from "$ecomponents/View";
|
|
3
3
|
import styles from "../styles";
|
|
4
|
+
import { useTable } from "../hooks";
|
|
5
|
+
import {useIsRowSelected} from "$ecomponents/Datagrid/hooks";
|
|
6
|
+
import { getRowStyle } from "$ecomponents/Datagrid/utils";
|
|
4
7
|
|
|
5
8
|
const TableRowWrapperComponent = forwardRef(({children,colSpan,...props},ref)=>{
|
|
6
|
-
|
|
9
|
+
const {bordered,withDatagridContext} = useTable();
|
|
10
|
+
const selected = withDatagridContext ? useIsRowSelected(props) : false;
|
|
11
|
+
const rowStyle = useMemo(()=>{
|
|
12
|
+
return getRowStyle({...props,bordered});
|
|
13
|
+
},[selected])
|
|
14
|
+
return <View ref={ref} {...props} style={[styles.row,rowStyle,props.style]} children={children}/>
|
|
7
15
|
});
|
|
8
16
|
|
|
9
17
|
TableRowWrapperComponent.displayName = "TableRowWrapperComponent";
|
|
@@ -11,7 +11,8 @@ import RowWrapper from "./RowWrapper";
|
|
|
11
11
|
import React from "$react";
|
|
12
12
|
import theme from "$theme";
|
|
13
13
|
export default function TableRowComponent({cells,rowKey,rowData,index,...rest}){
|
|
14
|
-
const {visibleColsNames,
|
|
14
|
+
const {visibleColsNames,visibleColsNamesStr,renderSectionHeader,columns} = useTable();
|
|
15
|
+
if(!isObj(rowData)) return null;
|
|
15
16
|
const content = React.useMemo(()=>{
|
|
16
17
|
if(rowData.isSectionListHeader && typeof renderSectionHeader ==='function'){
|
|
17
18
|
return <RowWrapper style={[styles.row,theme.styles.pv1]}>
|
|
@@ -23,8 +24,8 @@ export default function TableRowComponent({cells,rowKey,rowData,index,...rest}){
|
|
|
23
24
|
if(!isObj(columnDef)) return null;
|
|
24
25
|
return <Cell rowData={rowData} rowKey={rowKey} children={rowData[columnField]} rowIndex={index} columnDef={columnDef} index={cIndex} key={columnField} columnField={columnField}/>
|
|
25
26
|
});
|
|
26
|
-
},[rowKey,index,
|
|
27
|
-
return <RowWrapper style={[styles.row]}>
|
|
27
|
+
},[rowKey,index,visibleColsNamesStr]);
|
|
28
|
+
return <RowWrapper {...rest} rowKey={rowKey} rowData={rowData} rowIndex={index} style={[styles.row]}>
|
|
28
29
|
{content}
|
|
29
30
|
</RowWrapper>;
|
|
30
31
|
}
|