@happyvertical/smrt-ui 0.57.20 → 0.57.21
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/AGENTS.md +11 -1
- package/README.md +91 -0
- package/dist/components/display/DocumentViewer.svelte +443 -0
- package/dist/components/display/DocumentViewer.svelte.d.ts +24 -0
- package/dist/components/display/DocumentViewer.svelte.d.ts.map +1 -0
- package/dist/components/display/document-viewer-logic.d.ts +35 -0
- package/dist/components/display/document-viewer-logic.d.ts.map +1 -0
- package/dist/components/display/document-viewer-logic.js +56 -0
- package/dist/components/display/index.d.ts +5 -1
- package/dist/components/display/index.d.ts.map +1 -1
- package/dist/components/display/index.js +4 -0
- package/dist/components/display/pdf-opener.d.ts +44 -0
- package/dist/components/display/pdf-opener.d.ts.map +1 -0
- package/dist/components/display/pdf-opener.js +121 -0
- package/dist/components/display/pdf-types.d.ts +19 -0
- package/dist/components/display/pdf-types.d.ts.map +1 -0
- package/dist/components/display/pdf-types.js +7 -0
- package/dist/components/display/types.d.ts +19 -0
- package/dist/components/display/types.d.ts.map +1 -1
- package/dist/components/forms/NumericKeypad.svelte +511 -0
- package/dist/components/forms/NumericKeypad.svelte.d.ts +51 -0
- package/dist/components/forms/NumericKeypad.svelte.d.ts.map +1 -0
- package/dist/components/forms/index.d.ts +3 -1
- package/dist/components/forms/index.d.ts.map +1 -1
- package/dist/components/forms/index.js +2 -0
- package/dist/components/forms/numeric-keypad-logic.d.ts +68 -0
- package/dist/components/forms/numeric-keypad-logic.d.ts.map +1 -0
- package/dist/components/forms/numeric-keypad-logic.js +157 -0
- package/dist/components/forms/types.d.ts +17 -0
- package/dist/components/forms/types.d.ts.map +1 -1
- package/dist/i18n/strings.ui.d.ts +23 -0
- package/dist/i18n/strings.ui.d.ts.map +1 -1
- package/dist/i18n/strings.ui.js +25 -0
- package/dist/svelte/playground/TouchToolsPreview.svelte +47 -0
- package/dist/svelte/playground/TouchToolsPreview.svelte.d.ts +4 -0
- package/dist/svelte/playground/TouchToolsPreview.svelte.d.ts.map +1 -0
- package/dist/svelte/playground.d.ts.map +1 -1
- package/dist/svelte/playground.js +10 -0
- package/package.json +13 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for `DocumentViewer` (smrt#3463): zoom stepping, pinch
|
|
3
|
+
* clamping, page bounds, and the canvas render scale. Svelte-free.
|
|
4
|
+
*/
|
|
5
|
+
/** The zoom steps, as multiples of "Fit" (the sheet's width). */
|
|
6
|
+
export const ZOOM_STEPS = [1, 1.5, 2, 3, 4, 5];
|
|
7
|
+
/** The smallest and largest zoom. */
|
|
8
|
+
export const MIN_ZOOM = ZOOM_STEPS[0];
|
|
9
|
+
export const MAX_ZOOM = ZOOM_STEPS[ZOOM_STEPS.length - 1];
|
|
10
|
+
/** The biggest canvas drawn, in device pixels; zooming past it enlarges on screen instead. */
|
|
11
|
+
export const MAX_CANVAS_PIXELS = 4096 * 4096;
|
|
12
|
+
const EPSILON = 0.01;
|
|
13
|
+
/**
|
|
14
|
+
* The next zoom step above (`direction` 1) or below (-1) `zoom`. A zoom between
|
|
15
|
+
* steps (left by a pinch) moves to the nearest step in that direction; at an
|
|
16
|
+
* end it stays put.
|
|
17
|
+
*/
|
|
18
|
+
export function stepZoom(zoom, direction) {
|
|
19
|
+
if (direction > 0) {
|
|
20
|
+
return ZOOM_STEPS.find((step) => step > zoom + EPSILON) ?? MAX_ZOOM;
|
|
21
|
+
}
|
|
22
|
+
return ([...ZOOM_STEPS].reverse().find((step) => step < zoom - EPSILON) ?? MIN_ZOOM);
|
|
23
|
+
}
|
|
24
|
+
/** Clamp a zoom to the supported range. */
|
|
25
|
+
export function clampZoom(zoom) {
|
|
26
|
+
return Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, zoom));
|
|
27
|
+
}
|
|
28
|
+
/** The live pinch scale, bounded so `zoom * scale` stays within the zoom range. */
|
|
29
|
+
export function clampPinchScale(zoom, scale) {
|
|
30
|
+
return Math.min(MAX_ZOOM / zoom, Math.max(MIN_ZOOM / zoom, scale));
|
|
31
|
+
}
|
|
32
|
+
/** The zoom a finished pinch commits: `zoom * scale`, to 0.1, within range. */
|
|
33
|
+
export function commitPinchZoom(zoom, scale) {
|
|
34
|
+
return clampZoom(Math.round(zoom * scale * 10) / 10);
|
|
35
|
+
}
|
|
36
|
+
/** `page + delta` kept within `1..pages`. */
|
|
37
|
+
export function clampPage(page, delta, pages) {
|
|
38
|
+
return Math.min(Math.max(1, pages), Math.max(1, page + delta));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The pdf.js scale that draws a page `cssWidth` wide at `ratio` device pixels
|
|
42
|
+
* per CSS pixel, reduced when the canvas would exceed `MAX_CANVAS_PIXELS`.
|
|
43
|
+
*/
|
|
44
|
+
export function renderScale(pageWidth, pageHeight, cssWidth, ratio, maxPixels = MAX_CANVAS_PIXELS) {
|
|
45
|
+
const scale = (cssWidth / pageWidth) * ratio;
|
|
46
|
+
const pixels = pageWidth * scale * pageHeight * scale;
|
|
47
|
+
return pixels > maxPixels ? scale * Math.sqrt(maxPixels / pixels) : scale;
|
|
48
|
+
}
|
|
49
|
+
/** Whether a MIME type is a PDF. */
|
|
50
|
+
export function isPdfType(mimeType) {
|
|
51
|
+
return mimeType.split(';')[0]?.trim().toLowerCase() === 'application/pdf';
|
|
52
|
+
}
|
|
53
|
+
/** Whether a MIME type is an image the browser can show. */
|
|
54
|
+
export function isImageType(mimeType) {
|
|
55
|
+
return mimeType.trim().toLowerCase().startsWith('image/');
|
|
56
|
+
}
|
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
export { default as ConfidenceBadge } from './ConfidenceBadge.svelte';
|
|
5
5
|
export { default as CurrencyDisplay } from './CurrencyDisplay.svelte';
|
|
6
6
|
export { default as DateDisplay } from './DateDisplay.svelte';
|
|
7
|
+
export { default as DocumentViewer } from './DocumentViewer.svelte';
|
|
7
8
|
export { default as Icon } from './Icon.svelte';
|
|
8
9
|
export { default as StatusBadge } from './StatusBadge.svelte';
|
|
9
10
|
export type { IconPathMap } from './icons.svelte.js';
|
|
10
11
|
export { registerIcons } from './icons.svelte.js';
|
|
11
|
-
export type
|
|
12
|
+
export { createPdfJsOpener, type PdfJsLike, type PdfJsOpenerOptions, } from './pdf-opener.js';
|
|
13
|
+
export type { OpenPdf, PdfDocument } from './pdf-types.js';
|
|
14
|
+
export { PdfEngineUnavailableError } from './pdf-types.js';
|
|
15
|
+
export type { DocumentViewerLabels, StatusTone, StatusType } from './types.js';
|
|
12
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAM9D,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAM9D,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EACL,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
export { default as ConfidenceBadge } from './ConfidenceBadge.svelte';
|
|
6
6
|
export { default as CurrencyDisplay } from './CurrencyDisplay.svelte';
|
|
7
7
|
export { default as DateDisplay } from './DateDisplay.svelte';
|
|
8
|
+
export { default as DocumentViewer } from './DocumentViewer.svelte';
|
|
8
9
|
export { default as Icon } from './Icon.svelte';
|
|
9
10
|
export { default as StatusBadge } from './StatusBadge.svelte';
|
|
10
11
|
export { registerIcons } from './icons.svelte.js';
|
|
12
|
+
// Re-export types from types file
|
|
13
|
+
export { createPdfJsOpener, } from './pdf-opener.js';
|
|
14
|
+
export { PdfEngineUnavailableError } from './pdf-types.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { MAX_CANVAS_PIXELS, renderScale } from './document-viewer-logic.js';
|
|
2
|
+
import { type OpenPdf } from './pdf-types.js';
|
|
3
|
+
export { MAX_CANVAS_PIXELS, renderScale };
|
|
4
|
+
/** The slice of pdf.js this opener uses, so consumers need no pdf.js types. */
|
|
5
|
+
export interface PdfJsLike {
|
|
6
|
+
GlobalWorkerOptions: {
|
|
7
|
+
workerSrc: string;
|
|
8
|
+
};
|
|
9
|
+
getDocument(source: {
|
|
10
|
+
data: Uint8Array;
|
|
11
|
+
enableXfa?: boolean;
|
|
12
|
+
}): {
|
|
13
|
+
promise: Promise<PdfJsDocumentLike>;
|
|
14
|
+
destroy(): Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
interface PdfJsDocumentLike {
|
|
18
|
+
numPages: number;
|
|
19
|
+
getPage(page: number): Promise<{
|
|
20
|
+
getViewport(options: {
|
|
21
|
+
scale: number;
|
|
22
|
+
}): {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
};
|
|
26
|
+
render(options: {
|
|
27
|
+
canvas: HTMLCanvasElement;
|
|
28
|
+
viewport: unknown;
|
|
29
|
+
}): {
|
|
30
|
+
promise: Promise<void>;
|
|
31
|
+
cancel(): void;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
/** Options for `createPdfJsOpener`. */
|
|
36
|
+
export interface PdfJsOpenerOptions {
|
|
37
|
+
/** URL of `pdf.worker.min.mjs`; omitted, the worker runs on the main thread. */
|
|
38
|
+
workerSrc?: string | URL;
|
|
39
|
+
/** Supplies pdf.js; defaults to a dynamic `import('pdfjs-dist/legacy/build/pdf.mjs')`. */
|
|
40
|
+
loadLibrary?: () => Promise<PdfJsLike>;
|
|
41
|
+
}
|
|
42
|
+
/** Build an `OpenPdf` backed by pdf.js; the library loads on first use. */
|
|
43
|
+
export declare function createPdfJsOpener(options?: PdfJsOpenerOptions): OpenPdf;
|
|
44
|
+
//# sourceMappingURL=pdf-opener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-opener.d.ts","sourceRoot":"","sources":["../../../src/components/display/pdf-opener.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,KAAK,OAAO,EAA6B,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,CAAC;AAE1C,+EAA+E;AAC/E,MAAM,WAAW,SAAS;IACxB,mBAAmB,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,WAAW,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG;QAC9D,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACpC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;KAC1B,CAAC;CACH;AAED,UAAU,iBAAiB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAC7B,WAAW,CAAC,OAAO,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,GAAG;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QAC3E,MAAM,CAAC,OAAO,EAAE;YAAE,MAAM,EAAE,iBAAiB,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,GAAG;YACjE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;YACvB,MAAM,IAAI,IAAI,CAAC;SAChB,CAAC;KACH,CAAC,CAAC;CACJ;AAED,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACzB,0FAA0F;IAC1F,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;CACxC;AAcD,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAyF3E"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default PDF opener for `DocumentViewer`, on pdf.js (smrt#3463).
|
|
3
|
+
*
|
|
4
|
+
* `pdfjs-dist` is an OPTIONAL peer dependency: this module is only loaded
|
|
5
|
+
* (dynamically, by the viewer) when a PDF is shown without an injected
|
|
6
|
+
* `openPdf`, and it imports pdf.js dynamically too. The legacy build is used
|
|
7
|
+
* because it supports the widest range of WebViews. pdf.js never fetches
|
|
8
|
+
* anything itself: the bytes come from the caller.
|
|
9
|
+
*
|
|
10
|
+
* The default imports use a variable specifier (`importOptional`), so a
|
|
11
|
+
* consumer's bundler never resolves them: an app WITHOUT pdfjs-dist still
|
|
12
|
+
* builds, and the missing engine surfaces at runtime. The cost is that pdf.js is
|
|
13
|
+
* not bundled by default. An app that wants it bundled passes `loadLibrary`
|
|
14
|
+
* (a function holding its own literal `import('pdfjs-dist/legacy/build/pdf.mjs')`)
|
|
15
|
+
* and `workerSrc`.
|
|
16
|
+
*
|
|
17
|
+
* Worker: pass `workerSrc` (for Vite,
|
|
18
|
+
* `import url from 'pdfjs-dist/legacy/build/pdf.worker.min.mjs?url'`) to render
|
|
19
|
+
* off the main thread. Without it the worker module is imported and run on the
|
|
20
|
+
* main thread (pdf.js's "fake worker"), which needs no bundler URL handling
|
|
21
|
+
* and works under svelte-package and any bundler, at the cost of a busier UI
|
|
22
|
+
* thread while a page draws.
|
|
23
|
+
*/
|
|
24
|
+
import { importOptional } from '../../utils/import-optional.js';
|
|
25
|
+
import { MAX_CANVAS_PIXELS, renderScale } from './document-viewer-logic.js';
|
|
26
|
+
import { PdfEngineUnavailableError } from './pdf-types.js';
|
|
27
|
+
export { MAX_CANVAS_PIXELS, renderScale };
|
|
28
|
+
async function importPdfJs() {
|
|
29
|
+
return importOptional('pdfjs-dist/legacy/build/pdf.mjs');
|
|
30
|
+
}
|
|
31
|
+
async function useMainThreadWorker() {
|
|
32
|
+
const target = globalThis;
|
|
33
|
+
if (target.pdfjsWorker)
|
|
34
|
+
return;
|
|
35
|
+
target.pdfjsWorker = await importOptional('pdfjs-dist/legacy/build/pdf.worker.min.mjs');
|
|
36
|
+
}
|
|
37
|
+
/** Build an `OpenPdf` backed by pdf.js; the library loads on first use. */
|
|
38
|
+
export function createPdfJsOpener(options = {}) {
|
|
39
|
+
let library = null;
|
|
40
|
+
function load() {
|
|
41
|
+
library ??= (async () => {
|
|
42
|
+
try {
|
|
43
|
+
const lib = await (options.loadLibrary ?? importPdfJs)();
|
|
44
|
+
if (options.workerSrc !== undefined) {
|
|
45
|
+
lib.GlobalWorkerOptions.workerSrc = String(options.workerSrc);
|
|
46
|
+
}
|
|
47
|
+
else if (!lib.GlobalWorkerOptions.workerSrc) {
|
|
48
|
+
await useMainThreadWorker();
|
|
49
|
+
}
|
|
50
|
+
return lib;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
// pdf.js is an optional peer: not installed (or not loadable) means
|
|
54
|
+
// the viewer cannot show PDFs, not that this file is broken.
|
|
55
|
+
throw new PdfEngineUnavailableError(error instanceof Error ? error.message : undefined);
|
|
56
|
+
}
|
|
57
|
+
})();
|
|
58
|
+
// A failed load (pdf.js not installed) may be retried.
|
|
59
|
+
library.catch(() => {
|
|
60
|
+
library = null;
|
|
61
|
+
});
|
|
62
|
+
return library;
|
|
63
|
+
}
|
|
64
|
+
return async (bytes) => {
|
|
65
|
+
const lib = await load();
|
|
66
|
+
// pdf.js takes ownership of the buffer it is given; hand it a copy.
|
|
67
|
+
const loading = lib.getDocument({ data: bytes.slice(), enableXfa: false });
|
|
68
|
+
const document = await loading.promise;
|
|
69
|
+
// One page is drawn at a time: a newer request cancels the one drawing,
|
|
70
|
+
// and a request superseded while awaiting getPage never draws.
|
|
71
|
+
let drawing = null;
|
|
72
|
+
let generation = 0;
|
|
73
|
+
const stopDrawing = () => {
|
|
74
|
+
drawing?.cancel();
|
|
75
|
+
drawing = null;
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
pages: document.numPages,
|
|
79
|
+
async renderPage(page, canvas, cssWidth) {
|
|
80
|
+
const ticket = ++generation;
|
|
81
|
+
stopDrawing();
|
|
82
|
+
const proxy = await document.getPage(page);
|
|
83
|
+
if (ticket !== generation)
|
|
84
|
+
return { width: 0, height: 0 };
|
|
85
|
+
stopDrawing();
|
|
86
|
+
const base = proxy.getViewport({ scale: 1 });
|
|
87
|
+
const ratio = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;
|
|
88
|
+
const viewport = proxy.getViewport({
|
|
89
|
+
scale: renderScale(base.width, base.height, Math.max(cssWidth, 1), ratio),
|
|
90
|
+
});
|
|
91
|
+
canvas.width = Math.floor(viewport.width);
|
|
92
|
+
canvas.height = Math.floor(viewport.height);
|
|
93
|
+
canvas.style.width = `${Math.round(cssWidth)}px`;
|
|
94
|
+
canvas.style.height = `${Math.round((cssWidth * base.height) / base.width)}px`;
|
|
95
|
+
const task = proxy.render({ canvas, viewport });
|
|
96
|
+
drawing = task;
|
|
97
|
+
try {
|
|
98
|
+
await task.promise;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
// Superseded by a newer page or zoom: that one draws instead.
|
|
102
|
+
if (error?.name ===
|
|
103
|
+
'RenderingCancelledException') {
|
|
104
|
+
return { width: base.width, height: base.height };
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
if (drawing === task)
|
|
110
|
+
drawing = null;
|
|
111
|
+
}
|
|
112
|
+
return { width: base.width, height: base.height };
|
|
113
|
+
},
|
|
114
|
+
async destroy() {
|
|
115
|
+
generation += 1;
|
|
116
|
+
drawing?.cancel();
|
|
117
|
+
await loading.destroy();
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** One opened PDF. Pages are numbered from 1. */
|
|
2
|
+
export interface PdfDocument {
|
|
3
|
+
/** Page count. */
|
|
4
|
+
pages: number;
|
|
5
|
+
/** Draw a page onto `canvas`, `cssWidth` CSS pixels wide (sharp on a dense screen). */
|
|
6
|
+
renderPage(page: number, canvas: HTMLCanvasElement, cssWidth: number): Promise<{
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}>;
|
|
10
|
+
/** Release the document and any worker. */
|
|
11
|
+
destroy(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/** Opens PDF bytes. Inject one to use a PDF engine other than pdf.js. */
|
|
14
|
+
export type OpenPdf = (bytes: Uint8Array) => Promise<PdfDocument>;
|
|
15
|
+
/** Thrown by an opener whose PDF engine is not installed; the viewer shows "unsupported". */
|
|
16
|
+
export declare class PdfEngineUnavailableError extends Error {
|
|
17
|
+
constructor(message?: string);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=pdf-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-types.d.ts","sourceRoot":"","sources":["../../../src/components/display/pdf-types.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC1B,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,UAAU,CACR,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9C,2CAA2C;IAC3C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,yEAAyE;AACzE,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAElE,6FAA6F;AAC7F,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,SAAkD;CAItE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Thrown by an opener whose PDF engine is not installed; the viewer shows "unsupported". */
|
|
2
|
+
export class PdfEngineUnavailableError extends Error {
|
|
3
|
+
constructor(message = 'The PDF engine (pdfjs-dist) is not available.') {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = 'PdfEngineUnavailableError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -4,4 +4,23 @@
|
|
|
4
4
|
export type StatusType = 'default' | 'invoice' | 'project' | 'expense' | 'time' | 'compliance' | 'estimate';
|
|
5
5
|
/** Semantic tone for custom status vocabulary. */
|
|
6
6
|
export type StatusTone = 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
7
|
+
/** Text overrides for `DocumentViewer`; defaults come from the `ui` i18n catalog. */
|
|
8
|
+
export interface DocumentViewerLabels {
|
|
9
|
+
region: string;
|
|
10
|
+
pages: string;
|
|
11
|
+
zoom: string;
|
|
12
|
+
previousPage: string;
|
|
13
|
+
nextPage: string;
|
|
14
|
+
/** Template with `{page}` and `{pages}`. */
|
|
15
|
+
pageOf: string;
|
|
16
|
+
/** Template with `{label}` and `{page}`; names the PDF page canvas. */
|
|
17
|
+
pageLabel: string;
|
|
18
|
+
zoomOut: string;
|
|
19
|
+
zoomIn: string;
|
|
20
|
+
fit: string;
|
|
21
|
+
loading: string;
|
|
22
|
+
failed: string;
|
|
23
|
+
retry: string;
|
|
24
|
+
unsupported: string;
|
|
25
|
+
}
|
|
7
26
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/display/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,MAAM,GACN,YAAY,GACZ,UAAU,CAAC;AAEf,kDAAkD;AAClD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/display/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,MAAM,GACN,YAAY,GACZ,UAAU,CAAC;AAEf,kDAAkD;AAClD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAE/E,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB"}
|