c3-components 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/c3-components.mjs +5 -0
- package/esm2022/lib/c3-auto-animate/C3AutoAnimate.directive.mjs +23 -0
- package/esm2022/lib/c3-dialog/c3-dialog.module.mjs +52 -0
- package/esm2022/lib/c3-dialog/components/c3-dialog-confirm.component.mjs +51 -0
- package/esm2022/lib/c3-dialog/components/c3-dialog-embed-child.component.mjs +32 -0
- package/esm2022/lib/c3-dialog/components/c3-dialog-prompt.component.mjs +95 -0
- package/esm2022/lib/c3-dialog/services/c3-dialog.service.mjs +77 -0
- package/esm2022/lib/c3-dropdown/c3-dropdown.module.mjs +20 -0
- package/esm2022/lib/c3-dropdown/components/c3-dropdown.component.mjs +45 -0
- package/esm2022/lib/c3-dropdown/directives/c3-dropdown.trigger.mjs +128 -0
- package/esm2022/lib/c3-expansion/c3-expansion.module.mjs +43 -0
- package/esm2022/lib/c3-expansion/components/c3-expansion/c3-expansion.component.mjs +34 -0
- package/esm2022/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.mjs +24 -0
- package/esm2022/lib/c3-file-viewer/c3-file-viewer.module.mjs +47 -0
- package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.mjs +17 -0
- package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.mjs +20 -0
- package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.mjs +23 -0
- package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.mjs +32 -0
- package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.mjs +86 -0
- package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.mjs +40 -0
- package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.mjs +26 -0
- package/esm2022/lib/c3-file-viewer/consts/default.config.mjs +40 -0
- package/esm2022/lib/c3-file-viewer/directives/full-screen.directive.mjs +66 -0
- package/esm2022/lib/c3-file-viewer/models/custom-file-event.model.mjs +7 -0
- package/esm2022/lib/c3-file-viewer/models/file-metadata.mjs +2 -0
- package/esm2022/lib/c3-file-viewer/models/file-viewer-config.model.mjs +2 -0
- package/esm2022/lib/c3-file-viewer/models/file-viewer.mjs +206 -0
- package/esm2022/lib/c3-file-viewer/models/http.client.mjs +2 -0
- package/esm2022/lib/c3-safe-url/pipes/c3-safe-url.pipe.mjs +21 -0
- package/esm2022/public-api.mjs +45 -0
- package/fesm2022/c3-components.mjs +1160 -0
- package/fesm2022/c3-components.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/c3-auto-animate/C3AutoAnimate.directive.d.ts +11 -0
- package/lib/c3-dialog/c3-dialog.module.d.ts +15 -0
- package/lib/c3-dialog/components/c3-dialog-confirm.component.d.ts +23 -0
- package/lib/c3-dialog/components/c3-dialog-embed-child.component.d.ts +18 -0
- package/lib/c3-dialog/components/c3-dialog-prompt.component.d.ts +31 -0
- package/lib/c3-dialog/services/c3-dialog.service.d.ts +18 -0
- package/lib/c3-dropdown/c3-dropdown.module.d.ts +10 -0
- package/lib/c3-dropdown/components/c3-dropdown.component.d.ts +15 -0
- package/lib/c3-dropdown/directives/c3-dropdown.trigger.d.ts +45 -0
- package/lib/c3-expansion/c3-expansion.module.d.ts +14 -0
- package/lib/c3-expansion/components/c3-expansion/c3-expansion.component.d.ts +13 -0
- package/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.d.ts +9 -0
- package/lib/c3-file-viewer/c3-file-viewer.module.d.ts +17 -0
- package/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.d.ts +8 -0
- package/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.d.ts +9 -0
- package/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.d.ts +9 -0
- package/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.d.ts +12 -0
- package/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.d.ts +25 -0
- package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.d.ts +12 -0
- package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.d.ts +8 -0
- package/lib/c3-file-viewer/consts/default.config.d.ts +2 -0
- package/lib/c3-file-viewer/directives/full-screen.directive.d.ts +12 -0
- package/lib/c3-file-viewer/models/custom-file-event.model.d.ts +5 -0
- package/lib/c3-file-viewer/models/file-metadata.d.ts +12 -0
- package/lib/c3-file-viewer/models/file-viewer-config.model.d.ts +48 -0
- package/lib/c3-file-viewer/models/file-viewer.d.ts +65 -0
- package/lib/c3-file-viewer/models/http.client.d.ts +14 -0
- package/lib/c3-safe-url/pipes/c3-safe-url.pipe.d.ts +10 -0
- package/package.json +13 -4
- package/{src/public-api.ts → public-api.d.ts} +0 -10
- package/CONTRIBUTING.md +0 -80
- package/bun.lockb +0 -0
- package/ng-package.json +0 -19
- package/src/lib/c3-auto-animate/C3AutoAnimate.directive.ts +0 -18
- package/src/lib/c3-dialog/c3-dialog.module.ts +0 -30
- package/src/lib/c3-dialog/components/c3-dialog-confirm.component.ts +0 -44
- package/src/lib/c3-dialog/components/c3-dialog-embed-child.component.ts +0 -40
- package/src/lib/c3-dialog/components/c3-dialog-prompt.component.ts +0 -81
- package/src/lib/c3-dialog/services/c3-dialog.service.ts +0 -87
- package/src/lib/c3-dropdown/c3-dropdown.module.ts +0 -12
- package/src/lib/c3-dropdown/components/c3-dropdown.component.spec.ts +0 -22
- package/src/lib/c3-dropdown/components/c3-dropdown.component.ts +0 -39
- package/src/lib/c3-dropdown/directives/c3-dropdown.trigger.ts +0 -161
- package/src/lib/c3-expansion/c3-expansion.module.ts +0 -24
- package/src/lib/c3-expansion/components/c3-expansion/c3-expansion.component.html +0 -9
- package/src/lib/c3-expansion/components/c3-expansion/c3-expansion.component.ts +0 -33
- package/src/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.html +0 -12
- package/src/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.ts +0 -21
- package/src/lib/c3-file/c3-download/c3-download.module.ts +0 -7
- package/src/lib/c3-file/c3-download/c3-download.service.ts +0 -16
- package/src/lib/c3-file/c3-input-file/c3-input-file.module.ts +0 -30
- package/src/lib/c3-file/c3-input-file/class/c3-input-file.ts +0 -62
- package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.html +0 -7
- package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.ts +0 -96
- package/src/lib/c3-file/c3-input-file/components/c3-input-file-container/c3-input-file-container.component.ts +0 -53
- package/src/lib/c3-file/c3-input-file/components/c3-input-file-displayer/c3-input-file-displayer.component.ts +0 -107
- package/src/lib/c3-file/c3-input-file/components/c3-input-file-trigger/c3-input-file-trigger.component.ts +0 -22
- package/src/lib/c3-file/c3-input-file/directives/c3-input-file-trigger.directive.ts +0 -27
- package/src/lib/c3-file-upload/c3-file-upload.module.ts +0 -8
- package/src/lib/c3-file-viewer/c3-file-viewer.module.ts +0 -30
- package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.html +0 -185
- package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.spec.ts +0 -23
- package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.ts +0 -15
- package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.html +0 -7
- package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.spec.ts +0 -23
- package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.ts +0 -14
- package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.html +0 -7
- package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.spec.ts +0 -23
- package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.ts +0 -25
- package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.css +0 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.html +0 -1
- package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.spec.ts +0 -23
- package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.ts +0 -35
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.html +0 -32
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.spec.ts +0 -23
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.ts +0 -93
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.spec.ts +0 -23
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.ts +0 -37
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.spec.ts +0 -22
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.ts +0 -12
- package/src/lib/c3-file-viewer/consts/default.config.ts +0 -41
- package/src/lib/c3-file-viewer/directives/full-screen.directive.spec.ts +0 -11
- package/src/lib/c3-file-viewer/directives/full-screen.directive.ts +0 -68
- package/src/lib/c3-file-viewer/models/custom-file-event.model.ts +0 -9
- package/src/lib/c3-file-viewer/models/file-metadata.ts +0 -13
- package/src/lib/c3-file-viewer/models/file-viewer-config.model.ts +0 -53
- package/src/lib/c3-file-viewer/models/file-viewer.ts +0 -259
- package/src/lib/c3-file-viewer/models/http.client.ts +0 -23
- package/src/lib/c3-highlight-text/c3-highlight-text.module.ts +0 -12
- package/src/lib/c3-menu/c3-menu.module.ts +0 -12
- package/src/lib/c3-modal/c3-modal.module.ts +0 -12
- package/src/lib/c3-navbar/c3-navbar.module.ts +0 -12
- package/src/lib/c3-pdf-dialog/c3-pdf-dialog.module.ts +0 -12
- package/src/lib/c3-rounded-title/c3-rounded-title.module.ts +0 -12
- package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.spec.ts +0 -8
- package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.ts +0 -13
- package/src/lib/c3-tabs/c3-tabs.module.ts +0 -12
- package/tsconfig.lib.json +0 -14
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -14
- /package/{src/_index.scss → _index.scss} +0 -0
- /package/{src/lib → lib}/c3-dropdown/styles/_c3-dropdown.sass +0 -0
- /package/{src/lib → lib}/c3-expansion/styles/_c3-expansion.scss +0 -0
- /package/{src/lib → lib}/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.scss +0 -0
- /package/{src/lib → lib}/c3-file-viewer/styles/_c3-file-viewer.sass +0 -0
- /package/{src/lib → lib}/c3-styles/_c3-core.sass +0 -0
- /package/{src/lib → lib}/c3-styles/_c3-root-variables.sass +0 -0
- /package/{src/lib → lib}/c3-styles/_utils.sass +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
}
|
package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.spec.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
});
|
package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { BehaviorSubject, Observable, map, tap } from 'rxjs';
|
|
2
|
-
import { DEFAULT_CONFIG } from '../consts/default.config';
|
|
3
|
-
import { C3FileViewerConfig } from './file-viewer-config.model';
|
|
4
|
-
import { HttpClient } from '@angular/common/http';
|
|
5
|
-
import { CustomFileEvent } from './custom-file-event.model';
|
|
6
|
-
import { FileMetadata } from './file-metadata';
|
|
7
|
-
import { inject } from '@angular/core';
|
|
8
|
-
|
|
9
|
-
export class C3FileViewer {
|
|
10
|
-
private _config: C3FileViewerConfig = DEFAULT_CONFIG;
|
|
11
|
-
get config(): C3FileViewerConfig {
|
|
12
|
-
return this._config;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
set config(value: C3FileViewerConfig) {
|
|
16
|
-
this._config = this.mergeConfig(DEFAULT_CONFIG, value);
|
|
17
|
-
this.config$.next(this._config);
|
|
18
|
-
}
|
|
19
|
-
public config$ = new BehaviorSubject<C3FileViewerConfig>(DEFAULT_CONFIG);
|
|
20
|
-
|
|
21
|
-
public fullscreen$ = new BehaviorSubject<Boolean>(false);
|
|
22
|
-
|
|
23
|
-
public customFile$ = new BehaviorSubject<any>(null);
|
|
24
|
-
public index$ = new BehaviorSubject<number>(0);
|
|
25
|
-
public loading: boolean = true;
|
|
26
|
-
public currentIndex: number = 0;
|
|
27
|
-
|
|
28
|
-
get currentFile(): FileMetadata {
|
|
29
|
-
return this.filesObjectUrl[this.currentIndex];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public style = {
|
|
33
|
-
transform: '',
|
|
34
|
-
msTransform: '',
|
|
35
|
-
oTransform: '',
|
|
36
|
-
webkitTransform: '',
|
|
37
|
-
minHeight: 'auto',
|
|
38
|
-
maxHeight: 'auto',
|
|
39
|
-
height: 'auto',
|
|
40
|
-
minWidth: 'auto',
|
|
41
|
-
maxWidth: 'auto',
|
|
42
|
-
width: 'auto',
|
|
43
|
-
};
|
|
44
|
-
public styleHeight = '100%';
|
|
45
|
-
public hovered = false;
|
|
46
|
-
|
|
47
|
-
public set files(value: FileMetadata[]) {
|
|
48
|
-
this._files = value;
|
|
49
|
-
this.currentIndex = 0;
|
|
50
|
-
this.index$.next(this.currentIndex);
|
|
51
|
-
|
|
52
|
-
this.filesObjectUrl = value.map((file) => {
|
|
53
|
-
return {
|
|
54
|
-
...file,
|
|
55
|
-
objectUrl: file.objectUrl || this.createObjectURL(file),
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public get files(): FileMetadata[] {
|
|
61
|
-
return this._files;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private _files: FileMetadata[] = [];
|
|
65
|
-
|
|
66
|
-
public filesObjectUrl: Array<
|
|
67
|
-
FileMetadata & {
|
|
68
|
-
objectUrl?: Observable<string>;
|
|
69
|
-
}
|
|
70
|
-
> = [];
|
|
71
|
-
|
|
72
|
-
private scale = 1;
|
|
73
|
-
private rotation = 0;
|
|
74
|
-
private translateX = 0;
|
|
75
|
-
private translateY = 0;
|
|
76
|
-
private prevX: number = 0;
|
|
77
|
-
private prevY: number = 0;
|
|
78
|
-
|
|
79
|
-
constructor({
|
|
80
|
-
config,
|
|
81
|
-
files,
|
|
82
|
-
}: {
|
|
83
|
-
config?: C3FileViewerConfig;
|
|
84
|
-
files?: FileMetadata[];
|
|
85
|
-
}) {
|
|
86
|
-
if (config) this.config = config;
|
|
87
|
-
if (files) this.files = files;
|
|
88
|
-
|
|
89
|
-
this.config$.subscribe((config) => {
|
|
90
|
-
const { minHeight, maxHeight, minWidth, maxWidth, height, width } =
|
|
91
|
-
config;
|
|
92
|
-
this.style.minHeight = this.valueToCss(minHeight);
|
|
93
|
-
this.style.height = this.valueToCss(height);
|
|
94
|
-
this.style.width = this.valueToCss(width);
|
|
95
|
-
this.style.maxHeight = this.valueToCss(maxHeight);
|
|
96
|
-
this.style.minWidth = this.valueToCss(minWidth);
|
|
97
|
-
this.style.maxWidth = this.valueToCss(maxWidth);
|
|
98
|
-
this.styleHeight = this.valueToCss(height);
|
|
99
|
-
|
|
100
|
-
this.updateStyle();
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
createObjectURL(file: FileMetadata) {
|
|
105
|
-
this.onLoadStart(file);
|
|
106
|
-
return this.getFile(file.location).pipe(
|
|
107
|
-
map((response) => URL.createObjectURL(response)),
|
|
108
|
-
tap(() => this.onLoad(file))
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
getFile(location: string) {
|
|
113
|
-
const client =
|
|
114
|
-
this.config.customClient ||
|
|
115
|
-
inject(HttpClient).get.bind(inject(HttpClient));
|
|
116
|
-
if (!client) {
|
|
117
|
-
throw new Error(
|
|
118
|
-
'No http client provided. Please provide a custom client or import HttpClientModule'
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return client(location, {
|
|
123
|
-
responseType: 'blob',
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
previousImage(event: KeyboardEvent | MouseEvent) {
|
|
128
|
-
if (this.canNavigate(event)) {
|
|
129
|
-
this.loading = true;
|
|
130
|
-
if (this.currentIndex > 0) this.currentIndex--;
|
|
131
|
-
else this.currentIndex = this.files.length - 1;
|
|
132
|
-
this.index$.next(this.currentIndex);
|
|
133
|
-
this.reset();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
nextImage(event: KeyboardEvent | MouseEvent) {
|
|
138
|
-
if (this.canNavigate(event)) {
|
|
139
|
-
this.loading = true;
|
|
140
|
-
if (this.currentIndex < this.files.length - 1) this.currentIndex++;
|
|
141
|
-
else this.currentIndex = 0;
|
|
142
|
-
this.index$.next(this.currentIndex);
|
|
143
|
-
this.reset();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
zoomIn() {
|
|
148
|
-
this.scale *= 1 + (this.config.zoomFactor || 0);
|
|
149
|
-
this.updateStyle();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
zoomOut() {
|
|
153
|
-
if (this.scale > (this.config.zoomFactor || 0)) {
|
|
154
|
-
this.scale /= 1 + (this.config.zoomFactor || 0);
|
|
155
|
-
}
|
|
156
|
-
this.updateStyle();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
scrollZoom(evt: WheelEvent) {
|
|
160
|
-
if (this.config.wheelZoom) {
|
|
161
|
-
evt.deltaY > 0 ? this.zoomOut() : this.zoomIn();
|
|
162
|
-
return false;
|
|
163
|
-
} else {
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
rotateClockwise() {
|
|
169
|
-
this.rotation += 90;
|
|
170
|
-
this.updateStyle();
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
rotateCounterClockwise() {
|
|
174
|
-
this.rotation -= 90;
|
|
175
|
-
this.updateStyle();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
onLoad(file: FileMetadata) {
|
|
179
|
-
this.loading = false;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
onLoadStart(file: FileMetadata) {
|
|
183
|
-
this.loading = true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
imageNotFound(file: FileMetadata) {
|
|
187
|
-
this.loading = false;
|
|
188
|
-
this.customFile$.next(new CustomFileEvent('imageNotFound', file.location));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
onDragOver(evt: DragEvent) {
|
|
192
|
-
this.translateX += evt.clientX - this.prevX;
|
|
193
|
-
this.translateY += evt.clientY - this.prevY;
|
|
194
|
-
this.prevX = evt.clientX;
|
|
195
|
-
this.prevY = evt.clientY;
|
|
196
|
-
this.updateStyle();
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
onDragStart(evt: DragEvent) {
|
|
200
|
-
if (evt.target && evt.dataTransfer && evt.dataTransfer.setDragImage) {
|
|
201
|
-
const target = evt.target as HTMLDivElement;
|
|
202
|
-
const nextElementSibling = target.nextElementSibling as HTMLDivElement;
|
|
203
|
-
|
|
204
|
-
if (nextElementSibling)
|
|
205
|
-
evt.dataTransfer.setDragImage(nextElementSibling, 0, 0);
|
|
206
|
-
}
|
|
207
|
-
this.prevX = evt.clientX;
|
|
208
|
-
this.prevY = evt.clientY;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
toggleFullscreen() {
|
|
212
|
-
const fullScreenValue = this.fullscreen$.getValue();
|
|
213
|
-
this.fullscreen$.next(!fullScreenValue);
|
|
214
|
-
if (fullScreenValue) this.reset();
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
reset() {
|
|
218
|
-
this.scale = 1;
|
|
219
|
-
this.rotation = 0;
|
|
220
|
-
this.translateX = 0;
|
|
221
|
-
this.translateY = 0;
|
|
222
|
-
this.updateStyle();
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
private canNavigate(event: any) {
|
|
226
|
-
return (
|
|
227
|
-
event == null || (this.config.allowKeyboardNavigation && this.hovered)
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
private updateStyle() {
|
|
232
|
-
this.style.transform = `translate(${this.translateX}px, ${this.translateY}px) rotate(${this.rotation}deg) scale(${this.scale})`;
|
|
233
|
-
this.style.msTransform = this.style.transform;
|
|
234
|
-
this.style.webkitTransform = this.style.transform;
|
|
235
|
-
this.style.oTransform = this.style.transform;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
private valueToCss(value: number | string | undefined) {
|
|
239
|
-
return value ? (typeof value === 'string' ? value : value + 'px') : 'auto';
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
private mergeConfig(
|
|
243
|
-
defaultValues: C3FileViewerConfig,
|
|
244
|
-
overrideValues: C3FileViewerConfig
|
|
245
|
-
): C3FileViewerConfig {
|
|
246
|
-
let result: C3FileViewerConfig = { ...defaultValues };
|
|
247
|
-
if (overrideValues) {
|
|
248
|
-
result = { ...defaultValues, ...overrideValues };
|
|
249
|
-
|
|
250
|
-
if (overrideValues.btnIcons) {
|
|
251
|
-
result.btnIcons = {
|
|
252
|
-
...defaultValues.btnIcons,
|
|
253
|
-
...overrideValues.btnIcons,
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return result;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { HttpContext, HttpHeaders, HttpParams } from '@angular/common/http';
|
|
2
|
-
|
|
3
|
-
export interface HttpClientOptions {
|
|
4
|
-
headers?:
|
|
5
|
-
| HttpHeaders
|
|
6
|
-
| {
|
|
7
|
-
[header: string]: string | string[];
|
|
8
|
-
};
|
|
9
|
-
context?: HttpContext;
|
|
10
|
-
observe?: 'body';
|
|
11
|
-
params?:
|
|
12
|
-
| HttpParams
|
|
13
|
-
| {
|
|
14
|
-
[param: string]:
|
|
15
|
-
| string
|
|
16
|
-
| number
|
|
17
|
-
| boolean
|
|
18
|
-
| ReadonlyArray<string | number | boolean>;
|
|
19
|
-
};
|
|
20
|
-
reportProgress?: boolean;
|
|
21
|
-
responseType: 'blob';
|
|
22
|
-
withCredentials?: boolean;
|
|
23
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
-
import { DomSanitizer } from '@angular/platform-browser';
|
|
3
|
-
|
|
4
|
-
@Pipe({
|
|
5
|
-
name: 'c3SafeUrl',
|
|
6
|
-
standalone: true,
|
|
7
|
-
})
|
|
8
|
-
export class C3SafeUrlPipe implements PipeTransform {
|
|
9
|
-
constructor(private sanitizer: DomSanitizer) {}
|
|
10
|
-
transform(url: string | null) {
|
|
11
|
-
return url ? this.sanitizer.bypassSecurityTrustResourceUrl(url) : '';
|
|
12
|
-
}
|
|
13
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"outDir": "../../out-tsc/lib",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"inlineSources": true,
|
|
9
|
-
"types": []
|
|
10
|
-
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"**/*.spec.ts"
|
|
13
|
-
]
|
|
14
|
-
}
|