@fto-consult/expo-ui 8.9.1 → 8.11.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 +38 -36
- package/bin/index.js +7 -0
- package/bin/update.js +52 -0
- package/package.json +111 -111
- package/src/components/Barcode/Generator/Generator.js +7 -15
- package/src/components/Barcode/Generator/Generator.native.js +1 -1
- package/src/components/Barcode/Generator/index.js +35 -30
- package/src/components/Barcode/index.js +3 -0
- package/src/components/Barcode/utils.js +55 -0
- package/src/components/Barcode/utils.native.js +5 -0
@@ -1,36 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
|
2
|
+
module.exports = {
|
3
|
+
"@emotion/native": "^11.11.0",
|
4
|
+
"@expo/html-elements": "^0.5.1",
|
5
|
+
"@expo/vector-icons": "^14.0.0",
|
6
|
+
"@pchmn/expo-material3-theme": "^1.3.2",
|
7
|
+
"@react-native-community/datetimepicker": "^7.6.1",
|
8
|
+
"@react-native-community/netinfo": "^11.1.0",
|
9
|
+
"@react-native/assets-registry": "^0.72.0",
|
10
|
+
"@react-navigation/native": "^6.1.9",
|
11
|
+
"@react-navigation/native-stack": "^6.9.17",
|
12
|
+
"@react-navigation/stack": "^6.3.20",
|
13
|
+
"@shopify/flash-list": "^1.6.3",
|
14
|
+
"expo": "^50.0.3",
|
15
|
+
"expo-barcode-scanner": "~12.9.2",
|
16
|
+
"expo-camera": "~14.0.1",
|
17
|
+
"expo-clipboard": "~5.0.1",
|
18
|
+
"expo-font": "~11.10.2",
|
19
|
+
"expo-image-picker": "~14.7.1",
|
20
|
+
"expo-linking": "~6.2.2",
|
21
|
+
"expo-sharing": "~11.10.0",
|
22
|
+
"expo-sqlite": "~13.2.1",
|
23
|
+
"expo-status-bar": "~1.11.1",
|
24
|
+
"expo-system-ui": "~2.9.3",
|
25
|
+
"expo-web-browser": "~12.8.1",
|
26
|
+
"react-native": "^0.73.2",
|
27
|
+
"@react-native-async-storage/async-storage": "^1.21.0",
|
28
|
+
"react-native-big-list": "^1.6.1",
|
29
|
+
"react-native-blob-util": "^0.18.6",
|
30
|
+
"react-native-safe-area-context": "^4.8.2",
|
31
|
+
"react-native-screens": "~3.29.0",
|
32
|
+
"react-native-svg": "^14.1.0",
|
33
|
+
"react-native-webview": "^13.6.4",
|
34
|
+
"react-native-gesture-handler": "~2.14.0",
|
35
|
+
"react-native-reanimated": "~3.6.0",
|
36
|
+
"react-native-view-shot": "^3.8.0"
|
37
|
+
};
|
38
|
+
|
package/bin/index.js
CHANGED
@@ -33,4 +33,11 @@ program.command('generate-getTable')
|
|
33
33
|
require("./generate-tables")();
|
34
34
|
});
|
35
35
|
|
36
|
+
program.command('update')
|
37
|
+
.description('permet de mettre à jour les dépendences expo-ui de l\'application')
|
38
|
+
.action((src, options) => {
|
39
|
+
require("./update");
|
40
|
+
});
|
41
|
+
|
42
|
+
|
36
43
|
program.parse();
|
package/bin/update.js
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const projectRoot = process.cwd();
|
4
|
+
const {exec,writeFile} = require("@fto-consult/node-utils");
|
5
|
+
const dependencies = require("./create-app/dependencies");
|
6
|
+
const dependenciesArr = Object.keys(dependencies);
|
7
|
+
const dependenciesPath = path.resolve(__dirname,"create-app","dependencies.js")
|
8
|
+
const mainJSONPath = path.resolve(projectRoot,"package.json");
|
9
|
+
if(fs.existsSync(mainJSONPath)){
|
10
|
+
const packageObj = JSON.parse(fs.readFileSync(mainJSONPath));
|
11
|
+
const packageDev = typeof packageObj?.dependencies =="object" && packageObj?.dependencies || {};
|
12
|
+
const filterdDObj = {};
|
13
|
+
dependenciesArr.filter((v,index)=>{
|
14
|
+
if(!!packageDev[v]){
|
15
|
+
filterdDObj[v] = true;
|
16
|
+
return true;
|
17
|
+
}
|
18
|
+
return false;
|
19
|
+
});
|
20
|
+
const filteredDeps = Object.keys(filterdDObj);
|
21
|
+
if(filteredDeps.length){
|
22
|
+
const script = filteredDeps.join(" ");
|
23
|
+
exec(`npm install ${script}`,{projectRoot}).finally((i)=>{
|
24
|
+
exec(`npx expo install --fix`,{projectRoot}).finally(()=>{
|
25
|
+
const newPackageJS = JSON.parse(fs.readFileSync(mainJSONPath));
|
26
|
+
let hasChanged = false;
|
27
|
+
if(newPackageJS?.dependencies && typeof newPackageJS?.dependencies =="object"){
|
28
|
+
for(let i in dependencies){
|
29
|
+
const old = dependencies[i];
|
30
|
+
dependencies[i] = newPackageJS?.dependencies[i] || dependencies[i];
|
31
|
+
if(!hasChanged && dependencies[i] !== old){
|
32
|
+
hasChanged = true;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
if(hasChanged){
|
37
|
+
try {
|
38
|
+
writeFile(dependenciesPath,`
|
39
|
+
module.exports = ${JSON.stringify(dependencies,null,"\t")};
|
40
|
+
`)
|
41
|
+
} catch(e){
|
42
|
+
console.log(e," is generated error");
|
43
|
+
}
|
44
|
+
}
|
45
|
+
});
|
46
|
+
});
|
47
|
+
} else {
|
48
|
+
console.log("Aucune dépendence expo à mettre à jour");
|
49
|
+
}
|
50
|
+
} else {
|
51
|
+
console.error(`Le fichier ${mainJSONPath} de l'application est inexistant. impossible de mettre à jour les packages @fto-consult/expo-ui`)
|
52
|
+
}
|
package/package.json
CHANGED
@@ -1,111 +1,111 @@
|
|
1
|
-
{
|
2
|
-
"name": "@fto-consult/expo-ui",
|
3
|
-
"version": "8.
|
4
|
-
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
|
-
"scripts": {
|
6
|
-
"clear-npx-cache": "npx clear-npx-cache",
|
7
|
-
"publish1": "npm publish --access=public",
|
8
|
-
"unpublish": "npm -f unpublish @fto-consult/expo-ui",
|
9
|
-
"build-web": "",
|
10
|
-
"start": "npx expo start --dev --no-minify",
|
11
|
-
"start-d": "npx expo start -c --no-dev --no-minify",
|
12
|
-
"start-p": "npm run start-d",
|
13
|
-
"start-no-minify": "npx expo start --no-dev --minify",
|
14
|
-
"start-no-dev": "npx expo start --no-dev --minify",
|
15
|
-
"expo-start-client": "npx expo start --dev --no-minify --dev-client",
|
16
|
-
"start-m": "npx expo start - c--dev--no -minify",
|
17
|
-
"android": "npx expo start --android -c",
|
18
|
-
"ios": "npx expo start --ios",
|
19
|
-
"web": "npx expo start --web",
|
20
|
-
"web-c": "npx expo start --web -c",
|
21
|
-
"eject": "expo eject",
|
22
|
-
"emulator": "npm run android-emulator",
|
23
|
-
"web-server": "npx serve web-build",
|
24
|
-
"build-android": "eas build --clear-cache -p android --profile preview",
|
25
|
-
"build-android-local": "eas build --platform android --local",
|
26
|
-
"build-android-dist": "eas build --clear-cache -p android",
|
27
|
-
"build-ios": "eas build --clear-cache -p ios --profile preview",
|
28
|
-
"build-ios-dist": "eas build --clear-cache -p ios",
|
29
|
-
"install-apk": "adb -s emulator-5554 install myapp.apk",
|
30
|
-
"android-emulator": "emulator -avd EMULATOR",
|
31
|
-
"flipper": "npx cross-env METRO_SERVER_PORT=19000 E:\\Studies\\react-native\\debugger\\Flipper-win\\Flipper.exe",
|
32
|
-
"test:build": "electron-webpack && electron-builder --dir -c.compression=store -c.mac.identity=null",
|
33
|
-
"compile-electron": "webpack --env platform=electron",
|
34
|
-
"compile-electron-p": "webpack --config ./electron/webpack.config.js --mode=production",
|
35
|
-
"electron": "electron ./electron",
|
36
|
-
"logcat": "adb -d logcat com.ftc.apps.salite1:E > errors.txt",
|
37
|
-
"logcat-export": "adb -d logcat com.ftc.apps.salite1 *:S > logcat.txt",
|
38
|
-
"electron-c": "npm run compile-electron && npm run electron",
|
39
|
-
"electron-p": "npm run compile-electron-p && npm run electron",
|
40
|
-
"update-app-version": "node ./update-app-version.js",
|
41
|
-
"find-licenses": "node ./find-licenses.js",
|
42
|
-
"fix-dependencies": "expo-cli doctor --fix-dependencies",
|
43
|
-
"expo-fix": "npx expo install --fix",
|
44
|
-
"update-apexchart": "node ./bin/update-appex-chart.js",
|
45
|
-
"test-bin": "node ./bin/index.js",
|
46
|
-
"update-appexchart": "npm run update-apexchart",
|
47
|
-
"delete-node-modules": "rimraf ./**/node_modules",
|
48
|
-
"dev": "npx expo start --no-dev --minify -c",
|
49
|
-
"modifier-url-remote-git": "git remote set-url origin 'https://borispipo@github.com/borispipo/smart-eneo.git'",
|
50
|
-
"update-app": "expo @emotion/native@latest react-native-big-list@latest @pchmn/expo-material3-theme@latest @emotion/native@latest @react-navigation/stack react-native-blob-util @react-navigation/native@latest @react-navigation/native-stack@latest && npx expo install --fix",
|
51
|
-
"update": "npm i @fto-consult/node-utils@latest apexcharts@latest file-saver@latest google-libphonenumber@latest @fto-consult/common@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 websql@latest xlsx@latest react-native-web@latest react-dom@latest react-native-get-random-values@latest && npm run update-apexchart && npm run find-licenses"
|
52
|
-
},
|
53
|
-
"bin": {
|
54
|
-
"expo-ui": "./bin/index.js"
|
55
|
-
},
|
56
|
-
"repository": {
|
57
|
-
"type": "git",
|
58
|
-
"url": "git+https://github.com/borispipo/expo-ui.git"
|
59
|
-
},
|
60
|
-
"keywords": [
|
61
|
-
"Expo",
|
62
|
-
"React-Native"
|
63
|
-
],
|
64
|
-
"author": "Boris Fouomene",
|
65
|
-
"license": "ISC",
|
66
|
-
"bugs": {
|
67
|
-
"url": "https://github.com/borispipo/expo-ui/issues"
|
68
|
-
},
|
69
|
-
"homepage": "https://github.com/borispipo/expo-ui#readme",
|
70
|
-
"dependencies": {
|
71
|
-
"@emotion/react": "^11.11.1",
|
72
|
-
"@faker-js/faker": "^8.0.2",
|
73
|
-
"@fto-consult/common": "^4.
|
74
|
-
"@fto-consult/node-utils": "^1.4.7",
|
75
|
-
"apexcharts": "^3.45.2",
|
76
|
-
"commander": "^11.1.0",
|
77
|
-
"crypto-browserify": "^3.12.0",
|
78
|
-
"file-saver": "^2.0.5",
|
79
|
-
"google-libphonenumber": "^3.2.34",
|
80
|
-
"html2canvas": "^1.4.1",
|
81
|
-
"htmlparser2-without-node-native": "^3.9.2",
|
82
|
-
"is-plain-obj": "^4.1.0",
|
83
|
-
"js-base64": "^3.7.5",
|
84
|
-
"jsbarcode": "^3.11.6",
|
85
|
-
"prop-types": "^15.8.1",
|
86
|
-
"react": "^18.2.0",
|
87
|
-
"react-content-loader": "^6.2.1",
|
88
|
-
"react-dom": "^18.2.0",
|
89
|
-
"react-native-get-random-values": "^1.10.0",
|
90
|
-
"react-native-iphone-x-helper": "^1.3.1",
|
91
|
-
"react-native-mime-types": "^2.4.0",
|
92
|
-
"react-native-paper": "^5.12.1",
|
93
|
-
"react-native-paper-dates": "^0.21.7",
|
94
|
-
"react-native-web": "^0.19.10",
|
95
|
-
"react-virtuoso": "^4.6.2",
|
96
|
-
"readable-stream": "^4.5.2",
|
97
|
-
"sanitize-filename": "^1.6.3",
|
98
|
-
"sharp-cli": "^2.1.0",
|
99
|
-
"stream-browserify": "^3.0.0",
|
100
|
-
"tippy.js": "^6.3.7",
|
101
|
-
"websql": "^2.0.3",
|
102
|
-
"xlsx": "^0.18.5"
|
103
|
-
},
|
104
|
-
"devDependencies": {
|
105
|
-
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
106
|
-
"@expo/metro-config": "~0.17.1",
|
107
|
-
"@expo/webpack-config": "^19.0.1",
|
108
|
-
"babel-plugin-inline-dotenv": "^1.7.0",
|
109
|
-
"babel-plugin-module-resolver": "^5.0.0"
|
110
|
-
}
|
111
|
-
}
|
1
|
+
{
|
2
|
+
"name": "@fto-consult/expo-ui",
|
3
|
+
"version": "8.11.0",
|
4
|
+
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
|
+
"scripts": {
|
6
|
+
"clear-npx-cache": "npx clear-npx-cache",
|
7
|
+
"publish1": "npm publish --access=public",
|
8
|
+
"unpublish": "npm -f unpublish @fto-consult/expo-ui",
|
9
|
+
"build-web": "",
|
10
|
+
"start": "npx expo start --dev --no-minify",
|
11
|
+
"start-d": "npx expo start -c --no-dev --no-minify",
|
12
|
+
"start-p": "npm run start-d",
|
13
|
+
"start-no-minify": "npx expo start --no-dev --minify",
|
14
|
+
"start-no-dev": "npx expo start --no-dev --minify",
|
15
|
+
"expo-start-client": "npx expo start --dev --no-minify --dev-client",
|
16
|
+
"start-m": "npx expo start - c--dev--no -minify",
|
17
|
+
"android": "npx expo start --android -c",
|
18
|
+
"ios": "npx expo start --ios",
|
19
|
+
"web": "npx expo start --web",
|
20
|
+
"web-c": "npx expo start --web -c",
|
21
|
+
"eject": "expo eject",
|
22
|
+
"emulator": "npm run android-emulator",
|
23
|
+
"web-server": "npx serve web-build",
|
24
|
+
"build-android": "eas build --clear-cache -p android --profile preview",
|
25
|
+
"build-android-local": "eas build --platform android --local",
|
26
|
+
"build-android-dist": "eas build --clear-cache -p android",
|
27
|
+
"build-ios": "eas build --clear-cache -p ios --profile preview",
|
28
|
+
"build-ios-dist": "eas build --clear-cache -p ios",
|
29
|
+
"install-apk": "adb -s emulator-5554 install myapp.apk",
|
30
|
+
"android-emulator": "emulator -avd EMULATOR",
|
31
|
+
"flipper": "npx cross-env METRO_SERVER_PORT=19000 E:\\Studies\\react-native\\debugger\\Flipper-win\\Flipper.exe",
|
32
|
+
"test:build": "electron-webpack && electron-builder --dir -c.compression=store -c.mac.identity=null",
|
33
|
+
"compile-electron": "webpack --env platform=electron",
|
34
|
+
"compile-electron-p": "webpack --config ./electron/webpack.config.js --mode=production",
|
35
|
+
"electron": "electron ./electron",
|
36
|
+
"logcat": "adb -d logcat com.ftc.apps.salite1:E > errors.txt",
|
37
|
+
"logcat-export": "adb -d logcat com.ftc.apps.salite1 *:S > logcat.txt",
|
38
|
+
"electron-c": "npm run compile-electron && npm run electron",
|
39
|
+
"electron-p": "npm run compile-electron-p && npm run electron",
|
40
|
+
"update-app-version": "node ./update-app-version.js",
|
41
|
+
"find-licenses": "node ./find-licenses.js",
|
42
|
+
"fix-dependencies": "expo-cli doctor --fix-dependencies",
|
43
|
+
"expo-fix": "npx expo install --fix",
|
44
|
+
"update-apexchart": "node ./bin/update-appex-chart.js",
|
45
|
+
"test-bin": "node ./bin/index.js",
|
46
|
+
"update-appexchart": "npm run update-apexchart",
|
47
|
+
"delete-node-modules": "rimraf ./**/node_modules",
|
48
|
+
"dev": "npx expo start --no-dev --minify -c",
|
49
|
+
"modifier-url-remote-git": "git remote set-url origin 'https://borispipo@github.com/borispipo/smart-eneo.git'",
|
50
|
+
"update-app": "expo @emotion/native@latest react-native-big-list@latest @pchmn/expo-material3-theme@latest @emotion/native@latest @react-navigation/stack react-native-blob-util @react-navigation/native@latest @react-navigation/native-stack@latest && npx expo install --fix",
|
51
|
+
"update": "npm i @fto-consult/node-utils@latest apexcharts@latest file-saver@latest google-libphonenumber@latest @fto-consult/common@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 websql@latest xlsx@latest react-native-web@latest react-dom@latest react-native-get-random-values@latest && npm run update-apexchart && npm run find-licenses"
|
52
|
+
},
|
53
|
+
"bin": {
|
54
|
+
"expo-ui": "./bin/index.js"
|
55
|
+
},
|
56
|
+
"repository": {
|
57
|
+
"type": "git",
|
58
|
+
"url": "git+https://github.com/borispipo/expo-ui.git"
|
59
|
+
},
|
60
|
+
"keywords": [
|
61
|
+
"Expo",
|
62
|
+
"React-Native"
|
63
|
+
],
|
64
|
+
"author": "Boris Fouomene",
|
65
|
+
"license": "ISC",
|
66
|
+
"bugs": {
|
67
|
+
"url": "https://github.com/borispipo/expo-ui/issues"
|
68
|
+
},
|
69
|
+
"homepage": "https://github.com/borispipo/expo-ui#readme",
|
70
|
+
"dependencies": {
|
71
|
+
"@emotion/react": "^11.11.1",
|
72
|
+
"@faker-js/faker": "^8.0.2",
|
73
|
+
"@fto-consult/common": "^4.13.0",
|
74
|
+
"@fto-consult/node-utils": "^1.4.7",
|
75
|
+
"apexcharts": "^3.45.2",
|
76
|
+
"commander": "^11.1.0",
|
77
|
+
"crypto-browserify": "^3.12.0",
|
78
|
+
"file-saver": "^2.0.5",
|
79
|
+
"google-libphonenumber": "^3.2.34",
|
80
|
+
"html2canvas": "^1.4.1",
|
81
|
+
"htmlparser2-without-node-native": "^3.9.2",
|
82
|
+
"is-plain-obj": "^4.1.0",
|
83
|
+
"js-base64": "^3.7.5",
|
84
|
+
"jsbarcode": "^3.11.6",
|
85
|
+
"prop-types": "^15.8.1",
|
86
|
+
"react": "^18.2.0",
|
87
|
+
"react-content-loader": "^6.2.1",
|
88
|
+
"react-dom": "^18.2.0",
|
89
|
+
"react-native-get-random-values": "^1.10.0",
|
90
|
+
"react-native-iphone-x-helper": "^1.3.1",
|
91
|
+
"react-native-mime-types": "^2.4.0",
|
92
|
+
"react-native-paper": "^5.12.1",
|
93
|
+
"react-native-paper-dates": "^0.21.7",
|
94
|
+
"react-native-web": "^0.19.10",
|
95
|
+
"react-virtuoso": "^4.6.2",
|
96
|
+
"readable-stream": "^4.5.2",
|
97
|
+
"sanitize-filename": "^1.6.3",
|
98
|
+
"sharp-cli": "^2.1.0",
|
99
|
+
"stream-browserify": "^3.0.0",
|
100
|
+
"tippy.js": "^6.3.7",
|
101
|
+
"websql": "^2.0.3",
|
102
|
+
"xlsx": "^0.18.5"
|
103
|
+
},
|
104
|
+
"devDependencies": {
|
105
|
+
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
106
|
+
"@expo/metro-config": "~0.17.1",
|
107
|
+
"@expo/webpack-config": "^19.0.1",
|
108
|
+
"babel-plugin-inline-dotenv": "^1.7.0",
|
109
|
+
"babel-plugin-module-resolver": "^5.0.0"
|
110
|
+
}
|
111
|
+
}
|
@@ -8,35 +8,27 @@ import View from "$ecomponents/View";
|
|
8
8
|
const BarcodeGeneratorComponent = forwardRef(({value,format,id,errorText,testID,onReady,text,flat,width,height,displayValue,fontOptions,font,textAlign,textPosition,textMargin,fontSize,background,lineColor,margin,marginTop,marginBottom,marginLeft,marginRight,valid},ref)=>{
|
9
9
|
testID = defaultStr(testID,"RN_GeneratorWebSVG");
|
10
10
|
const idRef = useRef(defaultStr(id,uniqid("bar-code-generator-web")));
|
11
|
+
const innerRef = useRef(null);
|
11
12
|
const error = React.isValidElement(errorText)? errorText : null;
|
12
13
|
if(error){
|
13
14
|
displayValue = false;
|
14
15
|
}
|
16
|
+
const supportedProps = {format,width,flat,text,height,displayValue,fontOptions,font,textAlign,textPosition,textMargin,fontSize,background,lineColor,margin,marginTop,marginBottom,marginLeft,marginRight};
|
15
17
|
useEffect(()=>{
|
16
18
|
const element = document.querySelector(`#${idRef.current}`);
|
17
19
|
if(!element) return;
|
18
20
|
if(!error){
|
19
21
|
try {
|
20
|
-
JsBarcode(`#${idRef.current}
|
22
|
+
JsBarcode(`#${idRef.current}`,value,supportedProps);
|
21
23
|
if(typeof onReady ==="function"){
|
22
|
-
|
23
|
-
onReady();
|
24
|
-
},50);
|
24
|
+
onReady();
|
25
25
|
}
|
26
|
-
} catch(e){
|
27
|
-
}
|
26
|
+
} catch(e){}
|
28
27
|
}
|
29
|
-
},[value,error,format,
|
30
|
-
const jsProps = {};
|
31
|
-
const supportedProps = {value,format,width,flat,text,height,displayValue,fontOptions,font,textAlign,textPosition,textMargin,fontSize,background,lineColor,margin,marginTop,marginBottom,marginLeft,marginRight};
|
32
|
-
Object.keys(supportedProps).map(key=>{
|
33
|
-
if(supportedProps[key] !== undefined){
|
34
|
-
jsProps[`jsbarcode-${key.toLowerCase()}`] = String(supportedProps[key]);
|
35
|
-
}
|
36
|
-
});
|
28
|
+
},[value,error,format,width,height,displayValue,flat,text,fontOptions,font,textAlign,textPosition,textMargin,fontSize,background,lineColor,margin,marginTop,marginBottom,marginLeft,marginRight])
|
37
29
|
if(error) return error;
|
38
30
|
return <View style={[{alignSelf:'center'}]} ref={ref}>
|
39
|
-
<
|
31
|
+
<canvas id={`${idRef.current}`} data-test-id={`${testID}`} className="bar-code-generator-svg"/>
|
40
32
|
</View>
|
41
33
|
});
|
42
34
|
|
@@ -16,7 +16,7 @@ const BarcodeGeneratorComponent = forwardRef(({width,height,lineColor,errorText,
|
|
16
16
|
>{child}</Label> : null;
|
17
17
|
useEffect(()=>{
|
18
18
|
if(typeof onReady =='function'){
|
19
|
-
|
19
|
+
onReady();
|
20
20
|
}
|
21
21
|
},[width,height,lineColor,bars,value,format,id,testID,text,flat,displayValue,fontOptions,font,textAlign,textPosition,textMargin,fontSize,backgroun,margin,marginTop,marginBottom,marginLeft,marginRight])
|
22
22
|
containerProps = Object.assign({},containerProps);
|
@@ -28,13 +28,12 @@ const BarcodeGenerator = forwardRef(({
|
|
28
28
|
background,
|
29
29
|
dataURLOptions,
|
30
30
|
id,
|
31
|
+
onReady,
|
31
32
|
...rest
|
32
33
|
},ref) => {
|
33
34
|
dataURLOptions = defaultObj(dataURLOptions);
|
34
35
|
testID = defaultStr(testID,"RNBarcodeGenerator");
|
35
36
|
const innerRef = useRef(null);
|
36
|
-
const isReadyRef = useRef(false);
|
37
|
-
const setReady = ()=> isReadyRef.current = true;
|
38
37
|
const style = theme.flattenStyle(cStyle);
|
39
38
|
const idRef = useRef(defaultStr(id,uniqid("bar-code-generator-web")));
|
40
39
|
background = theme.Colors.isValid(background) ? background : style.backgroundColor = theme.Colors.isValid(style.backgroundColor)? style.backgroundColor : '#ffffff';
|
@@ -121,44 +120,46 @@ const BarcodeGenerator = forwardRef(({
|
|
121
120
|
}
|
122
121
|
}, [value, width, height, format, lineColor, maxWidth]);
|
123
122
|
useEffect(()=>{
|
124
|
-
if(autoConvertToDataURL === true){
|
123
|
+
if(true || autoConvertToDataURL === true){
|
125
124
|
toDataURL();
|
126
125
|
}
|
127
126
|
},[format,value,width,height,lineColor])
|
128
127
|
const toDataURL = ()=>{
|
129
128
|
return new Promise((resolve,reject)=>{
|
130
129
|
const cb2 = (x, y, width, height) => {
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
});
|
147
|
-
}
|
148
|
-
if(!isReadyRef.current){
|
149
|
-
return setTimeout(cb,50);
|
150
|
-
}
|
151
|
-
return cb();
|
130
|
+
return captureRef(innerRef.current,extendObj({},{
|
131
|
+
quality: 1,
|
132
|
+
format: 'png',
|
133
|
+
result : "data-uri",
|
134
|
+
width,
|
135
|
+
height,
|
136
|
+
},dataURLOptions)).then((r)=>{
|
137
|
+
if(isDataURL(r) && typeof onConvertToDataURL =="function"){
|
138
|
+
onConvertToDataURL({dataURL:r});
|
139
|
+
}
|
140
|
+
resolve({dataURL:r,width,height});
|
141
|
+
}).catch((e)=>{
|
142
|
+
console.log(e," is capturing data url");
|
143
|
+
reject(e);
|
144
|
+
});
|
152
145
|
};
|
153
146
|
if(!isMobileNative() && typeof document !=="undefined" && typeof document?.querySelector =='function'){
|
154
|
-
const
|
155
|
-
if(
|
156
|
-
|
157
|
-
|
147
|
+
const canvas = document.querySelector(`#${idRef.current}`);
|
148
|
+
if(canvas){
|
149
|
+
if(typeof canvas?.toDataURL =='function'){
|
150
|
+
return resolve(canvas.toDataURL());
|
151
|
+
}
|
152
|
+
} else {
|
153
|
+
try {
|
154
|
+
const {width,height} = canvas?.getBoundingClientRect();
|
155
|
+
return cb2(undefined,undefined,width,height);
|
156
|
+
} catch(e){
|
157
|
+
reject(e);
|
158
|
+
}
|
158
159
|
}
|
159
160
|
}
|
160
161
|
return innerRef.current?.measureInWindow(cb2);
|
161
|
-
})
|
162
|
+
});
|
162
163
|
}
|
163
164
|
return (<Generator
|
164
165
|
{...rest}
|
@@ -166,7 +167,11 @@ const BarcodeGenerator = forwardRef(({
|
|
166
167
|
{error?.toString()}
|
167
168
|
</Label>: null}
|
168
169
|
id = {idRef.current}
|
169
|
-
onReady = {
|
170
|
+
onReady = {()=>{
|
171
|
+
if(typeof onReady =="function"){
|
172
|
+
return onReady({toDataURL});
|
173
|
+
}
|
174
|
+
}}
|
170
175
|
value = {value}
|
171
176
|
bars = {bars}
|
172
177
|
format = {format}
|
@@ -1,12 +1,15 @@
|
|
1
1
|
import {default as Scanner} from "./Scanner";
|
2
2
|
import {default as Generator} from "./Generator";
|
3
3
|
import {default as Designer} from "./Designer";
|
4
|
+
import { generate } from "./utils";
|
4
5
|
export * from "./Scanner";
|
5
6
|
export * from "./Generator";
|
6
7
|
export * from "./Designer";
|
8
|
+
export * from "./utils";
|
7
9
|
|
8
10
|
Scanner.Generator = Generator;
|
9
11
|
Scanner.Designer = Designer;
|
12
|
+
Scanner.generate = generate;
|
10
13
|
|
11
14
|
export default Scanner;
|
12
15
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
import {defaultNumber,isNonNullString} from "$cutils";
|
3
|
+
import Preloader from "$preloader";
|
4
|
+
import JsBarcode from "jsbarcode";
|
5
|
+
|
6
|
+
/*** permet de generer une liste des codes barres à partir des props passés en paramètre
|
7
|
+
*/
|
8
|
+
export function generate ({startSequence,onFinish,barcodeTemplate,barcodeOptions,endSequence,generate}){
|
9
|
+
startSequence = Math.ceil(defaultNumber(startSequence,1));
|
10
|
+
endSequence = Math.ceil(defaultNumber(endSequence,startSequence+1));
|
11
|
+
if(startSequence > endSequence) {
|
12
|
+
return Promise.reject({
|
13
|
+
message : `Impossible de généner les codes barres car la séquence de début ${startSequence} est supérieure à la sequence de fin ${endSequence}`
|
14
|
+
});
|
15
|
+
}
|
16
|
+
const promises = [],data = [];;
|
17
|
+
barcodeOptions = defaultObj(barcodeOptions);
|
18
|
+
delete barcodeOptions.value;
|
19
|
+
delete barcodeOptions.text;
|
20
|
+
const length = (endSequence-startSequence)+1;
|
21
|
+
const prefix = `Génération de ${length.formatNumber()} code barres`;
|
22
|
+
Preloader.open(`${prefix}....`);
|
23
|
+
generate = typeof generate =='function'? generate : x=>undefined;
|
24
|
+
return new Promise((resolve,reject)=>{
|
25
|
+
setTimeout(()=>{
|
26
|
+
for(let sequence=startSequence;sequence<=endSequence;sequence++){
|
27
|
+
promises.push(new Promise((resolve)=>{
|
28
|
+
const canvas = document.createElement('canvas');
|
29
|
+
const b = generate({sequence,template:barcodeTemplate,barcodeTemplate});
|
30
|
+
const barcode = isNonNullString(b)? b : defaultStr(barcodeTemplate);//.replaceAll("{sequence}",sequence)
|
31
|
+
if(barcode){
|
32
|
+
Preloader.open(`${prefix} [${barcode}]...`)
|
33
|
+
try {
|
34
|
+
JsBarcode(canvas,barcode,barcodeOptions);
|
35
|
+
const dataURL = canvas.toDataURL();
|
36
|
+
const ret = {barcode,dataURL};
|
37
|
+
data.push(ret)
|
38
|
+
resolve(ret)
|
39
|
+
} catch(e){
|
40
|
+
resolve({error:e})
|
41
|
+
}
|
42
|
+
} else {
|
43
|
+
resolve({message:`Invalid barcode for sequence ${sequence}`,sequence,barcode})
|
44
|
+
}
|
45
|
+
}));
|
46
|
+
}
|
47
|
+
return Promise.all(promises).then(()=>{
|
48
|
+
resolve(data);
|
49
|
+
}).catch((e)=>{
|
50
|
+
console.log(e," generation barcode");
|
51
|
+
reject(e);
|
52
|
+
}).finally(Preloader.close);
|
53
|
+
},500);
|
54
|
+
});
|
55
|
+
}
|