c3-components 0.0.4 → 0.0.6

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 (127) hide show
  1. package/CONTRIBUTING.md +80 -0
  2. package/_index.scss +3 -0
  3. package/ng-package.json +19 -0
  4. package/package.json +11 -23
  5. package/src/lib/c3-dialog/c3-dialog.module.ts +30 -0
  6. package/src/lib/c3-dialog/components/c3-dialog-confirm.component.ts +44 -0
  7. package/src/lib/c3-dialog/components/c3-dialog-embed-child.component.ts +40 -0
  8. package/src/lib/c3-dialog/components/c3-dialog-prompt.component.ts +81 -0
  9. package/src/lib/c3-dialog/services/c3-dialog.service.ts +87 -0
  10. package/src/lib/c3-dropdown/c3-dropdown.module.ts +12 -0
  11. package/src/lib/c3-dropdown/components/c3-dropdown.component.spec.ts +22 -0
  12. package/src/lib/c3-dropdown/components/c3-dropdown.component.ts +39 -0
  13. package/src/lib/c3-dropdown/directives/c3-dropdown.trigger.ts +161 -0
  14. package/src/lib/c3-file/c3-download/c3-download.module.ts +10 -0
  15. package/src/lib/c3-file/c3-download/c3-download.service.ts +16 -0
  16. package/src/lib/c3-file/c3-input-file/c3-input-file.module.ts +30 -0
  17. package/src/lib/c3-file/c3-input-file/class/c3-input-file.ts +62 -0
  18. package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.html +7 -0
  19. package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.ts +96 -0
  20. package/src/lib/c3-file/c3-input-file/components/c3-input-file-container/c3-input-file-container.component.ts +53 -0
  21. package/src/lib/c3-file/c3-input-file/components/c3-input-file-displayer/c3-input-file-displayer.component.ts +107 -0
  22. package/src/lib/c3-file/c3-input-file/components/c3-input-file-trigger/c3-input-file-trigger.component.ts +22 -0
  23. package/src/lib/c3-file/c3-input-file/directives/c3-input-file-trigger.directive.ts +27 -0
  24. package/src/lib/c3-file-upload/c3-file-upload.module.ts +8 -0
  25. package/src/lib/c3-file-viewer/c3-file-viewer.module.ts +34 -0
  26. package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.html +185 -0
  27. package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.spec.ts +23 -0
  28. package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.ts +15 -0
  29. package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.html +7 -0
  30. package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.spec.ts +23 -0
  31. package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.ts +14 -0
  32. package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.html +7 -0
  33. package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.spec.ts +23 -0
  34. package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.ts +25 -0
  35. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.css +0 -0
  36. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.html +1 -0
  37. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.spec.ts +23 -0
  38. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.ts +35 -0
  39. package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.html +32 -0
  40. package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.spec.ts +23 -0
  41. package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.ts +93 -0
  42. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.spec.ts +23 -0
  43. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.ts +34 -0
  44. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.spec.ts +22 -0
  45. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.ts +12 -0
  46. package/src/lib/c3-file-viewer/consts/default.config.ts +41 -0
  47. package/src/lib/c3-file-viewer/directives/full-screen.directive.spec.ts +11 -0
  48. package/src/lib/c3-file-viewer/directives/full-screen.directive.ts +68 -0
  49. package/src/lib/c3-file-viewer/models/custom-file-event.model.ts +9 -0
  50. package/src/lib/c3-file-viewer/models/file-metadata.ts +13 -0
  51. package/src/lib/c3-file-viewer/models/file-viewer-config.model.ts +53 -0
  52. package/src/lib/c3-file-viewer/models/file-viewer.ts +259 -0
  53. package/src/lib/c3-file-viewer/models/http.client.ts +23 -0
  54. package/src/lib/c3-highlight-text/c3-highlight-text.module.ts +12 -0
  55. package/src/lib/c3-menu/c3-menu.module.ts +12 -0
  56. package/src/lib/c3-modal/c3-modal.module.ts +12 -0
  57. package/src/lib/c3-navbar/c3-navbar.module.ts +12 -0
  58. package/src/lib/c3-pdf-dialog/c3-pdf-dialog.module.ts +12 -0
  59. package/src/lib/c3-rounded-title/c3-rounded-title.module.ts +12 -0
  60. package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.spec.ts +8 -0
  61. package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.ts +13 -0
  62. package/src/lib/c3-tabs/c3-tabs.module.ts +12 -0
  63. package/{public-api.d.ts → src/public-api.ts} +8 -0
  64. package/tailwind.config.js +8 -0
  65. package/tsconfig.lib.json +14 -0
  66. package/tsconfig.lib.prod.json +10 -0
  67. package/tsconfig.spec.json +14 -0
  68. package/esm2020/c3-components.mjs +0 -5
  69. package/esm2020/lib/c3-dialog/c3-dialog.module.mjs +0 -56
  70. package/esm2020/lib/c3-dialog/components/c3-dialog-confirm.component.mjs +0 -52
  71. package/esm2020/lib/c3-dialog/components/c3-dialog-embed-child.component.mjs +0 -32
  72. package/esm2020/lib/c3-dialog/components/c3-dialog-prompt.component.mjs +0 -95
  73. package/esm2020/lib/c3-dialog/services/c3-dialog.service.mjs +0 -79
  74. package/esm2020/lib/c3-dropdown/c3-dropdown.module.mjs +0 -20
  75. package/esm2020/lib/c3-dropdown/components/c3-dropdown.component.mjs +0 -45
  76. package/esm2020/lib/c3-dropdown/directives/c3-dropdown.trigger.mjs +0 -128
  77. package/esm2020/lib/c3-file-viewer/c3-file-viewer.module.mjs +0 -51
  78. package/esm2020/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.mjs +0 -17
  79. package/esm2020/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.mjs +0 -20
  80. package/esm2020/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.mjs +0 -23
  81. package/esm2020/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.mjs +0 -32
  82. package/esm2020/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.mjs +0 -86
  83. package/esm2020/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.mjs +0 -37
  84. package/esm2020/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.mjs +0 -26
  85. package/esm2020/lib/c3-file-viewer/consts/default.config.mjs +0 -40
  86. package/esm2020/lib/c3-file-viewer/directives/full-screen.directive.mjs +0 -66
  87. package/esm2020/lib/c3-file-viewer/models/custom-file-event.model.mjs +0 -7
  88. package/esm2020/lib/c3-file-viewer/models/file-metadata.mjs +0 -2
  89. package/esm2020/lib/c3-file-viewer/models/file-viewer-config.model.mjs +0 -2
  90. package/esm2020/lib/c3-file-viewer/models/file-viewer.mjs +0 -206
  91. package/esm2020/lib/c3-file-viewer/models/http.client.mjs +0 -2
  92. package/esm2020/lib/c3-safe-url/pipes/c3-safe-url.pipe.mjs +0 -21
  93. package/esm2020/public-api.mjs +0 -35
  94. package/fesm2015/c3-components.mjs +0 -1064
  95. package/fesm2015/c3-components.mjs.map +0 -1
  96. package/fesm2020/c3-components.mjs +0 -1062
  97. package/fesm2020/c3-components.mjs.map +0 -1
  98. package/index.d.ts +0 -5
  99. package/lib/c3-dialog/c3-dialog.module.d.ts +0 -16
  100. package/lib/c3-dialog/components/c3-dialog-confirm.component.d.ts +0 -23
  101. package/lib/c3-dialog/components/c3-dialog-embed-child.component.d.ts +0 -18
  102. package/lib/c3-dialog/components/c3-dialog-prompt.component.d.ts +0 -31
  103. package/lib/c3-dialog/services/c3-dialog.service.d.ts +0 -19
  104. package/lib/c3-dropdown/c3-dropdown.module.d.ts +0 -10
  105. package/lib/c3-dropdown/components/c3-dropdown.component.d.ts +0 -15
  106. package/lib/c3-dropdown/directives/c3-dropdown.trigger.d.ts +0 -45
  107. package/lib/c3-file-viewer/c3-file-viewer.module.d.ts +0 -18
  108. package/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.d.ts +0 -8
  109. package/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.d.ts +0 -9
  110. package/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.d.ts +0 -9
  111. package/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.d.ts +0 -12
  112. package/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.d.ts +0 -25
  113. package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.d.ts +0 -12
  114. package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.d.ts +0 -8
  115. package/lib/c3-file-viewer/consts/default.config.d.ts +0 -2
  116. package/lib/c3-file-viewer/directives/full-screen.directive.d.ts +0 -12
  117. package/lib/c3-file-viewer/models/custom-file-event.model.d.ts +0 -5
  118. package/lib/c3-file-viewer/models/file-metadata.d.ts +0 -12
  119. package/lib/c3-file-viewer/models/file-viewer-config.model.d.ts +0 -48
  120. package/lib/c3-file-viewer/models/file-viewer.d.ts +0 -65
  121. package/lib/c3-file-viewer/models/http.client.d.ts +0 -14
  122. package/lib/c3-safe-url/pipes/c3-safe-url.pipe.d.ts +0 -10
  123. /package/{lib → src/lib}/c3-dropdown/styles/_c3-dropdown.sass +0 -0
  124. /package/{lib → src/lib}/c3-file-viewer/styles/_c3-file-viewer.sass +0 -0
  125. /package/{lib → src/lib}/c3-styles/_c3-core.sass +0 -0
  126. /package/{lib → src/lib}/c3-styles/_c3-root-variables.sass +0 -0
  127. /package/{lib → src/lib}/c3-styles/_utils.sass +0 -0
@@ -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,34 @@
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
+ })
14
+ export class C3FileViewerDialogComponent {
15
+ @Input()
16
+ public fileViewer!: C3FileViewer;
17
+
18
+ @Input()
19
+ public dialogConfig: Partial<MatDialogConfig> = {
20
+ panelClass: 'c3-file-viewer-dialog',
21
+ width: '80%',
22
+ height: '80%',
23
+ };
24
+
25
+ constructor(private _dialog: MatDialog) {}
26
+
27
+ @HostListener('click')
28
+ openDialog() {
29
+ this._dialog.open(C3FileViewerDialog, {
30
+ data: this.fileViewer,
31
+ ...this.dialogConfig,
32
+ });
33
+ }
34
+ }
@@ -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
+ }
@@ -0,0 +1,41 @@
1
+ import { C3FileViewerConfig } from '../models/file-viewer-config.model';
2
+
3
+ export const DEFAULT_CONFIG: C3FileViewerConfig = {
4
+ btnContainerClass: 'btn-container',
5
+ btnClass: 'default',
6
+ btnSubClass: 'material-icons',
7
+ zoomFactor: 0.1,
8
+ containerBackgroundColor: '#00000000',
9
+ wheelZoom: false,
10
+ allowFullscreen: true,
11
+ allowKeyboardNavigation: true,
12
+ btnShow: {
13
+ zoomIn: true,
14
+ zoomOut: true,
15
+ rotateClockwise: true,
16
+ rotateCounterClockwise: true,
17
+ next: true,
18
+ prev: true,
19
+ reset: true,
20
+ },
21
+ btnIcons: {
22
+ zoomIn: {
23
+ text: 'zoom_in',
24
+ },
25
+ zoomOut: {
26
+ text: 'zoom_out',
27
+ },
28
+ rotateClockwise: {
29
+ text: 'rotate_right',
30
+ },
31
+ rotateCounterClockwise: {
32
+ text: 'rotate_left',
33
+ },
34
+ fullscreen: {
35
+ text: 'fullscreen',
36
+ },
37
+ reset: {
38
+ text: 'restore',
39
+ },
40
+ },
41
+ };
@@ -0,0 +1,11 @@
1
+ import { ElementRef } from '@angular/core';
2
+ import { FullScreenDirective } from './full-screen.directive';
3
+ import { TestBed } from '@angular/core/testing';
4
+
5
+ describe('FullScreenDirective', () => {
6
+ it('should create an instance', () => {
7
+ const el = TestBed.inject(ElementRef);
8
+ const directive = new FullScreenDirective(el);
9
+ expect(directive).toBeTruthy();
10
+ });
11
+ });
@@ -0,0 +1,68 @@
1
+ import { Directive, ElementRef, Input } from '@angular/core';
2
+ import { BehaviorSubject, debounceTime, filter, skip } from 'rxjs';
3
+
4
+ @Directive({
5
+ selector: '[C3FullScreen], [c3-full-screen]',
6
+ })
7
+ export class FullScreenDirective {
8
+ @Input('c3Screenfull')
9
+ set fullscreenState(value: Boolean | null) {
10
+ this._fullscreenState.next(value?.valueOf() || false);
11
+ }
12
+
13
+ @Input('c3-full-screen')
14
+ set fullscreenStateSetter(value: Boolean | null) {
15
+ this.fullscreenState = value;
16
+ }
17
+
18
+ private _fullscreenState = new BehaviorSubject(false);
19
+
20
+ constructor(private el: ElementRef) {
21
+ this._fullscreenState
22
+ .pipe(
23
+ filter((value) => value !== null),
24
+ skip(2),
25
+ debounceTime(100)
26
+ )
27
+ .subscribe(() => {
28
+ this.defineState();
29
+ });
30
+ }
31
+
32
+ private defineState() {
33
+ if (this._fullscreenState.getValue()) {
34
+ const element: any = this.el.nativeElement;
35
+
36
+ const requestMethod =
37
+ element.requestFullscreen ||
38
+ element.webkitRequestFullScreen ||
39
+ element.mozRequestFullScreen ||
40
+ element.msRequestFullScreen;
41
+
42
+ if (requestMethod) {
43
+ // Native full screen.
44
+ requestMethod.call(element);
45
+ } else {
46
+ console.log('FullScreen Request Method Not Supported on this browser.');
47
+ }
48
+ } else {
49
+ const element: any = document;
50
+
51
+ const requestMethod =
52
+ element.cancelFullscreen ||
53
+ element.webkitExitFullscreen ||
54
+ element.webkitCancelFullScreen ||
55
+ element.mozCancelFullScreen ||
56
+ element.msExitFullScreen;
57
+
58
+ if (requestMethod) {
59
+ // Native Cancel full screen.
60
+ requestMethod.call(element);
61
+ } else {
62
+ console.log(
63
+ 'FullScreen Cancel Request Method Not Supported on this browser.'
64
+ );
65
+ }
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,9 @@
1
+ export class CustomFileEvent {
2
+ public name: string;
3
+ public fileUrl: string;
4
+
5
+ constructor(name: string, fileUrl: string) {
6
+ this.name = name;
7
+ this.fileUrl = fileUrl;
8
+ }
9
+ }
@@ -0,0 +1,13 @@
1
+ import { Observable } from 'rxjs';
2
+
3
+ export interface FileMetadata {
4
+ name: string;
5
+ size?: number;
6
+ type: string;
7
+ lastModified?: Date;
8
+ created?: Date;
9
+ extension?: string;
10
+ location: string;
11
+ objectUrl?: Observable<string>;
12
+ metadata?: Record<string, any>;
13
+ }
@@ -0,0 +1,53 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+
3
+ export interface C3FileViewerConfig {
4
+ btnContainerClass?: string;
5
+ btnClass?: string;
6
+ btnSubClass?: string;
7
+ zoomFactor?: number;
8
+ containerBackgroundColor?: string;
9
+ wheelZoom?: boolean;
10
+ allowFullscreen?: boolean;
11
+ allowKeyboardNavigation?: boolean;
12
+ customClient?: HttpClient['get'];
13
+
14
+ minHeight?: number | string;
15
+ minWidth?: number | string;
16
+ width?: number | string;
17
+ maxHeight?: number | string;
18
+ height?: number | string;
19
+ maxWidth?: number | string;
20
+
21
+ btnShow?: {
22
+ zoomIn?: boolean;
23
+ zoomOut?: boolean;
24
+ rotateClockwise?: boolean;
25
+ rotateCounterClockwise?: boolean;
26
+ next?: boolean;
27
+ prev?: boolean;
28
+ reset?: boolean;
29
+ };
30
+
31
+ btnIcons?: {
32
+ zoomIn?: MultiBtn['btn'];
33
+ zoomOut?: MultiBtn['btn'];
34
+ rotateClockwise?: MultiBtn['btn'];
35
+ rotateCounterClockwise?: MultiBtn['btn'];
36
+ next?: MultiBtn['btn'];
37
+ prev?: MultiBtn['btn'];
38
+ fullscreen?: MultiBtn['btn'];
39
+ reset?: MultiBtn['btn'];
40
+ };
41
+
42
+ customBtns?: Array<{
43
+ name: string;
44
+ icon: MultiBtn['btn'];
45
+ }>;
46
+ }
47
+
48
+ interface MultiBtn {
49
+ btn: {
50
+ classes?: string;
51
+ text?: string;
52
+ };
53
+ }