@fluid-topics/ft-viewer 2.1.10

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 (94) hide show
  1. package/README.md +19 -0
  2. package/build/asset/components/FtAssetViewerComponent.d.ts +5 -0
  3. package/build/asset/components/FtAssetViewerComponent.js +4 -0
  4. package/build/asset/components/ft-asset-viewer-content-control.d.ts +5 -0
  5. package/build/asset/components/ft-asset-viewer-content-control.js +4 -0
  6. package/build/asset/components/ft-asset-viewer-content.d.ts +5 -0
  7. package/build/asset/components/ft-asset-viewer-content.js +4 -0
  8. package/build/asset/components/ft-asset-viewer-document-title.d.ts +5 -0
  9. package/build/asset/components/ft-asset-viewer-document-title.js +4 -0
  10. package/build/asset/components/ft-asset-viewer-filename.d.ts +5 -0
  11. package/build/asset/components/ft-asset-viewer-filename.js +4 -0
  12. package/build/asset/components/ft-asset-viewer-mime-type-icon.d.ts +5 -0
  13. package/build/asset/components/ft-asset-viewer-mime-type-icon.js +4 -0
  14. package/build/asset/components/ft-asset-viewer-title.d.ts +5 -0
  15. package/build/asset/components/ft-asset-viewer-title.js +4 -0
  16. package/build/asset/components/registration.d.ts +12 -0
  17. package/build/asset/components/registration.js +40 -0
  18. package/build/asset/ft-asset-viewer-context.d.ts +16 -0
  19. package/build/asset/ft-asset-viewer-context.js +59 -0
  20. package/build/asset/ft-asset-viewer-context.properties.d.ts +2 -0
  21. package/build/asset/ft-asset-viewer-context.properties.js +1 -0
  22. package/build/asset/index.d.ts +10 -0
  23. package/build/asset/index.js +10 -0
  24. package/build/asset/model/FtAssetViewerService.d.ts +6 -0
  25. package/build/asset/model/FtAssetViewerService.js +12 -0
  26. package/build/asset/model/FtAssetViewerStateManager.d.ts +14 -0
  27. package/build/asset/model/FtAssetViewerStateManager.js +47 -0
  28. package/build/asset/model/ft-asset-viewer.models.d.ts +0 -0
  29. package/build/asset/model/ft-asset-viewer.models.js +1 -0
  30. package/build/common/FtViewerComponent.d.ts +5 -0
  31. package/build/common/FtViewerComponent.js +3 -0
  32. package/build/common/ft-viewer-content-control.d.ts +35 -0
  33. package/build/common/ft-viewer-content-control.js +164 -0
  34. package/build/common/ft-viewer-content.d.ts +51 -0
  35. package/build/common/ft-viewer-content.js +274 -0
  36. package/build/common/ft-viewer-display-name.d.ts +9 -0
  37. package/build/common/ft-viewer-display-name.js +31 -0
  38. package/build/common/ft-viewer-document-title.d.ts +9 -0
  39. package/build/common/ft-viewer-document-title.js +31 -0
  40. package/build/common/ft-viewer-filename.d.ts +9 -0
  41. package/build/common/ft-viewer-filename.js +31 -0
  42. package/build/common/ft-viewer-mime-type-icon.d.ts +9 -0
  43. package/build/common/ft-viewer-mime-type-icon.js +29 -0
  44. package/build/common/ft-viewer.messages.d.ts +11 -0
  45. package/build/common/ft-viewer.messages.js +10 -0
  46. package/build/common/index.d.ts +1 -0
  47. package/build/common/index.js +1 -0
  48. package/build/common/model/FtViewerReduxStore.d.ts +14 -0
  49. package/build/common/model/FtViewerReduxStore.js +25 -0
  50. package/build/common/model/FtViewerStateManager.d.ts +8 -0
  51. package/build/common/model/FtViewerStateManager.js +13 -0
  52. package/build/common/model/ft-viewer.models.d.ts +44 -0
  53. package/build/common/model/ft-viewer.models.js +23 -0
  54. package/build/define.d.ts +1 -0
  55. package/build/define.js +3 -0
  56. package/build/definitions.d.ts +19 -0
  57. package/build/definitions.js +18 -0
  58. package/build/ft-viewer.light.js +650 -0
  59. package/build/ft-viewer.min.js +773 -0
  60. package/build/index.d.ts +3 -0
  61. package/build/index.js +3 -0
  62. package/build/ud/components/FtUdViewerComponent.d.ts +5 -0
  63. package/build/ud/components/FtUdViewerComponent.js +4 -0
  64. package/build/ud/components/ft-ud-viewer-attachments.d.ts +16 -0
  65. package/build/ud/components/ft-ud-viewer-attachments.js +55 -0
  66. package/build/ud/components/ft-ud-viewer-attachments.styles.d.ts +2 -0
  67. package/build/ud/components/ft-ud-viewer-attachments.styles.js +14 -0
  68. package/build/ud/components/ft-ud-viewer-content-control.d.ts +5 -0
  69. package/build/ud/components/ft-ud-viewer-content-control.js +4 -0
  70. package/build/ud/components/ft-ud-viewer-content.d.ts +5 -0
  71. package/build/ud/components/ft-ud-viewer-content.js +4 -0
  72. package/build/ud/components/ft-ud-viewer-filename.d.ts +5 -0
  73. package/build/ud/components/ft-ud-viewer-filename.js +4 -0
  74. package/build/ud/components/ft-ud-viewer-mime-type-icon.d.ts +5 -0
  75. package/build/ud/components/ft-ud-viewer-mime-type-icon.js +4 -0
  76. package/build/ud/components/ft-ud-viewer-title.d.ts +5 -0
  77. package/build/ud/components/ft-ud-viewer-title.js +4 -0
  78. package/build/ud/components/registration.d.ts +16 -0
  79. package/build/ud/components/registration.js +62 -0
  80. package/build/ud/ft-ud-viewer-context.d.ts +13 -0
  81. package/build/ud/ft-ud-viewer-context.js +53 -0
  82. package/build/ud/ft-ud-viewer-context.properties.d.ts +3 -0
  83. package/build/ud/ft-ud-viewer-context.properties.js +1 -0
  84. package/build/ud/ft-ud-viewer.messages.d.ts +6 -0
  85. package/build/ud/ft-ud-viewer.messages.js +5 -0
  86. package/build/ud/index.d.ts +10 -0
  87. package/build/ud/index.js +10 -0
  88. package/build/ud/model/FtUdViewerService.d.ts +12 -0
  89. package/build/ud/model/FtUdViewerService.js +24 -0
  90. package/build/ud/model/FtUdViewerStateManager.d.ts +13 -0
  91. package/build/ud/model/FtUdViewerStateManager.js +58 -0
  92. package/build/ud/model/ft-ud-viewer.models.d.ts +6 -0
  93. package/build/ud/model/ft-ud-viewer.models.js +8 -0
  94. package/package.json +34 -0
@@ -0,0 +1,274 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { FtViewerComponent } from "./FtViewerComponent";
8
+ import { css, html, nothing, } from "lit";
9
+ import { redux, withConditionalVisibility, } from "@fluid-topics/ft-wc-utils";
10
+ import { query, state, } from "lit/decorators.js";
11
+ import { FtContentWatermark } from "@fluid-topics/ft-content-watermark";
12
+ import { FluidTopicsApiProvider } from "@fluid-topics/ft-app-context";
13
+ import { unsafeHTML } from "lit/directives/unsafe-html.js";
14
+ export class FtViewerContent extends withConditionalVisibility(FtViewerComponent) {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.viewerType = "none";
18
+ this.inlineSvgAllowed = false;
19
+ }
20
+ render() {
21
+ return html `
22
+ ${this.renderContent()}
23
+ <ft-content-watermark part="watermark"
24
+ .watermark=${this.watermark}
25
+ .exportpartsPrefixes=${["watermark"]}
26
+ .heightReference=${this}></ft-content-watermark>
27
+ `;
28
+ }
29
+ renderContent() {
30
+ var _a;
31
+ switch (this.viewerType) {
32
+ case "image":
33
+ return this.renderImageViewer();
34
+ case "inline-svg":
35
+ return this.renderImageViewer();
36
+ case "video":
37
+ return this.renderVideoViewer();
38
+ case "pdf":
39
+ return this.renderPdfViewer();
40
+ case "iframe":
41
+ return this.renderIframeViewer((_a = this.descriptor) === null || _a === void 0 ? void 0 : _a.contentUrl);
42
+ default:
43
+ return nothing;
44
+ }
45
+ }
46
+ renderImageViewer() {
47
+ var _a, _b;
48
+ return html `
49
+ <div class="image-viewer">
50
+ <div class="image-viewer-content">
51
+ <div class="image-container">
52
+ ${(this.viewerType === "image") ? html `
53
+ <img src="${(_a = this.descriptor) === null || _a === void 0 ? void 0 : _a.contentUrl}"
54
+ alt="${(_b = this.descriptor) === null || _b === void 0 ? void 0 : _b.alt}"
55
+ @load=${this.onImageLoad}>
56
+ ` : html `
57
+ ${unsafeHTML(this.svgContent)}
58
+ `}
59
+
60
+ </div>
61
+ </div>
62
+ </div>
63
+ `;
64
+ }
65
+ onImageLoad() {
66
+ var _a;
67
+ this.initialImageHeight = this.image.naturalHeight === 0 ? this.image.clientHeight : this.image.naturalHeight;
68
+ this.initialImageWidth = this.image.naturalWidth === 0 ? this.image.clientWidth : this.image.naturalWidth;
69
+ (_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.setZoom(Math.min(1, this.getImageToViewerRatio()));
70
+ }
71
+ onSvgLoad() {
72
+ var _a;
73
+ if (this.svg.clientWidth === 0 || this.svg.clientHeight === 0) {
74
+ this.svg.style.width = "90vw";
75
+ this.svg.style.height = "90vh";
76
+ }
77
+ this.initialImageHeight = this.svg.viewBox.baseVal.height === 0 ? this.svg.clientHeight : this.svg.viewBox.baseVal.height;
78
+ this.initialImageWidth = this.svg.viewBox.baseVal.width === 0 ? this.svg.clientWidth : this.svg.viewBox.baseVal.width;
79
+ (_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.setZoom(Math.min(1, this.getImageToViewerRatio()));
80
+ }
81
+ getImageToViewerRatio() {
82
+ if (this.initialImageHeight != undefined && this.initialImageWidth != undefined) {
83
+ const imageRatio = this.initialImageHeight / this.initialImageWidth;
84
+ const viewerRatio = this.clientHeight / this.clientWidth;
85
+ return imageRatio > viewerRatio
86
+ ? this.clientHeight / this.initialImageHeight
87
+ : this.clientWidth / this.initialImageWidth;
88
+ }
89
+ return undefined;
90
+ }
91
+ /***************************************
92
+ * Video viewer *
93
+ ***************************************/
94
+ renderVideoViewer() {
95
+ var _a;
96
+ return html `
97
+ <video src="${(_a = this.descriptor) === null || _a === void 0 ? void 0 : _a.contentUrl}" controls></video>
98
+ `;
99
+ }
100
+ /***************************************
101
+ * PDF viewer *
102
+ ***************************************/
103
+ renderPdfViewer() {
104
+ var _a;
105
+ const queryParameter = new URLSearchParams({ file: this.descriptor.contentUrl });
106
+ return this.renderIframeViewer(`${(_a = FluidTopicsApiProvider.get()) === null || _a === void 0 ? void 0 : _a.makeAbsolute("/pdf-viewer")}?${queryParameter}`);
107
+ }
108
+ /***************************************
109
+ * Iframe viewer *
110
+ ***************************************/
111
+ renderIframeViewer(url) {
112
+ return html `
113
+ <iframe src="${url}"></iframe>
114
+ `;
115
+ }
116
+ willUpdate(props) {
117
+ var _a, _b, _c;
118
+ super.willUpdate(props);
119
+ if (props.has("descriptor")) {
120
+ this.isVisible = !!((_a = this.descriptor) === null || _a === void 0 ? void 0 : _a.viewableInCurrentBrowser);
121
+ this.initialImageHeight = undefined;
122
+ this.initialImageWidth = undefined;
123
+ this.imageHeight = undefined;
124
+ this.imageWidth = undefined;
125
+ (_b = this.viewerStateManager) === null || _b === void 0 ? void 0 : _b.setZoom(undefined);
126
+ (_c = this.viewerStateManager) === null || _c === void 0 ? void 0 : _c.setRotation(0);
127
+ this.svgContent = undefined;
128
+ }
129
+ if (props.has("zoom")) {
130
+ this.imageHeight = this.zoom && this.initialImageHeight ? this.initialImageHeight * this.zoom : undefined;
131
+ this.imageWidth = this.zoom && this.initialImageWidth ? this.initialImageWidth * this.zoom : undefined;
132
+ }
133
+ }
134
+ updated(props) {
135
+ var _a, _b, _c, _d, _e, _f;
136
+ super.updated(props);
137
+ if (!((_a = this.descriptor) === null || _a === void 0 ? void 0 : _a.viewableInCurrentBrowser) || !((_b = this.descriptor) === null || _b === void 0 ? void 0 : _b.contentUrl)) {
138
+ this.viewerType = "none";
139
+ }
140
+ else if (this.inlineSvgAllowed && ((_c = this.descriptor) === null || _c === void 0 ? void 0 : _c.mimeType.startsWith("image/svg"))) {
141
+ this.viewerType = "inline-svg";
142
+ }
143
+ else if ((_d = this.descriptor) === null || _d === void 0 ? void 0 : _d.mimeType.startsWith("image/")) {
144
+ this.viewerType = "image";
145
+ }
146
+ else if ((_e = this.descriptor) === null || _e === void 0 ? void 0 : _e.mimeType.startsWith("video/")) {
147
+ this.viewerType = "video";
148
+ }
149
+ else if (((_f = this.descriptor) === null || _f === void 0 ? void 0 : _f.mimeType) === "application/pdf") {
150
+ this.viewerType = "pdf";
151
+ }
152
+ else {
153
+ this.viewerType = "iframe";
154
+ }
155
+ }
156
+ contentAvailableCallback(props) {
157
+ var _a, _b, _c, _d;
158
+ super.contentAvailableCallback(props);
159
+ if (this.viewerType === "image" || this.viewerType === "inline-svg") {
160
+ if (props.has("zoom") && this.zoom == undefined) { // Fit to container
161
+ (_a = this.viewerStateManager) === null || _a === void 0 ? void 0 : _a.setZoom(this.getImageToViewerRatio());
162
+ }
163
+ if (props.has("zoom") || props.has("rotation")) {
164
+ const image = this.image || this.svg;
165
+ if (image) {
166
+ image.style.transform = `scaleX(${this.zoom}) scaleY(${this.zoom}) rotate(${this.rotation}deg)`;
167
+ }
168
+ if (this.imageViewer && this.imageContainer && image) {
169
+ const scrollHeightRatio = (this.imageViewer.scrollTop + this.imageViewer.clientHeight / 2) / this.imageViewer.scrollHeight;
170
+ const scrollWidthRatio = (this.imageViewer.scrollLeft + this.imageViewer.clientWidth / 2) / this.imageViewer.scrollWidth;
171
+ const { height, width } = image.getClientRects()[0];
172
+ this.imageContainer.style.height = `${height}px`;
173
+ this.imageContainer.style.width = `${width}px`;
174
+ // Maintains the viewer at its current spot on the image
175
+ this.imageViewer.scrollTop = scrollHeightRatio * this.imageViewer.scrollHeight - this.imageViewer.clientHeight / 2;
176
+ this.imageViewer.scrollLeft = scrollWidthRatio * this.imageViewer.scrollWidth - this.imageViewer.clientWidth / 2;
177
+ }
178
+ }
179
+ }
180
+ if (this.viewerType === "inline-svg") {
181
+ if (props.has("descriptor") && ((_b = this.descriptor) === null || _b === void 0 ? void 0 : _b.contentUrl)) {
182
+ (_c = FluidTopicsApiProvider.get()) === null || _c === void 0 ? void 0 : _c.fetch((_d = this.descriptor) === null || _d === void 0 ? void 0 : _d.contentUrl).then((response) => response.text()).then((svgContent) => this.svgContent = svgContent);
183
+ }
184
+ if (props.has("svgContent") && this.svgContent) {
185
+ this.onSvgLoad();
186
+ }
187
+ }
188
+ }
189
+ }
190
+ FtViewerContent.elementDefinitions = {
191
+ "ft-content-watermark": FtContentWatermark,
192
+ };
193
+ FtViewerContent.styles = css `
194
+ :host {
195
+ display: block;
196
+ min-height: 100px;
197
+ }
198
+
199
+ .image-viewer {
200
+ display: flex;
201
+ flex-direction: column;
202
+ overflow: auto;
203
+ width: 100%;
204
+ height: 100%;
205
+ }
206
+
207
+ .image-viewer-content {
208
+ flex: 1 1 auto;
209
+ display: flex;
210
+ align-items: center;
211
+ justify-content: center;
212
+ min-height: fit-content;
213
+ min-width: fit-content;
214
+ }
215
+
216
+ .image-container {
217
+ display: flex;
218
+ align-items: center;
219
+ justify-content: center;
220
+ overflow: hidden;
221
+ }
222
+
223
+ video {
224
+ width: 100%;
225
+ height: auto;
226
+ max-height: 100%;
227
+ }
228
+
229
+ iframe {
230
+ width: 100%;
231
+ height: 100%;
232
+ max-height: 100%;
233
+ border: none;
234
+ }
235
+ `;
236
+ __decorate([
237
+ redux({ store: "viewer" })
238
+ ], FtViewerContent.prototype, "descriptor", void 0);
239
+ __decorate([
240
+ state()
241
+ ], FtViewerContent.prototype, "viewerType", void 0);
242
+ __decorate([
243
+ state()
244
+ ], FtViewerContent.prototype, "inlineSvgAllowed", void 0);
245
+ __decorate([
246
+ redux({ store: "viewer", selector: ({ contentModifiers }) => contentModifiers.zoom })
247
+ ], FtViewerContent.prototype, "zoom", void 0);
248
+ __decorate([
249
+ redux({ store: "viewer", selector: ({ contentModifiers }) => contentModifiers.rotation })
250
+ ], FtViewerContent.prototype, "rotation", void 0);
251
+ __decorate([
252
+ redux({ store: "viewer" })
253
+ ], FtViewerContent.prototype, "watermark", void 0);
254
+ __decorate([
255
+ query("img")
256
+ ], FtViewerContent.prototype, "image", void 0);
257
+ __decorate([
258
+ query("svg")
259
+ ], FtViewerContent.prototype, "svg", void 0);
260
+ __decorate([
261
+ query(".image-viewer")
262
+ ], FtViewerContent.prototype, "imageViewer", void 0);
263
+ __decorate([
264
+ query(".image-container")
265
+ ], FtViewerContent.prototype, "imageContainer", void 0);
266
+ __decorate([
267
+ state()
268
+ ], FtViewerContent.prototype, "imageHeight", void 0);
269
+ __decorate([
270
+ state()
271
+ ], FtViewerContent.prototype, "imageWidth", void 0);
272
+ __decorate([
273
+ state()
274
+ ], FtViewerContent.prototype, "svgContent", void 0);
@@ -0,0 +1,9 @@
1
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
2
+ import { nothing } from "lit";
3
+ import { FtViewerComponent } from "./FtViewerComponent";
4
+ export declare class FtViewerDisplayName extends FtViewerComponent {
5
+ static elementDefinitions: ElementDefinitionsMap;
6
+ static styles: import("lit").CSSResult;
7
+ private displayName?;
8
+ render(): import("lit-html").TemplateResult<1> | typeof nothing;
9
+ }
@@ -0,0 +1,31 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { redux, } from "@fluid-topics/ft-wc-utils";
8
+ import { css, html, nothing, } from "lit";
9
+ import { FtTypography, FtTypographyVariants, } from "@fluid-topics/ft-typography";
10
+ import { FtViewerComponent } from "./FtViewerComponent";
11
+ export class FtViewerDisplayName extends FtViewerComponent {
12
+ render() {
13
+ return this.displayName ? html `
14
+ <ft-typography variant="${FtTypographyVariants.title}" part="display-name" element="h2">
15
+ ${this.displayName}
16
+ </ft-typography>
17
+ ` : nothing;
18
+ }
19
+ }
20
+ FtViewerDisplayName.elementDefinitions = {
21
+ "ft-typography": FtTypography,
22
+ };
23
+ // language=css
24
+ FtViewerDisplayName.styles = css `
25
+ [part="display-name"]::part(text) {
26
+ margin: unset;
27
+ }
28
+ `;
29
+ __decorate([
30
+ redux({ store: "viewer", selector: ({ descriptor }) => descriptor === null || descriptor === void 0 ? void 0 : descriptor.displayName })
31
+ ], FtViewerDisplayName.prototype, "displayName", void 0);
@@ -0,0 +1,9 @@
1
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
2
+ import { nothing } from "lit";
3
+ import { FtViewerComponent } from "./FtViewerComponent";
4
+ export declare class FtViewerDocumentTitle extends FtViewerComponent {
5
+ static elementDefinitions: ElementDefinitionsMap;
6
+ static styles: import("lit").CSSResult;
7
+ private documentTitle?;
8
+ render(): import("lit-html").TemplateResult<1> | typeof nothing;
9
+ }
@@ -0,0 +1,31 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { redux, } from "@fluid-topics/ft-wc-utils";
8
+ import { css, html, nothing, } from "lit";
9
+ import { FtTypography, FtTypographyVariants, } from "@fluid-topics/ft-typography";
10
+ import { FtViewerComponent } from "./FtViewerComponent";
11
+ export class FtViewerDocumentTitle extends FtViewerComponent {
12
+ render() {
13
+ return this.documentTitle ? html `
14
+ <ft-typography variant="${FtTypographyVariants.title}" part="title" element="h1">
15
+ ${this.documentTitle}
16
+ </ft-typography>
17
+ ` : nothing;
18
+ }
19
+ }
20
+ FtViewerDocumentTitle.elementDefinitions = {
21
+ "ft-typography": FtTypography,
22
+ };
23
+ // language=css
24
+ FtViewerDocumentTitle.styles = css `
25
+ [part="title"]::part(text) {
26
+ margin: unset;
27
+ }
28
+ `;
29
+ __decorate([
30
+ redux({ store: "viewer", selector: ({ document }) => document === null || document === void 0 ? void 0 : document.title })
31
+ ], FtViewerDocumentTitle.prototype, "documentTitle", void 0);
@@ -0,0 +1,9 @@
1
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
2
+ import { nothing } from "lit";
3
+ import { FtViewerComponent } from "./FtViewerComponent";
4
+ export declare class FtViewerFilename extends FtViewerComponent {
5
+ static elementDefinitions: ElementDefinitionsMap;
6
+ static styles: import("lit").CSSResult;
7
+ private filename?;
8
+ render(): import("lit-html").TemplateResult<1> | typeof nothing;
9
+ }
@@ -0,0 +1,31 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { redux, } from "@fluid-topics/ft-wc-utils";
8
+ import { css, html, nothing, } from "lit";
9
+ import { FtTypography, FtTypographyVariants, } from "@fluid-topics/ft-typography";
10
+ import { FtViewerComponent } from "./FtViewerComponent";
11
+ export class FtViewerFilename extends FtViewerComponent {
12
+ render() {
13
+ return this.filename ? html `
14
+ <ft-typography variant="${FtTypographyVariants.body1}" part="filename">
15
+ ${this.filename}
16
+ </ft-typography>
17
+ ` : nothing;
18
+ }
19
+ }
20
+ FtViewerFilename.elementDefinitions = {
21
+ "ft-typography": FtTypography,
22
+ };
23
+ // language=css
24
+ FtViewerFilename.styles = css `
25
+ [part="filename"]::part(text) {
26
+ margin: unset;
27
+ }
28
+ `;
29
+ __decorate([
30
+ redux({ store: "viewer", selector: ({ descriptor }) => descriptor === null || descriptor === void 0 ? void 0 : descriptor.filename })
31
+ ], FtViewerFilename.prototype, "filename", void 0);
@@ -0,0 +1,9 @@
1
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
2
+ import { nothing } from "lit";
3
+ import { FtViewerComponent } from "./FtViewerComponent";
4
+ export declare class FtViewerMimeTypeIcon extends FtViewerComponent {
5
+ static elementDefinitions: ElementDefinitionsMap;
6
+ mimeType?: string;
7
+ filename?: string;
8
+ render(): import("lit-html").TemplateResult<1> | typeof nothing;
9
+ }
@@ -0,0 +1,29 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { last, redux, } from "@fluid-topics/ft-wc-utils";
8
+ import { html, nothing, } from "lit";
9
+ import { FtIcon, FtIconVariants, resolveFileFormatIcon, } from "@fluid-topics/ft-icon";
10
+ import { FtViewerComponent } from "./FtViewerComponent";
11
+ export class FtViewerMimeTypeIcon extends FtViewerComponent {
12
+ render() {
13
+ var _a, _b;
14
+ return this.mimeType ? html `
15
+ <ft-icon part="icon"
16
+ variant="${FtIconVariants.file_format}"
17
+ value="${resolveFileFormatIcon(this.mimeType, last((_b = (_a = this.filename) === null || _a === void 0 ? void 0 : _a.split(".")) !== null && _b !== void 0 ? _b : []))}"></ft-icon>
18
+ ` : nothing;
19
+ }
20
+ }
21
+ FtViewerMimeTypeIcon.elementDefinitions = {
22
+ "ft-icon": FtIcon,
23
+ };
24
+ __decorate([
25
+ redux({ store: "viewer", selector: ({ descriptor }) => descriptor === null || descriptor === void 0 ? void 0 : descriptor.mimeType })
26
+ ], FtViewerMimeTypeIcon.prototype, "mimeType", void 0);
27
+ __decorate([
28
+ redux({ store: "viewer", selector: ({ descriptor }) => descriptor === null || descriptor === void 0 ? void 0 : descriptor.filename })
29
+ ], FtViewerMimeTypeIcon.prototype, "filename", void 0);
@@ -0,0 +1,11 @@
1
+ import { DefaultI18nMessages, I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
2
+ export interface FtViewerMessages extends I18nMessages {
3
+ fitToContainerAriaLabel(): string;
4
+ zoomRealSizeAriaLabel(): string;
5
+ zoomInAriaLabel(): string;
6
+ zoomOutAriaLabel(): string;
7
+ rotateLeftAriaLabel(): string;
8
+ rotateRightAriaLabel(): string;
9
+ }
10
+ export declare const viewerContext: I18nMessageContext<FtViewerMessages>;
11
+ export declare const defaultViewerMessages: DefaultI18nMessages<FtViewerMessages>;
@@ -0,0 +1,10 @@
1
+ import { I18nMessageContext, } from "@fluid-topics/ft-i18n";
2
+ export const viewerContext = I18nMessageContext.build("designedViewer");
3
+ export const defaultViewerMessages = {
4
+ fitToContainerAriaLabel: "Fill available space",
5
+ zoomRealSizeAriaLabel: "Display content at original size",
6
+ zoomInAriaLabel: "Zoom in",
7
+ zoomOutAriaLabel: "Zoom out",
8
+ rotateLeftAriaLabel: "Rotate left",
9
+ rotateRightAriaLabel: "Rotate right",
10
+ };
@@ -0,0 +1 @@
1
+ export * from "./model/ft-viewer.models";
@@ -0,0 +1 @@
1
+ export * from "./model/ft-viewer.models";
@@ -0,0 +1,14 @@
1
+ import { FtReduxStore } from "@fluid-topics/ft-wc-utils";
2
+ import { FtViewerState } from "./ft-viewer.models";
3
+ import { PayloadAction } from "@reduxjs/toolkit";
4
+ declare const viewerStateReducers: {
5
+ setZoom: (state: FtViewerState, action: PayloadAction<FtViewerState["contentModifiers"]["zoom"]>) => void;
6
+ setRotation: (state: FtViewerState, action: PayloadAction<FtViewerState["contentModifiers"]["rotation"]>) => void;
7
+ };
8
+ export type FtViewerStateReducers = typeof viewerStateReducers;
9
+ export type FtViewerReduxStore = FtReduxStore<FtViewerState, FtViewerStateReducers>;
10
+ export declare const createViewerStore: (id: string) => FtReduxStore<FtViewerState, {
11
+ setZoom: (state: FtViewerState, action: PayloadAction<FtViewerState["contentModifiers"]["zoom"]>) => void;
12
+ setRotation: (state: FtViewerState, action: PayloadAction<FtViewerState["contentModifiers"]["rotation"]>) => void;
13
+ }, import("redux").AnyAction>;
14
+ export {};
@@ -0,0 +1,25 @@
1
+ import { FtReduxStore } from "@fluid-topics/ft-wc-utils";
2
+ const viewerStateReducers = {
3
+ setZoom: (state, action) => {
4
+ state.contentModifiers.zoom = action.payload;
5
+ },
6
+ setRotation: (state, action) => {
7
+ state.contentModifiers.rotation = action.payload;
8
+ },
9
+ };
10
+ export const createViewerStore = (id) => FtReduxStore.get({
11
+ name: "ft-viewer-" + id,
12
+ initialState: {
13
+ documentId: undefined,
14
+ document: undefined,
15
+ assetId: undefined,
16
+ origin: undefined,
17
+ descriptor: undefined,
18
+ contentModifiers: {
19
+ zoom: undefined,
20
+ rotation: 0,
21
+ },
22
+ watermark: undefined,
23
+ },
24
+ reducers: viewerStateReducers,
25
+ });
@@ -0,0 +1,8 @@
1
+ import { FtStateManager } from "@fluid-topics/ft-wc-utils";
2
+ import { FtViewerReduxStore } from "./FtViewerReduxStore";
3
+ export declare abstract class FtViewerStateManager extends FtStateManager {
4
+ store: FtViewerReduxStore;
5
+ protected constructor(store: FtViewerReduxStore);
6
+ setZoom(zoom: number | undefined): void;
7
+ setRotation(rotation: number): void;
8
+ }
@@ -0,0 +1,13 @@
1
+ import { FtStateManager } from "@fluid-topics/ft-wc-utils";
2
+ export class FtViewerStateManager extends FtStateManager {
3
+ constructor(store) {
4
+ super();
5
+ this.store = store;
6
+ }
7
+ setZoom(zoom) {
8
+ this.store.actions.setZoom(zoom);
9
+ }
10
+ setRotation(rotation) {
11
+ this.store.actions.setRotation(rotation);
12
+ }
13
+ }
@@ -0,0 +1,44 @@
1
+ import { FtAssetHolder, FtWatermark } from "@fluid-topics/public-api";
2
+ export declare enum FtViewerFileOrigin {
3
+ UNSTRUCTURED_DOCUMENT = "UNSTRUCTURED_DOCUMENT",
4
+ MAP_ATTACHMENT = "MAP_ATTACHMENT",
5
+ UD_ATTACHMENT = "UD_ATTACHMENT",
6
+ RESOURCE = "RESOURCE"
7
+ }
8
+ export interface FtFileDescriptor {
9
+ id: string;
10
+ portalUrl: string;
11
+ filename: string;
12
+ fingerprint: string;
13
+ displayName: string;
14
+ alt: string;
15
+ mimeType: string;
16
+ size: number;
17
+ viewableInCurrentBrowser: boolean;
18
+ contentUrl: string;
19
+ }
20
+ export interface FtViewerContentModifiers {
21
+ zoom: number | undefined;
22
+ rotation: number;
23
+ }
24
+ export interface FtViewerState {
25
+ documentId: string | undefined;
26
+ document: FtAssetHolder | undefined;
27
+ assetId: string | undefined;
28
+ origin: FtViewerFileOrigin | undefined;
29
+ descriptor: FtFileDescriptor | undefined;
30
+ contentModifiers: FtViewerContentModifiers;
31
+ watermark: FtWatermark | undefined;
32
+ }
33
+ export declare enum FtViewerContentControls {
34
+ FIT_TO_CONTAINER = "fit-to-container",
35
+ ZOOM_REAL_SIZE = "zoom-real-size",
36
+ ZOOM_IN = "zoom-in",
37
+ ZOOM_OUT = "zoom-out",
38
+ ROTATE_LEFT = "rotate-left",
39
+ ROTATE_RIGHT = "rotate-right"
40
+ }
41
+ export declare class FtViewerLoadedEvent extends CustomEvent<FtViewerState> {
42
+ static eventName: string;
43
+ constructor(state: FtViewerState);
44
+ }
@@ -0,0 +1,23 @@
1
+ import { deepCopy } from "@fluid-topics/ft-wc-utils";
2
+ export var FtViewerFileOrigin;
3
+ (function (FtViewerFileOrigin) {
4
+ FtViewerFileOrigin["UNSTRUCTURED_DOCUMENT"] = "UNSTRUCTURED_DOCUMENT";
5
+ FtViewerFileOrigin["MAP_ATTACHMENT"] = "MAP_ATTACHMENT";
6
+ FtViewerFileOrigin["UD_ATTACHMENT"] = "UD_ATTACHMENT";
7
+ FtViewerFileOrigin["RESOURCE"] = "RESOURCE";
8
+ })(FtViewerFileOrigin || (FtViewerFileOrigin = {}));
9
+ export var FtViewerContentControls;
10
+ (function (FtViewerContentControls) {
11
+ FtViewerContentControls["FIT_TO_CONTAINER"] = "fit-to-container";
12
+ FtViewerContentControls["ZOOM_REAL_SIZE"] = "zoom-real-size";
13
+ FtViewerContentControls["ZOOM_IN"] = "zoom-in";
14
+ FtViewerContentControls["ZOOM_OUT"] = "zoom-out";
15
+ FtViewerContentControls["ROTATE_LEFT"] = "rotate-left";
16
+ FtViewerContentControls["ROTATE_RIGHT"] = "rotate-right";
17
+ })(FtViewerContentControls || (FtViewerContentControls = {}));
18
+ export class FtViewerLoadedEvent extends CustomEvent {
19
+ constructor(state) {
20
+ super(FtViewerLoadedEvent.eventName, { detail: deepCopy(state), composed: true, bubbles: true });
21
+ }
22
+ }
23
+ FtViewerLoadedEvent.eventName = "ft-viewer-loaded";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { customElements } from "@fluid-topics/ft-wc-utils";
2
+ import definitions from "./definitions";
3
+ customElements(definitions);
@@ -0,0 +1,19 @@
1
+ import { FtAssetViewerContent, FtAssetViewerContentControl, FtAssetViewerContext, FtAssetViewerDocumentTitle, FtAssetViewerFilename, FtAssetViewerMimeTypeIcon, FtAssetViewerTitle } from "./asset";
2
+ import { FtUdViewerAttachments, FtUdViewerContent, FtUdViewerContentControl, FtUdViewerContext, FtUdViewerFilename, FtUdViewerMimeTypeIcon, FtUdViewerTitle } from "./ud";
3
+ declare const _default: {
4
+ "ft-asset-viewer-content": typeof FtAssetViewerContent;
5
+ "ft-asset-viewer-content-control": typeof FtAssetViewerContentControl;
6
+ "ft-asset-viewer-context": typeof FtAssetViewerContext;
7
+ "ft-asset-viewer-document-title": typeof FtAssetViewerDocumentTitle;
8
+ "ft-asset-viewer-filename": typeof FtAssetViewerFilename;
9
+ "ft-asset-viewer-mime-type-icon": typeof FtAssetViewerMimeTypeIcon;
10
+ "ft-asset-viewer-title": typeof FtAssetViewerTitle;
11
+ "ft-ud-viewer-attachments": typeof FtUdViewerAttachments;
12
+ "ft-ud-viewer-content": typeof FtUdViewerContent;
13
+ "ft-ud-viewer-content-control": typeof FtUdViewerContentControl;
14
+ "ft-ud-viewer-context": typeof FtUdViewerContext;
15
+ "ft-ud-viewer-filename": typeof FtUdViewerFilename;
16
+ "ft-ud-viewer-mime-type-icon": typeof FtUdViewerMimeTypeIcon;
17
+ "ft-ud-viewer-title": typeof FtUdViewerTitle;
18
+ };
19
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { FtAssetViewerContent, FtAssetViewerContentControl, FtAssetViewerContext, FtAssetViewerDocumentTitle, FtAssetViewerFilename, FtAssetViewerMimeTypeIcon, FtAssetViewerTitle, } from "./asset";
2
+ import { FtUdViewerAttachments, FtUdViewerContent, FtUdViewerContentControl, FtUdViewerContext, FtUdViewerFilename, FtUdViewerMimeTypeIcon, FtUdViewerTitle, } from "./ud";
3
+ export default {
4
+ "ft-asset-viewer-content": FtAssetViewerContent,
5
+ "ft-asset-viewer-content-control": FtAssetViewerContentControl,
6
+ "ft-asset-viewer-context": FtAssetViewerContext,
7
+ "ft-asset-viewer-document-title": FtAssetViewerDocumentTitle,
8
+ "ft-asset-viewer-filename": FtAssetViewerFilename,
9
+ "ft-asset-viewer-mime-type-icon": FtAssetViewerMimeTypeIcon,
10
+ "ft-asset-viewer-title": FtAssetViewerTitle,
11
+ "ft-ud-viewer-attachments": FtUdViewerAttachments,
12
+ "ft-ud-viewer-content": FtUdViewerContent,
13
+ "ft-ud-viewer-content-control": FtUdViewerContentControl,
14
+ "ft-ud-viewer-context": FtUdViewerContext,
15
+ "ft-ud-viewer-filename": FtUdViewerFilename,
16
+ "ft-ud-viewer-mime-type-icon": FtUdViewerMimeTypeIcon,
17
+ "ft-ud-viewer-title": FtUdViewerTitle,
18
+ };