@fto-consult/expo-ui 2.12.3 → 2.12.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.12.
|
|
3
|
+
"version": "2.12.5",
|
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -86,8 +86,10 @@
|
|
|
86
86
|
"expo-status-bar": "~1.4.2",
|
|
87
87
|
"expo-system-ui": "~2.0.1",
|
|
88
88
|
"expo-web-browser": "~12.0.0",
|
|
89
|
+
"file-saver": "^2.0.5",
|
|
89
90
|
"google-libphonenumber": "^3.2.31",
|
|
90
91
|
"htmlparser2-without-node-native": "^3.9.2",
|
|
92
|
+
"mime-types": "^2.1.35",
|
|
91
93
|
"mongo-parse": "^2.1.0",
|
|
92
94
|
"parent-package-json": "^2.0.1",
|
|
93
95
|
"prop-types": "^15.8.1",
|
|
@@ -0,0 +1,42 @@
|
|
|
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.
|
|
4
|
+
import {defaultStr,isNonNullString,defaultNumber,defaultBool,dataURLToBase64,isBlob,isBase64,isDataURL} from "$utils";
|
|
5
|
+
const FileSaver = require('file-saver');
|
|
6
|
+
const mime = require('mime-types')
|
|
7
|
+
/**** sauvegarde un fichier sur le disque
|
|
8
|
+
* @param {object} {
|
|
9
|
+
* content {mix}: le contenu du fichier à enregistrer
|
|
10
|
+
* charset {string}: L'encodage à utiliser pour l'enregistrement du fichier, par défaut utf-8
|
|
11
|
+
* directory || dir {string} : le répertoire dans lequel enregistrer le fichier
|
|
12
|
+
* systemDirectory || SystemDirectory : le répertoire racine au device, où enregistrer la données
|
|
13
|
+
* fileName {string} : le nom du fichier à enregistrer
|
|
14
|
+
* success {function} : la fonction de rappel à appeler en cas de success
|
|
15
|
+
* error {function} la fonction de rappel à appeler en cas d'erreur
|
|
16
|
+
* isBinary : si c'est un fichier binaire
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export const write = ({content,type,isBinary,timeout,delay,share,contentType,filename,path,directory,fileName})=>{
|
|
20
|
+
share = defaultBool(share,true);
|
|
21
|
+
fileName = sanitizeFileName(defaultStr(fileName,filename));
|
|
22
|
+
contentType = defaultStr(contentType) || mime.contentType(fileName) || mime.contentType(".txt");
|
|
23
|
+
return new Promise((resolve,reject)=>{
|
|
24
|
+
if(!isNonNullString(fileName)){
|
|
25
|
+
reject({status:false,msg:'Nom de fichier invalide'});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
content = isBlob(content)? content : new Blob(content,contentType);
|
|
29
|
+
try {
|
|
30
|
+
FileSaver.saveAs(blob, fileName);
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
resolve({path:fileName,isWeb : true});
|
|
33
|
+
}, defaultNumber(timeout,delay,3000));
|
|
34
|
+
} catch(e){
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const writeText = (args)=>{
|
|
41
|
+
return write({...args,contentType:mime.contentType(".txt")});
|
|
42
|
+
}
|
package/src/navigation/utils.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
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
|
import {navigate,sanitizeName} from "$cnavigation";
|
|
5
|
-
import {routeName as tableDataRouteName} from "$screens/TableData/utils";
|
|
6
5
|
import {isNonNullString,defaultObj,isObj} from "$utils";
|
|
7
6
|
|
|
7
|
+
export const tableDataRouteName = 'TableData';
|
|
8
|
+
|
|
8
9
|
export const navigateToTableData = function(tableName,params,actionType){
|
|
9
10
|
if(isNonNullString(tableName)){
|
|
10
11
|
tableName = {tableName};
|
|
@@ -48,4 +49,13 @@ export const getTableDataRouteName = function(tableName){
|
|
|
48
49
|
/*** permet d'obtenir le lien vers l'écran table data permettant de lister les données de la table data */
|
|
49
50
|
export const getTableDataListRouteName = function(tableName){
|
|
50
51
|
return buildScreenRoute(tableName,tableDataRouteName+"/LIST/");
|
|
51
|
-
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const navigateToTableDataList = function (tableName,params){
|
|
55
|
+
const route = getTableDataListRouteName(tableName);
|
|
56
|
+
if(isNonNullString(route)){
|
|
57
|
+
return navigate({routeName:route,params});
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|