c3-components 0.0.13 → 0.0.14

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 (132) hide show
  1. package/CONTRIBUTING.md +80 -0
  2. package/bun.lockb +0 -0
  3. package/ng-package.json +19 -0
  4. package/package.json +5 -15
  5. package/{_index.scss → src/_index.scss} +1 -3
  6. package/src/lib/c3-auto-animate/C3AutoAnimate.directive.ts +18 -0
  7. package/src/lib/c3-dialog/c3-dialog.module.ts +30 -0
  8. package/src/lib/c3-dialog/components/c3-dialog-confirm.component.ts +44 -0
  9. package/src/lib/c3-dialog/components/c3-dialog-embed-child.component.ts +40 -0
  10. package/src/lib/c3-dialog/components/c3-dialog-prompt.component.ts +81 -0
  11. package/src/lib/c3-dialog/services/c3-dialog.service.ts +87 -0
  12. package/src/lib/c3-dropdown/c3-dropdown.module.ts +12 -0
  13. package/src/lib/c3-dropdown/components/c3-dropdown.component.spec.ts +22 -0
  14. package/src/lib/c3-dropdown/components/c3-dropdown.component.ts +39 -0
  15. package/src/lib/c3-dropdown/directives/c3-dropdown.trigger.ts +161 -0
  16. package/src/lib/c3-expansion/c3-expansion.module.ts +24 -0
  17. package/src/lib/c3-expansion/components/c3-expansion/c3-expansion.component.html +9 -0
  18. package/src/lib/c3-expansion/components/c3-expansion/c3-expansion.component.ts +33 -0
  19. package/src/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.html +12 -0
  20. package/src/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.ts +21 -0
  21. package/src/lib/c3-expansion/styles/_c3-expansion.scss +39 -0
  22. package/src/lib/c3-file/c3-download/c3-download.module.ts +7 -0
  23. package/src/lib/c3-file/c3-download/c3-download.service.ts +16 -0
  24. package/src/lib/c3-file/c3-input-file/c3-input-file.module.ts +30 -0
  25. package/src/lib/c3-file/c3-input-file/class/c3-input-file.ts +62 -0
  26. package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.html +7 -0
  27. package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.ts +96 -0
  28. package/src/lib/c3-file/c3-input-file/components/c3-input-file-container/c3-input-file-container.component.ts +53 -0
  29. package/src/lib/c3-file/c3-input-file/components/c3-input-file-displayer/c3-input-file-displayer.component.ts +107 -0
  30. package/src/lib/c3-file/c3-input-file/components/c3-input-file-trigger/c3-input-file-trigger.component.ts +22 -0
  31. package/src/lib/c3-file/c3-input-file/directives/c3-input-file-trigger.directive.ts +27 -0
  32. package/src/lib/c3-file-upload/c3-file-upload.module.ts +8 -0
  33. package/src/lib/c3-file-viewer/c3-file-viewer.module.ts +30 -0
  34. package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.html +185 -0
  35. package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.spec.ts +23 -0
  36. package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.ts +15 -0
  37. package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.html +7 -0
  38. package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.spec.ts +23 -0
  39. package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.ts +14 -0
  40. package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.html +7 -0
  41. package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.spec.ts +23 -0
  42. package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.ts +25 -0
  43. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.css +0 -0
  44. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.html +1 -0
  45. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.spec.ts +23 -0
  46. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.ts +35 -0
  47. package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.html +32 -0
  48. package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.spec.ts +23 -0
  49. package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.ts +93 -0
  50. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.spec.ts +23 -0
  51. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.ts +37 -0
  52. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.spec.ts +22 -0
  53. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.ts +12 -0
  54. package/src/lib/c3-file-viewer/consts/default.config.ts +41 -0
  55. package/src/lib/c3-file-viewer/directives/full-screen.directive.spec.ts +11 -0
  56. package/src/lib/c3-file-viewer/directives/full-screen.directive.ts +68 -0
  57. package/src/lib/c3-file-viewer/models/custom-file-event.model.ts +9 -0
  58. package/src/lib/c3-file-viewer/models/file-metadata.ts +13 -0
  59. package/src/lib/c3-file-viewer/models/file-viewer-config.model.ts +53 -0
  60. package/src/lib/c3-file-viewer/models/file-viewer.ts +259 -0
  61. package/src/lib/c3-file-viewer/models/http.client.ts +23 -0
  62. package/src/lib/c3-highlight-text/c3-highlight-text.module.ts +12 -0
  63. package/src/lib/c3-menu/c3-menu.module.ts +12 -0
  64. package/src/lib/c3-modal/c3-modal.module.ts +12 -0
  65. package/src/lib/c3-navbar/c3-navbar.module.ts +12 -0
  66. package/src/lib/c3-pdf-dialog/c3-pdf-dialog.module.ts +12 -0
  67. package/src/lib/c3-rounded-title/c3-rounded-title.module.ts +12 -0
  68. package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.spec.ts +8 -0
  69. package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.ts +13 -0
  70. package/{lib → src/lib}/c3-styles/_c3-core.sass +4 -2
  71. package/src/lib/c3-tabs/c3-tabs.module.ts +12 -0
  72. package/{public-api.d.ts → src/public-api.ts} +20 -0
  73. package/tsconfig.lib.json +14 -0
  74. package/tsconfig.lib.prod.json +10 -0
  75. package/tsconfig.spec.json +14 -0
  76. package/esm2022/c3-components.mjs +0 -5
  77. package/esm2022/lib/c3-dialog/c3-dialog.module.mjs +0 -52
  78. package/esm2022/lib/c3-dialog/components/c3-dialog-confirm.component.mjs +0 -51
  79. package/esm2022/lib/c3-dialog/components/c3-dialog-embed-child.component.mjs +0 -32
  80. package/esm2022/lib/c3-dialog/components/c3-dialog-prompt.component.mjs +0 -95
  81. package/esm2022/lib/c3-dialog/services/c3-dialog.service.mjs +0 -79
  82. package/esm2022/lib/c3-dropdown/c3-dropdown.module.mjs +0 -20
  83. package/esm2022/lib/c3-dropdown/components/c3-dropdown.component.mjs +0 -45
  84. package/esm2022/lib/c3-dropdown/directives/c3-dropdown.trigger.mjs +0 -128
  85. package/esm2022/lib/c3-file-viewer/c3-file-viewer.module.mjs +0 -47
  86. package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.mjs +0 -17
  87. package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.mjs +0 -20
  88. package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.mjs +0 -23
  89. package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.mjs +0 -32
  90. package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.mjs +0 -86
  91. package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.mjs +0 -40
  92. package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.mjs +0 -26
  93. package/esm2022/lib/c3-file-viewer/consts/default.config.mjs +0 -40
  94. package/esm2022/lib/c3-file-viewer/directives/full-screen.directive.mjs +0 -66
  95. package/esm2022/lib/c3-file-viewer/models/custom-file-event.model.mjs +0 -7
  96. package/esm2022/lib/c3-file-viewer/models/file-metadata.mjs +0 -2
  97. package/esm2022/lib/c3-file-viewer/models/file-viewer-config.model.mjs +0 -2
  98. package/esm2022/lib/c3-file-viewer/models/file-viewer.mjs +0 -206
  99. package/esm2022/lib/c3-file-viewer/models/http.client.mjs +0 -2
  100. package/esm2022/lib/c3-safe-url/pipes/c3-safe-url.pipe.mjs +0 -21
  101. package/esm2022/public-api.mjs +0 -35
  102. package/fesm2022/c3-components.mjs +0 -1056
  103. package/fesm2022/c3-components.mjs.map +0 -1
  104. package/index.d.ts +0 -5
  105. package/lib/c3-dialog/c3-dialog.module.d.ts +0 -15
  106. package/lib/c3-dialog/components/c3-dialog-confirm.component.d.ts +0 -23
  107. package/lib/c3-dialog/components/c3-dialog-embed-child.component.d.ts +0 -18
  108. package/lib/c3-dialog/components/c3-dialog-prompt.component.d.ts +0 -31
  109. package/lib/c3-dialog/services/c3-dialog.service.d.ts +0 -19
  110. package/lib/c3-dropdown/c3-dropdown.module.d.ts +0 -10
  111. package/lib/c3-dropdown/components/c3-dropdown.component.d.ts +0 -15
  112. package/lib/c3-dropdown/directives/c3-dropdown.trigger.d.ts +0 -45
  113. package/lib/c3-file-viewer/c3-file-viewer.module.d.ts +0 -17
  114. package/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.d.ts +0 -8
  115. package/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.d.ts +0 -9
  116. package/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.d.ts +0 -9
  117. package/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.d.ts +0 -12
  118. package/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.d.ts +0 -25
  119. package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.d.ts +0 -12
  120. package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.d.ts +0 -8
  121. package/lib/c3-file-viewer/consts/default.config.d.ts +0 -2
  122. package/lib/c3-file-viewer/directives/full-screen.directive.d.ts +0 -12
  123. package/lib/c3-file-viewer/models/custom-file-event.model.d.ts +0 -5
  124. package/lib/c3-file-viewer/models/file-metadata.d.ts +0 -12
  125. package/lib/c3-file-viewer/models/file-viewer-config.model.d.ts +0 -48
  126. package/lib/c3-file-viewer/models/file-viewer.d.ts +0 -65
  127. package/lib/c3-file-viewer/models/http.client.d.ts +0 -14
  128. package/lib/c3-safe-url/pipes/c3-safe-url.pipe.d.ts +0 -10
  129. /package/{lib → src/lib}/c3-dropdown/styles/_c3-dropdown.sass +0 -0
  130. /package/{lib → src/lib}/c3-file-viewer/styles/_c3-file-viewer.sass +0 -0
  131. /package/{lib → src/lib}/c3-styles/_c3-root-variables.sass +0 -0
  132. /package/{lib → src/lib}/c3-styles/_utils.sass +0 -0
@@ -0,0 +1,185 @@
1
+ <div class="nav-button-container">
2
+ <button
3
+ *ngIf="config.btnShow?.prev"
4
+ type="button"
5
+ [class]="config.btnClass"
6
+ (click)="fileViewer.previousImage($event)"
7
+ [disabled]="fileViewer.currentIndex === 0"
8
+ >
9
+ <span
10
+ *ngIf="config.btnIcons?.prev?.classes"
11
+ [class]="config.btnIcons?.prev?.classes"
12
+ ></span>
13
+ </button>
14
+ <a
15
+ [class]="config.btnClass"
16
+ *ngIf="config.btnIcons?.prev?.text"
17
+ (click)="fileViewer.previousImage($event)"
18
+ >
19
+ <span [class]="config.btnSubClass">{{ config.btnIcons?.prev?.text }}</span>
20
+ </a>
21
+ <button
22
+ *ngIf="config.btnShow?.next"
23
+ type="button"
24
+ [class]="config.btnClass"
25
+ (click)="fileViewer.nextImage($event)"
26
+ [disabled]="fileViewer.currentIndex === fileViewer.files.length - 1"
27
+ >
28
+ <span
29
+ *ngIf="config.btnIcons?.next?.classes"
30
+ [class]="config.btnIcons?.next?.classes"
31
+ ></span>
32
+ </button>
33
+ <a
34
+ [class]="config.btnClass"
35
+ *ngIf="config.btnIcons?.next?.text"
36
+ (click)="fileViewer.nextImage($event)"
37
+ >
38
+ <span [class]="config.btnSubClass">{{ config.btnIcons?.next?.text }}</span>
39
+ </a>
40
+ </div>
41
+
42
+ <!-- Button Container -->
43
+ <div
44
+ class="btn-container"
45
+ [class]="config.btnContainerClass"
46
+ *ngIf="fileViewer.currentFile.type.startsWith('image')"
47
+ >
48
+ <!-- Rotate Counter Clockwise -->
49
+ <ng-container *ngIf="config.btnShow?.rotateCounterClockwise">
50
+ <button
51
+ type="button"
52
+ [class]="config.btnClass"
53
+ (click)="fileViewer.rotateCounterClockwise()"
54
+ *ngIf="config.btnIcons?.rotateCounterClockwise?.classes"
55
+ >
56
+ <span [class]="config.btnIcons?.rotateCounterClockwise?.classes"></span>
57
+ </button>
58
+ <a
59
+ [class]="config.btnClass"
60
+ *ngIf="config.btnIcons?.rotateCounterClockwise?.text"
61
+ (click)="fileViewer.rotateCounterClockwise()"
62
+ >
63
+ <span [class]="config.btnSubClass">{{
64
+ config.btnIcons?.rotateCounterClockwise?.text
65
+ }}</span>
66
+ </a>
67
+ </ng-container>
68
+
69
+ <!-- Rotate Clockwise -->
70
+ <ng-container *ngIf="config.btnShow?.rotateClockwise">
71
+ <button
72
+ type="button"
73
+ [class]="config.btnClass"
74
+ (click)="fileViewer.rotateClockwise()"
75
+ *ngIf="config.btnIcons?.rotateClockwise?.classes"
76
+ >
77
+ <span [class]="config.btnIcons?.rotateClockwise?.classes"></span>
78
+ </button>
79
+ <a
80
+ [class]="config.btnClass"
81
+ *ngIf="config.btnIcons?.rotateClockwise?.text"
82
+ (click)="fileViewer.rotateClockwise()"
83
+ >
84
+ <span [class]="config.btnSubClass">{{
85
+ config.btnIcons?.rotateClockwise?.text
86
+ }}</span>
87
+ </a>
88
+ </ng-container>
89
+
90
+ <!-- Zoom Out -->
91
+ <ng-container *ngIf="config.btnShow?.zoomOut">
92
+ <button
93
+ type="button"
94
+ [class]="config.btnClass"
95
+ (click)="fileViewer.zoomOut()"
96
+ *ngIf="config.btnIcons?.zoomOut?.classes"
97
+ >
98
+ <span [class]="config.btnIcons?.zoomOut?.classes"></span>
99
+ </button>
100
+ <a
101
+ [class]="config.btnClass"
102
+ *ngIf="config.btnIcons?.zoomOut?.text"
103
+ (click)="fileViewer.zoomOut()"
104
+ >
105
+ <span [class]="config.btnSubClass">{{
106
+ config.btnIcons?.zoomOut?.text
107
+ }}</span>
108
+ </a>
109
+ </ng-container>
110
+
111
+ <!-- Zoom In -->
112
+ <ng-container *ngIf="config.btnShow?.zoomIn">
113
+ <button
114
+ type="button"
115
+ [class]="config.btnClass"
116
+ (click)="fileViewer.zoomIn()"
117
+ *ngIf="config.btnIcons?.zoomIn?.classes"
118
+ >
119
+ <span [class]="config.btnIcons?.zoomIn?.classes"></span>
120
+ </button>
121
+ <a
122
+ [class]="config.btnClass"
123
+ *ngIf="config.btnIcons?.zoomIn?.text"
124
+ (click)="fileViewer.zoomIn()"
125
+ >
126
+ <span [class]="config.btnSubClass">{{
127
+ config.btnIcons?.zoomIn?.text
128
+ }}</span>
129
+ </a>
130
+ </ng-container>
131
+
132
+ <!-- Fullscreen -->
133
+ <ng-container *ngIf="config.allowFullscreen">
134
+ <button
135
+ type="button"
136
+ [class]="config.btnClass"
137
+ (click)="fileViewer.toggleFullscreen()"
138
+ *ngIf="config.btnIcons?.fullscreen?.classes"
139
+ >
140
+ <span [class]="config.btnIcons?.fullscreen?.classes"></span>
141
+ </button>
142
+ <a
143
+ [class]="config.btnClass"
144
+ *ngIf="config.btnIcons?.fullscreen?.text"
145
+ (click)="fileViewer.toggleFullscreen()"
146
+ >
147
+ <span [class]="config.btnSubClass">{{
148
+ config.btnIcons?.fullscreen?.text
149
+ }}</span>
150
+ </a>
151
+ </ng-container>
152
+
153
+ <!-- Reset -->
154
+ <ng-container *ngIf="config.btnShow?.reset">
155
+ <button
156
+ type="button"
157
+ [class]="config.btnClass"
158
+ (click)="fileViewer.reset()"
159
+ *ngIf="config.btnIcons?.reset?.classes"
160
+ >
161
+ <span [class]="config.btnIcons?.reset?.classes"></span>
162
+ </button>
163
+ <a
164
+ [class]="config.btnClass"
165
+ *ngIf="config.btnIcons?.reset?.text"
166
+ (click)="fileViewer.reset()"
167
+ >
168
+ <span [class]="config.btnSubClass">{{
169
+ config.btnIcons?.reset?.text
170
+ }}</span>
171
+ </a>
172
+ </ng-container>
173
+
174
+ <!-- Custom Buttons -->
175
+ <ng-container *ngFor="let cBtn of config.customBtns">
176
+ <button *ngIf="cBtn.icon.classes" type="button" [class]="config.btnClass">
177
+ <span *ngIf="cBtn.icon.classes" [class]="cBtn.icon.classes"></span>
178
+ </button>
179
+ <ng-container *ngIf="cBtn.icon.text">
180
+ <a [class]="config.btnClass" *ngIf="cBtn.icon.text">
181
+ <span [class]="config.btnSubClass">{{ cBtn.icon.text }}</span>
182
+ </a>
183
+ </ng-container>
184
+ </ng-container>
185
+ </div>
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { C3FileViewerActionsComponent } from './c3-file-viewer-actions.component';
4
+
5
+ describe('C3FileViewerActionsComponent', () => {
6
+ let component: C3FileViewerActionsComponent;
7
+ let fixture: ComponentFixture<C3FileViewerActionsComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ C3FileViewerActionsComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(C3FileViewerActionsComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,15 @@
1
+ import { Component, Host, Input } from '@angular/core';
2
+ import { C3FileViewer } from '../../models/file-viewer';
3
+
4
+ @Component({
5
+ selector: 'c3-file-viewer-actions',
6
+ templateUrl: './c3-file-viewer-actions.component.html',
7
+ })
8
+ export class C3FileViewerActionsComponent {
9
+ @Input()
10
+ fileViewer!: C3FileViewer;
11
+
12
+ get config() {
13
+ return this.fileViewer.config;
14
+ }
15
+ }
@@ -0,0 +1,7 @@
1
+ <img
2
+ *ngIf="fileViewer.currentFile.objectUrl"
3
+ [src]="fileViewer.currentFile.objectUrl | async | c3SafeUrl"
4
+ [ngStyle]="fileViewer.style"
5
+ alt="Image not found..."
6
+ (dragstart)="dragstart.emit($event)"
7
+ />
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { C3FileViewerImageComponent } from './c3-file-viewer-image.component';
4
+
5
+ describe('C3FileViewerImageComponent', () => {
6
+ let component: C3FileViewerImageComponent;
7
+ let fixture: ComponentFixture<C3FileViewerImageComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ C3FileViewerImageComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(C3FileViewerImageComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,14 @@
1
+ import { Component, EventEmitter, Input, Output } from '@angular/core';
2
+ import { C3FileViewer } from '../../models/file-viewer';
3
+
4
+ @Component({
5
+ selector: 'c3-file-viewer-image, [c3-file-viewer-image]',
6
+ templateUrl: './c3-file-viewer-image.component.html',
7
+ })
8
+ export class C3FileViewerImageComponent {
9
+ @Input()
10
+ public fileViewer!: C3FileViewer;
11
+
12
+ @Output()
13
+ dragstart = new EventEmitter<DragEvent>();
14
+ }
@@ -0,0 +1,7 @@
1
+ <!-- pdf viewer -->
2
+ <embed
3
+ type="application/pdf"
4
+ [src]="fileViewer.currentFile.objectUrl | async | c3SafeUrl"
5
+ [style.height]="'100%'"
6
+ [style.width]="'100%'"
7
+ />
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { C3FileViewerPdfComponent } from './c3-file-viewer-pdf.component';
4
+
5
+ describe('C3FileViewerPdfComponent', () => {
6
+ let component: C3FileViewerPdfComponent;
7
+ let fixture: ComponentFixture<C3FileViewerPdfComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ C3FileViewerPdfComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(C3FileViewerPdfComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,25 @@
1
+ import {
2
+ Component,
3
+ EventEmitter,
4
+ Input,
5
+ Output,
6
+ ViewEncapsulation,
7
+ } from '@angular/core';
8
+ import { C3FileViewer } from '../../models/file-viewer';
9
+
10
+ @Component({
11
+ selector: 'c3-file-viewer-pdf',
12
+ templateUrl: './c3-file-viewer-pdf.component.html',
13
+ encapsulation: ViewEncapsulation.None,
14
+ host: {
15
+ style: 'display: block',
16
+ class: 'c3-file-viewer-pdf',
17
+ },
18
+ })
19
+ export class C3FileViewerPdfComponent {
20
+ @Input()
21
+ public fileViewer!: C3FileViewer;
22
+
23
+ @Output()
24
+ dragstart = new EventEmitter<DragEvent>();
25
+ }
@@ -0,0 +1 @@
1
+ <video controls [src]="src" crossorigin="*"></video>
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { C3FileViewerVideoComponent } from './c3-file-viewer-video.component';
4
+
5
+ describe('C3FileViewerVideoComponent', () => {
6
+ let component: C3FileViewerVideoComponent;
7
+ let fixture: ComponentFixture<C3FileViewerVideoComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ C3FileViewerVideoComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(C3FileViewerVideoComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,35 @@
1
+ import { Component, Input } from '@angular/core';
2
+ import { FileMetadata } from '../../models/file-metadata';
3
+ import { Subject, filter, mergeMap, tap } from 'rxjs';
4
+ import { C3FileViewer } from '../../models/file-viewer';
5
+
6
+ @Component({
7
+ selector: 'c3-file-viewer-video',
8
+ templateUrl: './c3-file-viewer-video.component.html',
9
+ })
10
+ export class C3FileViewerVideoComponent {
11
+ @Input('file')
12
+ set _srcUpdated({ location }: FileMetadata) {
13
+ this.src$.next(location);
14
+ }
15
+ src = '';
16
+ private src$ = new Subject<string>();
17
+
18
+ @Input()
19
+ public fileViewer!: C3FileViewer;
20
+
21
+ constructor() {
22
+ this.src$
23
+ .pipe(
24
+ mergeMap((src) => this.fileViewer.getFile(src)),
25
+ filter((blob) => blob.type.startsWith('application/pdf')),
26
+ tap((blob) => (this.src = URL.createObjectURL(blob)))
27
+ )
28
+ .subscribe({
29
+ next: () => null,
30
+ error: (error) => {
31
+ console.log(error);
32
+ },
33
+ });
34
+ }
35
+ }
@@ -0,0 +1,32 @@
1
+ <div
2
+ class="container"
3
+ *ngIf="fileViewer"
4
+ [c3-full-screen]="fileViewer.fullscreen$ | async"
5
+ [style.height]="fileViewer.styleHeight"
6
+ [style.backgroundColor]="fileViewer.config.containerBackgroundColor"
7
+ (wheel)="fileViewer.scrollZoom($event)"
8
+ (dragover)="fileViewer.onDragOver($event)"
9
+ >
10
+ <c3-file-viewer-image
11
+ *ngIf="fileViewer.currentFile.type.startsWith('image')"
12
+ [fileViewer]="fileViewer"
13
+ [style]="fileViewer.style"
14
+ (dragstart)="fileViewer.onDragStart($event)"
15
+ />
16
+
17
+ <c3-file-viewer-video
18
+ *ngIf="fileViewer.currentFile.type.startsWith('video')"
19
+ />
20
+
21
+ <c3-file-viewer-pdf
22
+ *ngIf="fileViewer.currentFile.type.startsWith('application/pdf')"
23
+ [fileViewer]="fileViewer"
24
+ />
25
+ <!-- Div below will be used to hide the 'ghost' image when dragging -->
26
+ <div></div>
27
+ <div class="spinner-container" *ngIf="fileViewer.loading">
28
+ <div class="spinner"></div>
29
+ </div>
30
+
31
+ <c3-file-viewer-actions [fileViewer]="fileViewer" />
32
+ </div>
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { C3FileViewerComponent } from './c3-file-viewer.component';
4
+
5
+ describe('C3FileViewerComponent', () => {
6
+ let component: C3FileViewerComponent;
7
+ let fixture: ComponentFixture<C3FileViewerComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ C3FileViewerComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(C3FileViewerComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,93 @@
1
+ import {
2
+ Component,
3
+ EventEmitter,
4
+ HostListener,
5
+ Inject,
6
+ Input,
7
+ OnInit,
8
+ Optional,
9
+ Output,
10
+ SimpleChanges,
11
+ ViewEncapsulation,
12
+ } from '@angular/core';
13
+ import { C3FileViewerConfig } from '../../../models/file-viewer-config.model';
14
+ import { CustomFileEvent } from '../../../models/custom-file-event.model';
15
+ import { HttpClient } from '@angular/common/http';
16
+ import { C3FileViewer } from '../../../models/file-viewer';
17
+
18
+ @Component({
19
+ selector: 'c3-file-viewer',
20
+ templateUrl: './c3-file-viewer.component.html',
21
+ styleUrls: [],
22
+ encapsulation: ViewEncapsulation.None,
23
+ host: {
24
+ class: 'c3-file-viewer',
25
+ },
26
+ })
27
+ export class C3FileViewerComponent implements OnInit {
28
+ @Input()
29
+ public screenHeightOccupied?: 0; // In Px
30
+
31
+ @Input()
32
+ public fileViewer!: C3FileViewer;
33
+
34
+ @Output()
35
+ public indexChange: EventEmitter<number> = new EventEmitter();
36
+
37
+ @Output()
38
+ public configChange: EventEmitter<C3FileViewerConfig> = new EventEmitter();
39
+
40
+ @Output()
41
+ public customFileEvent: EventEmitter<CustomFileEvent> = new EventEmitter();
42
+
43
+ constructor(
44
+ @Optional() @Inject('config') public moduleConfig: C3FileViewerConfig,
45
+ public _http: HttpClient
46
+ ) {}
47
+
48
+ ngOnInit() {
49
+ this.defineStyleHeight();
50
+
51
+ this.fileViewer.customFile$.subscribe((event) => {
52
+ this.customFileEvent.emit(event);
53
+ });
54
+
55
+ this.fileViewer.index$.subscribe((index) => {
56
+ this.indexChange.emit(index);
57
+ });
58
+
59
+ this.fileViewer.config$.subscribe((config) => {
60
+ this.configChange.emit(config);
61
+ });
62
+ }
63
+
64
+ @HostListener('mouseover')
65
+ onMouseOver() {
66
+ this.fileViewer.hovered = true;
67
+ }
68
+
69
+ @HostListener('mouseleave')
70
+ onMouseLeave() {
71
+ this.fileViewer.hovered = false;
72
+ }
73
+
74
+ ngOnChanges(changes: SimpleChanges) {
75
+ if (changes['screenHeightOccupied'] && this.fileViewer)
76
+ this.defineStyleHeight();
77
+ }
78
+
79
+ @HostListener('window:keyup.ArrowRight', ['$event'])
80
+ next(event: KeyboardEvent) {
81
+ this.fileViewer.nextImage(event);
82
+ }
83
+
84
+ @HostListener('window:keyup.ArrowLeft', ['$event'])
85
+ previous(event: KeyboardEvent) {
86
+ this.fileViewer.previousImage(event);
87
+ }
88
+
89
+ defineStyleHeight() {
90
+ this.fileViewer.styleHeight =
91
+ 'calc(100% - ' + this.screenHeightOccupied + 'px)';
92
+ }
93
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { C3FileViewerDialogComponent } from './c3-file-viewer-dialog.component';
4
+
5
+ describe('C3FileViewerDialogComponent', () => {
6
+ let component: C3FileViewerDialogComponent;
7
+ let fixture: ComponentFixture<C3FileViewerDialogComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ C3FileViewerDialogComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(C3FileViewerDialogComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,37 @@
1
+ import { Component, HostListener, Inject, Input } from '@angular/core';
2
+ import {
3
+ MAT_DIALOG_DATA,
4
+ MatDialog,
5
+ MatDialogConfig,
6
+ } from '@angular/material/dialog';
7
+ import { C3FileViewer } from '../../../models/file-viewer';
8
+ import { C3FileViewerDialog } from './c3-file-viewer-dialog';
9
+
10
+ @Component({
11
+ selector: 'c3-file-viewer-dialog',
12
+ template: ` <ng-content /> `,
13
+ host: {
14
+ class: 'c3-file-viewer-dialog',
15
+ },
16
+ })
17
+ export class C3FileViewerDialogComponent {
18
+ @Input()
19
+ public fileViewer!: C3FileViewer;
20
+
21
+ @Input()
22
+ public dialogConfig: Partial<MatDialogConfig> = {
23
+ panelClass: 'c3-file-viewer-dialog',
24
+ width: '80%',
25
+ height: '80%',
26
+ };
27
+
28
+ constructor(private _dialog: MatDialog) {}
29
+
30
+ @HostListener('click')
31
+ openDialog() {
32
+ this._dialog.open(C3FileViewerDialog, {
33
+ data: this.fileViewer,
34
+ ...this.dialogConfig,
35
+ });
36
+ }
37
+ }
@@ -0,0 +1,22 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { C3FileViewerDialog } from './c3-file-viewer-dialog';
4
+
5
+ describe('C3FileViewerDialog', () => {
6
+ let component: C3FileViewerDialog;
7
+ let fixture: ComponentFixture<C3FileViewerDialog>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [C3FileViewerDialog],
12
+ }).compileComponents();
13
+
14
+ fixture = TestBed.createComponent(C3FileViewerDialog);
15
+ component = fixture.componentInstance;
16
+ fixture.detectChanges();
17
+ });
18
+
19
+ it('should create', () => {
20
+ expect(component).toBeTruthy();
21
+ });
22
+ });
@@ -0,0 +1,12 @@
1
+ import { Component, Inject } from '@angular/core';
2
+ import { MAT_DIALOG_DATA } from '@angular/material/dialog';
3
+ import { C3FileViewer } from '../../../models/file-viewer';
4
+
5
+ @Component({
6
+ template: `
7
+ <c3-file-viewer [fileViewer]="fileViewer" [screenHeightOccupied]="0" />
8
+ `,
9
+ })
10
+ export class C3FileViewerDialog {
11
+ constructor(@Inject(MAT_DIALOG_DATA) public fileViewer: C3FileViewer) {}
12
+ }