@fto-consult/expo-ui 2.31.4 → 2.31.5
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": "2.31.
|
|
3
|
+
"version": "2.31.5",
|
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@emotion/native": "^11.10.0",
|
|
62
62
|
"@expo/html-elements": "^0.2.0",
|
|
63
63
|
"@expo/vector-icons": "^13.0.0",
|
|
64
|
-
"@fto-consult/common": "^1.25.
|
|
64
|
+
"@fto-consult/common": "^1.25.24",
|
|
65
65
|
"@gorhom/portal": "^1.0.14",
|
|
66
66
|
"@react-native-async-storage/async-storage": "~1.17.3",
|
|
67
67
|
"@react-native-community/datetimepicker": "6.5.2",
|
|
@@ -40,7 +40,7 @@ import {styles as tableStyles} from "$ecomponents/Table";
|
|
|
40
40
|
import {DialogProvider} from "$ecomponents/Form/FormData";
|
|
41
41
|
import Chart,{getMaxSupportedSeriesSize} from "$ecomponents/Chart";
|
|
42
42
|
import notify from "$cnotify";
|
|
43
|
-
import
|
|
43
|
+
import FileSystem from "$file-system";
|
|
44
44
|
|
|
45
45
|
export const donutChart = {
|
|
46
46
|
isChart : true,
|
|
@@ -244,6 +244,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
244
244
|
displayTypes : {value : hasFoundDisplayTypes ? disTypes : Object.clone(displayTypes)},
|
|
245
245
|
dateFields : {value : {}},
|
|
246
246
|
sectionListColumnsSize : {value : {current:0}}, //la taille du nombre d'éléments de section dans les colonnes
|
|
247
|
+
chartRef : {value : {current:null}},
|
|
247
248
|
})
|
|
248
249
|
const sessionAggregator = defaultStr(this.getSessionData("aggregatorFunction")).trim();
|
|
249
250
|
const aggregatorProps = defaultStr(this.props.aggregatorFunction).trim();
|
|
@@ -1485,6 +1486,28 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1485
1486
|
isDashboard(){
|
|
1486
1487
|
return false;
|
|
1487
1488
|
}
|
|
1489
|
+
/*** télécharge le chart actif */
|
|
1490
|
+
downloadChart(){
|
|
1491
|
+
if(!this.chartRef.current || !this.chartRef.current.dataURI) return Promise.reject({message:'Référence du graphique non valide'});
|
|
1492
|
+
return this.chartRef.current.dataURI().then(({ imgURI, blob })=>{
|
|
1493
|
+
FileSystem.write({content:imgURI,fileName:"graphe.png",contentType:"image/png"})
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
///reoturne les options de menus à appliquer sur le char
|
|
1497
|
+
getChartMenus(){
|
|
1498
|
+
return [
|
|
1499
|
+
{
|
|
1500
|
+
text : "Options du graphe",
|
|
1501
|
+
textBold : true,
|
|
1502
|
+
divider:true,
|
|
1503
|
+
},
|
|
1504
|
+
{
|
|
1505
|
+
text :"Télécharger",
|
|
1506
|
+
icon : "download",
|
|
1507
|
+
onPress : this.downloadChart.bind(this),
|
|
1508
|
+
}
|
|
1509
|
+
]
|
|
1510
|
+
}
|
|
1488
1511
|
renderDisplayTypes(){
|
|
1489
1512
|
const m = [];
|
|
1490
1513
|
let activeType = null,hasFoundChart = false,hasFoundTable = false;
|
|
@@ -1539,6 +1562,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1539
1562
|
if(!isMobileOrTabletMedia()){
|
|
1540
1563
|
m.unshift({text:"Type d'affichage des données",divider:true,textBold:true});
|
|
1541
1564
|
}
|
|
1565
|
+
if(hasFoundChart){
|
|
1566
|
+
Object.map(this.getChartMenus(),(c,i)=>{
|
|
1567
|
+
m.push(c);
|
|
1568
|
+
})
|
|
1569
|
+
}
|
|
1542
1570
|
return <Menu
|
|
1543
1571
|
title = "Type d'affichage"
|
|
1544
1572
|
items = {m}
|
|
@@ -1782,9 +1810,11 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1782
1810
|
},
|
|
1783
1811
|
},chartProps.title),
|
|
1784
1812
|
series,
|
|
1785
|
-
chart : extendObj(true,{},
|
|
1786
|
-
|
|
1787
|
-
|
|
1813
|
+
chart : extendObj(true,{},
|
|
1814
|
+
{toolbar : {show : false}},
|
|
1815
|
+
{height :this.isDashboard()?80:350},chartProps.chart,
|
|
1816
|
+
{type : chartType.type}
|
|
1817
|
+
)
|
|
1788
1818
|
}
|
|
1789
1819
|
const labelColor = theme.Colors.isValid(config.labelColor)? config.labelColor : theme.colors.text;
|
|
1790
1820
|
if(!isDonut){
|
|
@@ -1827,6 +1857,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1827
1857
|
}
|
|
1828
1858
|
return <Chart
|
|
1829
1859
|
options = {chartOptions}
|
|
1860
|
+
ref = {this.chartRef}
|
|
1830
1861
|
key = {chartOptions.chart.id+"-"+this.state.displayType}
|
|
1831
1862
|
/>
|
|
1832
1863
|
}
|
|
@@ -2101,7 +2132,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
2101
2132
|
mItem.right = (p)=>{
|
|
2102
2133
|
return <Icon name="material-settings" {...p} onPress={(e)=>{
|
|
2103
2134
|
//React.stopEventPropagation(e);
|
|
2104
|
-
this.configureSectionListColumn(mItem);
|
|
2135
|
+
this.configureSectionListColumn({...mItem,...defaultObj(sectionListColumns[field])});
|
|
2105
2136
|
//return false;
|
|
2106
2137
|
}}/>
|
|
2107
2138
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
|
|
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
|
-
import {defaultStr,base64toBlob,isNonNullString,getFileName,getFileExtension,defaultNumber,defaultBool,dataURLToBase64,isBlob,isBase64,isDataURL} from "$utils";
|
|
4
|
+
import {defaultStr,base64toBlob,dataURLToBlob,getTypeFromDataURL,isNonNullString,getFileName,getFileExtension,defaultNumber,defaultBool,dataURLToBase64,isBlob,isBase64,isDataURL} from "$utils";
|
|
5
5
|
const FileSaver = require('file-saver');
|
|
6
6
|
const mime = require('mime-types')
|
|
7
7
|
const XLSX = require("xlsx");
|
|
@@ -29,6 +29,13 @@ import Preloader from "$preloader";
|
|
|
29
29
|
reject({status:false,msg:'Nom de fichier invalide'});
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
+
if(isDataURL(content)){
|
|
33
|
+
const type = getTypeFromDataURL(content);
|
|
34
|
+
content = dataURLToBlob(content);
|
|
35
|
+
if(isNonNullString(type)){
|
|
36
|
+
contentType = type;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
32
39
|
content = isBlob(content)? content : new Blob([content], { type: content?.type||contentType})
|
|
33
40
|
try {
|
|
34
41
|
FileSaver.saveAs(content, fileName);
|
|
@@ -55,10 +62,6 @@ function s2ab(s) {
|
|
|
55
62
|
* .xls : application/vnd.ms-excel
|
|
56
63
|
*/
|
|
57
64
|
export const writeExcel = ({workbook,content,contentType,fileName,...rest})=>{
|
|
58
|
-
if(!isNonNullString(contentType) || !contentType.contains("application/vnd.")){
|
|
59
|
-
//contentType = "application/vnd.ms-excel";
|
|
60
|
-
contentType : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
61
|
-
}
|
|
62
65
|
let ext = defaultStr(getFileExtension(fileName,true),"xlsx");
|
|
63
66
|
fileName = sanitizeFileName(getFileName(fileName,true))+"."+ext;
|
|
64
67
|
if(!isNonNullString(fileName)){
|
|
@@ -70,11 +73,31 @@ export const writeExcel = ({workbook,content,contentType,fileName,...rest})=>{
|
|
|
70
73
|
if(isBlob(content)){
|
|
71
74
|
return write({...rest,content,fileName,contentType})
|
|
72
75
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
return new Promise((resolve,reject)=>{
|
|
77
|
+
Preloader.open("génération du fichier excel "+fileName);
|
|
78
|
+
try {
|
|
79
|
+
XLSX.writeFile(workbook, fileName);
|
|
80
|
+
setTimeout(()=>{
|
|
81
|
+
Preloader.close();
|
|
82
|
+
resolve({fileName});
|
|
83
|
+
},1000);
|
|
84
|
+
} catch(e){
|
|
85
|
+
reject(e);
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/***
|
|
91
|
+
* @see https://ourtechroom.com/tech/mime-type-for-excel/ for excel mimesTypes
|
|
92
|
+
* .xls : application/vnd.ms-excel
|
|
93
|
+
*/
|
|
94
|
+
export const writeImage = ({content,fileName,...rest})=>{
|
|
95
|
+
let ext = defaultStr(getFileExtension(fileName,true),"png");
|
|
96
|
+
fileName = sanitizeFileName(getFileName(fileName,true))+"."+ext;
|
|
97
|
+
if(!isNonNullString(fileName)){
|
|
98
|
+
return Promise.reject({status:false,message:'Nom de fichier invalide pour le contenu excel à créer'});
|
|
99
|
+
}
|
|
100
|
+
|
|
78
101
|
}
|
|
79
102
|
|
|
80
103
|
|