@fto-consult/expo-ui 8.23.1 → 8.24.1

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/babel.config.js CHANGED
@@ -20,6 +20,7 @@ module.exports = function(api,opts) {
20
20
  options.aliasMutator({...options,alias});
21
21
  }
22
22
  require(`${path.resolve(__dirname,"bin","generate-tables")}`)();//génère les tables des bases de données
23
+ require(`${path.resolve(__dirname,"bin","find-licenses")}`); //met à jour les licenses de l'application
23
24
  const plugins = (Array.isArray(opts.plugins) ? options.plugins : []);
24
25
  let reanimated = "react-native-reanimated/plugin";
25
26
  const filteredPlugins = plugins.filter((p)=>{
@@ -6,12 +6,12 @@ module.exports = {
6
6
  "@pchmn/expo-material3-theme": "^1.3.2",
7
7
  "@react-native-community/netinfo": "11.1.0",
8
8
  "@react-native/assets-registry": "^0.72.0",
9
+ "react-native-get-random-values": "~1.8.0",
9
10
  "@react-navigation/native": "^6.1.9",
10
11
  "@react-navigation/native-stack": "^6.9.17",
11
12
  "@react-navigation/stack": "^6.3.20",
12
13
  "@shopify/flash-list": "1.6.3",
13
14
  "expo": "~50.0.5",
14
- "expo-barcode-scanner": "~12.9.2",
15
15
  "expo-camera": "~14.0.3",
16
16
  "expo-clipboard": "~5.0.1",
17
17
  "expo-font": "~11.10.2",
package/bin/create-app.js CHANGED
@@ -116,13 +116,10 @@ const createAPPJSONFile = (projectRoot,{name,version})=>{
116
116
  "cameraPermission" : `Autoriser $(PRODUCT_NAME) à accéder à votre camera`
117
117
  }, cameraPluginsOptions = {
118
118
  "cameraPermission" : `Autoriser $(PRODUCT_NAME) à accéder à votre camera`
119
- }, barCodePermission = {
120
- "cameraPermission": "Autoriser $(PRODUCT_NAME) à accéder à la caméra."
121
- };
119
+ }
122
120
  const plugins = [
123
121
  ["expo-image-picker",imagePluginOptions],
124
122
  ["expo-camera",cameraPluginsOptions],
125
- ["expo-barcode-scanner",barCodePermission]
126
123
  ];
127
124
  appSheme = name? sanitizeFileName(name).replace(/ /g, '') : null;
128
125
  const appJSONPath = path.join(projectRoot,"app.json");
@@ -179,15 +176,13 @@ const createAPPJSONFile = (projectRoot,{name,version})=>{
179
176
  if(!Array.isArray(appPlugins)){
180
177
  appPlugins = plugins;
181
178
  } else {
182
- let hasFoundCamera = false, hasFoundImagePicker = false,hasFoundBarCode = false;
179
+ let hasFoundCamera = false, hasFoundImagePicker = false;
183
180
  appPlugins.map(pl=>{
184
181
  if(Array.isArray(pl)){
185
182
  if(typeof pl[0] ==="expo-image-picker"){
186
183
  hasFoundImagePicker = true;
187
184
  } else if(pl[0] === "expo-camera"){
188
185
  hasFoundCamera = true;
189
- } else if(pl[0] =="expo-barcode-scanner"){
190
- hasFoundBarCode = true;
191
186
  }
192
187
  }
193
188
  });
@@ -197,9 +192,6 @@ const createAPPJSONFile = (projectRoot,{name,version})=>{
197
192
  if(!hasFoundCamera){
198
193
  appPlugins.push(plugins[1]);
199
194
  }
200
- if(!hasFoundBarCode){
201
- appPlugins.push(plugins[2]);
202
- }
203
195
  }
204
196
  appJSONManager.set({
205
197
  expo : {plugins:appPlugins}
@@ -84,7 +84,7 @@ const findLicencesMain = (options)=>{
84
84
  if (a.toLowerCase() > b.toLowerCase()) return 1;
85
85
  return 0;
86
86
  });
87
- const packageJSON = require("./package.json");
87
+ const packageJSON = require("../package.json");
88
88
  const content = {
89
89
  [packageJSON.name] : {
90
90
  name : packageJSON.name,
@@ -108,7 +108,7 @@ const findLicencesMain = (options)=>{
108
108
  module.exports = ()=>{
109
109
  ///on génère les librairies open sources utilisées par l'application
110
110
  const root = path.resolve(process.cwd());
111
- const expoUI = require("./expo-ui-path")();
111
+ const expoUI = require("../expo-ui-path")();
112
112
  const localNodeModule = path.resolve(root,"node_modules");
113
113
  const HelpScreen = path.resolve(expoUI,"src","screens","Help");
114
114
  const outputPath = path.resolve(HelpScreen,"openLibraries.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "8.23.1",
3
+ "version": "8.24.1",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
@@ -46,7 +46,7 @@
46
46
  "delete-node-modules": "rimraf ./**/node_modules",
47
47
  "dev": "npx expo start --no-dev --minify -c",
48
48
  "modifier-url-remote-git": "git remote set-url origin 'https://borispipo@github.com/borispipo/smart-eneo.git'",
49
- "update": "npm i @fto-consult/common@latest @fto-consult/node-utils@latest react-native-web react-native-blob-util@latest react-native-big-list@latest apexcharts@latest file-saver@latest google-libphonenumber@latest react-native-iphone-x-helper@latest react-native-mime-types@latest react-native-paper@5 react-native-paper-dates@latest react-virtuoso@latest tippy.js@latest xlsx@latest && npm run update-apexchart && npm run find-licenses"
49
+ "update": "npm i @fto-consult/common@latest @fto-consult/node-utils@latest react-native-web react-native-big-list@latest apexcharts@latest file-saver@latest google-libphonenumber@latest react-native-iphone-x-helper@latest react-native-mime-types@latest react-native-paper@5 react-native-paper-dates@latest react-virtuoso@latest tippy.js@latest xlsx@latest && npm run update-apexchart && npm run find-licenses"
50
50
  },
51
51
  "bin": {
52
52
  "expo-ui": "./bin/index.js"
@@ -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.23.1",
71
+ "@fto-consult/common": "^4.24.0",
72
72
  "@fto-consult/node-utils": "^1.4.7",
73
73
  "apexcharts": "^3.45.2",
74
74
  "crypto-browserify": "^3.12.0",
@@ -82,7 +82,6 @@
82
82
  "react-content-loader": "^6.2.1",
83
83
  "react-dom": "^18.2.0",
84
84
  "react-native-big-list": "^1.6.1",
85
- "react-native-blob-util": "^0.19.6",
86
85
  "react-native-iphone-x-helper": "^1.3.1",
87
86
  "react-native-mime-types": "^2.4.0",
88
87
  "react-native-paper": "^5.12.3",
@@ -1,61 +1,98 @@
1
- import React, { useState, useEffect,useMemo } from '$react';
1
+ import React, { useState, useEffect,useMemo,useRef } from '$react';
2
2
  import { View, StyleSheet} from 'react-native';
3
- import { BarCodeScanner } from 'expo-barcode-scanner';
3
+ import { CameraView, Camera } from "expo-camera/next";
4
4
  import theme from "$theme";
5
5
  import ActivityIndicator from "$ecomponents/ActivityIndicator";
6
6
  import Label from "$ecomponents/Label";
7
7
  import PropTypes from "prop-types";
8
- import { isNonNullString,defaultStr } from '$cutils';
8
+ import { isNonNullString,defaultStr,defaultObj } from '$cutils';
9
9
  import Button from "$ecomponents/Button";
10
10
  import Dialog from "$ecomponents/Dialog";
11
+ import {DialogProvider} from "$ecomponents/Form/FormData";
11
12
 
12
- export const scannerTypes = {back:"back",front:"front"};
13
+ export const CameraFacing = {back:"back",front:"front"};
14
+ export const FlashModes = {off:{code:"off",label:"Inactif"},on:{code:"on",label:"Actif"},auto:{code:"auto",label:"Automatique"}}
15
+ export const CameraSettingsFields = {
16
+ enableTorch : {
17
+ type : "switch",
18
+ label : "Allumer la torche",
19
+ defaultValue : false,
20
+ checkedValue : true,
21
+ uncheckedValue : false,
22
+ },
23
+ flash : {
24
+ label : "Flash",
25
+ type : "select",
26
+ required : true,
27
+ items : FlashModes,
28
+ defaultValue : FlashModes.auto.code,
29
+ },
30
+ }
13
31
 
14
32
  /***@see : https://docs.expo.dev/versions/latest/sdk/bar-code-scanner/ */
15
- export default function App({onScan,onGrantAccess,testID,onDenyAccess,scannerProps,onCancel,dialogProps}) {
33
+ export default function BarCodeScanner({onScan,onGrantAccess,testID,onDenyAccess,cameraProps,onCancel,dialogProps}) {
16
34
  testID = defaultStr(testID,"RN_BarCodeScanner");
17
35
  const [hasPermission, setHasPermission] = useState(null);
18
36
  const [visible,setVisible] = useState(true);
19
37
  dialogProps = Object.assign({},dialogProps);
20
- scannerProps = Object.assign({},scannerProps);
38
+ cameraProps = Object.assign({},cameraProps);
39
+ const getFlashMode = ()=>{
40
+ let {flash} = cameraProps;
41
+ if(isNonNullString(flash)){
42
+ flash = flash.toLowerCase().trim();
43
+ if(FlashModes[flash]) return FlashModes[flash].code;
44
+ }
45
+ return FlashModes.auto.code;
46
+ }
47
+ const [cameraSetting,setCameraSetting] = useState({
48
+ enableTorch : !!cameraProps.enableTorch,
49
+ flash : getFlashMode(cameraProps.flash),
50
+ });
51
+ useEffect(()=>{
52
+ const flash = getFlashMode();
53
+ if(flash !== cameraSetting.flash){
54
+ setCameraSetting({...cameraSetting,flash});
55
+ }
56
+ },[cameraProps.flash]);
57
+ useEffect(()=>{
58
+ const enableTorch = !!cameraProps.enableTorch;
59
+ if(enableTorch !== cameraSetting.enableTorch){
60
+ setCameraSetting({...cameraSetting,enableTorch});
61
+ }
62
+ },[!!cameraProps.enableTorch]);
21
63
  const prevVisible = React.usePrevious(visible);
22
64
  const cancelRef = React.useRef(false);
23
65
  const cancel = ()=>{
24
66
  cancelRef.current = true;
25
67
  setVisible(false);
26
68
  }
27
- const getCameraType = ()=>{
28
- let {type} = scannerProps;
29
- if(isNonNullString(type)){
30
- type = type.toLowerCase().trim();
31
- } else type = scannerTypes.back;
32
- if(!scannerTypes[type]){
33
- type = scannerTypes.back;
34
- }
35
- return type;
36
- }
37
- const sType = useMemo(()=>{
38
- return getCameraType();
39
- },[scannerProps.type]);
40
- const [scannerType,setScannerType] = useState(sType);
69
+ const sFacing = useMemo(()=>{
70
+ let {facing} = cameraProps;
71
+ if(isNonNullString(facing)){
72
+ facing = facing.trim().toLowerCase();
73
+ } else return CameraFacing.back;
74
+ return CameraFacing[facing] || CameraFacing.back;
75
+ },[cameraProps.facing]);
76
+ const [facing,setFacing] = useState(sFacing);
41
77
  useEffect(()=>{
42
- const type = getCameraType();
43
- if(type !== scannerType){
44
- setScannerType(type);
78
+ if(sFacing !== facing){
79
+ setFacing(sFacing);
45
80
  }
46
- },scannerProps.type)
47
- const isBack = scannerType === scannerTypes.back;
81
+ },[sFacing]);
82
+ const isBack = facing === CameraFacing.back;
48
83
  useEffect(() => {
49
- const getBarCodeScannerPermissions = async () => {
50
- const { status } = await BarCodeScanner.requestPermissionsAsync();
51
- setHasPermission(status === 'granted');
84
+ const getCameraPermissions = async () => {
85
+ const { status } = await Camera.requestCameraPermissionsAsync();
86
+ setHasPermission(status === "granted");
52
87
  };
53
-
54
- getBarCodeScannerPermissions();
88
+ getCameraPermissions();
55
89
  }, []);
56
-
90
+ //const torchEnabledRef = useRef(cameraSetting.enableTorch);
91
+ //const prevTorchEnabled = React.usePrevious(torchEnabledRef.current);
57
92
  const handleBarCodeScanned = ({ type, data,...rest }) => {
58
- //setScanned(true);
93
+ if(cameraSetting.enableTorch){
94
+ setCameraSetting({...cameraSetting,enableTorch:false});
95
+ }
59
96
  if(typeof onScan =="function"){
60
97
  onScan({type,data,code:data,barCode:data,...rest});
61
98
  }
@@ -84,12 +121,30 @@ export default function App({onScan,onGrantAccess,testID,onDenyAccess,scannerPro
84
121
  icon : "camera-flip",
85
122
  tooltip : `Cliquez pour basculer à la camera ${isBack ? "frontable":"arrière"}`,
86
123
  onPress : ()=>{
87
- setScannerType(isBack ? scannerTypes.front : scannerTypes.back);
124
+ setFacing(isBack ? CameraFacing.front : CameraFacing.back);
88
125
  }
89
126
  };
90
127
  return <Dialog
91
128
  fullPage
92
- actions={[switchCameraBtn]}
129
+ actions={[
130
+ switchCameraBtn,
131
+ {
132
+ text : "Options de la camera",
133
+ icon : "material-settings",
134
+ tooltip : `Définir les options de la camera`,
135
+ onPress : ()=>{
136
+ DialogProvider.open({
137
+ tile : "Options de la camera",
138
+ data : cameraSetting,
139
+ fields : CameraSettingsFields,
140
+ onSuccess : ({data})=>{
141
+ setCameraSetting(data);
142
+ DialogProvider.close();
143
+ },
144
+ })
145
+ }
146
+ }
147
+ ]}
93
148
  title = {`Scanner un code barre`}
94
149
  {...dialogProps}
95
150
  onBackActionPress={cancel}
@@ -102,13 +157,14 @@ export default function App({onScan,onGrantAccess,testID,onDenyAccess,scannerPro
102
157
  <ActivityIndicator size={'large'}/>
103
158
  </View>}
104
159
  </View> : <View style={[theme.styles.flex1]} testID={testID}>
105
- <BarCodeScanner
160
+ <CameraView
106
161
  ratio='16:9'
107
162
  testID={testID+"_ScannerContent"}
108
- {...scannerProps}
109
- type={scannerType}
110
- style={[theme.styles.flex1,{width:"100%",height:"100%"},scannerProps.style]}
111
- onBarCodeScanned={handleBarCodeScanned}
163
+ {...cameraProps}
164
+ {...cameraSetting}
165
+ facing = {facing}
166
+ style={[theme.styles.flex1,{width:"100%",height:"100%"},cameraProps.style]}
167
+ onBarcodeScanned={handleBarCodeScanned}
112
168
  />
113
169
  <View style={[styles.row,theme.styles.w100]}>
114
170
  <Button
@@ -141,6 +197,10 @@ const styles = StyleSheet.create({
141
197
  flexWrap :"wrap",
142
198
  }
143
199
  });
200
+
201
+ /***
202
+ @see : https://docs.expo.dev/versions/latest/sdk/camera-next
203
+ */
144
204
  BarCodeScanner.propTypes = {
145
205
  onScan : PropTypes.func,
146
206
  onGrantAccess : PropTypes.func, //lorsque la permission est allouée
@@ -1,3 +1,5 @@
1
1
  export default function BarCodeScanner(){
2
2
  return null;
3
- }
3
+ }
4
+
5
+ BarCodeScanner.propTypes = {}
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  "@fto-consult/expo-ui": {
3
3
  "name": "@fto-consult/expo-ui",
4
- "version": "8.19.0",
4
+ "version": "8.24.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/borispipo/expo-ui.git"
@@ -34,7 +34,7 @@ module.exports = {
34
34
  "license": "MIT"
35
35
  },
36
36
  "@fto-consult/common": {
37
- "version": "4.19.4",
37
+ "version": "4.24.0",
38
38
  "url": "https://github.com/borispipo/common#readme",
39
39
  "license": "ISC"
40
40
  },
@@ -135,6 +135,11 @@ module.exports = {
135
135
  "url": "https://github.com/web-ridge/react-native-paper-dates#readme",
136
136
  "license": "MIT"
137
137
  },
138
+ "react-native-uuid": {
139
+ "version": "2.0.1",
140
+ "url": "https://github.com/eugenehp/react-native-uuid#readme",
141
+ "license": "MIT"
142
+ },
138
143
  "react-native-web": {
139
144
  "version": "0.19.10",
140
145
  "url": "git://github.com/necolas/react-native-web.git",
@@ -0,0 +1 @@
1
+ export default {}
@@ -0,0 +1,2 @@
1
+ import 'react-native-get-random-values';
2
+ export default {}
package/src/uuid/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import "./deps";
1
2
  import uuid from 'react-native-uuid';
2
3
  const {parse,unparse,validate,version,v1,v3,v4,v5,NIL,DNS,URL,OID,X500,} = uuid;
3
4
  export {parse,unparse,validate,version,v1,v3,v4,v5,NIL,DNS,URL,OID,X500}