@fto-consult/expo-ui 8.31.1 → 8.32.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "8.31.1",
3
+ "version": "8.32.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
@@ -68,7 +68,7 @@
68
68
  "dependencies": {
69
69
  "@emotion/react": "^11.11.1",
70
70
  "@faker-js/faker": "^8.0.2",
71
- "@fto-consult/common": "^4.31.0",
71
+ "@fto-consult/common": "^4.32.1",
72
72
  "@fto-consult/node-utils": "^1.5.1",
73
73
  "apexcharts": "^3.46.0",
74
74
  "crypto-browserify": "^3.12.0",
@@ -1,12 +1,22 @@
1
1
  const FileSaver = require('file-saver');
2
- import {defaultNumber} from "$cutils";
2
+ import {defaultNumber,postWebviewMessage} from "$cutils";
3
+ import {isReactNativeWebview} from "$cplatform";
3
4
 
4
5
  /***
5
6
  sauvegarde par défaut un fichier blob
6
7
  */
7
- export const save = ({content,fileName,timeout,delay})=>{
8
+ export const save = ({content,fileName,mimeType,contentType,isBase64,timeout,delay})=>{
8
9
  return new Promise((resolve,reject)=>{
9
10
  try {
11
+ if(isReactNativeWebview()){
12
+ postWebviewMessage("FILE_SAVER_SAVE_FILE",{
13
+ content,
14
+ fileName,
15
+ contentType,
16
+ mimeType,
17
+ isBase64,
18
+ });
19
+ }
10
20
  FileSaver.saveAs(content, fileName);
11
21
  setTimeout(() => {
12
22
  resolve({path:fileName,isWeb : true});
@@ -1,10 +1,31 @@
1
1
  import {isElectron} from "$cplatform";
2
2
  import electronPrint from "./print.electron";
3
3
  import {isTouchDevice} from "$cplatform";
4
+ import {canPostWebviewMessage,postWebviewMessage} from "$cutils/webview";
5
+ import {defaultStr,getFileExtension} from "$cutils";
6
+ import DateLib from "$clib/date";
4
7
  export default function print(pdfMakeInstance,options,...rest){
5
8
  if(isElectron()){
6
9
  return electronPrint(pdfMakeInstance,options,...rest);
7
10
  }
11
+ if(canPostWebviewMessage()){
12
+ return pdfMakeInstance.getBase64((content)=>{
13
+ let fileName = defaultStr(options?.fileName);
14
+ if(!fileName){
15
+ fileName = "printed-pdf-"+DateLib.format(new Date(),"dd-mm-yyyy HH MM SS");
16
+ }
17
+ const ext = getFileExtension(fileName,true);
18
+ if(!ext || ext.toLowerCase() !=="pdf"){
19
+ fileName+=".pdf";
20
+ }
21
+ return postWebviewMessage("FILE_SAVER_SAVE_FILE",{
22
+ content,
23
+ contentType : 'application/pdf',
24
+ fileName,
25
+ isBase64 : true,
26
+ });
27
+ })
28
+ }
8
29
  if(isTouchDevice()){
9
30
  return pdfMakeInstance.open({},window);
10
31
  }