@getflip/swirl-components 0.174.2 → 0.175.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/components.json +42 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-file-viewer_7.cjs.entry.js +2 -1
- package/dist/cjs/swirl-pdf-reader.cjs.entry.js +21 -7
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/collection/components/swirl-file-viewer/swirl-file-viewer.js +19 -1
- package/dist/collection/components/swirl-pdf-reader/swirl-pdf-reader.js +42 -7
- package/dist/collection/components/swirl-pdf-reader/swirl-pdf-reader.stories.js +1 -1
- package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/components/swirl-file-viewer2.js +3 -1
- package/dist/components/swirl-pdf-reader.js +23 -7
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-file-viewer_7.entry.js +2 -1
- package/dist/esm/swirl-pdf-reader.entry.js +21 -7
- package/dist/swirl-components/{p-775f5bab.entry.js → p-27a798b0.entry.js} +1 -1
- package/dist/swirl-components/p-34e94b6a.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-file-viewer/swirl-file-viewer.d.ts +1 -0
- package/dist/types/components/swirl-pdf-reader/swirl-pdf-reader.d.ts +3 -0
- package/dist/types/components.d.ts +4 -0
- package/package.json +1 -1
- package/vscode-data.json +8 -0
- package/dist/swirl-components/p-c0bddc94.entry.js +0 -1
|
@@ -13,6 +13,7 @@ export class SwirlFileViewer {
|
|
|
13
13
|
this.description = undefined;
|
|
14
14
|
this.errorMessage = "File could not be loaded.";
|
|
15
15
|
this.file = undefined;
|
|
16
|
+
this.fileName = undefined;
|
|
16
17
|
this.pdfWorkerSrc = undefined;
|
|
17
18
|
this.thumbnailUrl = undefined;
|
|
18
19
|
this.type = undefined;
|
|
@@ -24,7 +25,7 @@ export class SwirlFileViewer {
|
|
|
24
25
|
* Download the file.
|
|
25
26
|
*/
|
|
26
27
|
async download() {
|
|
27
|
-
const fileName = this.file.split("/").pop();
|
|
28
|
+
const fileName = this.fileName || this.file.split("/").pop();
|
|
28
29
|
const file = await fetch(this.file);
|
|
29
30
|
saveAs(await file.blob(), fileName);
|
|
30
31
|
}
|
|
@@ -147,6 +148,23 @@ export class SwirlFileViewer {
|
|
|
147
148
|
"attribute": "file",
|
|
148
149
|
"reflect": false
|
|
149
150
|
},
|
|
151
|
+
"fileName": {
|
|
152
|
+
"type": "string",
|
|
153
|
+
"mutable": false,
|
|
154
|
+
"complexType": {
|
|
155
|
+
"original": "string",
|
|
156
|
+
"resolved": "string",
|
|
157
|
+
"references": {}
|
|
158
|
+
},
|
|
159
|
+
"required": false,
|
|
160
|
+
"optional": true,
|
|
161
|
+
"docs": {
|
|
162
|
+
"tags": [],
|
|
163
|
+
"text": ""
|
|
164
|
+
},
|
|
165
|
+
"attribute": "file-name",
|
|
166
|
+
"reflect": false
|
|
167
|
+
},
|
|
150
168
|
"pdfWorkerSrc": {
|
|
151
169
|
"type": "string",
|
|
152
170
|
"mutable": false,
|
|
@@ -27,7 +27,6 @@ export class SwirlPdfReader {
|
|
|
27
27
|
this.onActivate = async (event) => {
|
|
28
28
|
this.pdfViewer = event.detail;
|
|
29
29
|
this.lockBodyScroll();
|
|
30
|
-
this.generateThumbnails();
|
|
31
30
|
};
|
|
32
31
|
this.onVisiblePagesChange = async (event) => {
|
|
33
32
|
this.visiblePages = event.detail;
|
|
@@ -75,6 +74,7 @@ export class SwirlPdfReader {
|
|
|
75
74
|
this.downloadButtonEnabled = true;
|
|
76
75
|
this.downloadButtonLabel = "Download PDF";
|
|
77
76
|
this.file = undefined;
|
|
77
|
+
this.fileName = undefined;
|
|
78
78
|
this.fileTypeLabel = "PDF Document";
|
|
79
79
|
this.label = undefined;
|
|
80
80
|
this.menuLabel = "File menu";
|
|
@@ -92,6 +92,7 @@ export class SwirlPdfReader {
|
|
|
92
92
|
this.active = false;
|
|
93
93
|
this.closing = false;
|
|
94
94
|
this.downloading = false;
|
|
95
|
+
this.loadingThumbnails = false;
|
|
95
96
|
this.thumbnails = [];
|
|
96
97
|
this.showThumbnails = undefined;
|
|
97
98
|
this.viewMode = "single";
|
|
@@ -117,6 +118,15 @@ export class SwirlPdfReader {
|
|
|
117
118
|
this.updateZoomSteps();
|
|
118
119
|
this.zoom = isMobileViewport() ? "auto" : 1;
|
|
119
120
|
}
|
|
121
|
+
watchShowThumbnails() {
|
|
122
|
+
if (this.showThumbnails) {
|
|
123
|
+
this.loadingThumbnails = true;
|
|
124
|
+
queueMicrotask(async () => {
|
|
125
|
+
await this.generateThumbnails();
|
|
126
|
+
this.loadingThumbnails = false;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
120
130
|
/**
|
|
121
131
|
* Open the reader.
|
|
122
132
|
*/
|
|
@@ -170,12 +180,13 @@ export class SwirlPdfReader {
|
|
|
170
180
|
"pdf-reader--hide-menu": !hasMenuItems,
|
|
171
181
|
"pdf-reader--show-thumbnails": this.showThumbnails,
|
|
172
182
|
});
|
|
173
|
-
return (h(Host, null, h("section", { "aria-hidden": "true", "aria-label": this.label, class: className, id: "pdf-reader", onKeyDown: this.onKeyDown, ref: (el) => (this.modalEl = el) }, h("div", { class: "pdf-reader__body", role: "document" }, h("header", { class: "pdf-reader__header" }, h("span", { class: "pdf-reader__header-left" }, h("swirl-button", { class: "pdf-reader__close-button", hideLabel: true, icon: "<swirl-icon-close></swirl-icon-close>", label: this.closeButtonLabel, onClick: this.onCloseButtonClick }), h("span", { class: "pdf-reader__label" }, this.label)), h("span", { class: "pdf-reader__header-center" }, h("span", { class: "pdf-reader__zoom-button-container" }, h("swirl-button", { class: "pdf-reader__zoom-button", disabled: this.zoom === this.zoomSteps[0], hideLabel: true, icon: "<swirl-icon-remove></swirl-icon-remove>", label: this.zoomOutButtonLabel, onClick: this.onZoomOutButtonClick }), h("swirl-button", { class: "pdf-reader__zoom-button", disabled: this.zoom === this.zoomSteps[this.zoomSteps.length - 1], hideLabel: true, icon: "<swirl-icon-add></swirl-icon-add>", label: this.zoomInButtonLabel, onClick: this.onZoomInButtonClick })), h("span", { class: "pdf-reader__zoom-select-container" }, h("select", { "aria-label": this.zoomSelectLabel, class: "pdf-reader__zoom-select", name: "zoom-select", id: "zoom-select", onChange: this.onZoomChange }, h("option", { selected: this.zoom === "auto", value: "auto" }, this.autoZoomLabel), this.zoomSteps.map((zoom) => (h("option", { key: zoom, selected: this.zoom === zoom, value: zoom }, zoom * 100, "%")))), h("swirl-icon-expand-more", { class: "pdf-reader__zoom-select-icon" }))), h("span", { class: "pdf-reader__header-right" }, h("swirl-popover-trigger", { popover: this.menu }, h("swirl-button", { class: "pdf-reader__menu-button", hideLabel: true, icon: "<swirl-icon-more-vertikal></swirl-icon-more-vertikal>", label: this.menuTriggerLabel }))), h("span", { class: "pdf-reader__floating-tools" }, h("button", { "aria-label": this.sideBySideButtonLabel, class: "pdf-reader__floating-tool-button", onClick: this.toggleViewMode, type: "button" }, h("swirl-icon-menu-book", null)), h("button", { "aria-controls": "thumbnails", "aria-expanded": String(Boolean(this.showThumbnails)), "aria-label": this.thumbnailsButtonLabel, class: "pdf-reader__floating-tool-button", onClick: this.toggleThumbnals, type: "button" }, h("swirl-icon-file-copy", null)))), h("div", { class: "pdf-reader__content" }, h("nav", { "aria-label": this.thumbnailsLabel, class: "pdf-reader__thumbnails", id: "thumbnails" }, this.
|
|
174
|
-
|
|
175
|
-
"pdf-reader__thumbnail
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
183
|
+
return (h(Host, null, h("section", { "aria-hidden": "true", "aria-label": this.label, class: className, id: "pdf-reader", onKeyDown: this.onKeyDown, ref: (el) => (this.modalEl = el) }, h("div", { class: "pdf-reader__body", role: "document" }, h("header", { class: "pdf-reader__header" }, h("span", { class: "pdf-reader__header-left" }, h("swirl-button", { class: "pdf-reader__close-button", hideLabel: true, icon: "<swirl-icon-close></swirl-icon-close>", label: this.closeButtonLabel, onClick: this.onCloseButtonClick }), h("span", { class: "pdf-reader__label" }, this.label)), h("span", { class: "pdf-reader__header-center" }, h("span", { class: "pdf-reader__zoom-button-container" }, h("swirl-button", { class: "pdf-reader__zoom-button", disabled: this.zoom === this.zoomSteps[0], hideLabel: true, icon: "<swirl-icon-remove></swirl-icon-remove>", label: this.zoomOutButtonLabel, onClick: this.onZoomOutButtonClick }), h("swirl-button", { class: "pdf-reader__zoom-button", disabled: this.zoom === this.zoomSteps[this.zoomSteps.length - 1], hideLabel: true, icon: "<swirl-icon-add></swirl-icon-add>", label: this.zoomInButtonLabel, onClick: this.onZoomInButtonClick })), h("span", { class: "pdf-reader__zoom-select-container" }, h("select", { "aria-label": this.zoomSelectLabel, class: "pdf-reader__zoom-select", name: "zoom-select", id: "zoom-select", onChange: this.onZoomChange }, h("option", { selected: this.zoom === "auto", value: "auto" }, this.autoZoomLabel), this.zoomSteps.map((zoom) => (h("option", { key: zoom, selected: this.zoom === zoom, value: zoom }, zoom * 100, "%")))), h("swirl-icon-expand-more", { class: "pdf-reader__zoom-select-icon" }))), h("span", { class: "pdf-reader__header-right" }, h("swirl-popover-trigger", { popover: this.menu }, h("swirl-button", { class: "pdf-reader__menu-button", hideLabel: true, icon: "<swirl-icon-more-vertikal></swirl-icon-more-vertikal>", label: this.menuTriggerLabel }))), h("span", { class: "pdf-reader__floating-tools" }, h("button", { "aria-label": this.sideBySideButtonLabel, class: "pdf-reader__floating-tool-button", onClick: this.toggleViewMode, type: "button" }, h("swirl-icon-menu-book", null)), h("button", { "aria-controls": "thumbnails", "aria-expanded": String(Boolean(this.showThumbnails)), "aria-label": this.thumbnailsButtonLabel, class: "pdf-reader__floating-tool-button", onClick: this.toggleThumbnals, type: "button" }, h("swirl-icon-file-copy", null)))), h("div", { class: "pdf-reader__content" }, h("nav", { "aria-label": this.thumbnailsLabel, class: "pdf-reader__thumbnails", id: "thumbnails" }, this.loadingThumbnails && h("swirl-spinner", null), !this.loadingThumbnails &&
|
|
184
|
+
this.thumbnails.map((thumbnail, index) => {
|
|
185
|
+
const thumbnailClassName = classnames("pdf-reader__thumbnail", {
|
|
186
|
+
"pdf-reader__thumbnail--active": this.visiblePages[0] === index + 1,
|
|
187
|
+
});
|
|
188
|
+
return (h("button", { "aria-label": `${this.thumbnailButtonLabel} ${index + 1}`, class: thumbnailClassName, onClick: this.onThumbnailClick(index), type: "button" }, h("img", { src: thumbnail.toDataURL("image/png"), alt: "" })));
|
|
189
|
+
})), h("swirl-file-viewer", { active: this.active, class: "pdf-reader__viewer", file: this.file, fileName: this.fileName, onActivate: this.onActivate, onVisiblePagesChange: this.onVisiblePagesChange, pdfWorkerSrc: this.pdfWorkerSrc, ref: (el) => (this.viewer = el), type: "application/pdf", viewMode: this.viewMode, zoom: this.zoom }), h("div", { class: "pdf-reader__mobile-zoom-controls" }, h("button", { "aria-label": this.autoZoomLabel, class: "pdf-reader__mobile-zoom-button", onClick: this.onZoomAutoButtonClick, type: "button" }, this.zoom === "auto" ? (h("swirl-icon-fullscreen-exit", null)) : (h("swirl-icon-fullscreen", null))), h("button", { "aria-label": this.zoomInButtonLabel, class: "pdf-reader__mobile-zoom-button", disabled: this.zoom === this.zoomSteps[this.zoomSteps.length - 1], onClick: this.onZoomInButtonClick, type: "button" }, h("swirl-icon-add", null)), h("button", { "aria-label": this.zoomOutButtonLabel, class: "pdf-reader__mobile-zoom-button", disabled: this.zoom === this.zoomSteps[0], onClick: this.onZoomOutButtonClick, type: "button" }, h("swirl-icon-remove", null))))), h("swirl-popover", { animation: "scale-in-y", disableScrollLock: true, id: "menu", label: this.menuLabel, placement: "bottom-end", ref: (el) => (this.menu = el) }, h("swirl-stack", null, h("div", { class: "pdf-reader__meta" }, h("div", { class: "pdf-reader__file-icon" }, h("svg", { fill: "none", height: "36", viewBox: "0 0 24 36", width: "24" }, h("path", { d: "M7.01755 21.6V15.192H8.39455C8.64655 15.192 8.86855 15.225 9.06055 15.291C9.25255 15.357 9.42655 15.474 9.58255 15.642C9.73855 15.81 9.84655 16.008 9.90655 16.236C9.96655 16.458 9.99655 16.761 9.99655 17.145C9.99655 17.433 9.97855 17.676 9.94255 17.874C9.91255 18.072 9.84355 18.258 9.73555 18.432C9.60955 18.642 9.44155 18.807 9.23155 18.927C9.02155 19.041 8.74555 19.098 8.40355 19.098H7.93555V21.6H7.01755ZM7.93555 16.056V18.234H8.37655C8.56255 18.234 8.70655 18.207 8.80855 18.153C8.91055 18.099 8.98555 18.024 9.03355 17.928C9.08155 17.838 9.10855 17.727 9.11455 17.595C9.12655 17.463 9.13255 17.316 9.13255 17.154C9.13255 17.004 9.12955 16.863 9.12355 16.731C9.11755 16.593 9.09055 16.473 9.04255 16.371C8.99455 16.269 8.92255 16.191 8.82655 16.137C8.73055 16.083 8.59255 16.056 8.41255 16.056H7.93555Z", fill: "white" }), h("path", { d: "M10.6826 21.6V15.192H12.0416C12.5696 15.192 12.9686 15.336 13.2386 15.624C13.5146 15.912 13.6526 16.32 13.6526 16.848V19.845C13.6526 20.445 13.5056 20.889 13.2116 21.177C12.9236 21.459 12.5066 21.6 11.9606 21.6H10.6826ZM11.6006 16.056V20.736H12.0236C12.2816 20.736 12.4646 20.673 12.5726 20.547C12.6806 20.415 12.7346 20.211 12.7346 19.935V16.848C12.7346 16.596 12.6836 16.401 12.5816 16.263C12.4796 16.125 12.2936 16.056 12.0236 16.056H11.6006Z", fill: "white" }), h("path", { d: "M14.5146 21.6V15.192H17.2506V16.056H15.4326V18H17.0166V18.864H15.4326V21.6H14.5146Z", fill: "white" }), h("path", { d: "M3.59961 9.00001C3.59961 8.0059 4.4055 7.20001 5.39961 7.20001H14.854C15.3314 7.20001 15.7893 7.38965 16.1268 7.72722L19.8724 11.4728C20.21 11.8104 20.3996 12.2682 20.3996 12.7456V27C20.3996 27.9941 19.5937 28.8 18.5996 28.8H5.39961C4.4055 28.8 3.59961 27.9941 3.59961 27V9.00001Z", fill: "#FF574D" }), h("path", { d: "M15.5996 7.36166V10.2C15.5996 11.1941 16.4055 12 17.3996 12H20.2379C20.3237 12.1884 20.3768 12.3913 20.3937 12.6H17.3996C16.0785 12.6 15.0067 11.5325 14.9996 10.213L14.9996 7.20587C15.2083 7.2228 15.4112 7.27593 15.5996 7.36166Z", fill: "white" }), h("path", { d: "M7.01755 21.6V15.192H8.39455C8.64655 15.192 8.86855 15.225 9.06055 15.291C9.25255 15.357 9.42655 15.474 9.58255 15.642C9.73855 15.81 9.84655 16.008 9.90655 16.236C9.96655 16.458 9.99655 16.761 9.99655 17.145C9.99655 17.433 9.97855 17.676 9.94255 17.874C9.91255 18.072 9.84355 18.258 9.73555 18.432C9.60955 18.642 9.44155 18.807 9.23155 18.927C9.02155 19.041 8.74555 19.098 8.40355 19.098H7.93555V21.6H7.01755ZM7.93555 16.056V18.234H8.37655C8.56255 18.234 8.70655 18.207 8.80855 18.153C8.91055 18.099 8.98555 18.024 9.03355 17.928C9.08155 17.838 9.10855 17.727 9.11455 17.595C9.12655 17.463 9.13255 17.316 9.13255 17.154C9.13255 17.004 9.12955 16.863 9.12355 16.731C9.11755 16.593 9.09055 16.473 9.04255 16.371C8.99455 16.269 8.92255 16.191 8.82655 16.137C8.73055 16.083 8.59255 16.056 8.41255 16.056H7.93555Z", fill: "white" }), h("path", { d: "M10.6826 21.6V15.192H12.0416C12.5696 15.192 12.9686 15.336 13.2386 15.624C13.5146 15.912 13.6526 16.32 13.6526 16.848V19.845C13.6526 20.445 13.5056 20.889 13.2116 21.177C12.9236 21.459 12.5066 21.6 11.9606 21.6H10.6826ZM11.6006 16.056V20.736H12.0236C12.2816 20.736 12.4646 20.673 12.5726 20.547C12.6806 20.415 12.7346 20.211 12.7346 19.935V16.848C12.7346 16.596 12.6836 16.401 12.5816 16.263C12.4796 16.125 12.2936 16.056 12.0236 16.056H11.6006Z", fill: "white" }), h("path", { d: "M14.5146 21.6V15.192H17.2506V16.056H15.4326V18H17.0166V18.864H15.4326V21.6H14.5146Z", fill: "white" }))), h("div", { class: "pdf-reader__file-info" }, h("swirl-text", { truncate: true, weight: "semibold" }, this.label), h("swirl-text", { color: "subdued", size: "sm", truncate: true }, this.fileTypeLabel))), hasMenuItems && h("swirl-separator", null), h("swirl-action-list", { class: "pdf-reader__menu" }, this.printButtonEnabled && (h("swirl-action-list-item", { class: "pdf-reader__print-button", icon: "<swirl-icon-print></swirl-icon-print>", label: this.printButtonLabel, onClick: this.onPrintButtonClick })), this.downloadButtonEnabled && (h("swirl-action-list-item", { class: "pdf-reader__download-button", disabled: this.downloading, icon: !this.downloading
|
|
179
190
|
? "<swirl-icon-download></swirl-icon-download>"
|
|
180
191
|
: '<swirl-spinner size="xs"></swirl-spinner>', label: this.downloadButtonLabel, onClick: this.onDownloadButtonClick })), h("slot", { name: "menu-items" })))))));
|
|
181
192
|
}
|
|
@@ -282,6 +293,23 @@ export class SwirlPdfReader {
|
|
|
282
293
|
"attribute": "file",
|
|
283
294
|
"reflect": false
|
|
284
295
|
},
|
|
296
|
+
"fileName": {
|
|
297
|
+
"type": "string",
|
|
298
|
+
"mutable": false,
|
|
299
|
+
"complexType": {
|
|
300
|
+
"original": "string",
|
|
301
|
+
"resolved": "string",
|
|
302
|
+
"references": {}
|
|
303
|
+
},
|
|
304
|
+
"required": false,
|
|
305
|
+
"optional": true,
|
|
306
|
+
"docs": {
|
|
307
|
+
"tags": [],
|
|
308
|
+
"text": ""
|
|
309
|
+
},
|
|
310
|
+
"attribute": "file-name",
|
|
311
|
+
"reflect": false
|
|
312
|
+
},
|
|
285
313
|
"fileTypeLabel": {
|
|
286
314
|
"type": "string",
|
|
287
315
|
"mutable": false,
|
|
@@ -539,6 +567,7 @@ export class SwirlPdfReader {
|
|
|
539
567
|
"active": {},
|
|
540
568
|
"closing": {},
|
|
541
569
|
"downloading": {},
|
|
570
|
+
"loadingThumbnails": {},
|
|
542
571
|
"thumbnails": {},
|
|
543
572
|
"showThumbnails": {},
|
|
544
573
|
"viewMode": {},
|
|
@@ -617,6 +646,12 @@ export class SwirlPdfReader {
|
|
|
617
646
|
};
|
|
618
647
|
}
|
|
619
648
|
static get elementRef() { return "el"; }
|
|
649
|
+
static get watchers() {
|
|
650
|
+
return [{
|
|
651
|
+
"propName": "showThumbnails",
|
|
652
|
+
"methodName": "watchShowThumbnails"
|
|
653
|
+
}];
|
|
654
|
+
}
|
|
620
655
|
static get listeners() {
|
|
621
656
|
return [{
|
|
622
657
|
"name": "resize",
|