@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
@@ -0,0 +1,334 @@
|
|
1
|
+
const pdfjsLib = require("pdfjs-dist/build/pdf.min.mjs");
|
2
|
+
|
3
|
+
const MAX_CANVAS_PIXELS = 0; // CSS-only zooming.
|
4
|
+
const TEXT_LAYER_MODE = 0; // DISABLE
|
5
|
+
const MAX_IMAGE_SIZE = 1024 * 1024;
|
6
|
+
const CMAP_URL = "../../node_modules/pdfjs-dist/cmaps/";
|
7
|
+
const CMAP_PACKED = true;
|
8
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = "../../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
|
9
|
+
const DEFAULT_SCALE_DELTA = 1.1;
|
10
|
+
const MIN_SCALE = 0.25;
|
11
|
+
const MAX_SCALE = 10.0;
|
12
|
+
const DEFAULT_SCALE_VALUE = "auto";
|
13
|
+
|
14
|
+
const PDFViewerApplication = {
|
15
|
+
pdfLoadingTask: null,
|
16
|
+
pdfDocument: null,
|
17
|
+
pdfViewer: null,
|
18
|
+
pdfHistory: null,
|
19
|
+
pdfLinkService: null,
|
20
|
+
eventBus: null,
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Opens PDF document specified by URL.
|
24
|
+
* @returns {Promise} - Returns the promise, which is resolved when document
|
25
|
+
* is opened.
|
26
|
+
*/
|
27
|
+
open(params) {
|
28
|
+
if (this.pdfLoadingTask) {
|
29
|
+
// We need to destroy already opened document
|
30
|
+
return this.close().then(
|
31
|
+
function () {
|
32
|
+
// ... and repeat the open() call.
|
33
|
+
return this.open(params);
|
34
|
+
}.bind(this)
|
35
|
+
);
|
36
|
+
}
|
37
|
+
const url = params.url;
|
38
|
+
const self = this;
|
39
|
+
this.setTitleUsingUrl(url);
|
40
|
+
|
41
|
+
// Loading document.
|
42
|
+
const loadingTask = pdfjsLib.getDocument({
|
43
|
+
url,
|
44
|
+
maxImageSize: MAX_IMAGE_SIZE,
|
45
|
+
cMapUrl: CMAP_URL,
|
46
|
+
cMapPacked: CMAP_PACKED,
|
47
|
+
});
|
48
|
+
this.pdfLoadingTask = loadingTask;
|
49
|
+
|
50
|
+
loadingTask.onProgress = function (progressData) {
|
51
|
+
self.progress(progressData.loaded / progressData.total);
|
52
|
+
};
|
53
|
+
|
54
|
+
return loadingTask.promise.then(
|
55
|
+
function (pdfDocument) {
|
56
|
+
// Document loaded, specifying document for the viewer.
|
57
|
+
self.pdfDocument = pdfDocument;
|
58
|
+
self.pdfViewer.setDocument(pdfDocument);
|
59
|
+
self.pdfLinkService.setDocument(pdfDocument);
|
60
|
+
self.pdfHistory.initialize({
|
61
|
+
fingerprint: pdfDocument.fingerprints[0],
|
62
|
+
});
|
63
|
+
|
64
|
+
self.loadingBar.hide();
|
65
|
+
self.setTitleUsingMetadata(pdfDocument);
|
66
|
+
},
|
67
|
+
function (reason) {
|
68
|
+
let key = "pdfjs-loading-error";
|
69
|
+
if (reason instanceof pdfjsLib.InvalidPDFException) {
|
70
|
+
key = "pdfjs-invalid-file-error";
|
71
|
+
} else if (reason instanceof pdfjsLib.MissingPDFException) {
|
72
|
+
key = "pdfjs-missing-file-error";
|
73
|
+
} else if (reason instanceof pdfjsLib.UnexpectedResponseException) {
|
74
|
+
key = "pdfjs-unexpected-response-error";
|
75
|
+
}
|
76
|
+
self.l10n.get(key).then(msg => {
|
77
|
+
self.error(msg, { message: reason?.message });
|
78
|
+
});
|
79
|
+
self.loadingBar.hide();
|
80
|
+
}
|
81
|
+
);
|
82
|
+
},
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Closes opened PDF document.
|
86
|
+
* @returns {Promise} - Returns the promise, which is resolved when all
|
87
|
+
* destruction is completed.
|
88
|
+
*/
|
89
|
+
close() {
|
90
|
+
if (!this.pdfLoadingTask) {
|
91
|
+
return Promise.resolve();
|
92
|
+
}
|
93
|
+
|
94
|
+
const promise = this.pdfLoadingTask.destroy();
|
95
|
+
this.pdfLoadingTask = null;
|
96
|
+
|
97
|
+
if (this.pdfDocument) {
|
98
|
+
this.pdfDocument = null;
|
99
|
+
|
100
|
+
this.pdfViewer.setDocument(null);
|
101
|
+
this.pdfLinkService.setDocument(null, null);
|
102
|
+
|
103
|
+
if (this.pdfHistory) {
|
104
|
+
this.pdfHistory.reset();
|
105
|
+
}
|
106
|
+
}
|
107
|
+
return promise;
|
108
|
+
},
|
109
|
+
|
110
|
+
get loadingBar() {
|
111
|
+
const bar = document.getElementById("loadingBar");
|
112
|
+
return pdfjsLib.shadow(
|
113
|
+
this,
|
114
|
+
"loadingBar",
|
115
|
+
new pdfjsViewer.ProgressBar(bar)
|
116
|
+
);
|
117
|
+
},
|
118
|
+
|
119
|
+
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
|
120
|
+
this.url = url;
|
121
|
+
let title = pdfjsLib.getFilenameFromUrl(url) || url;
|
122
|
+
try {
|
123
|
+
title = decodeURIComponent(title);
|
124
|
+
} catch {
|
125
|
+
// decodeURIComponent may throw URIError,
|
126
|
+
// fall back to using the unprocessed url in that case
|
127
|
+
}
|
128
|
+
this.setTitle(title);
|
129
|
+
},
|
130
|
+
|
131
|
+
setTitleUsingMetadata(pdfDocument) {
|
132
|
+
const self = this;
|
133
|
+
pdfDocument.getMetadata().then(function (data) {
|
134
|
+
const info = data.info,
|
135
|
+
metadata = data.metadata;
|
136
|
+
self.documentInfo = info;
|
137
|
+
self.metadata = metadata;
|
138
|
+
|
139
|
+
// Provides some basic debug information
|
140
|
+
console.log(
|
141
|
+
"PDF " +
|
142
|
+
pdfDocument.fingerprints[0] +
|
143
|
+
" [" +
|
144
|
+
info.PDFFormatVersion +
|
145
|
+
" " +
|
146
|
+
(info.Producer || "-").trim() +
|
147
|
+
" / " +
|
148
|
+
(info.Creator || "-").trim() +
|
149
|
+
"]" +
|
150
|
+
" (PDF.js: " +
|
151
|
+
(pdfjsLib.version || "-") +
|
152
|
+
")"
|
153
|
+
);
|
154
|
+
|
155
|
+
let pdfTitle;
|
156
|
+
if (metadata && metadata.has("dc:title")) {
|
157
|
+
const title = metadata.get("dc:title");
|
158
|
+
// Ghostscript sometimes returns 'Untitled', so prevent setting the
|
159
|
+
// title to 'Untitled.
|
160
|
+
if (title !== "Untitled") {
|
161
|
+
pdfTitle = title;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
if (!pdfTitle && info && info.Title) {
|
166
|
+
pdfTitle = info.Title;
|
167
|
+
}
|
168
|
+
|
169
|
+
if (pdfTitle) {
|
170
|
+
self.setTitle(pdfTitle + " - " + document.title);
|
171
|
+
}
|
172
|
+
});
|
173
|
+
},
|
174
|
+
|
175
|
+
setTitle: function pdfViewSetTitle(title) {
|
176
|
+
document.title = title;
|
177
|
+
document.getElementById("title").textContent = title;
|
178
|
+
},
|
179
|
+
|
180
|
+
error: function pdfViewError(message, moreInfo) {
|
181
|
+
const moreInfoText = [
|
182
|
+
`PDF.js v${pdfjsLib.version || "?"} (build: ${pdfjsLib.build || "?"})`,
|
183
|
+
];
|
184
|
+
if (moreInfo) {
|
185
|
+
moreInfoText.push(`Message: ${moreInfo.message}`);
|
186
|
+
|
187
|
+
if (moreInfo.stack) {
|
188
|
+
moreInfoText.push(`Stack: ${moreInfo.stack}`);
|
189
|
+
} else {
|
190
|
+
if (moreInfo.filename) {
|
191
|
+
moreInfoText.push(`File: ${moreInfo.filename}`);
|
192
|
+
}
|
193
|
+
if (moreInfo.lineNumber) {
|
194
|
+
moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
console.error(`${message}\n\n${moreInfoText.join("\n")}`);
|
200
|
+
},
|
201
|
+
|
202
|
+
progress: function pdfViewProgress(level) {
|
203
|
+
const percent = Math.round(level * 100);
|
204
|
+
// Updating the bar if value increases.
|
205
|
+
if (percent > this.loadingBar.percent || isNaN(percent)) {
|
206
|
+
this.loadingBar.percent = percent;
|
207
|
+
}
|
208
|
+
},
|
209
|
+
|
210
|
+
get pagesCount() {
|
211
|
+
return this.pdfDocument.numPages;
|
212
|
+
},
|
213
|
+
|
214
|
+
get page() {
|
215
|
+
return this.pdfViewer.currentPageNumber;
|
216
|
+
},
|
217
|
+
|
218
|
+
set page(val) {
|
219
|
+
this.pdfViewer.currentPageNumber = val;
|
220
|
+
},
|
221
|
+
|
222
|
+
zoomIn: function pdfViewZoomIn(ticks) {
|
223
|
+
let newScale = this.pdfViewer.currentScale;
|
224
|
+
do {
|
225
|
+
newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
|
226
|
+
newScale = Math.ceil(newScale * 10) / 10;
|
227
|
+
newScale = Math.min(MAX_SCALE, newScale);
|
228
|
+
} while (--ticks && newScale < MAX_SCALE);
|
229
|
+
this.pdfViewer.currentScaleValue = newScale;
|
230
|
+
},
|
231
|
+
|
232
|
+
zoomOut: function pdfViewZoomOut(ticks) {
|
233
|
+
let newScale = this.pdfViewer.currentScale;
|
234
|
+
do {
|
235
|
+
newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
|
236
|
+
newScale = Math.floor(newScale * 10) / 10;
|
237
|
+
newScale = Math.max(MIN_SCALE, newScale);
|
238
|
+
} while (--ticks && newScale > MIN_SCALE);
|
239
|
+
this.pdfViewer.currentScaleValue = newScale;
|
240
|
+
},
|
241
|
+
|
242
|
+
initUI: function pdfViewInitUI() {
|
243
|
+
const eventBus = new pdfjsViewer.EventBus();
|
244
|
+
this.eventBus = eventBus;
|
245
|
+
|
246
|
+
const linkService = new pdfjsViewer.PDFLinkService({
|
247
|
+
eventBus,
|
248
|
+
});
|
249
|
+
this.pdfLinkService = linkService;
|
250
|
+
|
251
|
+
this.l10n = new pdfjsViewer.GenericL10n();
|
252
|
+
|
253
|
+
const container = document.getElementById("viewerContainer");
|
254
|
+
const pdfViewer = new pdfjsViewer.PDFViewer({
|
255
|
+
container,
|
256
|
+
eventBus,
|
257
|
+
linkService,
|
258
|
+
l10n: this.l10n,
|
259
|
+
maxCanvasPixels: MAX_CANVAS_PIXELS,
|
260
|
+
textLayerMode: TEXT_LAYER_MODE,
|
261
|
+
});
|
262
|
+
this.pdfViewer = pdfViewer;
|
263
|
+
linkService.setViewer(pdfViewer);
|
264
|
+
|
265
|
+
this.pdfHistory = new pdfjsViewer.PDFHistory({
|
266
|
+
eventBus,
|
267
|
+
linkService,
|
268
|
+
});
|
269
|
+
linkService.setHistory(this.pdfHistory);
|
270
|
+
|
271
|
+
document.getElementById("previous").addEventListener("click", function () {
|
272
|
+
PDFViewerApplication.page--;
|
273
|
+
});
|
274
|
+
|
275
|
+
document.getElementById("next").addEventListener("click", function () {
|
276
|
+
PDFViewerApplication.page++;
|
277
|
+
});
|
278
|
+
|
279
|
+
document.getElementById("zoomIn").addEventListener("click", function () {
|
280
|
+
PDFViewerApplication.zoomIn();
|
281
|
+
});
|
282
|
+
|
283
|
+
document.getElementById("zoomOut").addEventListener("click", function () {
|
284
|
+
PDFViewerApplication.zoomOut();
|
285
|
+
});
|
286
|
+
|
287
|
+
document
|
288
|
+
.getElementById("pageNumber")
|
289
|
+
.addEventListener("click", function () {
|
290
|
+
this.select();
|
291
|
+
});
|
292
|
+
|
293
|
+
document
|
294
|
+
.getElementById("pageNumber")
|
295
|
+
.addEventListener("change", function () {
|
296
|
+
PDFViewerApplication.page = this.value | 0;
|
297
|
+
|
298
|
+
// Ensure that the page number input displays the correct value,
|
299
|
+
// even if the value entered by the user was invalid
|
300
|
+
// (e.g. a floating point number).
|
301
|
+
if (this.value !== PDFViewerApplication.page.toString()) {
|
302
|
+
this.value = PDFViewerApplication.page;
|
303
|
+
}
|
304
|
+
});
|
305
|
+
|
306
|
+
eventBus.on("pagesinit", function () {
|
307
|
+
// We can use pdfViewer now, e.g. let's change default scale.
|
308
|
+
pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
|
309
|
+
});
|
310
|
+
|
311
|
+
eventBus.on(
|
312
|
+
"pagechanging",
|
313
|
+
function (evt) {
|
314
|
+
const page = evt.pageNumber;
|
315
|
+
const numPages = PDFViewerApplication.pagesCount;
|
316
|
+
|
317
|
+
document.getElementById("pageNumber").value = page;
|
318
|
+
document.getElementById("previous").disabled = page <= 1;
|
319
|
+
document.getElementById("next").disabled = page >= numPages;
|
320
|
+
},
|
321
|
+
true
|
322
|
+
);
|
323
|
+
},
|
324
|
+
};
|
325
|
+
|
326
|
+
window.PDFViewerApplication = PDFViewerApplication;
|
327
|
+
|
328
|
+
document.addEventListener(
|
329
|
+
"DOMContentLoaded",
|
330
|
+
function () {
|
331
|
+
PDFViewerApplication.initUI();
|
332
|
+
},
|
333
|
+
true
|
334
|
+
);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module.exports = {
|
2
2
|
"@fto-consult/expo-ui": {
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.73.0",
|
4
4
|
"url": "https://github.com/borispipo/expo-ui#readme",
|
5
5
|
"license": "ISC"
|
6
6
|
},
|
@@ -20,7 +20,7 @@ module.exports = {
|
|
20
20
|
"license": "MIT"
|
21
21
|
},
|
22
22
|
"@expo/metro-config": {
|
23
|
-
"version": "0.17.
|
23
|
+
"version": "0.17.7",
|
24
24
|
"url": "https://github.com/expo/expo.git",
|
25
25
|
"license": "MIT"
|
26
26
|
},
|
@@ -85,12 +85,12 @@ module.exports = {
|
|
85
85
|
"license": "MIT"
|
86
86
|
},
|
87
87
|
"expo": {
|
88
|
-
"version": "50.0.
|
88
|
+
"version": "50.0.17",
|
89
89
|
"url": "https://github.com/expo/expo/tree/main/packages/expo",
|
90
90
|
"license": "MIT"
|
91
91
|
},
|
92
92
|
"expo-camera": {
|
93
|
-
"version": "14.1.
|
93
|
+
"version": "14.1.3",
|
94
94
|
"url": "https://docs.expo.dev/versions/latest/sdk/camera/",
|
95
95
|
"license": "MIT"
|
96
96
|
},
|
@@ -140,7 +140,7 @@ module.exports = {
|
|
140
140
|
"license": "MIT"
|
141
141
|
},
|
142
142
|
"expo-system-ui": {
|
143
|
-
"version": "2.9.
|
143
|
+
"version": "2.9.4",
|
144
144
|
"url": "https://docs.expo.dev/versions/latest/sdk/system-ui",
|
145
145
|
"license": "MIT"
|
146
146
|
},
|