@fto-consult/expo-ui 8.72.0 → 8.73.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/bin/create-app/dependencies.js +3 -3
- package/package.json +4 -4
- package/src/components/BottomSheet/Sheet.js +0 -6
- package/src/components/Datagrid/Accordion/index.js +3 -3
- package/src/components/Dialog/Dialog.js +5 -2
- package/src/components/Dropdown/index.js +35 -23
- package/src/components/Form/Fields/SelectField.js +1 -1
- package/src/components/Form/Fields/SelectTableData/Component.js +23 -6
- package/src/components/Form/utils/FormsManager.js +11 -5
- package/src/components/List/hooks.js +2 -2
- package/src/components/Menu/Menu.js +5 -3
- package/src/layouts/Screen/TableData.js +1 -2
- package/src/media/Assets/utils.js +9 -2
- package/src/pdf/Reader/index.js +6 -0
- package/src/pdf/Reader/index.web.js +16 -173
- package/src/pdf/Reader/index.web.old.js +178 -0
- package/src/pdf/Reader/web/Viewer.js +20 -0
- package/src/pdf/Reader/web/script.js +334 -0
- package/src/screens/Help/openLibraries.js +5 -5
- package/src/table-data/importer/parser.js +1824 -0
- package/src/table-data/importer/run.js +0 -1
@@ -1,178 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
let Icon = require("$ecomponents/Icon")
|
4
|
-
require("./styles.css")
|
5
|
-
let PDFObject = require("pdfobject")
|
6
|
-
let {MenuButton} = require("$ui")
|
7
|
-
let isMSE = //checkEdge ? false :
|
8
|
-
window.navigator && typeof window.navigator.msSaveOrOpenBlob == "function" ? true : false;
|
9
|
-
class PDFViewer extends APP.Component {
|
10
|
-
constructor(props){
|
11
|
-
super(props);
|
12
|
-
APP.extend(this._events,{
|
13
|
-
resize : this.resetPos.bind(this)
|
14
|
-
})
|
15
|
-
this.autobind();
|
16
|
-
}
|
1
|
+
import React from "$react";
|
2
|
+
import DialogProvider from "$ecomponents/Dialog/Provider";
|
17
3
|
|
18
|
-
|
19
|
-
super.componentDidMount();
|
20
|
-
this.updatePdfContent();
|
21
|
-
window.addEventListener('resize',this._events.resize, true)
|
22
|
-
this.resetPos();
|
23
|
-
}
|
24
|
-
resetPos (){
|
25
|
-
if(!this._isMounted()) return;
|
26
|
-
let pdfWrap = document.getElementById(this.pdfViewerWrapperDomId);
|
27
|
-
if(isDOMElement(pdfWrap)){
|
28
|
-
let parent = pdfWrap.parentNode;
|
29
|
-
let mP = pdfWrap.closest(".dialog.md-dialog-container");
|
30
|
-
if(isDOMElement(parent) && isDOMElement(mP)){
|
31
|
-
let maxHeight = mezr.height(parent);
|
32
|
-
let maxH2 = mezr.height(mP);
|
33
|
-
let min = Math.min(maxHeight,maxH2);
|
34
|
-
if(min == 0){
|
35
|
-
min = "100%";
|
36
|
-
} else min = min+"px";
|
37
|
-
pdfWrap.style.height = min;
|
38
|
-
}
|
39
|
-
}
|
40
|
-
}
|
4
|
+
let dialogRef = null;
|
41
5
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
componentWillUnmount(){
|
51
|
-
super.componentWillUnmount();
|
52
|
-
this.dialogRef = undefined;
|
53
|
-
window.removeEventListener('resize',this._events.resize, true)
|
54
|
-
this.clearEvents();
|
55
|
-
}
|
56
|
-
viewCapacitor (){
|
57
|
-
let f = window.PreviewAnyFile || (cordova && cordova.plugins.PreviewAnyFile);
|
58
|
-
if(f && f.preview){
|
59
|
-
f = f.preview;
|
60
|
-
let {file} = this.props;
|
61
|
-
APP.FILE.getCapacitorPDFromDataURL({content:file,fileName:this.props.fileName,success:({path})=>{
|
62
|
-
if(isFunction(f)){
|
63
|
-
f(
|
64
|
-
path,
|
65
|
-
function(win){},
|
66
|
-
function(err){
|
67
|
-
console.log(err," pdf viewer in cap android ios")
|
68
|
-
}
|
69
|
-
)
|
70
|
-
}
|
71
|
-
}})
|
72
|
-
}
|
73
|
-
}
|
74
|
-
updatePdfContent(){
|
75
|
-
let file = this.props.file;
|
76
|
-
if (isMSE) {
|
77
|
-
let b64 = dataURLToBase64(file);
|
78
|
-
if(b64){
|
79
|
-
var byteCharacters = atob(b64);
|
80
|
-
var byteNumbers = new Array(byteCharacters.length);
|
81
|
-
for (var i = 0; i < byteCharacters.length; i++) {
|
82
|
-
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
83
|
-
}
|
84
|
-
var byteArray = new Uint8Array(byteNumbers);
|
85
|
-
var blob = new Blob([byteArray], {
|
86
|
-
type: 'application/pdf'
|
87
|
-
});
|
88
|
-
return window.navigator.msSaveOrOpenBlob(blob, defaultStr(this.props.title,'données-impr')+".pdf");
|
89
|
-
}
|
90
|
-
return null;
|
91
|
-
}
|
92
|
-
if(isElectron()){
|
93
|
-
return ELECTRON.PRINTER.preview({
|
94
|
-
content:this.props.file,
|
95
|
-
fileName : this.props.fileName,
|
96
|
-
fileExtension : 'pdf',
|
97
|
-
});
|
98
|
-
}
|
99
|
-
if(isCapacitor(true)){
|
100
|
-
return this.viewCapacitor();
|
101
|
-
}
|
102
|
-
let dom = document.getElementById(this.pdfViewerWrapperDomId);
|
103
|
-
if(isDOMElement(dom)){
|
104
|
-
try {
|
105
|
-
this.pdfInstance = PDFObject.embed(file,dom);
|
106
|
-
} catch (e){
|
107
|
-
console.log(e,' error on loading pdf file')
|
108
|
-
}
|
109
|
-
}
|
110
|
-
}
|
111
|
-
UNSAFE_componentWillReceiveProps(nexProps,prevProps){
|
112
|
-
if(nexProps.file && nexProps.file != this.state.file){
|
113
|
-
this._pageNumber = 1;
|
114
|
-
}
|
115
|
-
}
|
116
|
-
onPrint (args){
|
117
|
-
console.log(args,' was printed');
|
118
|
-
}
|
119
|
-
getPrintSettings(){
|
120
|
-
return defaultObj(this.props.printProps,this.props.printOptions);
|
121
|
-
}
|
122
|
-
render (){
|
123
|
-
if(isMSE || isElectron() || isCapacitor(true)) return null;
|
124
|
-
let {file,dialogProps,title,onPrint,printProps,printOptions,fileName,...rest} = this.props;
|
125
|
-
dialogProps = defaultObj(dialogProps);
|
126
|
-
dialogProps.contentProps = defaultObj(dialogProps.contentProps)
|
127
|
-
dialogProps.contentProps.id = defaultStr(dialogProps.contentProps.id,this.dialogWrapperParentId,uniqid('dialog-content-wrp-par'))
|
128
|
-
this.dialogWrapperParentId = dialogProps.contentProps.id;
|
129
|
-
dialogProps.contentProps.className = classNames(dialogProps.contentProps.className,'no-padding pdf-viewer-dialog-content')
|
130
|
-
dialogProps.className = classNames(dialogProps.className,'pdf-viewer-dialog')
|
131
|
-
dialogProps.title = defaultStr(dialogProps.title,title)
|
132
|
-
rest = defaultObj(rest)
|
133
|
-
let {actions} = dialogProps;
|
134
|
-
let acts = []
|
135
|
-
let mIts = []
|
136
|
-
if(mIts.length > 0){
|
137
|
-
acts.push(
|
138
|
-
<MenuButton
|
139
|
-
menuItems = {mIts}
|
140
|
-
flat
|
141
|
-
id = {uniqid("view-page-id-butt")}
|
142
|
-
>
|
143
|
-
{<Icon name="material-more_vert" title={"pages"}/>}
|
144
|
-
</MenuButton>
|
145
|
-
)
|
146
|
-
}
|
147
|
-
Object.map(actions,(a,i)=>{
|
148
|
-
if(!a) return;
|
149
|
-
acts.push(a);
|
150
|
-
})
|
151
|
-
this.pdfViewerWrapperDomId = defaultStr(this.pdfViewerWrapperDomId,uniqid("pdf-viewer-wrapper-id"))
|
152
|
-
return (
|
153
|
-
<Dialog
|
154
|
-
key = {_uniqid("dialog-pdf-viewer-key-id")}
|
155
|
-
{...dialogProps}
|
156
|
-
ref = {(el)=>{
|
157
|
-
if(el){
|
158
|
-
this.dialogRef = el;
|
159
|
-
}
|
160
|
-
}}
|
161
|
-
fullPage
|
162
|
-
visible
|
163
|
-
actions = {acts}
|
164
|
-
>
|
165
|
-
<div className="pdf-viewer-wrapper w100 h100" id={this.pdfViewerWrapperDomId}></div>
|
166
|
-
</Dialog>
|
167
|
-
);
|
168
|
-
}
|
6
|
+
export default function WebPDFReader(){
|
7
|
+
dialogRef = React.useRef(null);
|
8
|
+
return <>
|
9
|
+
<DialogProvider
|
10
|
+
ref = {dialogRef}
|
11
|
+
responsive = {false}
|
12
|
+
/>
|
13
|
+
</>
|
169
14
|
}
|
170
15
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
/*** méthode appelée lorsque le document est imprimé */
|
177
|
-
onPrint : PropTypes.func,
|
16
|
+
export const open = (props)=>{
|
17
|
+
if(!dialogRef || !dialogRef?.current) return;
|
18
|
+
DialogProvider.open({
|
19
|
+
...props,
|
20
|
+
},dialogRef.current);
|
178
21
|
}
|
@@ -0,0 +1,178 @@
|
|
1
|
+
/**@see : https://github.com/pipwerks/PDFObject#readme */
|
2
|
+
let {Dialog} = require("$ecomponents/Dialog")
|
3
|
+
let Icon = require("$ecomponents/Icon")
|
4
|
+
require("./styles.css")
|
5
|
+
let PDFObject = require("pdfobject")
|
6
|
+
let {MenuButton} = require("$ui")
|
7
|
+
let isMSE = //checkEdge ? false :
|
8
|
+
window.navigator && typeof window.navigator.msSaveOrOpenBlob == "function" ? true : false;
|
9
|
+
class PDFViewer extends APP.Component {
|
10
|
+
constructor(props){
|
11
|
+
super(props);
|
12
|
+
APP.extend(this._events,{
|
13
|
+
resize : this.resetPos.bind(this)
|
14
|
+
})
|
15
|
+
this.autobind();
|
16
|
+
}
|
17
|
+
|
18
|
+
componentDidMount(){
|
19
|
+
super.componentDidMount();
|
20
|
+
this.updatePdfContent();
|
21
|
+
window.addEventListener('resize',this._events.resize, true)
|
22
|
+
this.resetPos();
|
23
|
+
}
|
24
|
+
resetPos (){
|
25
|
+
if(!this._isMounted()) return;
|
26
|
+
let pdfWrap = document.getElementById(this.pdfViewerWrapperDomId);
|
27
|
+
if(isDOMElement(pdfWrap)){
|
28
|
+
let parent = pdfWrap.parentNode;
|
29
|
+
let mP = pdfWrap.closest(".dialog.md-dialog-container");
|
30
|
+
if(isDOMElement(parent) && isDOMElement(mP)){
|
31
|
+
let maxHeight = mezr.height(parent);
|
32
|
+
let maxH2 = mezr.height(mP);
|
33
|
+
let min = Math.min(maxHeight,maxH2);
|
34
|
+
if(min == 0){
|
35
|
+
min = "100%";
|
36
|
+
} else min = min+"px";
|
37
|
+
pdfWrap.style.height = min;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
componentDidUpdate(){
|
43
|
+
super.componentDidUpdate();
|
44
|
+
if(this.dialogRef && this.dialogRef.open){
|
45
|
+
this.dialogRef.open();
|
46
|
+
}
|
47
|
+
this.updatePdfContent()
|
48
|
+
this.resetPos();
|
49
|
+
}
|
50
|
+
componentWillUnmount(){
|
51
|
+
super.componentWillUnmount();
|
52
|
+
this.dialogRef = undefined;
|
53
|
+
window.removeEventListener('resize',this._events.resize, true)
|
54
|
+
this.clearEvents();
|
55
|
+
}
|
56
|
+
viewCapacitor (){
|
57
|
+
let f = window.PreviewAnyFile || (cordova && cordova.plugins.PreviewAnyFile);
|
58
|
+
if(f && f.preview){
|
59
|
+
f = f.preview;
|
60
|
+
let {file} = this.props;
|
61
|
+
APP.FILE.getCapacitorPDFromDataURL({content:file,fileName:this.props.fileName,success:({path})=>{
|
62
|
+
if(isFunction(f)){
|
63
|
+
f(
|
64
|
+
path,
|
65
|
+
function(win){},
|
66
|
+
function(err){
|
67
|
+
console.log(err," pdf viewer in cap android ios")
|
68
|
+
}
|
69
|
+
)
|
70
|
+
}
|
71
|
+
}})
|
72
|
+
}
|
73
|
+
}
|
74
|
+
updatePdfContent(){
|
75
|
+
let file = this.props.file;
|
76
|
+
if (isMSE) {
|
77
|
+
let b64 = dataURLToBase64(file);
|
78
|
+
if(b64){
|
79
|
+
var byteCharacters = atob(b64);
|
80
|
+
var byteNumbers = new Array(byteCharacters.length);
|
81
|
+
for (var i = 0; i < byteCharacters.length; i++) {
|
82
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
83
|
+
}
|
84
|
+
var byteArray = new Uint8Array(byteNumbers);
|
85
|
+
var blob = new Blob([byteArray], {
|
86
|
+
type: 'application/pdf'
|
87
|
+
});
|
88
|
+
return window.navigator.msSaveOrOpenBlob(blob, defaultStr(this.props.title,'données-impr')+".pdf");
|
89
|
+
}
|
90
|
+
return null;
|
91
|
+
}
|
92
|
+
if(isElectron()){
|
93
|
+
return ELECTRON.PRINTER.preview({
|
94
|
+
content:this.props.file,
|
95
|
+
fileName : this.props.fileName,
|
96
|
+
fileExtension : 'pdf',
|
97
|
+
});
|
98
|
+
}
|
99
|
+
if(isCapacitor(true)){
|
100
|
+
return this.viewCapacitor();
|
101
|
+
}
|
102
|
+
let dom = document.getElementById(this.pdfViewerWrapperDomId);
|
103
|
+
if(isDOMElement(dom)){
|
104
|
+
try {
|
105
|
+
this.pdfInstance = PDFObject.embed(file,dom);
|
106
|
+
} catch (e){
|
107
|
+
console.log(e,' error on loading pdf file')
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
UNSAFE_componentWillReceiveProps(nexProps,prevProps){
|
112
|
+
if(nexProps.file && nexProps.file != this.state.file){
|
113
|
+
this._pageNumber = 1;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
onPrint (args){
|
117
|
+
console.log(args,' was printed');
|
118
|
+
}
|
119
|
+
getPrintSettings(){
|
120
|
+
return defaultObj(this.props.printProps,this.props.printOptions);
|
121
|
+
}
|
122
|
+
render (){
|
123
|
+
if(isMSE || isElectron() || isCapacitor(true)) return null;
|
124
|
+
let {file,dialogProps,title,onPrint,printProps,printOptions,fileName,...rest} = this.props;
|
125
|
+
dialogProps = defaultObj(dialogProps);
|
126
|
+
dialogProps.contentProps = defaultObj(dialogProps.contentProps)
|
127
|
+
dialogProps.contentProps.id = defaultStr(dialogProps.contentProps.id,this.dialogWrapperParentId,uniqid('dialog-content-wrp-par'))
|
128
|
+
this.dialogWrapperParentId = dialogProps.contentProps.id;
|
129
|
+
dialogProps.contentProps.className = classNames(dialogProps.contentProps.className,'no-padding pdf-viewer-dialog-content')
|
130
|
+
dialogProps.className = classNames(dialogProps.className,'pdf-viewer-dialog')
|
131
|
+
dialogProps.title = defaultStr(dialogProps.title,title)
|
132
|
+
rest = defaultObj(rest)
|
133
|
+
let {actions} = dialogProps;
|
134
|
+
let acts = []
|
135
|
+
let mIts = []
|
136
|
+
if(mIts.length > 0){
|
137
|
+
acts.push(
|
138
|
+
<MenuButton
|
139
|
+
menuItems = {mIts}
|
140
|
+
flat
|
141
|
+
id = {uniqid("view-page-id-butt")}
|
142
|
+
>
|
143
|
+
{<Icon name="material-more_vert" title={"pages"}/>}
|
144
|
+
</MenuButton>
|
145
|
+
)
|
146
|
+
}
|
147
|
+
Object.map(actions,(a,i)=>{
|
148
|
+
if(!a) return;
|
149
|
+
acts.push(a);
|
150
|
+
})
|
151
|
+
this.pdfViewerWrapperDomId = defaultStr(this.pdfViewerWrapperDomId,uniqid("pdf-viewer-wrapper-id"))
|
152
|
+
return (
|
153
|
+
<Dialog
|
154
|
+
key = {_uniqid("dialog-pdf-viewer-key-id")}
|
155
|
+
{...dialogProps}
|
156
|
+
ref = {(el)=>{
|
157
|
+
if(el){
|
158
|
+
this.dialogRef = el;
|
159
|
+
}
|
160
|
+
}}
|
161
|
+
fullPage
|
162
|
+
visible
|
163
|
+
actions = {acts}
|
164
|
+
>
|
165
|
+
<div className="pdf-viewer-wrapper w100 h100" id={this.pdfViewerWrapperDomId}></div>
|
166
|
+
</Dialog>
|
167
|
+
);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
module.exports = PDFViewer;
|
172
|
+
PDFViewer.PDFObject = PDFObject;
|
173
|
+
|
174
|
+
PDFViewer.propTypes = {
|
175
|
+
...Document.propTypes,
|
176
|
+
/*** méthode appelée lorsque le document est imprimé */
|
177
|
+
onPrint : PropTypes.func,
|
178
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React from "$react";
|
2
|
+
import View from "$ecomponents/View";
|
3
|
+
export default function PdfViewerWeb(){
|
4
|
+
return <View testID="RN_PDF_WEBVIEW_COMPONENT">
|
5
|
+
<div id="viewerContainer">
|
6
|
+
<div id="viewer" class="pdfViewer"></div>
|
7
|
+
</div>
|
8
|
+
<div id="loadingBar">
|
9
|
+
<div class="progress"></div>
|
10
|
+
<div class="glimmer"></div>
|
11
|
+
</div>
|
12
|
+
<footer>
|
13
|
+
<button class="toolbarButton pageUp" title="Previous Page" id="previous"></button>
|
14
|
+
<button class="toolbarButton pageDown" title="Next Page" id="next"></button>
|
15
|
+
<input type="number" id="pageNumber" class="toolbarField pageNumber" value="1" size="4" min="1"/>
|
16
|
+
<button class="toolbarButton zoomOut" title="Zoom Out" id="zoomOut"></button>
|
17
|
+
<button class="toolbarButton zoomIn" title="Zoom In" id="zoomIn"></button>
|
18
|
+
</footer>
|
19
|
+
</View>
|
20
|
+
}
|