@vaadin-component-factory/vcf-pdf-viewer 4.0.2 → 4.2.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.
@@ -0,0 +1,247 @@
1
+ /**
2
+ * Public type declarations for `<vcf-pdf-viewer>`.
3
+ *
4
+ * These are hand-written because the component is authored in plain
5
+ * JavaScript, so there is no `tsc` pass that could emit them. They sit next to
6
+ * the `.js` they describe, and both files are listed in `files` and in the
7
+ * `exports` map of `package.json`, so `import { PdfViewerElement } from
8
+ * '@vaadin-component-factory/vcf-pdf-viewer'` resolves under `strict`.
9
+ *
10
+ * Only the documented public surface is declared. The `_` and `__` prefixed
11
+ * members are internal and deliberately left out, apart from `_getPage()`,
12
+ * which is declared as protected because it is the read counterpart of
13
+ * `setCurrentPage()`.
14
+ *
15
+ * The base is `HTMLElement`, not `LitElement`, on purpose: `lit` is not a
16
+ * direct dependency of this package, so referencing it here would leak an
17
+ * unresolvable type onto consumers. The one Lit member that is part of the
18
+ * public contract, `updateComplete`, is declared explicitly.
19
+ */
20
+ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
21
+ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
22
+ import { SlotStylesMixin } from '@vaadin/component-base/src/slot-styles-mixin.js';
23
+ import { ThemeDetectionMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-detection-mixin.js';
24
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
25
+
26
+ /**
27
+ * The pdf.js `PDFDocumentProxy` handed out by `document-loaded`, narrowed to
28
+ * the members that are usable without the pdf.js typings — the `pdfjs/dist`
29
+ * bundle shipped by this package has none.
30
+ */
31
+ export interface PdfDocumentProxy {
32
+ /** Total number of pages of the loaded document. */
33
+ readonly numPages: number;
34
+
35
+ /** Fingerprints of the document, as computed by pdf.js. */
36
+ readonly fingerprints: ReadonlyArray<string | null>;
37
+
38
+ /** The document's `info` dictionary and its XMP metadata. */
39
+ getMetadata(): Promise<{ info: Record<string, unknown>; metadata: unknown }>;
40
+ }
41
+
42
+ export interface PdfViewerDocumentLoadedEventDetail {
43
+ /** The document that finished loading. */
44
+ document: PdfDocumentProxy;
45
+ }
46
+
47
+ export interface PdfViewerThumbnailClickedEventDetail {
48
+ /** The viewer whose sidebar thumbnail was clicked. */
49
+ source: PdfViewerElement;
50
+
51
+ /** One-based number of the page the thumbnail stands for. */
52
+ pageNumber: number;
53
+ }
54
+
55
+ /**
56
+ * Fired after `currentPage` has been updated by the element itself, i.e. when
57
+ * scrolling or the toolbar changed the page. Carries no detail; read
58
+ * `currentPage` off the target.
59
+ */
60
+ export type PdfViewerCurrentPageChangedEvent = CustomEvent<null>;
61
+
62
+ /** Fired once the document behind `src` has loaded and its title is resolved. */
63
+ export type PdfViewerDocumentLoadedEvent = CustomEvent<PdfViewerDocumentLoadedEventDetail>;
64
+
65
+ /** Fired when a thumbnail in the sidebar is clicked, after navigating to its page. */
66
+ export type PdfViewerThumbnailClickedEvent = CustomEvent<PdfViewerThumbnailClickedEventDetail>;
67
+
68
+ export interface PdfViewerElementCustomEventMap {
69
+ 'currentPage-changed': PdfViewerCurrentPageChangedEvent;
70
+ 'document-loaded': PdfViewerDocumentLoadedEvent;
71
+ 'thumbnail-clicked': PdfViewerThumbnailClickedEvent;
72
+ }
73
+
74
+ export interface PdfViewerElementEventMap extends HTMLElementEventMap, PdfViewerElementCustomEventMap {}
75
+
76
+ /**
77
+ * `<vcf-pdf-viewer>` is a Web Component for rendering PDF files without the
78
+ * need of plugins. You can provide a pdf file to it through the `src`
79
+ * attribute.
80
+ *
81
+ * ```html
82
+ * <vcf-pdf-viewer src="myfile.pdf"></vcf-pdf-viewer>
83
+ * ```
84
+ *
85
+ * ### Styling
86
+ *
87
+ * The following shadow DOM parts are available for styling:
88
+ *
89
+ * Part name | Description
90
+ * --------------------|------------
91
+ * `toolbar` | The bar above the document, holding the title and the controls.
92
+ * `outer-container` | The element wrapping both the sidebar and the document.
93
+ * `main-container` | The element wrapping the document.
94
+ * `viewer-container` | The scrolling container of the rendered pages.
95
+ * `sidebar-container` | The collapsible sidebar.
96
+ * `sidebar-content` | The content of the sidebar.
97
+ * `thumbnail-view` | The list of page thumbnails inside the sidebar.
98
+ *
99
+ * @mixes ElementMixin
100
+ * @mixes ResizeMixin
101
+ * @mixes SlotStylesMixin
102
+ * @mixes ThemableMixin
103
+ * @mixes ThemeDetectionMixin
104
+ */
105
+ declare class PdfViewerElement extends ResizeMixin(
106
+ SlotStylesMixin(ThemeDetectionMixin(ThemableMixin(ElementMixin(HTMLElement))))
107
+ ) {
108
+ static readonly is: 'vcf-pdf-viewer';
109
+
110
+ static readonly version: string;
111
+
112
+ /**
113
+ * The pdf file to render, resolved against `document.baseURI`. Note that
114
+ * regular cross site scripting (XSS) rules apply: the file should be on the
115
+ * same server as where the component is run, or that server should be
116
+ * configured to allow loading files from other sites.
117
+ *
118
+ * @attr {string} src
119
+ */
120
+ src: string;
121
+
122
+ /**
123
+ * The level of zoom on the document. Allowed values are
124
+ * - a number, as a string, for a zoom factor — e.g. `'1.5'` means 150% zoom
125
+ * - `'auto'`, the default
126
+ * - `'page-fit'`, to fit a full page into the component
127
+ *
128
+ * @attr {string} zoom
129
+ */
130
+ zoom: string;
131
+
132
+ /**
133
+ * The page currently in view, one-based and as a string. The element writes
134
+ * to it as well, and fires `currentPage-changed` when it does. Assigning to
135
+ * it does not scroll; call `setCurrentPage()` for that.
136
+ *
137
+ * @attr {string} currentpage
138
+ */
139
+ currentPage: string;
140
+
141
+ /**
142
+ * When true, the toolbar shows only the filename as the title, instead of
143
+ * combining it with the title from the PDF metadata.
144
+ *
145
+ * @attr {boolean} toolbaronlyfilename
146
+ */
147
+ toolbarOnlyFilename: boolean;
148
+
149
+ /**
150
+ * Label of the automatic zoom entry of the zoom dropdown.
151
+ *
152
+ * @attr {string} autozoomoptionlabel
153
+ */
154
+ autoZoomOptionLabel: string;
155
+
156
+ /**
157
+ * Label of the page fit entry of the zoom dropdown.
158
+ *
159
+ * @attr {string} fitzoomoptionlabel
160
+ */
161
+ fitZoomOptionLabel: string;
162
+
163
+ /**
164
+ * A custom title for the viewer. When set, it replaces the title the
165
+ * component derives from the filename and the PDF metadata.
166
+ *
167
+ * @attr {string} customtitle
168
+ */
169
+ customTitle: string;
170
+
171
+ /**
172
+ * When true, form elements are rendered as interactive HTML in the
173
+ * annotation layer; when false, their values are painted directly onto the
174
+ * canvas.
175
+ *
176
+ * @attr {boolean} renderinteractiveforms
177
+ */
178
+ renderInteractiveForms: boolean;
179
+
180
+ /**
181
+ * When true, the zoom dropdown is hidden. By default it is always shown.
182
+ *
183
+ * @attr {boolean} hidezoom
184
+ */
185
+ hideZoom: boolean;
186
+
187
+ /**
188
+ * A custom tooltip for the sidebar toggle button.
189
+ *
190
+ * @attr {string} sidebartoggletooltip
191
+ */
192
+ sidebarToggleTooltip: string;
193
+
194
+ /**
195
+ * A custom tooltip for the previous page button.
196
+ *
197
+ * @attr {string} previouspagetooltip
198
+ */
199
+ previousPageTooltip: string;
200
+
201
+ /**
202
+ * A custom tooltip for the next page button.
203
+ *
204
+ * @attr {string} nextpagetooltip
205
+ */
206
+ nextPageTooltip: string;
207
+
208
+ /** Resolves when the element has finished its pending update. */
209
+ readonly updateComplete: Promise<boolean>;
210
+
211
+ /**
212
+ * Scrolls to `value`, clamped to the document, or re-applies the current
213
+ * value of `currentPage` when called without an argument.
214
+ */
215
+ setCurrentPage(value?: number | string): void;
216
+
217
+ /** Rotates the document 90° clockwise. Requires a loaded document. */
218
+ rotateCw(): void;
219
+
220
+ /** Rotates the document 90° counterclockwise. Requires a loaded document. */
221
+ rotateCcw(): void;
222
+
223
+ /** The one-based number of the page in view, as reported by the pdf.js viewer. */
224
+ protected _getPage(): number;
225
+ }
226
+
227
+ declare interface PdfViewerElement {
228
+ addEventListener<K extends keyof PdfViewerElementEventMap>(
229
+ type: K,
230
+ listener: (this: PdfViewerElement, ev: PdfViewerElementEventMap[K]) => void,
231
+ options?: AddEventListenerOptions | boolean
232
+ ): void;
233
+
234
+ removeEventListener<K extends keyof PdfViewerElementEventMap>(
235
+ type: K,
236
+ listener: (this: PdfViewerElement, ev: PdfViewerElementEventMap[K]) => void,
237
+ options?: EventListenerOptions | boolean
238
+ ): void;
239
+ }
240
+
241
+ declare global {
242
+ interface HTMLElementTagNameMap {
243
+ 'vcf-pdf-viewer': PdfViewerElement;
244
+ }
245
+ }
246
+
247
+ export { PdfViewerElement };