@fto-consult/expo-ui 7.8.11 → 7.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/components/Datagrid/Common/Common.js +2 -11
- package/src/layouts/Screen/ScreenWithoutAuthContainer.js +8 -5
- package/src/media/file-system/utils/FileSaver.electron.js +7 -0
- package/src/media/file-system/utils/FileSaver.js +6 -16
- package/src/media/file-system/utils/FileSaver.native.js +1 -1
- package/src/media/file-system/utils/Fsaver.web.js +18 -0
- package/src/media/file-system/utils/utils.js +8 -8
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fto-consult/expo-ui",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.10.0",
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
5
|
"scripts": {
|
6
6
|
"clear-npx-cache": "npx clear-npx-cache",
|
@@ -72,7 +72,7 @@
|
|
72
72
|
"@expo/vector-icons": "^13.0.0",
|
73
73
|
"@faker-js/faker": "^8.0.2",
|
74
74
|
"@fto-consult/common": "^3.75.2",
|
75
|
-
"@fto-consult/electron-gen": "^
|
75
|
+
"@fto-consult/electron-gen": "^2.0.0",
|
76
76
|
"@pchmn/expo-material3-theme": "^1.3.1",
|
77
77
|
"@react-native-async-storage/async-storage": "1.18.2",
|
78
78
|
"@react-native-community/datetimepicker": "7.2.0",
|
@@ -45,7 +45,7 @@ import {MORE_ICON} from "$ecomponents/Icon"
|
|
45
45
|
import ActivityIndicator from "$ecomponents/ActivityIndicator";
|
46
46
|
import {createTableHeader,fields as pdfFields,pageHeaderMargin,sprintf as pdfSprintf} from "$cpdf";
|
47
47
|
import {isWeb,isMobileNative} from "$cplatform";
|
48
|
-
import { createPDF,getFields as getPdfFields } from '
|
48
|
+
import { createPDF,getFields as getPdfFields } from '$expo-ui/pdf';
|
49
49
|
|
50
50
|
export const TIMEOUT = 100;
|
51
51
|
|
@@ -1835,16 +1835,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
1835
1835
|
if(pdfDocumentTitle){
|
1836
1836
|
content.unshift(pdfDocumentTitle);
|
1837
1837
|
}
|
1838
|
-
|
1839
|
-
if(isWeb()){
|
1840
|
-
return pdf.open();
|
1841
|
-
}
|
1842
|
-
return;
|
1843
|
-
FileSystem.writeExcel({...config,workbook:wb}).then(({path})=>{
|
1844
|
-
if(isNonNullString(path)){
|
1845
|
-
notify.success("Fichier enregistré dans le répertoire {0}".sprintf(path))
|
1846
|
-
}
|
1847
|
-
})
|
1838
|
+
return createPDF({...config,content});
|
1848
1839
|
}).finally(Preloader.close);
|
1849
1840
|
}
|
1850
1841
|
handleTableExport(args){
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from '$react';
|
2
2
|
import {StyleSheet} from 'react-native';
|
3
3
|
import PropTypes from "prop-types";
|
4
|
-
import {defaultObj,defaultStr,defaultNumber,
|
4
|
+
import {defaultObj,defaultStr,defaultNumber,isValidUrl,uniqid} from "$cutils";
|
5
5
|
import View from "$ecomponents/View";
|
6
6
|
import { useNavigation} from '$cnavigation';
|
7
7
|
import Fab from "$elayouts/Fab";
|
@@ -75,7 +75,7 @@ export default function MainScreenScreenWithoutAuthContainer(props) {
|
|
75
75
|
|
76
76
|
|
77
77
|
React.useEffect(() => {
|
78
|
-
if(
|
78
|
+
if(navigation && typeof navigation?.setOptions ==="function"){
|
79
79
|
const appName = APP.getName().toUpperCase();
|
80
80
|
subtitle = React.getTextContent(subtitle);
|
81
81
|
let screenTitle = getDefaultTitle(title,true);
|
@@ -85,15 +85,18 @@ export default function MainScreenScreenWithoutAuthContainer(props) {
|
|
85
85
|
if(!screenTitle.toUpperCase().contains(appName)){
|
86
86
|
screenTitle+=" | "+appName;
|
87
87
|
}
|
88
|
+
if(isElectron() && typeof window?.ELECTRON !== "undefined" && typeof ELECTRON?.getLoadedAppUrl =='function'){
|
89
|
+
const loadedUrl = ELECTRON.getLoadedAppUrl();
|
90
|
+
if(isValidUrl(loadedUrl) && !screenTitle.includes(loadedUrl)){
|
91
|
+
screenTitle = `${screenTitle} [${loadedUrl}]`;
|
92
|
+
}
|
93
|
+
}
|
88
94
|
navigation.setOptions({
|
89
95
|
...options,
|
90
96
|
appBarProps:{...options.appBarProps,...appBarProps,title,subtitle},
|
91
97
|
subtitle :subtitle,
|
92
98
|
title : screenTitle,
|
93
99
|
});
|
94
|
-
if(isElectron() && typeof window?.ELECTRON !== "undefined" && typeof ELECTRON?.setTitle =='function'){
|
95
|
-
ELECTRON.setTitle(screenTitle);
|
96
|
-
}
|
97
100
|
}
|
98
101
|
}, [title,subtitle]);
|
99
102
|
const fab = withFab ? <Fab
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import {save as saveWeb} from "./Fsaver.web";
|
2
|
+
import {isElectron} from "$cplatform";
|
3
|
+
|
4
|
+
export const save = (options,...rest)=>{
|
5
|
+
if(!isElectron() || typeof window?.ELECTRON =="undefined" || typeof window?.ELECTRON?.FILE !=="object" || typeof window?.ELECTRON?.FILE?.write !=="function") return saveWeb(options,...rest);
|
6
|
+
return ELECTRON.FILE.write(options,...rest);
|
7
|
+
}
|
@@ -1,18 +1,8 @@
|
|
1
|
-
|
2
|
-
import {
|
1
|
+
import {save as saveWeb} from "./Fsaver.web";
|
2
|
+
import {save as saveEelectron} from "./FileSaver.electron";
|
3
|
+
import {isElectron} from "$cplatform";
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
export const save = ({content,fileName,timeout,delay})=>{
|
8
|
-
return new Promise((resolve,reject)=>{
|
9
|
-
try {
|
10
|
-
FileSaver.saveAs(content, fileName);
|
11
|
-
setTimeout(() => {
|
12
|
-
resolve({path:fileName,isWeb : true});
|
13
|
-
}, defaultNumber(timeout,delay,3000));
|
14
|
-
} catch(e){
|
15
|
-
reject(e);
|
16
|
-
}
|
17
|
-
})
|
5
|
+
export const save = (options,...rest)=> {
|
6
|
+
if(isElectron()) return saveEelectron(options,...rest);
|
7
|
+
return saveWeb(options,...rest);
|
18
8
|
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
const FileSaver = require('file-saver');
|
2
|
+
import {defaultNumber} from "$cutils";
|
3
|
+
|
4
|
+
/***
|
5
|
+
sauvegarde par défaut un fichier blob
|
6
|
+
*/
|
7
|
+
export const save = ({content,fileName,timeout,delay})=>{
|
8
|
+
return new Promise((resolve,reject)=>{
|
9
|
+
try {
|
10
|
+
FileSaver.saveAs(content, fileName);
|
11
|
+
setTimeout(() => {
|
12
|
+
resolve({path:fileName,isWeb : true});
|
13
|
+
}, defaultNumber(timeout,delay,3000));
|
14
|
+
} catch(e){
|
15
|
+
reject(e);
|
16
|
+
}
|
17
|
+
})
|
18
|
+
}
|
@@ -6,8 +6,7 @@ const mime = require('react-native-mime-types')
|
|
6
6
|
const XLSX = require("xlsx");
|
7
7
|
import Preloader from "$preloader";
|
8
8
|
import * as FileSaver from "./FileSaver";
|
9
|
-
import {
|
10
|
-
|
9
|
+
import {isMobileNative,isElectron} from "$cplatform";
|
11
10
|
|
12
11
|
/**** sauvegarde un fichier sur le disque
|
13
12
|
* @param {object} {
|
@@ -28,14 +27,15 @@ import {isWeb,isMobileNative} from "$cplatform";
|
|
28
27
|
if(!isNonNullString(fileName)){
|
29
28
|
return Promise.reject({status:false,msg:'Nom de fichier invalide'});
|
30
29
|
}
|
30
|
+
const isNative = isMobileNative() || isElectron();
|
31
31
|
if(isBase64(content)){
|
32
|
-
if(
|
32
|
+
if(isNative){
|
33
33
|
return FileSaver.save({content,contentType,isBase64:true,fileName,...rest});
|
34
34
|
}
|
35
35
|
content = new Blob([base64toBlob(content,contentType)], {});
|
36
36
|
} else if(isDataURL(content)){
|
37
|
-
if(
|
38
|
-
return FileSaver.save({content:dataURLToBase64(content),contentType,isBase64:true,fileName,...rest});
|
37
|
+
if(isNative){
|
38
|
+
return FileSaver.save({content:dataURLToBase64(content),contentType,mime:contentType,isBase64:true,fileName,...rest});
|
39
39
|
}
|
40
40
|
const type = getTypeFromDataURL(content);
|
41
41
|
content = dataURLToBlob(content);
|
@@ -61,16 +61,16 @@ export const writeExcel = ({workbook,content,contentType,fileName,...rest})=>{
|
|
61
61
|
if(!isNonNullString(fileName)){
|
62
62
|
return Promise.reject({status:false,message:'Nom de fichier invalide pour le contenu excel à créer'});
|
63
63
|
}
|
64
|
-
|
64
|
+
const isNative = isMobileNative() || isElectron();
|
65
65
|
Preloader.open("génération du fichier excel "+fileName);
|
66
66
|
if(isBase64(content)){
|
67
|
-
if(
|
67
|
+
if(isNative) return FileSaver.save({content,isBase64:true,contentType,fileName,...rest}).finally(Preloader.close);
|
68
68
|
content = new Blob([base64toBlob(content, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')], {});
|
69
69
|
}
|
70
70
|
if(isBlob(content)){
|
71
71
|
return write({...rest,content,fileName,contentType}).finally(Preloader.close)
|
72
72
|
}
|
73
|
-
if(
|
73
|
+
if(isNative){
|
74
74
|
return FileSaver.save({...rest,content:XLSX.write(workbook, {type:'base64', bookType:ext}),fileName}).finally(Preloader.close).finally(Preloader.close);
|
75
75
|
}
|
76
76
|
return new Promise((resolve,reject)=>{
|