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.
Files changed (141) hide show
  1. package/esm2022/c3-components.mjs +5 -0
  2. package/esm2022/lib/c3-auto-animate/C3AutoAnimate.directive.mjs +23 -0
  3. package/esm2022/lib/c3-dialog/c3-dialog.module.mjs +52 -0
  4. package/esm2022/lib/c3-dialog/components/c3-dialog-confirm.component.mjs +51 -0
  5. package/esm2022/lib/c3-dialog/components/c3-dialog-embed-child.component.mjs +32 -0
  6. package/esm2022/lib/c3-dialog/components/c3-dialog-prompt.component.mjs +95 -0
  7. package/esm2022/lib/c3-dialog/services/c3-dialog.service.mjs +77 -0
  8. package/esm2022/lib/c3-dropdown/c3-dropdown.module.mjs +20 -0
  9. package/esm2022/lib/c3-dropdown/components/c3-dropdown.component.mjs +45 -0
  10. package/esm2022/lib/c3-dropdown/directives/c3-dropdown.trigger.mjs +128 -0
  11. package/esm2022/lib/c3-expansion/c3-expansion.module.mjs +43 -0
  12. package/esm2022/lib/c3-expansion/components/c3-expansion/c3-expansion.component.mjs +34 -0
  13. package/esm2022/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.mjs +24 -0
  14. package/esm2022/lib/c3-file-viewer/c3-file-viewer.module.mjs +47 -0
  15. package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.mjs +17 -0
  16. package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.mjs +20 -0
  17. package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.mjs +23 -0
  18. package/esm2022/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.mjs +32 -0
  19. package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.mjs +86 -0
  20. package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.mjs +40 -0
  21. package/esm2022/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.mjs +26 -0
  22. package/esm2022/lib/c3-file-viewer/consts/default.config.mjs +40 -0
  23. package/esm2022/lib/c3-file-viewer/directives/full-screen.directive.mjs +66 -0
  24. package/esm2022/lib/c3-file-viewer/models/custom-file-event.model.mjs +7 -0
  25. package/esm2022/lib/c3-file-viewer/models/file-metadata.mjs +2 -0
  26. package/esm2022/lib/c3-file-viewer/models/file-viewer-config.model.mjs +2 -0
  27. package/esm2022/lib/c3-file-viewer/models/file-viewer.mjs +206 -0
  28. package/esm2022/lib/c3-file-viewer/models/http.client.mjs +2 -0
  29. package/esm2022/lib/c3-safe-url/pipes/c3-safe-url.pipe.mjs +21 -0
  30. package/esm2022/public-api.mjs +45 -0
  31. package/fesm2022/c3-components.mjs +1160 -0
  32. package/fesm2022/c3-components.mjs.map +1 -0
  33. package/index.d.ts +5 -0
  34. package/lib/c3-auto-animate/C3AutoAnimate.directive.d.ts +11 -0
  35. package/lib/c3-dialog/c3-dialog.module.d.ts +15 -0
  36. package/lib/c3-dialog/components/c3-dialog-confirm.component.d.ts +23 -0
  37. package/lib/c3-dialog/components/c3-dialog-embed-child.component.d.ts +18 -0
  38. package/lib/c3-dialog/components/c3-dialog-prompt.component.d.ts +31 -0
  39. package/lib/c3-dialog/services/c3-dialog.service.d.ts +18 -0
  40. package/lib/c3-dropdown/c3-dropdown.module.d.ts +10 -0
  41. package/lib/c3-dropdown/components/c3-dropdown.component.d.ts +15 -0
  42. package/lib/c3-dropdown/directives/c3-dropdown.trigger.d.ts +45 -0
  43. package/lib/c3-expansion/c3-expansion.module.d.ts +14 -0
  44. package/lib/c3-expansion/components/c3-expansion/c3-expansion.component.d.ts +13 -0
  45. package/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.d.ts +9 -0
  46. package/lib/c3-file-viewer/c3-file-viewer.module.d.ts +17 -0
  47. package/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.d.ts +8 -0
  48. package/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.d.ts +9 -0
  49. package/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.d.ts +9 -0
  50. package/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.d.ts +12 -0
  51. package/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.d.ts +25 -0
  52. package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.d.ts +12 -0
  53. package/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.d.ts +8 -0
  54. package/lib/c3-file-viewer/consts/default.config.d.ts +2 -0
  55. package/lib/c3-file-viewer/directives/full-screen.directive.d.ts +12 -0
  56. package/lib/c3-file-viewer/models/custom-file-event.model.d.ts +5 -0
  57. package/lib/c3-file-viewer/models/file-metadata.d.ts +12 -0
  58. package/lib/c3-file-viewer/models/file-viewer-config.model.d.ts +48 -0
  59. package/lib/c3-file-viewer/models/file-viewer.d.ts +65 -0
  60. package/lib/c3-file-viewer/models/http.client.d.ts +14 -0
  61. package/lib/c3-safe-url/pipes/c3-safe-url.pipe.d.ts +10 -0
  62. package/package.json +13 -4
  63. package/{src/public-api.ts → public-api.d.ts} +0 -10
  64. package/CONTRIBUTING.md +0 -80
  65. package/bun.lockb +0 -0
  66. package/ng-package.json +0 -19
  67. package/src/lib/c3-auto-animate/C3AutoAnimate.directive.ts +0 -18
  68. package/src/lib/c3-dialog/c3-dialog.module.ts +0 -30
  69. package/src/lib/c3-dialog/components/c3-dialog-confirm.component.ts +0 -44
  70. package/src/lib/c3-dialog/components/c3-dialog-embed-child.component.ts +0 -40
  71. package/src/lib/c3-dialog/components/c3-dialog-prompt.component.ts +0 -81
  72. package/src/lib/c3-dialog/services/c3-dialog.service.ts +0 -87
  73. package/src/lib/c3-dropdown/c3-dropdown.module.ts +0 -12
  74. package/src/lib/c3-dropdown/components/c3-dropdown.component.spec.ts +0 -22
  75. package/src/lib/c3-dropdown/components/c3-dropdown.component.ts +0 -39
  76. package/src/lib/c3-dropdown/directives/c3-dropdown.trigger.ts +0 -161
  77. package/src/lib/c3-expansion/c3-expansion.module.ts +0 -24
  78. package/src/lib/c3-expansion/components/c3-expansion/c3-expansion.component.html +0 -9
  79. package/src/lib/c3-expansion/components/c3-expansion/c3-expansion.component.ts +0 -33
  80. package/src/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.html +0 -12
  81. package/src/lib/c3-expansion/components/c3-expansion-header/c3-expansion-header.component.ts +0 -21
  82. package/src/lib/c3-file/c3-download/c3-download.module.ts +0 -7
  83. package/src/lib/c3-file/c3-download/c3-download.service.ts +0 -16
  84. package/src/lib/c3-file/c3-input-file/c3-input-file.module.ts +0 -30
  85. package/src/lib/c3-file/c3-input-file/class/c3-input-file.ts +0 -62
  86. package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.html +0 -7
  87. package/src/lib/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.ts +0 -96
  88. package/src/lib/c3-file/c3-input-file/components/c3-input-file-container/c3-input-file-container.component.ts +0 -53
  89. package/src/lib/c3-file/c3-input-file/components/c3-input-file-displayer/c3-input-file-displayer.component.ts +0 -107
  90. package/src/lib/c3-file/c3-input-file/components/c3-input-file-trigger/c3-input-file-trigger.component.ts +0 -22
  91. package/src/lib/c3-file/c3-input-file/directives/c3-input-file-trigger.directive.ts +0 -27
  92. package/src/lib/c3-file-upload/c3-file-upload.module.ts +0 -8
  93. package/src/lib/c3-file-viewer/c3-file-viewer.module.ts +0 -30
  94. package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.html +0 -185
  95. package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.spec.ts +0 -23
  96. package/src/lib/c3-file-viewer/components/c3-file-viewer-actions/c3-file-viewer-actions.component.ts +0 -15
  97. package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.html +0 -7
  98. package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.spec.ts +0 -23
  99. package/src/lib/c3-file-viewer/components/c3-file-viewer-image/c3-file-viewer-image.component.ts +0 -14
  100. package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.html +0 -7
  101. package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.spec.ts +0 -23
  102. package/src/lib/c3-file-viewer/components/c3-file-viewer-pdf/c3-file-viewer-pdf.component.ts +0 -25
  103. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.css +0 -0
  104. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.html +0 -1
  105. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.spec.ts +0 -23
  106. package/src/lib/c3-file-viewer/components/c3-file-viewer-video/c3-file-viewer-video.component.ts +0 -35
  107. package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.html +0 -32
  108. package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.spec.ts +0 -23
  109. package/src/lib/c3-file-viewer/components/public/c3-file-viewer/c3-file-viewer.component.ts +0 -93
  110. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.spec.ts +0 -23
  111. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.component.ts +0 -37
  112. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.spec.ts +0 -22
  113. package/src/lib/c3-file-viewer/components/public/c3-file-viewer-dialog/c3-file-viewer-dialog.ts +0 -12
  114. package/src/lib/c3-file-viewer/consts/default.config.ts +0 -41
  115. package/src/lib/c3-file-viewer/directives/full-screen.directive.spec.ts +0 -11
  116. package/src/lib/c3-file-viewer/directives/full-screen.directive.ts +0 -68
  117. package/src/lib/c3-file-viewer/models/custom-file-event.model.ts +0 -9
  118. package/src/lib/c3-file-viewer/models/file-metadata.ts +0 -13
  119. package/src/lib/c3-file-viewer/models/file-viewer-config.model.ts +0 -53
  120. package/src/lib/c3-file-viewer/models/file-viewer.ts +0 -259
  121. package/src/lib/c3-file-viewer/models/http.client.ts +0 -23
  122. package/src/lib/c3-highlight-text/c3-highlight-text.module.ts +0 -12
  123. package/src/lib/c3-menu/c3-menu.module.ts +0 -12
  124. package/src/lib/c3-modal/c3-modal.module.ts +0 -12
  125. package/src/lib/c3-navbar/c3-navbar.module.ts +0 -12
  126. package/src/lib/c3-pdf-dialog/c3-pdf-dialog.module.ts +0 -12
  127. package/src/lib/c3-rounded-title/c3-rounded-title.module.ts +0 -12
  128. package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.spec.ts +0 -8
  129. package/src/lib/c3-safe-url/pipes/c3-safe-url.pipe.ts +0 -13
  130. package/src/lib/c3-tabs/c3-tabs.module.ts +0 -12
  131. package/tsconfig.lib.json +0 -14
  132. package/tsconfig.lib.prod.json +0 -10
  133. package/tsconfig.spec.json +0 -14
  134. /package/{src/_index.scss → _index.scss} +0 -0
  135. /package/{src/lib → lib}/c3-dropdown/styles/_c3-dropdown.sass +0 -0
  136. /package/{src/lib → lib}/c3-expansion/styles/_c3-expansion.scss +0 -0
  137. /package/{src/lib → lib}/c3-file/c3-input-file/components/c3-input-file/c3-input-file.component.scss +0 -0
  138. /package/{src/lib → lib}/c3-file-viewer/styles/_c3-file-viewer.sass +0 -0
  139. /package/{src/lib → lib}/c3-styles/_c3-core.sass +0 -0
  140. /package/{src/lib → lib}/c3-styles/_c3-root-variables.sass +0 -0
  141. /package/{src/lib → lib}/c3-styles/_utils.sass +0 -0
@@ -1,39 +0,0 @@
1
- import {
2
- ChangeDetectorRef,
3
- Component,
4
- TemplateRef,
5
- ViewChild,
6
- Input,
7
- OnChanges,
8
- SimpleChanges,
9
- } from '@angular/core';
10
-
11
- @Component({
12
- selector: 'c3-dropdown',
13
- template: `
14
- <ng-template>
15
- <div class="c3-dropdown-panel" [ngClass]="dropdownClass">
16
- <ng-content></ng-content>
17
- </div>
18
- </ng-template>
19
- `,
20
- })
21
- export class C3DropdownComponent implements OnChanges {
22
- @ViewChild(TemplateRef) template!: TemplateRef<any>;
23
-
24
- /** Classes to be added to the container of the content. Supports the same syntax as `ngClass`. */
25
- @Input()
26
- dropdownClass: string | string[] | Set<string> | { [key: string]: any } = '';
27
-
28
- constructor(private _changeDetectorRef: ChangeDetectorRef) {}
29
-
30
- ngOnChanges(changes: SimpleChanges) {
31
- if (changes['dropdownClass']) {
32
- this._markForCheck();
33
- }
34
- }
35
-
36
- _markForCheck(): void {
37
- this._changeDetectorRef.markForCheck();
38
- }
39
- }
@@ -1,161 +0,0 @@
1
- import {
2
- Directive,
3
- forwardRef,
4
- ElementRef,
5
- ViewContainerRef,
6
- Input,
7
- OnDestroy,
8
- HostListener,
9
- OnChanges,
10
- SimpleChanges,
11
- } from '@angular/core';
12
- import { NG_VALUE_ACCESSOR } from '@angular/forms';
13
- import {
14
- Overlay,
15
- OverlayRef,
16
- OverlayConfig,
17
- ConnectedPosition,
18
- } from '@angular/cdk/overlay';
19
- import { C3DropdownComponent } from '../components/c3-dropdown.component';
20
- import { coerceBooleanProperty } from '@angular/cdk/coercion';
21
- import { TemplatePortal } from '@angular/cdk/portal';
22
- import { merge, Subject, Subscription, takeUntil } from 'rxjs';
23
-
24
- export const MAT_DROPDOWN_VALUE_ACCESSOR: any = {
25
- provide: NG_VALUE_ACCESSOR,
26
- useExisting: forwardRef(() => C3DropdownTrigger),
27
- multi: true,
28
- };
29
-
30
- /**
31
- * @description The C3DropdownTrigger directive is used to display or hide a dropdown menu
32
- * C3DropdownComponent when an item is clicked.
33
- * @selector [c3Dropdown]
34
- * @exportAs c3DropdownTrigger
35
- * @input c3Dropdown - A reference to an instance of C3DropdownComponent.
36
- * @input c3DropdownDisabled - A boolean indicating whether the directive should be disabled.
37
- * @input c3DropdownClass - A string, an array of strings, a set of strings or a
38
- * object representing the CSS classes to be applied to the dropdown menu.
39
- */
40
- @Directive({
41
- selector: '[c3Dropdown]',
42
- exportAs: 'c3DropdownTrigger',
43
- providers: [MAT_DROPDOWN_VALUE_ACCESSOR],
44
- })
45
- export class C3DropdownTrigger implements OnChanges, OnDestroy {
46
- private overlayRef?: OverlayRef | null;
47
- private _closingActionsSubscription: Subscription = Subscription.EMPTY;
48
- private _destroyed = new Subject<void>();
49
-
50
- private _dropdownClass:
51
- | string
52
- | string[]
53
- | Set<string>
54
- | { [key: string]: any } = '';
55
-
56
- private _dropdownDisabled: boolean = false;
57
-
58
- /** The dropdown menu instance */
59
- @Input('c3Dropdown')
60
- dropdown?: C3DropdownComponent;
61
-
62
- /** Whether the dropdown is disabled. */
63
- @Input('c3DropdownDisabled')
64
- get dropdownDisabled(): boolean {
65
- return this._dropdownDisabled;
66
- }
67
- set dropdownDisabled(value: boolean) {
68
- this._dropdownDisabled = coerceBooleanProperty(value);
69
- }
70
-
71
- /** Classes to be passed to the dropdown menu. Supports the same syntax as `ngClass`. */
72
- @Input('c3DropdownClass')
73
- dropdownClass: string | string[] | Set<string> | { [key: string]: any } = '';
74
-
75
- constructor(
76
- private _element: ElementRef<HTMLElement>,
77
- private _overlay: Overlay,
78
- private _viewContainerRef: ViewContainerRef
79
- ) {}
80
-
81
- @HostListener('click')
82
- onClick() {
83
- this.show();
84
- }
85
-
86
- ngOnChanges(changes: SimpleChanges) {
87
- if (changes['dropdownClass'] && this.dropdown) {
88
- this.dropdown.dropdownClass = this._dropdownClass;
89
- this.dropdown._markForCheck();
90
- }
91
- }
92
-
93
- ngOnDestroy() {
94
- this._destroyed.next();
95
- this._destroyed.complete();
96
- this._closingActionsSubscription.unsubscribe();
97
- this.close();
98
- }
99
-
100
- public show(): void {
101
- if (!this.dropdown) return;
102
-
103
- const overlayRef = this._overlay.create(this._getOverlayConfig());
104
- const portal = new TemplatePortal(
105
- this.dropdown.template,
106
- this._viewContainerRef
107
- );
108
- overlayRef.attach(portal);
109
-
110
- this.overlayRef = overlayRef;
111
-
112
- this._closingActionsSubscription = this._menuClosingActions().subscribe(
113
- () => this.close()
114
- );
115
- }
116
-
117
- public close(): void {
118
- if (this.overlayRef && this.overlayRef.hasAttached())
119
- this.overlayRef.detach();
120
- }
121
-
122
- private _getOverlayConfig(): OverlayConfig {
123
- const belowPosition: ConnectedPosition = {
124
- originX: 'start',
125
- originY: 'bottom',
126
- overlayX: 'start',
127
- overlayY: 'top',
128
- };
129
- const abovePosition: ConnectedPosition = {
130
- originX: 'start',
131
- originY: 'top',
132
- overlayX: 'start',
133
- overlayY: 'bottom',
134
-
135
- // The overlay edge connected to the trigger should have squared corners, while
136
- // the opposite end has rounded corners. We apply a CSS class to swap the
137
- // border-radius based on the overlay position.
138
- panelClass: 'mat-autocomplete-panel-above',
139
- };
140
-
141
- const positionStrategy = this._overlay
142
- .position()
143
- .flexibleConnectedTo(this._element)
144
- .withLockedPosition()
145
- .withPositions([belowPosition, abovePosition]);
146
-
147
- return new OverlayConfig({
148
- positionStrategy,
149
- backdropClass: 'cdk-overlay-transparent-backdrop',
150
- hasBackdrop: true,
151
- });
152
- }
153
-
154
- /** Returns a stream that emits whenever an action that should close the menu occurs. */
155
- private _menuClosingActions() {
156
- const backdrop = this.overlayRef!.backdropClick();
157
- const detachments = this.overlayRef!.detachments();
158
-
159
- return merge(backdrop, detachments).pipe(takeUntil(this._destroyed));
160
- }
161
- }
@@ -1,24 +0,0 @@
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 {}
@@ -1,9 +0,0 @@
1
- <div [class]="' mat-toolbar mat-elevation-z4 ' + headerClass()">
2
- <ng-content select="c3-expansion-header">
3
- <c3-expansion-header [c3Expansion]="this" />
4
- </ng-content>
5
- </div>
6
-
7
- <div *ngIf="isExpanded()">
8
- <ng-content></ng-content>
9
- </div>
@@ -1,33 +0,0 @@
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
- }
@@ -1,12 +0,0 @@
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>
@@ -1,21 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
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 {}
@@ -1,16 +0,0 @@
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
- }
@@ -1,30 +0,0 @@
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 {}
@@ -1,62 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
1
- <input
2
- type="file"
3
- #fileInput
4
- [accept]="accept"
5
- [multiple]="multiple"
6
- (change)="change($event)"
7
- />
@@ -1,96 +0,0 @@
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
- }
@@ -1,53 +0,0 @@
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
- }
@@ -1,107 +0,0 @@
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
- }