c3-components 0.0.12 → 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.
- package/CONTRIBUTING.md +80 -0
- package/bun.lockb +0 -0
- package/ng-package.json +19 -0
- package/package.json +5 -15
- package/{_index.scss → src/_index.scss} +1 -3
- package/src/lib/c3-auto-animate/C3AutoAnimate.directive.ts +18 -0
- package/src/lib/c3-dialog/c3-dialog.module.ts +30 -0
- package/src/lib/c3-dialog/components/c3-dialog-confirm.component.ts +44 -0
- package/src/lib/c3-dialog/components/c3-dialog-embed-child.component.ts +40 -0
- package/src/lib/c3-dialog/components/c3-dialog-prompt.component.ts +81 -0
- package/src/lib/c3-dialog/services/c3-dialog.service.ts +87 -0
- package/src/lib/c3-dropdown/c3-dropdown.module.ts +12 -0
- package/src/lib/c3-dropdown/components/c3-dropdown.component.spec.ts +22 -0
- package/src/lib/c3-dropdown/components/c3-dropdown.component.ts +39 -0
- package/src/lib/c3-dropdown/directives/c3-dropdown.trigger.ts +161 -0
- package/src/lib/c3-expansion/c3-expansion.module.ts +24 -0
- package/src/lib/c3-expansion/components/c3-expansion/c3-expansion.component.html +9 -0
- package/src/lib/c3-expansion/components/c3-expansion/c3-expansion.component.ts +33 -0
- package/src/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.html +12 -0
- package/src/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.ts +21 -0
- package/src/lib/c3-expansion/styles/_c3-expansion.scss +39 -0
- package/src/lib/c3-file/c3-download/c3-download.module.ts +7 -0
- package/src/lib/c3-file/c3-download/c3-download.service.ts +16 -0
- package/src/lib/c3-file/c3-input-file/c3-input-file.module.ts +30 -0
- package/src/lib/c3-file/c3-input-file/class/c3-input-file.ts +62 -0
- package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.html +7 -0
- package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.ts +96 -0
- package/src/lib/c3-file/c3-input-file/components/c3-input-file-container/c3-input-file-container.component.ts +53 -0
- package/src/lib/c3-file/c3-input-file/components/c3-input-file-displayer/c3-input-file-displayer.component.ts +107 -0
- package/src/lib/c3-file/c3-input-file/components/c3-input-file-trigger/c3-input-file-trigger.component.ts +22 -0
- package/src/lib/c3-file/c3-input-file/directives/c3-input-file-trigger.directive.ts +27 -0
- package/src/lib/c3-file-upload/c3-file-upload.module.ts +8 -0
- package/src/lib/c3-file-viewer/c3-file-viewer.module.ts +30 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.html +185 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.ts +15 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.html +7 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.ts +14 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.html +7 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.ts +25 -0
- 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 +1 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.ts +35 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.html +32 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.ts +93 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.spec.ts +23 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.ts +37 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.spec.ts +22 -0
- package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.ts +12 -0
- package/src/lib/c3-file-viewer/consts/default.config.ts +41 -0
- package/src/lib/c3-file-viewer/directives/full-screen.directive.spec.ts +11 -0
- package/src/lib/c3-file-viewer/directives/full-screen.directive.ts +68 -0
- package/src/lib/c3-file-viewer/models/custom-file-event.model.ts +9 -0
- package/src/lib/c3-file-viewer/models/file-metadata.ts +13 -0
- package/src/lib/c3-file-viewer/models/file-viewer-config.model.ts +53 -0
- package/src/lib/c3-file-viewer/models/file-viewer.ts +259 -0
- package/src/lib/c3-file-viewer/models/http.client.ts +23 -0
- package/{lib → src/lib}/c3-file-viewer/styles/_c3-file-viewer.sass +2 -20
- package/src/lib/c3-highlight-text/c3-highlight-text.module.ts +12 -0
- package/src/lib/c3-menu/c3-menu.module.ts +12 -0
- package/src/lib/c3-modal/c3-modal.module.ts +12 -0
- package/src/lib/c3-navbar/c3-navbar.module.ts +12 -0
- package/src/lib/c3-pdf-dialog/c3-pdf-dialog.module.ts +12 -0
- package/src/lib/c3-rounded-title/c3-rounded-title.module.ts +12 -0
- package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.spec.ts +8 -0
- package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.ts +13 -0
- package/{lib → src/lib}/c3-styles/_c3-core.sass +4 -2
- package/src/lib/c3-tabs/c3-tabs.module.ts +12 -0
- package/{public-api.d.ts → src/public-api.ts} +20 -0
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
- package/esm2022/c3-components.mjs +0 -5
- package/esm2022/lib/c3-dialog/c3-dialog.module.mjs +0 -52
- package/esm2022/lib/c3-dialog/components/c3-dialog-confirm.component.mjs +0 -51
- package/esm2022/lib/c3-dialog/components/c3-dialog-embed-child.component.mjs +0 -32
- package/esm2022/lib/c3-dialog/components/c3-dialog-prompt.component.mjs +0 -95
- package/esm2022/lib/c3-dialog/services/c3-dialog.service.mjs +0 -79
- package/esm2022/lib/c3-dropdown/c3-dropdown.module.mjs +0 -20
- package/esm2022/lib/c3-dropdown/components/c3-dropdown.component.mjs +0 -45
- package/esm2022/lib/c3-dropdown/directives/c3-dropdown.trigger.mjs +0 -128
- package/esm2022/lib/c3-file-viewer/c3-file-viewer.module.mjs +0 -47
- package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.mjs +0 -17
- package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.mjs +0 -20
- package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.mjs +0 -23
- package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.mjs +0 -32
- package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.mjs +0 -86
- package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.mjs +0 -40
- package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.mjs +0 -26
- package/esm2022/lib/c3-file-viewer/consts/default.config.mjs +0 -40
- package/esm2022/lib/c3-file-viewer/directives/full-screen.directive.mjs +0 -66
- package/esm2022/lib/c3-file-viewer/models/custom-file-event.model.mjs +0 -7
- package/esm2022/lib/c3-file-viewer/models/file-metadata.mjs +0 -2
- package/esm2022/lib/c3-file-viewer/models/file-viewer-config.model.mjs +0 -2
- package/esm2022/lib/c3-file-viewer/models/file-viewer.mjs +0 -206
- package/esm2022/lib/c3-file-viewer/models/http.client.mjs +0 -2
- package/esm2022/lib/c3-safe-url/pipes/c3-safe-url.pipe.mjs +0 -21
- package/esm2022/public-api.mjs +0 -35
- package/fesm2022/c3-components.mjs +0 -1056
- package/fesm2022/c3-components.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/c3-dialog/c3-dialog.module.d.ts +0 -15
- package/lib/c3-dialog/components/c3-dialog-confirm.component.d.ts +0 -23
- package/lib/c3-dialog/components/c3-dialog-embed-child.component.d.ts +0 -18
- package/lib/c3-dialog/components/c3-dialog-prompt.component.d.ts +0 -31
- package/lib/c3-dialog/services/c3-dialog.service.d.ts +0 -19
- package/lib/c3-dropdown/c3-dropdown.module.d.ts +0 -10
- package/lib/c3-dropdown/components/c3-dropdown.component.d.ts +0 -15
- package/lib/c3-dropdown/directives/c3-dropdown.trigger.d.ts +0 -45
- package/lib/c3-file-viewer/c3-file-viewer.module.d.ts +0 -17
- package/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.d.ts +0 -8
- package/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.d.ts +0 -9
- package/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.d.ts +0 -9
- package/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.d.ts +0 -12
- package/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.d.ts +0 -25
- package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.d.ts +0 -12
- package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.d.ts +0 -8
- package/lib/c3-file-viewer/consts/default.config.d.ts +0 -2
- package/lib/c3-file-viewer/directives/full-screen.directive.d.ts +0 -12
- package/lib/c3-file-viewer/models/custom-file-event.model.d.ts +0 -5
- package/lib/c3-file-viewer/models/file-metadata.d.ts +0 -12
- package/lib/c3-file-viewer/models/file-viewer-config.model.d.ts +0 -48
- package/lib/c3-file-viewer/models/file-viewer.d.ts +0 -65
- package/lib/c3-file-viewer/models/http.client.d.ts +0 -14
- package/lib/c3-safe-url/pipes/c3-safe-url.pipe.d.ts +0 -10
- /package/{lib → src/lib}/c3-dropdown/styles/_c3-dropdown.sass +0 -0
- /package/{lib → src/lib}/c3-styles/_c3-root-variables.sass +0 -0
- /package/{lib → src/lib}/c3-styles/_utils.sass +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { C3ExpansionHeaderComponent } from './components/c3-expansion-header/c3-expansion-header.component';
|
|
4
|
+
import { C3ExpansionComponent } from './components/c3-expansion/c3-expansion.component';
|
|
5
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
6
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
7
|
+
import { MatToolbarModule } from '@angular/material/toolbar';
|
|
8
|
+
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
9
|
+
import { C3AutoAnimateDirective } from '../c3-auto-animate/C3AutoAnimate.directive';
|
|
10
|
+
|
|
11
|
+
@NgModule({
|
|
12
|
+
declarations: [C3ExpansionComponent, C3ExpansionHeaderComponent],
|
|
13
|
+
imports: [
|
|
14
|
+
CommonModule,
|
|
15
|
+
C3AutoAnimateDirective,
|
|
16
|
+
MatButtonModule,
|
|
17
|
+
MatIconModule,
|
|
18
|
+
MatTooltipModule,
|
|
19
|
+
MatButtonModule,
|
|
20
|
+
MatToolbarModule,
|
|
21
|
+
],
|
|
22
|
+
exports: [C3ExpansionComponent, C3ExpansionHeaderComponent],
|
|
23
|
+
})
|
|
24
|
+
export class C3ExpansionModule {}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
ElementRef,
|
|
4
|
+
HostBinding,
|
|
5
|
+
input,
|
|
6
|
+
model,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { C3AutoAnimateDirective } from '../../../c3-auto-animate/C3AutoAnimate.directive';
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'c3-expansion',
|
|
12
|
+
templateUrl: './c3-expansion.component.html',
|
|
13
|
+
hostDirectives: [
|
|
14
|
+
{
|
|
15
|
+
directive: C3AutoAnimateDirective,
|
|
16
|
+
inputs: ['options'],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
})
|
|
20
|
+
export class C3ExpansionComponent {
|
|
21
|
+
public headerClass = input<string>('c3-expansion-header');
|
|
22
|
+
public isExpanded = model<boolean>(false);
|
|
23
|
+
|
|
24
|
+
@HostBinding('class') get hostClass() {
|
|
25
|
+
return 'c3-expansion';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
constructor(public _elementRef: ElementRef) {}
|
|
29
|
+
|
|
30
|
+
toggleExpand() {
|
|
31
|
+
this.isExpanded.set(!this.isExpanded());
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.html
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<h4 class="text-lg">
|
|
2
|
+
{{ title() }}
|
|
3
|
+
</h4>
|
|
4
|
+
<button
|
|
5
|
+
mat-icon-button
|
|
6
|
+
(click)="c3Expansion().toggleExpand()"
|
|
7
|
+
[matTooltip]="c3Expansion().isExpanded() ? 'Réduire' : 'Développer'"
|
|
8
|
+
>
|
|
9
|
+
<mat-icon>{{
|
|
10
|
+
c3Expansion().isExpanded() ? "expand_less" : "expand_more"
|
|
11
|
+
}}</mat-icon>
|
|
12
|
+
</button>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
HostBinding,
|
|
4
|
+
ViewEncapsulation,
|
|
5
|
+
input,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
import { type C3ExpansionComponent } from '../c3-expansion/c3-expansion.component';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'c3-expansion-header',
|
|
11
|
+
templateUrl: './c3-expansion-header.component.html',
|
|
12
|
+
encapsulation: ViewEncapsulation.None,
|
|
13
|
+
})
|
|
14
|
+
export class C3ExpansionHeaderComponent {
|
|
15
|
+
public title = input<string>('Default Title');
|
|
16
|
+
public c3Expansion = input.required<C3ExpansionComponent>();
|
|
17
|
+
|
|
18
|
+
@HostBinding('class') get hostClass() {
|
|
19
|
+
return 'c3-expansion-header';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@use "sass:map";
|
|
2
|
+
@use "sass:meta";
|
|
3
|
+
@use "@angular/material" as mat;
|
|
4
|
+
|
|
5
|
+
@mixin c3-expansion($theme) {
|
|
6
|
+
$config: mat.m2-get-color-config($theme);
|
|
7
|
+
$is-dark: map.get($config, is-dark);
|
|
8
|
+
|
|
9
|
+
$bg-toolbar: if(
|
|
10
|
+
$is-dark,
|
|
11
|
+
rgb(244 244 245 / var(--tw-bg-opacity)),
|
|
12
|
+
rgb(63 63 70 / var(--tw-bg-opacity))
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
.c3-expansion {
|
|
16
|
+
display: block;
|
|
17
|
+
width: 100%;
|
|
18
|
+
|
|
19
|
+
.mat-toolbar {
|
|
20
|
+
padding: 0 1rem;
|
|
21
|
+
display: flex;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
align-items: center;
|
|
24
|
+
background-color: $bg-toolbar;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.c3-expansion-header {
|
|
28
|
+
display: flex;
|
|
29
|
+
width: 100%;
|
|
30
|
+
justify-content: space-between;
|
|
31
|
+
align-items: center;
|
|
32
|
+
|
|
33
|
+
h4 {
|
|
34
|
+
font-size: 1.125rem;
|
|
35
|
+
line-height: 1.75rem;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { C3DownloadService } from './c3-download.service';
|
|
4
|
+
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
|
|
5
|
+
|
|
6
|
+
@NgModule({ imports: [CommonModule], providers: [C3DownloadService, provideHttpClient(withInterceptorsFromDi())] })
|
|
7
|
+
export class C3DownloadModule {}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { HttpClient } from '@angular/common/http';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: 'root',
|
|
7
|
+
})
|
|
8
|
+
export class C3DownloadService {
|
|
9
|
+
constructor(private _http: HttpClient) {}
|
|
10
|
+
|
|
11
|
+
download(url: string): Observable<Blob> {
|
|
12
|
+
return this._http.get(url, {
|
|
13
|
+
responseType: 'blob',
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { C3InputFileTriggerComponent } from './components/c3-input-file-trigger/c3-input-file-trigger.component';
|
|
4
|
+
import { C3InputFileContainerComponent } from './components/c3-input-file-container/c3-input-file-container.component';
|
|
5
|
+
import { C3InputFileDisplayerComponent } from './components/c3-input-file-displayer/c3-input-file-displayer.component';
|
|
6
|
+
import { C3InputFileTriggerDirective } from './directives/c3-input-file-trigger.directive';
|
|
7
|
+
|
|
8
|
+
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
9
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
10
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
11
|
+
import { C3InputFileComponent } from './components/c3-input-file/c3-input-file.component';
|
|
12
|
+
|
|
13
|
+
@NgModule({
|
|
14
|
+
declarations: [
|
|
15
|
+
C3InputFileComponent,
|
|
16
|
+
C3InputFileTriggerComponent,
|
|
17
|
+
C3InputFileContainerComponent,
|
|
18
|
+
C3InputFileDisplayerComponent,
|
|
19
|
+
C3InputFileTriggerDirective,
|
|
20
|
+
],
|
|
21
|
+
imports: [CommonModule, MatProgressBarModule, MatButtonModule, MatIconModule],
|
|
22
|
+
exports: [
|
|
23
|
+
C3InputFileComponent,
|
|
24
|
+
C3InputFileTriggerComponent,
|
|
25
|
+
C3InputFileContainerComponent,
|
|
26
|
+
C3InputFileDisplayerComponent,
|
|
27
|
+
C3InputFileTriggerDirective,
|
|
28
|
+
],
|
|
29
|
+
})
|
|
30
|
+
export class C3InputFileModule {}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Subject } from 'rxjs';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
|
|
4
|
+
export class C3InputFile<ResponseType = any> extends EventEmitter {
|
|
5
|
+
name?: string;
|
|
6
|
+
id?: number;
|
|
7
|
+
fileName: string;
|
|
8
|
+
mimetype: string;
|
|
9
|
+
progressionChange = new Subject<number>();
|
|
10
|
+
private _progression = 0;
|
|
11
|
+
loaded: boolean = false;
|
|
12
|
+
path?: string;
|
|
13
|
+
size?: number;
|
|
14
|
+
aborded: boolean = false;
|
|
15
|
+
response?: ResponseType;
|
|
16
|
+
|
|
17
|
+
constructor({
|
|
18
|
+
fileName,
|
|
19
|
+
mimetype,
|
|
20
|
+
size,
|
|
21
|
+
}: {
|
|
22
|
+
fileName: string;
|
|
23
|
+
mimetype: string;
|
|
24
|
+
size: number;
|
|
25
|
+
}) {
|
|
26
|
+
super();
|
|
27
|
+
this.fileName = fileName;
|
|
28
|
+
this.mimetype = mimetype;
|
|
29
|
+
this.size = size;
|
|
30
|
+
this.progressionChange.next(this._progression);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
set progression(value: number) {
|
|
34
|
+
this._progression = value;
|
|
35
|
+
if (value === 100) {
|
|
36
|
+
this.loaded = true;
|
|
37
|
+
this.emit('loaded');
|
|
38
|
+
}
|
|
39
|
+
this.progressionChange.next(value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get progression(): number {
|
|
43
|
+
return this._progression;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override on(event: string | symbol, listener: (...args: any[]) => void) {
|
|
47
|
+
return super.on(event, listener);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override emit(event: string | symbol, ...args: any[]): boolean {
|
|
51
|
+
return super.emit(event, args);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override off(event: string | symbol, listener: (...args: any[]) => void) {
|
|
55
|
+
return super.off(event, listener);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
abord() {
|
|
59
|
+
this.aborded = true;
|
|
60
|
+
this.emit('abord');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Input,
|
|
5
|
+
ViewChild,
|
|
6
|
+
ElementRef,
|
|
7
|
+
Output,
|
|
8
|
+
EventEmitter,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { C3InputFile } from '../../class/c3-input-file';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'c3-input-file',
|
|
14
|
+
templateUrl: './c3-input-file.component.html',
|
|
15
|
+
styleUrls: ['./c3-input-file.component.scss'],
|
|
16
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
17
|
+
})
|
|
18
|
+
export class C3InputFileComponent {
|
|
19
|
+
@Input() accept!: string;
|
|
20
|
+
@Input() multiple: Boolean = false;
|
|
21
|
+
@Input() dest: string = 'api/upload';
|
|
22
|
+
@Input() baseUrl: string = 'localhost:3000';
|
|
23
|
+
@Input() method: string = 'POST';
|
|
24
|
+
@Input() headers?: Object;
|
|
25
|
+
|
|
26
|
+
@ViewChild('fileInput') fileInput!: ElementRef<HTMLInputElement>;
|
|
27
|
+
@Output()
|
|
28
|
+
fileAdded: EventEmitter<C3InputFile> = new EventEmitter<C3InputFile>();
|
|
29
|
+
|
|
30
|
+
click() {
|
|
31
|
+
this.fileInput.nativeElement.click();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
change({ target }: any) {
|
|
35
|
+
const files = Array.from(target.files as FileList);
|
|
36
|
+
|
|
37
|
+
files.forEach((file) => {
|
|
38
|
+
const formData = new FormData();
|
|
39
|
+
const xhr = new XMLHttpRequest();
|
|
40
|
+
|
|
41
|
+
formData.append('upload', file);
|
|
42
|
+
|
|
43
|
+
// ecoute la progression de l'upload
|
|
44
|
+
xhr.upload.addEventListener(
|
|
45
|
+
'progress',
|
|
46
|
+
(progress) => {
|
|
47
|
+
_file.progression = Math.round(
|
|
48
|
+
(progress.loaded / progress.total) * 100
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
false
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
// ecoute si une erreur survient lors de l'upload
|
|
55
|
+
xhr.addEventListener('error', (event) => console.log(event), false);
|
|
56
|
+
|
|
57
|
+
// ecoute si l'utilisateur annul l'upload en cours
|
|
58
|
+
xhr.addEventListener('abort', (event) => console.log(event), false);
|
|
59
|
+
|
|
60
|
+
xhr.addEventListener('readystatechange', (ev) => {
|
|
61
|
+
if (xhr.readyState === 4) {
|
|
62
|
+
const data = JSON.parse(xhr.response);
|
|
63
|
+
_file.name = data.name;
|
|
64
|
+
_file.id = data.id;
|
|
65
|
+
_file.path = data.path;
|
|
66
|
+
_file.response = data;
|
|
67
|
+
if (_file.progression !== 100) _file.progression = 100;
|
|
68
|
+
_file.progressionChange.complete();
|
|
69
|
+
_file.emit('completed');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// initialise le type de connection et l'url
|
|
74
|
+
xhr.open(this.method, `${this.baseUrl}/${this.dest}`);
|
|
75
|
+
|
|
76
|
+
// set header if data is transmitted
|
|
77
|
+
if (this.headers)
|
|
78
|
+
for (const [key, value] of Object.entries(this.headers))
|
|
79
|
+
xhr.setRequestHeader(key, value);
|
|
80
|
+
|
|
81
|
+
// start upload
|
|
82
|
+
xhr.send(formData);
|
|
83
|
+
|
|
84
|
+
const _file: C3InputFile = new C3InputFile({
|
|
85
|
+
fileName: file.name,
|
|
86
|
+
mimetype: file.type,
|
|
87
|
+
size: file.size,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
_file.on('abord', () => {
|
|
91
|
+
xhr.abort();
|
|
92
|
+
});
|
|
93
|
+
this.fileAdded.emit(_file);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
ViewEncapsulation,
|
|
4
|
+
ContentChild,
|
|
5
|
+
OnDestroy,
|
|
6
|
+
Input,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { C3InputFileTriggerComponent } from '../c3-input-file-trigger/c3-input-file-trigger.component';
|
|
9
|
+
import { C3InputFileTriggerDirective } from '../../directives/c3-input-file-trigger.directive';
|
|
10
|
+
import { C3InputFileComponent } from '../c3-input-file/c3-input-file.component';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector:
|
|
14
|
+
'c3-input-file-container, [c3InputFileContainer], [c3-input-file-container]',
|
|
15
|
+
template: ` <ng-content> </ng-content>
|
|
16
|
+
<c3-input-file-displayer
|
|
17
|
+
*ngIf="c3InputFile"
|
|
18
|
+
[c3InputFile]="c3InputFile"
|
|
19
|
+
[autoclose]="autoclose"
|
|
20
|
+
></c3-input-file-displayer>`,
|
|
21
|
+
styles: [],
|
|
22
|
+
encapsulation: ViewEncapsulation.None,
|
|
23
|
+
host: {
|
|
24
|
+
class: 'c3-input-file-container',
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
export class C3InputFileContainerComponent implements OnDestroy {
|
|
28
|
+
@Input() autoclose?: boolean | number;
|
|
29
|
+
|
|
30
|
+
@ContentChild(C3InputFileComponent) c3InputFile?: C3InputFileComponent;
|
|
31
|
+
|
|
32
|
+
@ContentChild(C3InputFileTriggerComponent)
|
|
33
|
+
c3Trigger?: C3InputFileTriggerComponent;
|
|
34
|
+
|
|
35
|
+
@ContentChild(C3InputFileTriggerDirective)
|
|
36
|
+
c3TriggerDirective?: C3InputFileTriggerDirective;
|
|
37
|
+
|
|
38
|
+
ngAfterViewInit() {
|
|
39
|
+
if (this.c3Trigger)
|
|
40
|
+
this.c3Trigger.clicked.subscribe(($event) => {
|
|
41
|
+
this.c3InputFile?.click();
|
|
42
|
+
});
|
|
43
|
+
else if (this.c3TriggerDirective)
|
|
44
|
+
this.c3TriggerDirective.click.subscribe(($event) => {
|
|
45
|
+
this.c3InputFile?.click();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
ngOnDestroy() {
|
|
50
|
+
if (this.c3Trigger) this.c3Trigger.clicked.unsubscribe();
|
|
51
|
+
if (this.c3TriggerDirective) this.c3TriggerDirective.click.unsubscribe();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
OnInit,
|
|
4
|
+
ViewEncapsulation,
|
|
5
|
+
Input,
|
|
6
|
+
AfterContentInit,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { C3InputFile } from '../../class/c3-input-file';
|
|
9
|
+
import { C3InputFileComponent } from '../c3-input-file/c3-input-file.component';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'c3-input-file-displayer',
|
|
13
|
+
template: `
|
|
14
|
+
<ng-container *ngIf="files.length">
|
|
15
|
+
<div class="c3-input-file-displayer mat-card">
|
|
16
|
+
<div
|
|
17
|
+
class="title-bar mat-elevation-z4"
|
|
18
|
+
fxLayout="row"
|
|
19
|
+
fxLayoutAlign="space-between center"
|
|
20
|
+
>
|
|
21
|
+
<span>Liste des téléversement</span>
|
|
22
|
+
<div>
|
|
23
|
+
<button mat-icon-button (click)="toggleMinimize()">
|
|
24
|
+
<mat-icon *ngIf="minimized">open_in_full</mat-icon>
|
|
25
|
+
<mat-icon *ngIf="!minimized">close_fullscreen</mat-icon>
|
|
26
|
+
</button>
|
|
27
|
+
<button mat-icon-button [disabled]="!closable" (click)="close()">
|
|
28
|
+
<mat-icon>close</mat-icon>
|
|
29
|
+
</button>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="container-list" *ngIf="!minimized">
|
|
33
|
+
<div class="item" *ngFor="let item of files">
|
|
34
|
+
<div class="title">{{ item.fileName }}</div>
|
|
35
|
+
<div
|
|
36
|
+
fxLayout="row"
|
|
37
|
+
fxLayoutAlign="space-around center"
|
|
38
|
+
fxLayoutGap="4px"
|
|
39
|
+
>
|
|
40
|
+
<mat-progress-bar
|
|
41
|
+
fxFlex
|
|
42
|
+
[color]="item.aborded ? 'warn' : 'primary'"
|
|
43
|
+
[mode]="item.aborded ? 'determinate' : 'buffer'"
|
|
44
|
+
[value]="item.progression"
|
|
45
|
+
[bufferValue]="0"
|
|
46
|
+
>
|
|
47
|
+
</mat-progress-bar>
|
|
48
|
+
|
|
49
|
+
<button
|
|
50
|
+
mat-icon-button
|
|
51
|
+
[disabled]="item.aborded || item.loaded"
|
|
52
|
+
(click)="item.abord()"
|
|
53
|
+
>
|
|
54
|
+
<mat-icon>cancel</mat-icon>
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</ng-container>
|
|
61
|
+
`,
|
|
62
|
+
styles: [],
|
|
63
|
+
encapsulation: ViewEncapsulation.None,
|
|
64
|
+
})
|
|
65
|
+
export class C3InputFileDisplayerComponent implements AfterContentInit {
|
|
66
|
+
@Input() c3InputFile!: C3InputFileComponent;
|
|
67
|
+
files: Array<C3InputFile> = [];
|
|
68
|
+
@Input() autoclose?: boolean | number;
|
|
69
|
+
|
|
70
|
+
minimized: boolean = false;
|
|
71
|
+
|
|
72
|
+
get closable() {
|
|
73
|
+
return this.files.every(({ loaded, aborded }) => loaded || aborded);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
constructor() {}
|
|
77
|
+
|
|
78
|
+
ngAfterContentInit(): void {
|
|
79
|
+
this.c3InputFile.fileAdded.subscribe(
|
|
80
|
+
(newFile: C3InputFile) => {
|
|
81
|
+
this.files.push(newFile);
|
|
82
|
+
if (this.autoclose)
|
|
83
|
+
if (newFile.loaded) this._autoclose();
|
|
84
|
+
else newFile.on('loaded', () => this._autoclose());
|
|
85
|
+
},
|
|
86
|
+
console.error,
|
|
87
|
+
() => {
|
|
88
|
+
console.log('completed');
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
toggleMinimize() {
|
|
94
|
+
this.minimized = !this.minimized;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
_autoclose() {
|
|
98
|
+
if (this.closable)
|
|
99
|
+
if (typeof this.autoclose === 'number')
|
|
100
|
+
setTimeout(() => this.close(), 1000 * this.autoclose);
|
|
101
|
+
else this.close();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
close() {
|
|
105
|
+
this.files = [];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
ViewEncapsulation,
|
|
4
|
+
Output,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'c3-input-file-trigger',
|
|
10
|
+
template: `
|
|
11
|
+
<button (click)="click($event)">Ajouter des fichiers....</button>
|
|
12
|
+
`,
|
|
13
|
+
styles: [],
|
|
14
|
+
encapsulation: ViewEncapsulation.None,
|
|
15
|
+
})
|
|
16
|
+
export class C3InputFileTriggerComponent {
|
|
17
|
+
@Output('click') clicked: EventEmitter<MouseEvent> = new EventEmitter();
|
|
18
|
+
|
|
19
|
+
click($event: MouseEvent) {
|
|
20
|
+
this.clicked.emit($event);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Directive,
|
|
3
|
+
Output,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
ElementRef,
|
|
6
|
+
AfterViewInit,
|
|
7
|
+
OnDestroy,
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
|
|
10
|
+
@Directive({
|
|
11
|
+
selector: '[c3InputFileTrigger], [c3-input-file-trigger]',
|
|
12
|
+
})
|
|
13
|
+
export class C3InputFileTriggerDirective implements AfterViewInit, OnDestroy {
|
|
14
|
+
@Output() click: EventEmitter<MouseEvent> = new EventEmitter();
|
|
15
|
+
constructor(private elementRef: ElementRef) {}
|
|
16
|
+
|
|
17
|
+
ngAfterViewInit() {
|
|
18
|
+
this.elementRef.nativeElement.addEventListener(
|
|
19
|
+
'click',
|
|
20
|
+
($event: MouseEvent) => this.click.emit($event)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
ngOnDestroy() {
|
|
25
|
+
this.elementRef.nativeElement.removeEventListener('click', () => {});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { FullScreenDirective } from './directives/full-screen.directive';
|
|
3
|
+
import { C3FileViewerComponent } from './components/public/c3-file-viewer/c3-file-viewer.component';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { C3FileViewerActionsComponent } from './components/c3-file-viewer-actions/c3-file-viewer-actions.component';
|
|
6
|
+
import { C3FileViewerImageComponent } from './components/c3-file-viewer-image/c3-file-viewer-image.component';
|
|
7
|
+
import { C3FileViewerPdfComponent } from './components/c3-file-viewer-pdf/c3-file-viewer-pdf.component';
|
|
8
|
+
import { C3FileViewerVideoComponent } from './components/c3-file-viewer-video/c3-file-viewer-video.component';
|
|
9
|
+
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
|
|
10
|
+
import { C3SafeUrlPipe } from '../../public-api';
|
|
11
|
+
import { C3FileViewerDialogComponent } from './components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component';
|
|
12
|
+
import { MatDialogModule } from '@angular/material/dialog';
|
|
13
|
+
import { C3FileViewerDialog } from './components/public/c3-file-viewer-dialog/c3-file-viewer-dialog';
|
|
14
|
+
|
|
15
|
+
@NgModule({ declarations: [
|
|
16
|
+
FullScreenDirective,
|
|
17
|
+
C3FileViewerComponent,
|
|
18
|
+
C3FileViewerActionsComponent,
|
|
19
|
+
C3FileViewerImageComponent,
|
|
20
|
+
C3FileViewerPdfComponent,
|
|
21
|
+
C3FileViewerVideoComponent,
|
|
22
|
+
C3FileViewerDialogComponent,
|
|
23
|
+
C3FileViewerDialog,
|
|
24
|
+
],
|
|
25
|
+
exports: [
|
|
26
|
+
FullScreenDirective,
|
|
27
|
+
C3FileViewerComponent,
|
|
28
|
+
C3FileViewerDialogComponent,
|
|
29
|
+
], imports: [CommonModule, C3SafeUrlPipe, MatDialogModule], providers: [provideHttpClient(withInterceptorsFromDi())] })
|
|
30
|
+
export class C3FileViewerModule {}
|