@fto-consult/expo-ui 8.58.5 → 8.59.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/bin/create-app/dependencies.js +2 -1
- package/bin/create-app.js +2 -1
- package/package.json +2 -2
- package/src/components/Chart/appexChart/index.js +5 -1
- package/src/components/DocumentPicker/index.js +41 -0
- package/src/media/document.js +55 -0
- package/src/media/exports.js +131 -0
- package/src/media/index.js +1 -131
- package/src/screens/Help/openLibraries.js +1 -1
package/bin/create-app.js
CHANGED
@@ -153,6 +153,7 @@ electron/**/*
|
|
153
153
|
const plugins = [
|
154
154
|
["expo-image-picker",imagePluginOptions],
|
155
155
|
["expo-camera",cameraPluginsOptions],
|
156
|
+
["expo-document-picker",{"iCloudContainerEnvironment": "Production" }]
|
156
157
|
];
|
157
158
|
appSheme = name? sanitizeFileName(name).replace(/ /g, '') : null;
|
158
159
|
const appJSONPath = path.join(projectRoot,"app.json");
|
@@ -165,7 +166,7 @@ electron/**/*
|
|
165
166
|
"slug": "${name.toLowerCase().replace(/\s\s+/g, '-')}",
|
166
167
|
"version":"${version}",
|
167
168
|
"orientation": "portrait",
|
168
|
-
"plugins":${JSON.stringify(plugins)},
|
169
|
+
"plugins":${JSON.stringify(plugins,null,2)},
|
169
170
|
"icon": "./assets/icon.png",
|
170
171
|
"jsEngine": "hermes",
|
171
172
|
"splash": {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fto-consult/expo-ui",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.59.0",
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
5
|
"react-native-paper-doc": "https://github.com/callstack/react-native-paper/tree/main/docs/docs/guides",
|
6
6
|
"scripts": {
|
@@ -71,7 +71,7 @@
|
|
71
71
|
"@faker-js/faker": "^8.0.2",
|
72
72
|
"@fto-consult/common": "^4.39.8",
|
73
73
|
"@fto-consult/node-utils": "^1.7.1",
|
74
|
-
"apexcharts": "^3.
|
74
|
+
"apexcharts": "^3.48.0",
|
75
75
|
"file-saver": "^2.0.5",
|
76
76
|
"google-libphonenumber": "^3.2.34",
|
77
77
|
"html2canvas": "^1.4.1",
|
@@ -8,7 +8,11 @@ const AppexChartComponent = React.forwardRef(({chartContext,style,options,...pro
|
|
8
8
|
const viewRef = React.useRef(null);
|
9
9
|
React.useEffect(()=>{
|
10
10
|
chartContext.current = new ApexChart(viewRef.current,options)
|
11
|
-
|
11
|
+
try {
|
12
|
+
chartContext.current.render();
|
13
|
+
} catch(e){
|
14
|
+
console.log(e," rendering chartt with options ",options);
|
15
|
+
}
|
12
16
|
React.setRef(ref,chartContext.current)
|
13
17
|
return ()=>{
|
14
18
|
React.setRef(ref,chartContext.current)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import Button from "$ecomponents/Button";
|
2
|
+
import React from "$react";
|
3
|
+
import PropTypes from "prop-types";
|
4
|
+
import { pickDocument } from "$emedia/document";
|
5
|
+
|
6
|
+
const DocumentPickerComponent = React.forwardRef(({pickOptions,onSuccess,onCancel,onPress,...props},ref)=>{
|
7
|
+
return <Button
|
8
|
+
onPress = {(...r)=>{
|
9
|
+
if(typeof onPress =="function" && onPress(...r) === false) return;
|
10
|
+
pickDocument(pickOptions).then((r)=>{
|
11
|
+
if(typeof onSuccess =="function"){
|
12
|
+
onSuccess(r);
|
13
|
+
}
|
14
|
+
}).catch((r)=>{
|
15
|
+
if(typeof onCancel =="function"){
|
16
|
+
onCancel(r);
|
17
|
+
}
|
18
|
+
});
|
19
|
+
}}
|
20
|
+
ref={ref} {...props}/>
|
21
|
+
});
|
22
|
+
|
23
|
+
DocumentPickerComponent.displayName = "DocumentPickerComponent";
|
24
|
+
|
25
|
+
export default DocumentPickerComponent;
|
26
|
+
|
27
|
+
DocumentPickerComponent.propTypes = {
|
28
|
+
...Object.assign({},Button.propTypes),
|
29
|
+
onSuccess : PropTypes.func,
|
30
|
+
onCancel : PropTypes.func,
|
31
|
+
/*** @see : https://docs.expo.dev/versions/latest/sdk/document-picker/#documentpickeroptions */
|
32
|
+
pickOptions : PropTypes.shape({
|
33
|
+
copyToCacheDirectory : PropTypes.bool,
|
34
|
+
multiple : PropTypes.bool,
|
35
|
+
/*** @seee : https://en.wikipedia.org/wiki/Media_type */
|
36
|
+
type : PropTypes.oneOfType([
|
37
|
+
PropTypes.string,
|
38
|
+
PropTypes.arrayOf(PropTypes.string),
|
39
|
+
])
|
40
|
+
}),
|
41
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import * as DocumentPicker from 'expo-document-picker';
|
2
|
+
import {extendObj} from "$cutils";
|
3
|
+
import notify from "$cnotify";
|
4
|
+
|
5
|
+
export const mimeTypes = {
|
6
|
+
sql : "application/sql",
|
7
|
+
json : "application/json",
|
8
|
+
pdf : "application/pdf",
|
9
|
+
xlsx : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
10
|
+
image : "image/*",
|
11
|
+
xml : "application/xml",
|
12
|
+
csv : "text/csv",
|
13
|
+
}
|
14
|
+
/****
|
15
|
+
@param {object}, @see : https://docs.expo.dev/versions/latest/sdk/document-picker/#documentpickeroptions
|
16
|
+
for mimeTypes, @see : https://en.wikipedia.org/wiki/Media_type
|
17
|
+
*/
|
18
|
+
export const pickDocument = (options)=>{
|
19
|
+
options = extendObj({},{
|
20
|
+
copyToCacheDirectory : true,
|
21
|
+
multiple : false,
|
22
|
+
type : undefined,
|
23
|
+
},options);
|
24
|
+
return new Promise((resolve,reject)=>{
|
25
|
+
return DocumentPicker.getDocumentAsync(options).then(({canceled,...rest})=>{
|
26
|
+
if(canceled){
|
27
|
+
notify.error("Opération annulée par l'utilisateur");
|
28
|
+
return reject({canceled});
|
29
|
+
}
|
30
|
+
return resolve({canceled,...rest});
|
31
|
+
})
|
32
|
+
})
|
33
|
+
}
|
34
|
+
|
35
|
+
export const pickJSON = (options)=>{
|
36
|
+
return pickDocument(extendObj({},options,{
|
37
|
+
type : mimeTypes.json,
|
38
|
+
}));
|
39
|
+
}
|
40
|
+
export const pickCSV = (options)=>{
|
41
|
+
return pickDocument(extendObj({},options,{
|
42
|
+
type : mimeTypes.csv,
|
43
|
+
}));
|
44
|
+
}
|
45
|
+
export const pickPDF = (options)=>{
|
46
|
+
return pickDocument(extendObj({},options,{
|
47
|
+
type : mimeTypes.pdf
|
48
|
+
}));
|
49
|
+
}
|
50
|
+
|
51
|
+
export const pickSQL = (options)=>{
|
52
|
+
return pickDocument(extendObj({},options,{
|
53
|
+
type : mimeTypes.sql,
|
54
|
+
}));
|
55
|
+
}
|
@@ -0,0 +1,131 @@
|
|
1
|
+
import {isObj,isBase64} from "$cutils";
|
2
|
+
import notify from "$enotify";
|
3
|
+
import Camera from "./camera";
|
4
|
+
import {isMobileNative} from "$platform";
|
5
|
+
import {getFilePickerOptions} from "./utils";
|
6
|
+
import React from "react";
|
7
|
+
|
8
|
+
let cameraRef = null;
|
9
|
+
|
10
|
+
export {cameraRef}
|
11
|
+
|
12
|
+
export const createCameraRef = ()=>{
|
13
|
+
const ref = React.useRef(null);
|
14
|
+
React.useEffect(()=>{
|
15
|
+
cameraRef = ref.current;
|
16
|
+
},[ref.current])
|
17
|
+
return ref;
|
18
|
+
}
|
19
|
+
|
20
|
+
import * as ImagePicker from 'expo-image-picker';
|
21
|
+
|
22
|
+
export const MEDIA_TYPES = {
|
23
|
+
ALL : ImagePicker.MediaTypeOptions.All,
|
24
|
+
IMAGES : ImagePicker.MediaTypeOptions.Images,
|
25
|
+
VIDEOS : ImagePicker.MediaTypeOptions.Videos,
|
26
|
+
}
|
27
|
+
|
28
|
+
export {ImagePicker};
|
29
|
+
|
30
|
+
export function checkPermission (method){
|
31
|
+
return new Promise((resolve,reject)=>{
|
32
|
+
(typeof method =="function" && method || ImagePicker.requestMediaLibraryPermissionsAsync)().then((r)=>{
|
33
|
+
if(isObj(r) && (r.granted || r.status =='granted')){
|
34
|
+
resolve(r);
|
35
|
+
return true;
|
36
|
+
} else {
|
37
|
+
reject(r);
|
38
|
+
}
|
39
|
+
}).catch((e)=>{
|
40
|
+
console.log(e," unable to grand media permission");
|
41
|
+
notify.error("Permission à l'accès aux médias refusée par l'utilisateur");
|
42
|
+
reject(e);
|
43
|
+
});
|
44
|
+
})
|
45
|
+
}
|
46
|
+
|
47
|
+
export * from "./utils";
|
48
|
+
|
49
|
+
const prepareImageResult = (result)=>{
|
50
|
+
if(!isObj(result)) return result;
|
51
|
+
if(Array.isArray(result.assets) && isObj(result.assets[0])){
|
52
|
+
result = {
|
53
|
+
...result,
|
54
|
+
...result.assets[0],
|
55
|
+
}
|
56
|
+
}
|
57
|
+
result.dataURL = result.dataUrl = isBase64(result.base64) ? ('data:image/jpeg;base64,'+result.base64) : null;
|
58
|
+
return result;
|
59
|
+
}
|
60
|
+
|
61
|
+
/**** @see : https://docs.expo.dev/versions/latest/sdk/imagepicker/#imagepickeroptions
|
62
|
+
* form more options.
|
63
|
+
*/
|
64
|
+
export const pickImageOrVideo = (options)=>{
|
65
|
+
return checkPermission().then(()=>{
|
66
|
+
return new Promise((resolve,reject)=>{
|
67
|
+
ImagePicker.launchImageLibraryAsync(getFilePickerOptions(options)).then((result)=>{
|
68
|
+
if(!result.cancelled && !result.canceled) {
|
69
|
+
resolve(prepareImageResult(result));
|
70
|
+
} else {
|
71
|
+
notify.warning("Opération annulée par l'utilisateur");
|
72
|
+
reject(result);
|
73
|
+
}
|
74
|
+
return null;
|
75
|
+
}).catch(reject);
|
76
|
+
})
|
77
|
+
})
|
78
|
+
}
|
79
|
+
|
80
|
+
export const pickImage = (options)=>{
|
81
|
+
options = defaultObj(options);
|
82
|
+
options.mediaTypes = ImagePicker.MediaTypeOptions.Images;
|
83
|
+
return pickImageOrVideo(options)
|
84
|
+
}
|
85
|
+
|
86
|
+
export const pickVideo = (options)=>{
|
87
|
+
options = defaultObj(options);
|
88
|
+
options.mediaTypes = ImagePicker.MediaTypeOptions.Videos;
|
89
|
+
return pickImageOrVideo(options)
|
90
|
+
}
|
91
|
+
|
92
|
+
export const nonZeroMin = function(args){
|
93
|
+
let arra = Array.prototype.slice.call(arguments,0).sort();
|
94
|
+
let min = 0;
|
95
|
+
for(let i in arra){
|
96
|
+
if(isNumber(arra[i]) && arra[i] > 0) {
|
97
|
+
if(min <= 0){
|
98
|
+
min = arra[i]
|
99
|
+
} else if(arra[i]< min ){
|
100
|
+
min = arra[i]
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
return min;
|
105
|
+
};
|
106
|
+
|
107
|
+
export {Camera};
|
108
|
+
|
109
|
+
export async function canTakePhoto(){
|
110
|
+
if(!isMobileNative()) return false;
|
111
|
+
return true;
|
112
|
+
}
|
113
|
+
|
114
|
+
export const takePhoto = (options)=>{
|
115
|
+
return new Promise((resolve,reject)=>{
|
116
|
+
return checkPermission(ImagePicker.requestCameraPermissionsAsync).then((perm)=>{
|
117
|
+
options = {base64:true,...Object.assign({},options)}
|
118
|
+
return ImagePicker.launchCameraAsync({...getFilePickerOptions(options)}).then((result)=>{
|
119
|
+
if(!result.cancelled && !result.canceled) {
|
120
|
+
resolve(prepareImageResult(result));
|
121
|
+
} else {
|
122
|
+
notify.warning("Opération annulée par l'utilisateur");
|
123
|
+
reject(result);
|
124
|
+
}
|
125
|
+
return null;
|
126
|
+
})
|
127
|
+
}).catch(reject);
|
128
|
+
})
|
129
|
+
}
|
130
|
+
|
131
|
+
export const takePicture = takePhoto;
|
package/src/media/index.js
CHANGED
@@ -1,131 +1 @@
|
|
1
|
-
|
2
|
-
import notify from "$enotify";
|
3
|
-
import Camera from "./camera";
|
4
|
-
import {isMobileNative} from "$platform";
|
5
|
-
import {getFilePickerOptions} from "./utils";
|
6
|
-
import React from "react";
|
7
|
-
|
8
|
-
let cameraRef = null;
|
9
|
-
|
10
|
-
export {cameraRef}
|
11
|
-
|
12
|
-
export const createCameraRef = ()=>{
|
13
|
-
const ref = React.useRef(null);
|
14
|
-
React.useEffect(()=>{
|
15
|
-
cameraRef = ref.current;
|
16
|
-
},[ref.current])
|
17
|
-
return ref;
|
18
|
-
}
|
19
|
-
|
20
|
-
import * as ImagePicker from 'expo-image-picker';
|
21
|
-
|
22
|
-
export const MEDIA_TYPES = {
|
23
|
-
ALL : ImagePicker.MediaTypeOptions.All,
|
24
|
-
IMAGES : ImagePicker.MediaTypeOptions.Images,
|
25
|
-
VIDEOS : ImagePicker.MediaTypeOptions.Videos,
|
26
|
-
}
|
27
|
-
|
28
|
-
export {ImagePicker};
|
29
|
-
|
30
|
-
export function checkPermission (method){
|
31
|
-
return new Promise((resolve,reject)=>{
|
32
|
-
(typeof method =="function" && method || ImagePicker.requestMediaLibraryPermissionsAsync)().then((r)=>{
|
33
|
-
if(isObj(r) && (r.granted || r.status =='granted')){
|
34
|
-
resolve(r);
|
35
|
-
return true;
|
36
|
-
} else {
|
37
|
-
reject(r);
|
38
|
-
}
|
39
|
-
}).catch((e)=>{
|
40
|
-
console.log(e," unable to grand media permission");
|
41
|
-
notify.error("Permission à l'accès aux médias refusée par l'utilisateur");
|
42
|
-
reject(e);
|
43
|
-
});
|
44
|
-
})
|
45
|
-
}
|
46
|
-
|
47
|
-
export * from "./utils";
|
48
|
-
|
49
|
-
const prepareImageResult = (result)=>{
|
50
|
-
if(!isObj(result)) return result;
|
51
|
-
if(Array.isArray(result.assets) && isObj(result.assets[0])){
|
52
|
-
result = {
|
53
|
-
...result,
|
54
|
-
...result.assets[0],
|
55
|
-
}
|
56
|
-
}
|
57
|
-
result.dataURL = result.dataUrl = isBase64(result.base64) ? ('data:image/jpeg;base64,'+result.base64) : null;
|
58
|
-
return result;
|
59
|
-
}
|
60
|
-
|
61
|
-
/**** @see : https://docs.expo.dev/versions/latest/sdk/imagepicker/#imagepickeroptions
|
62
|
-
* form more options.
|
63
|
-
*/
|
64
|
-
export const pickImageOrVideo = (options)=>{
|
65
|
-
return checkPermission().then(()=>{
|
66
|
-
return new Promise((resolve,reject)=>{
|
67
|
-
ImagePicker.launchImageLibraryAsync(getFilePickerOptions(options)).then((result)=>{
|
68
|
-
if(!result.cancelled && !result.canceled) {
|
69
|
-
resolve(prepareImageResult(result));
|
70
|
-
} else {
|
71
|
-
notify.warning("Opération annulée par l'utilisateur");
|
72
|
-
reject(result);
|
73
|
-
}
|
74
|
-
return null;
|
75
|
-
}).catch(reject);
|
76
|
-
})
|
77
|
-
})
|
78
|
-
}
|
79
|
-
|
80
|
-
export const pickImage = (options)=>{
|
81
|
-
options = defaultObj(options);
|
82
|
-
options.mediaTypes = ImagePicker.MediaTypeOptions.Images;
|
83
|
-
return pickImageOrVideo(options)
|
84
|
-
}
|
85
|
-
|
86
|
-
export const pickVideo = (options)=>{
|
87
|
-
options = defaultObj(options);
|
88
|
-
options.mediaTypes = ImagePicker.MediaTypeOptions.Videos;
|
89
|
-
return pickImageOrVideo(options)
|
90
|
-
}
|
91
|
-
|
92
|
-
export const nonZeroMin = function(args){
|
93
|
-
let arra = Array.prototype.slice.call(arguments,0).sort();
|
94
|
-
let min = 0;
|
95
|
-
for(let i in arra){
|
96
|
-
if(isNumber(arra[i]) && arra[i] > 0) {
|
97
|
-
if(min <= 0){
|
98
|
-
min = arra[i]
|
99
|
-
} else if(arra[i]< min ){
|
100
|
-
min = arra[i]
|
101
|
-
}
|
102
|
-
}
|
103
|
-
}
|
104
|
-
return min;
|
105
|
-
};
|
106
|
-
|
107
|
-
export {Camera};
|
108
|
-
|
109
|
-
export async function canTakePhoto(){
|
110
|
-
if(!isMobileNative()) return false;
|
111
|
-
return true;
|
112
|
-
}
|
113
|
-
|
114
|
-
export const takePhoto = (options)=>{
|
115
|
-
return new Promise((resolve,reject)=>{
|
116
|
-
return checkPermission(ImagePicker.requestCameraPermissionsAsync).then((perm)=>{
|
117
|
-
options = {base64:true,...Object.assign({},options)}
|
118
|
-
return ImagePicker.launchCameraAsync({...getFilePickerOptions(options)}).then((result)=>{
|
119
|
-
if(!result.cancelled && !result.canceled) {
|
120
|
-
resolve(prepareImageResult(result));
|
121
|
-
} else {
|
122
|
-
notify.warning("Opération annulée par l'utilisateur");
|
123
|
-
reject(result);
|
124
|
-
}
|
125
|
-
return null;
|
126
|
-
})
|
127
|
-
}).catch(reject);
|
128
|
-
})
|
129
|
-
}
|
130
|
-
|
131
|
-
export const takePicture = takePhoto;
|
1
|
+
export * from "./exports";
|