@getflip/swirl-components 0.114.0 → 0.116.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.
Files changed (40) hide show
  1. package/components.json +87 -19
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/swirl-components.cjs.js +1 -1
  4. package/dist/cjs/swirl-file-viewer_7.cjs.entry.js +5 -2
  5. package/dist/cjs/swirl-pdf-reader.cjs.entry.js +6 -1
  6. package/dist/cjs/swirl-theme-provider.cjs.entry.js +42 -285
  7. package/dist/collection/assets/pdfjs/pdf.worker.min.js +1 -1
  8. package/dist/collection/collection-manifest.json +1 -1
  9. package/dist/collection/components/swirl-file-viewer/swirl-file-viewer.js +19 -1
  10. package/dist/collection/components/swirl-file-viewer/viewers/swirl-file-viewer-pdf/swirl-file-viewer-pdf.js +21 -1
  11. package/dist/collection/components/swirl-pdf-reader/swirl-pdf-reader.js +54 -1
  12. package/dist/collection/components/swirl-theme-provider/swirl-theme-provider.js +72 -99
  13. package/dist/collection/components/swirl-theme-provider/swirl-theme-provider.spec.js +67 -18
  14. package/dist/collection/components/swirl-theme-provider/swirl-theme-provider.stories.js +371 -17
  15. package/dist/collection/components/swirl-theme-provider/swirl-theme-provider.types.js +1 -0
  16. package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
  17. package/dist/components/swirl-file-viewer-pdf2.js +4 -1
  18. package/dist/components/swirl-file-viewer2.js +3 -1
  19. package/dist/components/swirl-pdf-reader.js +8 -2
  20. package/dist/components/swirl-theme-provider.js +46 -289
  21. package/dist/esm/loader.js +1 -1
  22. package/dist/esm/swirl-components.js +1 -1
  23. package/dist/esm/swirl-file-viewer_7.entry.js +5 -2
  24. package/dist/esm/swirl-pdf-reader.entry.js +7 -2
  25. package/dist/esm/swirl-theme-provider.entry.js +42 -285
  26. package/dist/swirl-components/p-353eab4c.entry.js +1 -0
  27. package/dist/swirl-components/{p-05d56f14.entry.js → p-4368ba9d.entry.js} +2 -2
  28. package/dist/swirl-components/p-bceafa56.entry.js +1 -0
  29. package/dist/swirl-components/swirl-components.esm.js +1 -1
  30. package/dist/types/components/swirl-file-viewer/swirl-file-viewer.d.ts +1 -0
  31. package/dist/types/components/swirl-file-viewer/viewers/swirl-file-viewer-pdf/swirl-file-viewer-pdf.d.ts +6 -0
  32. package/dist/types/components/swirl-pdf-reader/swirl-pdf-reader.d.ts +4 -0
  33. package/dist/types/components/swirl-theme-provider/swirl-theme-provider.d.ts +15 -34
  34. package/dist/types/components/swirl-theme-provider/swirl-theme-provider.types.d.ts +45 -0
  35. package/dist/types/components.d.ts +23 -11
  36. package/dist/types/index.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/vscode-data.json +12 -0
  39. package/dist/swirl-components/p-1a4c6557.entry.js +0 -1
  40. package/dist/swirl-components/p-af636e9c.entry.js +0 -1
@@ -26,6 +26,7 @@ const SwirlFileViewer = class {
26
26
  this.description = undefined;
27
27
  this.errorMessage = "File could not be loaded.";
28
28
  this.file = undefined;
29
+ this.pdfWorkerSrc = undefined;
29
30
  this.thumbnailUrl = undefined;
30
31
  this.type = undefined;
31
32
  this.typeUnsupportedMessage = "File type is not supported.";
@@ -56,7 +57,7 @@ const SwirlFileViewer = class {
56
57
  this.type !== "text/plain" &&
57
58
  this.type !== "text/csv" &&
58
59
  this.type !== "application/pdf");
59
- return (h(Host, null, h("div", { class: "file-viewer" }, this.type && this.active && (h("div", { class: "file-viewer__file" }, this.type.startsWith("image/") && (h("swirl-file-viewer-image", { description: this.description, errorMessage: this.errorMessage, file: this.file, ref: (el) => (this.viewer = el) })), this.type === "text/plain" && (h("swirl-file-viewer-text", { errorMessage: this.errorMessage, file: this.file, ref: (el) => (this.viewer = el) })), this.type === "text/csv" && (h("swirl-file-viewer-csv", { errorMessage: this.errorMessage, file: this.file, ref: (el) => (this.viewer = el) })), this.type === "application/pdf" && (h("swirl-file-viewer-pdf", { errorMessage: this.errorMessage, file: this.file, onActivate: this.onActivate, onVisiblePagesChange: this.onVisiblePagesChange, ref: (el) => (this.viewer = el), viewMode: this.viewMode, zoom: this.zoom })), this.type.startsWith("video/") && (h("swirl-file-viewer-video", { autoplay: this.autoplay, file: this.file, ref: (el) => (this.viewer = el), type: this.type })), this.type.startsWith("audio/") && (h("swirl-file-viewer-audio", { autoplay: this.autoplay, file: this.file, ref: (el) => (this.viewer = el), type: this.type })), unsupportedType && (h("swirl-inline-error", { message: this.typeUnsupportedMessage })))))));
60
+ return (h(Host, null, h("div", { class: "file-viewer" }, this.type && this.active && (h("div", { class: "file-viewer__file" }, this.type.startsWith("image/") && (h("swirl-file-viewer-image", { description: this.description, errorMessage: this.errorMessage, file: this.file, ref: (el) => (this.viewer = el) })), this.type === "text/plain" && (h("swirl-file-viewer-text", { errorMessage: this.errorMessage, file: this.file, ref: (el) => (this.viewer = el) })), this.type === "text/csv" && (h("swirl-file-viewer-csv", { errorMessage: this.errorMessage, file: this.file, ref: (el) => (this.viewer = el) })), this.type === "application/pdf" && (h("swirl-file-viewer-pdf", { errorMessage: this.errorMessage, file: this.file, onActivate: this.onActivate, onVisiblePagesChange: this.onVisiblePagesChange, ref: (el) => (this.viewer = el), viewMode: this.viewMode, workerSrc: this.pdfWorkerSrc, zoom: this.zoom })), this.type.startsWith("video/") && (h("swirl-file-viewer-video", { autoplay: this.autoplay, file: this.file, ref: (el) => (this.viewer = el), type: this.type })), this.type.startsWith("audio/") && (h("swirl-file-viewer-audio", { autoplay: this.autoplay, file: this.file, ref: (el) => (this.viewer = el), type: this.type })), unsupportedType && (h("swirl-inline-error", { message: this.typeUnsupportedMessage })))))));
60
61
  }
61
62
  };
62
63
  SwirlFileViewer.style = swirlFileViewerCss;
@@ -29835,7 +29836,7 @@ const pdf$1 = /*@__PURE__*/getDefaultExportFromCjs(pdf);
29835
29836
 
29836
29837
  const swirlFileViewerPdfCss = ":host{position:relative;display:inline-flex;width:100%;height:100%}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__pages{display:grid;grid-template-columns:repeat(2, 1fr);grid-row-gap:var(--s-space-8);grid-column-gap:var(--s-space-8);grid-auto-rows:auto}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__page{margin:0}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__page:nth-child(odd){justify-self:end}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__page:nth-child(even){justify-self:start}:host *{box-sizing:border-box}.file-viewer-pdf__pages{overflow:auto;width:100%;height:100%}@media (min-width: 768px){.file-viewer-pdf__pages{padding:var(--s-space-16)}}.file-viewer-pdf__page{position:relative;margin-right:auto;margin-left:auto;border-bottom:var(--s-border-width-default) solid var(--s-border-default);background-color:#fff}@media (min-width: 768px){.file-viewer-pdf__page{border:var(--s-border-width-default) solid var(--s-border-default)}.file-viewer-pdf__page:not(:last-of-type){margin-bottom:var(--s-space-8)}}.file-viewer-pdf__page-spinner{position:absolute;top:50%;left:50%;transform:translate3d(-50%, -50%, 0)}.file-viewer-pdf__canvas{display:flex;width:100%;height:100%;margin-right:auto;margin-left:auto}.file-viewer-pdf__text-container{position:absolute;overflow:hidden;line-height:1;text-align:initial;-webkit-user-select:none;-moz-user-select:none;user-select:none;inset:0;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;forced-color-adjust:none}.file-viewer-pdf__text-container>*{position:absolute;color:transparent;white-space:pre;cursor:text;transform-origin:0% 0%}.file-viewer-pdf__text-container>*.markedContent{top:0;height:0}.file-viewer-pdf__text-container>*.highlight{margin:-1px;padding:1px;border-radius:4px;background-color:rgba(180, 0, 170, 1)}.file-viewer-pdf__text-container>*.highlight.appended{position:initial}.file-viewer-pdf__text-container>*.highlight.begin{border-radius:4px 0 0 4px}.file-viewer-pdf__text-container>*.highlight.end{border-radius:0 4px 4px 0}.file-viewer-pdf__text-container>*.highlight.middle{border-radius:0}.file-viewer-pdf__text-container>*.highlight.selected{background-color:rgba(0, 100, 0, 1)}.file-viewer-pdf__text-container>*.endOfContent{position:absolute;z-index:-1;top:100%;right:0;bottom:0;left:0;display:block;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none}.file-viewer-pdf__text-container>*.endOfContent.active{top:0}.file-viewer-pdf__text-container>br::-moz-selection{background:transparent}.file-viewer-pdf__text-container>br::selection{background:transparent}@media (min-width: 768px){.file-viewer-pdf__text-container{-webkit-user-select:auto;-moz-user-select:auto;user-select:auto}}.file-viewer-pdf__spinner{position:absolute;display:flex;justify-content:center;align-items:center;background-color:rgba(0, 0, 0, 0.2);inset:0}.file-viewer-pdf__error{position:absolute;top:50%;left:50%;transform:translate3d(-50%, -50%, 0)}.file-viewer-pdf__pagination{position:absolute;bottom:var(--s-space-16);left:50%;padding:var(--s-space-4) var(--s-space-12);border-radius:var(--s-border-radius-base);color:var(--s-text-on-image);background-color:rgba(0, 0, 0, 0.6);font-weight:var(--s-font-weight-medium);line-height:var(--s-line-height-base);transform:translateX(-50%);pointer-events:none}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.file-viewer-pdf__pagination{font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}";
29837
29838
 
29838
- pdf$1.GlobalWorkerOptions.workerSrc = "/pdfjs/pdf.worker.min.js";
29839
+ window.pdf = pdf$1;
29839
29840
  const SwirlFileViewerPdf = class {
29840
29841
  constructor(hostRef) {
29841
29842
  registerInstance(this, hostRef);
@@ -29869,6 +29870,7 @@ const SwirlFileViewerPdf = class {
29869
29870
  this.file = undefined;
29870
29871
  this.singlePageMode = undefined;
29871
29872
  this.viewMode = "single";
29873
+ this.workerSrc = "/pdfjs/pdf.worker.min.js";
29872
29874
  this.zoom = 1;
29873
29875
  this.doc = undefined;
29874
29876
  this.error = undefined;
@@ -29879,6 +29881,7 @@ const SwirlFileViewerPdf = class {
29879
29881
  this.visiblePages = [];
29880
29882
  }
29881
29883
  async componentWillLoad() {
29884
+ window.pdf.GlobalWorkerOptions.workerSrc = this.workerSrc;
29882
29885
  await this.getPages();
29883
29886
  }
29884
29887
  async componentDidLoad() {
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h, H as Host, g as getElement } from './index-99d0060d.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-99d0060d.js';
2
2
  import { A as A11yDialog } from './a11y-dialog.esm-d7a94c8c.js';
3
3
  import { d as disableBodyScroll, e as enableBodyScroll } from './bodyScrollLock.esm-ce6356d8.js';
4
4
  import { c as classnames } from './index-d280dafb.js';
@@ -9,6 +9,8 @@ const swirlPdfReaderCss = ":host{--thumbnails-width:7rem;display:block}:host *{b
9
9
  const SwirlPdfReader = class {
10
10
  constructor(hostRef) {
11
11
  registerInstance(this, hostRef);
12
+ this.modalClose = createEvent(this, "modalClose", 7);
13
+ this.modalOpen = createEvent(this, "modalOpen", 7);
12
14
  this.desktopZoomSteps = [0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4];
13
15
  this.mobileZoomSteps = [0.5, 0.75, 1, 1.25, 1.5];
14
16
  this.toggleViewMode = () => {
@@ -81,6 +83,7 @@ const SwirlPdfReader = class {
81
83
  this.label = undefined;
82
84
  this.menuLabel = "File menu";
83
85
  this.menuTriggerLabel = "Open file menu";
86
+ this.pdfWorkerSrc = undefined;
84
87
  this.printButtonLabel = "Print PDF";
85
88
  this.sideBySideButtonLabel = "Toggle side by side view";
86
89
  this.thumbnailButtonLabel = "Scroll to page";
@@ -123,6 +126,7 @@ const SwirlPdfReader = class {
123
126
  async open() {
124
127
  this.modal.show();
125
128
  this.active = true;
129
+ this.modalOpen.emit();
126
130
  }
127
131
  /**
128
132
  * Close the reader.
@@ -137,6 +141,7 @@ const SwirlPdfReader = class {
137
141
  this.modal.hide();
138
142
  this.closing = false;
139
143
  this.active = false;
144
+ this.modalClose.emit();
140
145
  }, 150);
141
146
  }
142
147
  lockBodyScroll() {
@@ -169,7 +174,7 @@ const SwirlPdfReader = class {
169
174
  "pdf-reader__thumbnail--active": this.visiblePages[0] === index + 1,
170
175
  });
171
176
  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: "" })));
172
- })), h("swirl-file-viewer", { active: this.active, class: "pdf-reader__viewer", file: this.file, onActivate: this.onActivate, onVisiblePagesChange: this.onVisiblePagesChange, 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))), h("swirl-separator", null), h("swirl-action-list", null, h("swirl-action-list-item", { class: "pdf-reader__print-button", icon: "<swirl-icon-print></swirl-icon-print>", label: this.printButtonLabel, onClick: this.onPrintButtonClick }), h("swirl-action-list-item", { class: "pdf-reader__download-button", disabled: this.downloading, icon: !this.downloading
177
+ })), h("swirl-file-viewer", { active: this.active, class: "pdf-reader__viewer", file: this.file, 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))), h("swirl-separator", null), h("swirl-action-list", null, h("swirl-action-list-item", { class: "pdf-reader__print-button", icon: "<swirl-icon-print></swirl-icon-print>", label: this.printButtonLabel, onClick: this.onPrintButtonClick }), h("swirl-action-list-item", { class: "pdf-reader__download-button", disabled: this.downloading, icon: !this.downloading
173
178
  ? "<swirl-icon-download></swirl-icon-download>"
174
179
  : '<swirl-spinner size="xs"></swirl-spinner>', label: this.downloadButtonLabel, onClick: this.onDownloadButtonClick }), h("slot", { name: "menu-items" })))))));
175
180
  }
@@ -1,246 +1,13 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host } from './index-99d0060d.js';
2
2
 
3
- /**
4
- * A simple guard function:
5
- *
6
- * ```js
7
- * Math.min(Math.max(low, value), high)
8
- * ```
9
- */
10
- function guard(low, high, value) {
11
- return Math.min(Math.max(low, value), high);
12
- }
13
-
14
- class ColorError extends Error {
15
- constructor(color) {
16
- super(`Failed to parse color: "${color}"`);
17
- }
18
-
19
- }
20
-
21
- var ColorError$1 = ColorError;
22
-
23
- /**
24
- * Parses a color into red, gree, blue, alpha parts
25
- *
26
- * @param color the input color. Can be a RGB, RBGA, HSL, HSLA, or named color
27
- */
28
-
29
- function parseToRgba(color) {
30
- if (typeof color !== 'string') throw new ColorError$1(color);
31
- if (color.trim().toLowerCase() === 'transparent') return [0, 0, 0, 0];
32
- let normalizedColor = color.trim();
33
- normalizedColor = namedColorRegex.test(color) ? nameToHex(color) : color;
34
- const reducedHexMatch = reducedHexRegex.exec(normalizedColor);
35
-
36
- if (reducedHexMatch) {
37
- const arr = Array.from(reducedHexMatch).slice(1);
38
- return [...arr.slice(0, 3).map(x => parseInt(r(x, 2), 16)), parseInt(r(arr[3] || 'f', 2), 16) / 255];
39
- }
40
-
41
- const hexMatch = hexRegex.exec(normalizedColor);
42
-
43
- if (hexMatch) {
44
- const arr = Array.from(hexMatch).slice(1);
45
- return [...arr.slice(0, 3).map(x => parseInt(x, 16)), parseInt(arr[3] || 'ff', 16) / 255];
46
- }
47
-
48
- const rgbaMatch = rgbaRegex.exec(normalizedColor);
49
-
50
- if (rgbaMatch) {
51
- const arr = Array.from(rgbaMatch).slice(1);
52
- return [...arr.slice(0, 3).map(x => parseInt(x, 10)), parseFloat(arr[3] || '1')];
53
- }
54
-
55
- const hslaMatch = hslaRegex.exec(normalizedColor);
56
-
57
- if (hslaMatch) {
58
- const [h, s, l, a] = Array.from(hslaMatch).slice(1).map(parseFloat);
59
- if (guard(0, 100, s) !== s) throw new ColorError$1(color);
60
- if (guard(0, 100, l) !== l) throw new ColorError$1(color);
61
- return [...hslToRgb(h, s, l), a || 1];
62
- }
63
-
64
- throw new ColorError$1(color);
65
- }
66
-
67
- function hash(str) {
68
- let hash = 5381;
69
- let i = str.length;
70
-
71
- while (i) {
72
- hash = hash * 33 ^ str.charCodeAt(--i);
73
- }
74
- /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
75
- * integers. Since we want the results to be always positive, convert the
76
- * signed int to an unsigned by doing an unsigned bitshift. */
77
-
78
-
79
- return (hash >>> 0) % 2341;
80
- }
81
-
82
- const colorToInt = x => parseInt(x.replace(/_/g, ''), 36);
83
-
84
- const compressedColorMap = '1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm'.split(' ').reduce((acc, next) => {
85
- const key = colorToInt(next.substring(0, 3));
86
- const hex = colorToInt(next.substring(3)).toString(16); // NOTE: padStart could be used here but it breaks Node 6 compat
87
- // https://github.com/ricokahler/color2k/issues/351
88
-
89
- let prefix = '';
90
-
91
- for (let i = 0; i < 6 - hex.length; i++) {
92
- prefix += '0';
93
- }
94
-
95
- acc[key] = `${prefix}${hex}`;
96
- return acc;
97
- }, {});
98
- /**
99
- * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
100
- */
101
-
102
- function nameToHex(color) {
103
- const normalizedColorName = color.toLowerCase().trim();
104
- const result = compressedColorMap[hash(normalizedColorName)];
105
- if (!result) throw new ColorError$1(color);
106
- return `#${result}`;
107
- }
108
-
109
- const r = (str, amount) => Array.from(Array(amount)).map(() => str).join('');
110
-
111
- const reducedHexRegex = new RegExp(`^#${r('([a-f0-9])', 3)}([a-f0-9])?$`, 'i');
112
- const hexRegex = new RegExp(`^#${r('([a-f0-9]{2})', 3)}([a-f0-9]{2})?$`, 'i');
113
- const rgbaRegex = new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${r(',\\s*(\\d+)\\s*', 2)}(?:,\\s*([\\d.]+))?\\s*\\)$`, 'i');
114
- const hslaRegex = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i;
115
- const namedColorRegex = /^[a-z]+$/i;
116
-
117
- const roundColor = color => {
118
- return Math.round(color * 255);
119
- };
120
-
121
- const hslToRgb = (hue, saturation, lightness) => {
122
- let l = lightness / 100;
123
-
124
- if (saturation === 0) {
125
- // achromatic
126
- return [l, l, l].map(roundColor);
127
- } // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
128
-
129
-
130
- const huePrime = (hue % 360 + 360) % 360 / 60;
131
- const chroma = (1 - Math.abs(2 * l - 1)) * (saturation / 100);
132
- const secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
133
- let red = 0;
134
- let green = 0;
135
- let blue = 0;
136
-
137
- if (huePrime >= 0 && huePrime < 1) {
138
- red = chroma;
139
- green = secondComponent;
140
- } else if (huePrime >= 1 && huePrime < 2) {
141
- red = secondComponent;
142
- green = chroma;
143
- } else if (huePrime >= 2 && huePrime < 3) {
144
- green = chroma;
145
- blue = secondComponent;
146
- } else if (huePrime >= 3 && huePrime < 4) {
147
- green = secondComponent;
148
- blue = chroma;
149
- } else if (huePrime >= 4 && huePrime < 5) {
150
- red = secondComponent;
151
- blue = chroma;
152
- } else if (huePrime >= 5 && huePrime < 6) {
153
- red = chroma;
154
- blue = secondComponent;
155
- }
156
-
157
- const lightnessModification = l - chroma / 2;
158
- const finalRed = red + lightnessModification;
159
- const finalGreen = green + lightnessModification;
160
- const finalBlue = blue + lightnessModification;
161
- return [finalRed, finalGreen, finalBlue].map(roundColor);
162
- };
163
-
164
- // taken from:
165
- /**
166
- * Parses a color in hue, saturation, lightness, and the alpha channel.
167
- *
168
- * Hue is a number between 0 and 360, saturation, lightness, and alpha are
169
- * decimal percentages between 0 and 1
170
- */
171
-
172
- function parseToHsla(color) {
173
- const [red, green, blue, alpha] = parseToRgba(color).map((value, index) => // 3rd index is alpha channel which is already normalized
174
- index === 3 ? value : value / 255);
175
- const max = Math.max(red, green, blue);
176
- const min = Math.min(red, green, blue);
177
- const lightness = (max + min) / 2; // achromatic
178
-
179
- if (max === min) return [0, 0, lightness, alpha];
180
- const delta = max - min;
181
- const saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
182
- const hue = 60 * (red === max ? (green - blue) / delta + (green < blue ? 6 : 0) : green === max ? (blue - red) / delta + 2 : (red - green) / delta + 4);
183
- return [hue, saturation, lightness, alpha];
184
- }
185
-
186
- /**
187
- * Takes in hsla parts and constructs an hsla string
188
- *
189
- * @param hue The color circle (from 0 to 360) - 0 (or 360) is red, 120 is green, 240 is blue
190
- * @param saturation Percentage of saturation, given as a decimal between 0 and 1
191
- * @param lightness Percentage of lightness, given as a decimal between 0 and 1
192
- * @param alpha Percentage of opacity, given as a decimal between 0 and 1
193
- */
194
-
195
- function hsla(hue, saturation, lightness, alpha) {
196
- return `hsla(${(hue % 360).toFixed()}, ${guard(0, 100, saturation * 100).toFixed()}%, ${guard(0, 100, lightness * 100).toFixed()}%, ${parseFloat(guard(0, 1, alpha).toFixed(3))})`;
197
- }
198
-
199
- /**
200
- * Takes in rgba parts and returns an rgba string
201
- *
202
- * @param red The amount of red in the red channel, given in a number between 0 and 255 inclusive
203
- * @param green The amount of green in the red channel, given in a number between 0 and 255 inclusive
204
- * @param blue The amount of blue in the red channel, given in a number between 0 and 255 inclusive
205
- * @param alpha Percentage of opacity, given as a decimal between 0 and 1
206
- */
207
-
208
- function rgba(red, green, blue, alpha) {
209
- return `rgba(${guard(0, 255, red).toFixed()}, ${guard(0, 255, green).toFixed()}, ${guard(0, 255, blue).toFixed()}, ${parseFloat(guard(0, 1, alpha).toFixed(3))})`;
210
- }
211
-
212
- /**
213
- * Takes in any color and returns it as an rgba string.
214
- */
215
-
216
- function toRgba(color) {
217
- return rgba(...parseToRgba(color));
218
- }
219
-
220
3
  const swirlThemeProviderCss = ".sc-swirl-theme-provider-h{display:block}";
221
4
 
222
5
  const preferredThemeStorageKey = "swirl-preferred-theme";
223
- const tenantColorMapping = {
224
- "--s-action-primary-default": "primary",
225
- "--s-action-primary-hovered": "primaryHovered",
226
- "--s-action-primary-pressed": "primaryPressed",
227
- "--s-text-on-action-primary": "primaryContrast",
228
- "--s-icon-on-action-primary": "primaryContrast",
229
- "--s-surface-highlight-default": "secondary",
230
- "--s-surface-highlight-hovered": "secondaryHovered",
231
- "--s-surface-highlight-pressed": "secondaryPressed",
232
- "--s-on-surface-highlight-default": "secondaryHovered",
233
- "--s-text-on-surface-highlight": "secondaryContrast",
234
- "--s-icon-on-surface-highlight": "secondaryContrast",
235
- "--s-text-highlight": "text",
236
- "--s-interactive-primary-default": "text",
237
- "--s-interactive-primary-hovered": "textHovered",
238
- "--s-interactive-primary-pressed": "textPressed",
239
- };
240
6
  const SwirlThemeProvider = class {
241
7
  constructor(hostRef) {
242
8
  registerInstance(this, hostRef);
243
9
  this.themeChange = createEvent(this, "themeChange", 7);
10
+ this.setDesignTokens = [];
244
11
  this.config = undefined;
245
12
  }
246
13
  componentWillLoad() {
@@ -254,27 +21,27 @@ const SwirlThemeProvider = class {
254
21
  this.updateAppTheme();
255
22
  }
256
23
  /**
257
- * Returns the active app theme.
24
+ * Returns the active OS theme.
258
25
  * @returns SwirlTheme
259
26
  */
260
- async getActiveTheme() {
261
- return this.appTheme;
27
+ async getActiveOSTheme() {
28
+ return this.appOSTheme;
262
29
  }
263
30
  /**
264
- * Returns the user's preferred theme stored in local storage.
31
+ * Returns the user's preferred OS theme stored in local storage.
265
32
  * @returns SwirlTheme
266
33
  */
267
- async getPreferredTheme() {
34
+ async getPreferredOSTheme() {
268
35
  if (!Boolean(this.resolvedConfig.storage)) {
269
36
  return;
270
37
  }
271
38
  return this.resolvedConfig.storage.getItem(preferredThemeStorageKey);
272
39
  }
273
40
  /**
274
- * Sets the user's preferred theme and stores it in local storage. Overrides
275
- * the OS theme.
41
+ * Sets the user's preferred OS theme and stores it in local storage. Overrides
42
+ * the system theme.
276
43
  */
277
- async setPreferredTheme(theme) {
44
+ async setPreferredOSTheme(theme) {
278
45
  if (!Boolean(this.resolvedConfig.storage)) {
279
46
  return;
280
47
  }
@@ -282,9 +49,9 @@ const SwirlThemeProvider = class {
282
49
  this.updateAppTheme();
283
50
  }
284
51
  /**
285
- * Resets the user's preferred theme, using the OS theme instead.
52
+ * Resets the user's preferred OS theme, using the system theme instead.
286
53
  */
287
- async resetPreferredTheme() {
54
+ async resetPreferredOSTheme() {
288
55
  if (!Boolean(this.resolvedConfig.storage)) {
289
56
  return;
290
57
  }
@@ -311,8 +78,8 @@ const SwirlThemeProvider = class {
311
78
  });
312
79
  }
313
80
  async updateAppTheme() {
314
- this.appTheme = (await this.getPreferredTheme()) || this.osTheme;
315
- if (this.appTheme === "dark") {
81
+ this.appOSTheme = (await this.getPreferredOSTheme()) || this.osTheme;
82
+ if (this.appOSTheme === "dark") {
316
83
  document.documentElement.classList.remove("theme-light");
317
84
  document.documentElement.classList.add("theme-dark");
318
85
  }
@@ -321,59 +88,49 @@ const SwirlThemeProvider = class {
321
88
  document.documentElement.classList.add("theme-light");
322
89
  }
323
90
  this.updateTenantVariables();
91
+ this.updateTenantAssets();
324
92
  const themeChangeEventData = {
325
- activeTheme: await this.getActiveTheme(),
326
- preferredTheme: await this.getPreferredTheme(),
93
+ activeTheme: await this.getActiveOSTheme(),
94
+ preferredTheme: await this.getPreferredOSTheme(),
327
95
  };
328
- if (!Boolean(this.recentThemeChangeEventData) ||
96
+ if (!Boolean(this.recentOSThemeChangeEventData) ||
329
97
  themeChangeEventData.activeTheme !==
330
- this.recentThemeChangeEventData.activeTheme ||
98
+ this.recentOSThemeChangeEventData.activeTheme ||
331
99
  themeChangeEventData.preferredTheme !==
332
- this.recentThemeChangeEventData.preferredTheme) {
333
- this.recentThemeChangeEventData = themeChangeEventData;
334
- this.themeChange.emit(this.recentThemeChangeEventData);
100
+ this.recentOSThemeChangeEventData.preferredTheme) {
101
+ this.recentOSThemeChangeEventData = themeChangeEventData;
102
+ this.themeChange.emit(this.recentOSThemeChangeEventData);
103
+ }
104
+ }
105
+ updateTenantAssets() {
106
+ const theme = this.resolvedConfig?.themes?.[this.appOSTheme];
107
+ if (!Boolean(theme)) {
108
+ return;
335
109
  }
110
+ document.head
111
+ .querySelector('link[rel="icon"]')
112
+ ?.setAttribute("href", theme.favicon.link);
336
113
  }
337
114
  updateTenantVariables() {
338
- const tenantTheme = this.resolvedConfig?.tenantColors;
339
- if (!Boolean(tenantTheme)) {
115
+ const theme = this.resolvedConfig?.themes?.[this.appOSTheme];
116
+ if (!Boolean(theme)) {
340
117
  this.resetTenantVariables();
341
118
  return;
342
119
  }
343
120
  const rootElement = this.resolvedConfig.rootElement;
344
- // generate state colors (hovered, pressed) from base colors
345
- const primaryHsla = parseToHsla(tenantTheme.primary);
346
- const secondaryHsla = parseToHsla(tenantTheme.secondary);
347
- const textHsla = parseToHsla(tenantTheme.text);
348
- const primaryHovered = toRgba(hsla(primaryHsla[0], primaryHsla[1] - 0.21, primaryHsla[2] + 0.09, 1));
349
- const primaryPressed = toRgba(hsla(primaryHsla[0], primaryHsla[1] - 0.2, primaryHsla[2] + 0.17, 1));
350
- const secondaryHovered = toRgba(hsla(secondaryHsla[0], secondaryHsla[1], secondaryHsla[2] + 0.07, 1));
351
- const secondaryPressed = toRgba(hsla(secondaryHsla[0], secondaryHsla[1], secondaryHsla[2] + 0.15, 1));
352
- const textHovered = toRgba(hsla(textHsla[0], textHsla[1] - 0.34, textHsla[2] + 0.1, 1));
353
- const textPressed = toRgba(hsla(textHsla[0], textHsla[1] - 0.48, textHsla[2] + 0.2, 1));
354
- const tenantThemeWithGeneratedStateColors = {
355
- ...tenantTheme,
356
- primaryHovered: primaryHovered,
357
- primaryPressed: primaryPressed,
358
- secondaryHovered: secondaryHovered,
359
- secondaryPressed: secondaryPressed,
360
- textHovered: textHovered,
361
- textPressed: textPressed,
362
- };
363
- // set custom properties for tenant theme colors
364
- Object.entries(tenantColorMapping).forEach(([key, value]) => rootElement.style.setProperty(key, tenantThemeWithGeneratedStateColors[value]));
121
+ this.setDesignTokens = [];
122
+ theme.design_tokens.forEach((token) => {
123
+ const propertyName = `--s-${token.id}`;
124
+ rootElement.style.setProperty(propertyName, `rgba(${token.color.r}, ${token.color.g}, ${token.color.b}, ${token.color.a})`);
125
+ this.setDesignTokens.push(propertyName);
126
+ });
365
127
  }
366
128
  resetTenantVariables() {
367
129
  const rootElement = this.resolvedConfig.rootElement;
368
- [
369
- ...Object.keys(tenantColorMapping),
370
- "primaryHovered",
371
- "primaryPressed",
372
- "secondaryHovered",
373
- "secondaryPressed",
374
- "textHovered",
375
- "textPressed",
376
- ].forEach((key) => rootElement.style.removeProperty(key));
130
+ this.setDesignTokens.forEach((property) => {
131
+ rootElement.style.removeProperty(property);
132
+ });
133
+ this.setDesignTokens = [];
377
134
  }
378
135
  render() {
379
136
  return (h(Host, null, h("slot", null)));
@@ -0,0 +1 @@
1
+ import{r as e,c as i,h as t,H as a,g as s}from"./p-3fca9a05.js";import{A as r}from"./p-fe0b5250.js";import{d as o,e as d}from"./p-33c168b3.js";import{c as l}from"./p-b7898321.js";import{q as n,i as h}from"./p-6e4e9ae0.js";const c=class{constructor(t){e(this,t),this.modalClose=i(this,"modalClose",7),this.modalOpen=i(this,"modalOpen",7),this.desktopZoomSteps=[.5,.75,1,1.25,1.5,2,3,4],this.mobileZoomSteps=[.5,.75,1,1.25,1.5],this.toggleViewMode=()=>{this.viewMode="single"===this.viewMode?"side-by-side":"single"},this.toggleThumbnals=()=>{this.showThumbnails=!this.showThumbnails},this.onKeyDown=e=>{"Escape"===e.code&&this.close()},this.onActivate=async e=>{this.pdfViewer=e.detail,this.lockBodyScroll(),this.generateThumbnails()},this.onVisiblePagesChange=async e=>{this.visiblePages=e.detail},this.onCloseButtonClick=()=>{this.close()},this.onPrintButtonClick=()=>{this.pdfViewer.print(),this.menu.close()},this.onDownloadButtonClick=async()=>{this.downloading=!0,await this.viewer.download(),this.downloading=!1,this.menu.close()},this.onZoomInButtonClick=()=>{const e=this.zoomSteps.indexOf(+this.zoom);this.zoom=-1===e?1:this.zoomSteps[Math.min(this.zoomSteps.length-1,e+1)]},this.onZoomOutButtonClick=()=>{const e=this.zoomSteps.indexOf(+this.zoom);this.zoom=-1===e?1:this.zoomSteps[Math.max(0,e-1)]},this.onZoomAutoButtonClick=()=>{this.zoom="auto"===this.zoom?1:"auto"},this.onZoomChange=e=>{const i=e.target.value;this.zoom="auto"===i?i:+i},this.onThumbnailClick=e=>()=>{const i=n(this.el,`[data-page-number="${e+1}"]`)?.[0];i?.scrollIntoView()},this.autoZoomLabel="Full width",this.closeButtonLabel="Close PDF viewer",this.downloadButtonLabel="Download PDF",this.file=void 0,this.fileTypeLabel="PDF Document",this.label=void 0,this.menuLabel="File menu",this.menuTriggerLabel="Open file menu",this.pdfWorkerSrc=void 0,this.printButtonLabel="Print PDF",this.sideBySideButtonLabel="Toggle side by side view",this.thumbnailButtonLabel="Scroll to page",this.thumbnailsButtonLabel="Toggle thumbnails",this.thumbnailsLabel="Page thumbnails",this.zoomInButtonLabel="Zoom in",this.zoomOutButtonLabel="Zoom out",this.zoomSelectLabel="Select zoom",this.active=!1,this.closing=!1,this.downloading=!1,this.thumbnails=[],this.showThumbnails=void 0,this.viewMode="single",this.visiblePages=[],this.zoom=void 0,this.zoomSteps=void 0}componentWillLoad(){this.updateZoomSteps(),this.zoom=h()?"auto":1}componentDidLoad(){this.modal=new r(this.modalEl)}disconnectedCallback(){this.unlockBodyScroll(),this.modal?.destroy()}onWindowResize(){Boolean(this.pdfViewer)&&(this.updateZoomSteps(),this.zoom=h()?"auto":1)}async open(){this.modal.show(),this.active=!0,this.modalOpen.emit()}async close(){this.closing||(this.closing=!0,this.unlockBodyScroll(),setTimeout((()=>{this.modal.hide(),this.closing=!1,this.active=!1,this.modalClose.emit()}),150))}lockBodyScroll(){const e=this.pdfViewer.shadowRoot.querySelector(".file-viewer-pdf__pages");Boolean(e)&&o(e)}unlockBodyScroll(){const e=this.pdfViewer.shadowRoot.querySelector(".file-viewer-pdf__pages");Boolean(e)&&d(e)}async generateThumbnails(){this.thumbnails=await this.pdfViewer.getThumbnails()}updateZoomSteps(){this.zoomSteps=h()?this.mobileZoomSteps:this.desktopZoomSteps}render(){const e=l("pdf-reader",{"pdf-reader--closing":this.closing,"pdf-reader--show-thumbnails":this.showThumbnails});return t(a,null,t("section",{"aria-hidden":"true","aria-label":this.label,class:e,id:"pdf-reader",onKeyDown:this.onKeyDown,ref:e=>this.modalEl=e},t("div",{class:"pdf-reader__body",role:"document"},t("header",{class:"pdf-reader__header"},t("span",{class:"pdf-reader__header-left"},t("swirl-button",{class:"pdf-reader__close-button",hideLabel:!0,icon:"<swirl-icon-close></swirl-icon-close>",label:this.closeButtonLabel,onClick:this.onCloseButtonClick}),t("span",{class:"pdf-reader__label"},this.label)),t("span",{class:"pdf-reader__header-center"},t("span",{class:"pdf-reader__zoom-button-container"},t("swirl-button",{class:"pdf-reader__zoom-button",disabled:this.zoom===this.zoomSteps[0],hideLabel:!0,icon:"<swirl-icon-remove></swirl-icon-remove>",label:this.zoomOutButtonLabel,onClick:this.onZoomOutButtonClick}),t("swirl-button",{class:"pdf-reader__zoom-button",disabled:this.zoom===this.zoomSteps[this.zoomSteps.length-1],hideLabel:!0,icon:"<swirl-icon-add></swirl-icon-add>",label:this.zoomInButtonLabel,onClick:this.onZoomInButtonClick})),t("span",{class:"pdf-reader__zoom-select-container"},t("select",{"aria-label":this.zoomSelectLabel,class:"pdf-reader__zoom-select",name:"zoom-select",id:"zoom-select",onChange:this.onZoomChange},t("option",{selected:"auto"===this.zoom,value:"auto"},this.autoZoomLabel),this.zoomSteps.map((e=>t("option",{key:e,selected:this.zoom===e,value:e},100*e,"%")))),t("swirl-icon-expand-more",{class:"pdf-reader__zoom-select-icon"}))),t("span",{class:"pdf-reader__header-right"},t("swirl-popover-trigger",{popover:this.menu},t("swirl-button",{class:"pdf-reader__menu-button",hideLabel:!0,icon:"<swirl-icon-more-vertikal></swirl-icon-more-vertikal>",label:this.menuTriggerLabel}))),t("span",{class:"pdf-reader__floating-tools"},t("button",{"aria-label":this.sideBySideButtonLabel,class:"pdf-reader__floating-tool-button",onClick:this.toggleViewMode,type:"button"},t("swirl-icon-menu-book",null)),t("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"},t("swirl-icon-file-copy",null)))),t("div",{class:"pdf-reader__content"},t("nav",{"aria-label":this.thumbnailsLabel,class:"pdf-reader__thumbnails",id:"thumbnails"},this.thumbnails.map(((e,i)=>{const a=l("pdf-reader__thumbnail",{"pdf-reader__thumbnail--active":this.visiblePages[0]===i+1});return t("button",{"aria-label":`${this.thumbnailButtonLabel} ${i+1}`,class:a,onClick:this.onThumbnailClick(i),type:"button"},t("img",{src:e.toDataURL("image/png"),alt:""}))}))),t("swirl-file-viewer",{active:this.active,class:"pdf-reader__viewer",file:this.file,onActivate:this.onActivate,onVisiblePagesChange:this.onVisiblePagesChange,pdfWorkerSrc:this.pdfWorkerSrc,ref:e=>this.viewer=e,type:"application/pdf",viewMode:this.viewMode,zoom:this.zoom}),t("div",{class:"pdf-reader__mobile-zoom-controls"},t("button",{"aria-label":this.autoZoomLabel,class:"pdf-reader__mobile-zoom-button",onClick:this.onZoomAutoButtonClick,type:"button"},t("auto"===this.zoom?"swirl-icon-fullscreen-exit":"swirl-icon-fullscreen",null)),t("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"},t("swirl-icon-add",null)),t("button",{"aria-label":this.zoomOutButtonLabel,class:"pdf-reader__mobile-zoom-button",disabled:this.zoom===this.zoomSteps[0],onClick:this.onZoomOutButtonClick,type:"button"},t("swirl-icon-remove",null))))),t("swirl-popover",{animation:"scale-in-y",disableScrollLock:!0,id:"menu",label:this.menuLabel,placement:"bottom-end",ref:e=>this.menu=e},t("swirl-stack",null,t("div",{class:"pdf-reader__meta"},t("div",{class:"pdf-reader__file-icon"},t("svg",{fill:"none",height:"36",viewBox:"0 0 24 36",width:"24"},t("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"}),t("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"}),t("path",{d:"M14.5146 21.6V15.192H17.2506V16.056H15.4326V18H17.0166V18.864H15.4326V21.6H14.5146Z",fill:"white"}),t("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"}),t("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"}),t("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"}),t("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"}),t("path",{d:"M14.5146 21.6V15.192H17.2506V16.056H15.4326V18H17.0166V18.864H15.4326V21.6H14.5146Z",fill:"white"}))),t("div",{class:"pdf-reader__file-info"},t("swirl-text",{truncate:!0,weight:"semibold"},this.label),t("swirl-text",{color:"subdued",size:"sm",truncate:!0},this.fileTypeLabel))),t("swirl-separator",null),t("swirl-action-list",null,t("swirl-action-list-item",{class:"pdf-reader__print-button",icon:"<swirl-icon-print></swirl-icon-print>",label:this.printButtonLabel,onClick:this.onPrintButtonClick}),t("swirl-action-list-item",{class:"pdf-reader__download-button",disabled:this.downloading,icon:this.downloading?'<swirl-spinner size="xs"></swirl-spinner>':"<swirl-icon-download></swirl-icon-download>",label:this.downloadButtonLabel,onClick:this.onDownloadButtonClick}),t("slot",{name:"menu-items"}))))))}get el(){return s(this)}};c.style=':host{--thumbnails-width:7rem;display:block}:host *{box-sizing:border-box}.pdf-reader{position:fixed;z-index:var(--s-z-40);background-color:var(--s-surface-raised-default);inset:0;touch-action:pan-x pan-y}.pdf-reader[aria-hidden="true"]{display:none}.pdf-reader:not(.pdf-reader--closing) .pdf-reader__body{animation:0.15s pdf-reader-fade-in}@media (prefers-reduced-motion){.pdf-reader:not(.pdf-reader--closing) .pdf-reader__body{animation:none}}.pdf-reader--closing{animation:0.15s pdf-reader-fade-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.pdf-reader--closing{animation:none}}.pdf-reader--show-thumbnails .pdf-reader__thumbnails{max-width:var(--thumbnails-width)}.pdf-reader--show-thumbnails .pdf-reader__floating-tools{left:calc(var(--s-space-16) + var(--thumbnails-width))}.pdf-reader__body{position:relative;width:100%;height:100%}.pdf-reader__header{display:flex;height:4rem;padding-right:var(--s-space-16);padding-left:var(--s-space-16);align-items:center;border-bottom:var(--s-border-width-default) solid var(--s-border-default);background-color:var(--s-background-default);gap:var(--s-space-8)}.pdf-reader__header-left,.pdf-reader__header-right{display:flex;flex-grow:1;align-items:center;gap:var(--s-space-8)}@media (min-width: 768px){.pdf-reader__header-left,.pdf-reader__header-right{flex-basis:calc(100 / 3 * 1%);flex-grow:0}}.pdf-reader__header-right{justify-content:flex-end}.pdf-reader__header-center{display:none;flex-grow:1;justify-content:center;align-items:center;gap:var(--s-space-16)}@media (min-width: 768px){.pdf-reader__header-center{display:flex}}.pdf-reader__label{overflow:hidden;flex-grow:1;font-weight:var(--s-font-weight-semibold);white-space:nowrap;text-overflow:ellipsis}.pdf-reader__zoom-button-container{display:flex;align-items:center;gap:var(--s-space-8)}.pdf-reader__zoom-button-container>*:not(:last-child){position:relative}.pdf-reader__zoom-button-container>*:not(:last-child):after{position:absolute;top:50%;right:calc(-1 * var(--s-space-4));width:var(--s-border-width-default);height:1.5rem;background-color:var(--s-border-default);content:"";transform:translate3d(50%, -50%, 0)}.pdf-reader__zoom-select-container{position:relative}.pdf-reader__zoom-select{display:inline-flex;height:2.5rem;padding-right:var(--s-space-12);padding-right:calc(var(--s-space-8) + 1.5rem + var(--s-space-12));padding-left:var(--s-space-12);justify-content:flex-start;align-items:center;border:var(--s-border-width-default) solid var(--s-border-default);border-radius:var(--s-border-radius-sm);color:var(--s-interactive-neutral-default);background-color:transparent;font:inherit;font-weight:var(--s-font-weight-medium);cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.pdf-reader__zoom-select:focus:not(:focus-visible){outline:none}.pdf-reader__zoom-select:focus-visible{outline-color:var(--s-focus-default)}.pdf-reader__zoom-select-icon{position:absolute;top:50%;right:var(--s-space-8);display:inline-flex;transform:translateY(-50%);pointer-events:none}.pdf-reader__content{display:flex;width:100%;height:calc(100% - 4rem)}.pdf-reader__thumbnails{display:flex;overflow-x:hidden;overflow-y:auto;max-width:0;height:100%;padding-top:var(--s-space-16);padding-bottom:var(--s-space-16);flex-basis:var(--thumbnails-width);flex-grow:0;flex-shrink:0;align-items:center;background-color:var(--s-background-default);flex-direction:column;transition:max-width 0.2s linear;box-shadow:inset calc(-1 * var(--s-border-width-default)) 0 0 0\n var(--s-border-default);gap:var(--s-space-4)}.pdf-reader__thumbnail{width:5rem;margin:0;padding:0;border:var(--s-border-width-default) solid var(--s-border-default);background-color:transparent;cursor:pointer}.pdf-reader__thumbnail>img{display:inline-flex;width:100%}.pdf-reader__thumbnail--active{border-width:0.125rem;border-color:var(--s-border-highlight)}.pdf-reader__viewer{flex-grow:1}.pdf-reader__mobile-zoom-controls{position:absolute;z-index:1;right:var(--s-space-16);bottom:var(--s-space-32);display:flex;padding-bottom:var(--s-space-4);flex-direction:column;gap:var(--s-space-8)}@media (min-width: 768px){.pdf-reader__mobile-zoom-controls{display:none}}.pdf-reader__mobile-zoom-button{display:inline-flex;width:2.5rem;height:2.5rem;justify-content:center;align-items:center;border:none;border-radius:50%;color:var(--s-icon-on-image);background-color:rgba(0, 0, 0, 0.6);cursor:pointer;transition:opacity 0.15s;pointer-events:auto}.pdf-reader__mobile-zoom-button:disabled{cursor:default}.pdf-reader__floating-tools{position:fixed;z-index:1;bottom:var(--s-space-16);left:var(--s-space-16);display:none;flex-direction:column;transition:left 0.2s linear;gap:var(--s-space-12)}@media (min-width: 768px){.pdf-reader__floating-tools{display:flex}}.pdf-reader__floating-tool-button{display:inline-flex;width:2.5rem;height:2.5rem;justify-content:center;align-items:center;border:none;border-radius:50%;color:var(--s-icon-on-image);background-color:rgba(0, 0, 0, 0.6);cursor:pointer}.pdf-reader__meta{display:flex;padding-top:var(--s-space-4);padding-right:var(--s-space-16);padding-bottom:var(--s-space-4);padding-left:var(--s-space-8);align-items:center;gap:var(--s-space-12)}@media (min-width: 768px){.pdf-reader__meta{max-width:18rem}}.pdf-reader__file-icon{display:inline-flex;padding-left:var(--s-space-4);flex-shrink:0}.pdf-reader__file-info{display:flex;min-width:0;flex-grow:1;flex-direction:column}@keyframes pdf-reader-fade-in{from{opacity:0}to{opacity:1}}@keyframes pdf-reader-fade-out{from{opacity:1}to{opacity:0}}';export{c as swirl_pdf_reader}