@uppy/angular 0.9.0 → 0.9.1
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/.eslintrc.json +46 -0
- package/CHANGELOG.md +6 -0
- package/ng-package.json +7 -0
- package/package.json +1 -4
- package/src/lib/components/dashboard/dashboard-demo.component.ts +17 -0
- package/src/lib/components/dashboard/dashboard.component.spec.ts +24 -0
- package/src/lib/components/dashboard/dashboard.component.ts +53 -0
- package/src/lib/components/dashboard/dashboard.stories.ts +15 -0
- package/src/lib/components/dashboard-modal/dashboard-modal-demo.component.ts +21 -0
- package/src/lib/components/dashboard-modal/dashboard-modal.component.spec.ts +24 -0
- package/src/lib/components/dashboard-modal/dashboard-modal.component.ts +67 -0
- package/src/lib/components/dashboard-modal/dashboard-modal.stories.ts +15 -0
- package/src/lib/components/drag-drop/drag-drop-demo.component.ts +18 -0
- package/src/lib/components/drag-drop/drag-drop.component.spec.ts +24 -0
- package/src/lib/components/drag-drop/drag-drop.component.ts +53 -0
- package/src/lib/components/drag-drop/drag-drop.stories.ts +15 -0
- package/src/lib/components/progress-bar/progress-bar-demo.component.ts +105 -0
- package/src/lib/components/progress-bar/progress-bar.component.spec.ts +24 -0
- package/src/lib/components/progress-bar/progress-bar.component.ts +53 -0
- package/src/lib/components/progress-bar/progress-bar.stories.ts +17 -0
- package/src/lib/components/status-bar/status-bar-demo.component.ts +33 -0
- package/src/lib/components/status-bar/status-bar.component.spec.ts +24 -0
- package/src/lib/components/status-bar/status-bar.component.ts +53 -0
- package/src/lib/components/status-bar/status-bar.stories.ts +15 -0
- package/src/lib/utils/wrapper.ts +58 -0
- package/src/public-api.ts +9 -0
- package/tsconfig.lib.json +12 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +9 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../.eslintrc.json",
|
|
3
|
+
"ignorePatterns": ["!**/*"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts"],
|
|
7
|
+
"parserOptions": {
|
|
8
|
+
"project": [
|
|
9
|
+
"packages/@uppy/angular/projects/angular/tsconfig.lib.json",
|
|
10
|
+
"packages/@uppy/angular/projects/angular/tsconfig.spec.json"
|
|
11
|
+
],
|
|
12
|
+
"createDefaultProgram": true
|
|
13
|
+
},
|
|
14
|
+
"rules": {
|
|
15
|
+
"@angular-eslint/component-selector": [
|
|
16
|
+
"error",
|
|
17
|
+
{
|
|
18
|
+
"type": "element",
|
|
19
|
+
"prefix": "uppy",
|
|
20
|
+
"style": "kebab-case"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"@angular-eslint/directive-selector": [
|
|
24
|
+
"error",
|
|
25
|
+
{
|
|
26
|
+
"type": "attribute",
|
|
27
|
+
"prefix": "uppy",
|
|
28
|
+
"style": "camelCase"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"dot-notation": "error",
|
|
32
|
+
"indent": "error",
|
|
33
|
+
"no-empty-function": "off",
|
|
34
|
+
"no-shadow": "error",
|
|
35
|
+
"no-unused-expressions": "error",
|
|
36
|
+
"no-use-before-define": "off",
|
|
37
|
+
"quotes": "error",
|
|
38
|
+
"semi": "error"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"files": ["*.html"],
|
|
43
|
+
"rules": {}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
package/CHANGELOG.md
CHANGED
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uppy/angular",
|
|
3
3
|
"description": "Angular component wrappers around Uppy's official UI plugins.",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://uppy.io",
|
|
7
7
|
"keywords": [
|
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git+https://github.com/transloadit/uppy.git"
|
|
20
20
|
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
24
21
|
"scripts": {
|
|
25
22
|
"prepublishOnly": "rm -fr * && cp -r ../../../dist/uppy/angular .."
|
|
26
23
|
},
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
2
|
+
import { Uppy } from "@uppy/core";
|
|
3
|
+
import type * as Dashboard from "@uppy/dashboard";
|
|
4
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
5
|
+
import { DashboardComponent } from "./dashboard.component";
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: "uppy-dashboard-demo",
|
|
9
|
+
template: `<uppy-dashboard [uppy]="uppy" [props]="props"></uppy-dashboard>`,
|
|
10
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
11
|
+
standalone: true,
|
|
12
|
+
imports: [DashboardComponent],
|
|
13
|
+
})
|
|
14
|
+
export class DashboardDemoComponent<M extends Meta, B extends Body> {
|
|
15
|
+
uppy: Uppy<M, B> = new Uppy({ debug: true, autoProceed: true });
|
|
16
|
+
props: Dashboard.DashboardOptions<M, B> = {};
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { async, type ComponentFixture, TestBed } from "@angular/core/testing";
|
|
2
|
+
|
|
3
|
+
import { DashboardComponent } from "./dashboard.component";
|
|
4
|
+
|
|
5
|
+
describe("DashboardComponent", () => {
|
|
6
|
+
let component: DashboardComponent;
|
|
7
|
+
let fixture: ComponentFixture<DashboardComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [DashboardComponent],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
fixture = TestBed.createComponent(DashboardComponent);
|
|
17
|
+
component = fixture.componentInstance;
|
|
18
|
+
fixture.detectChanges();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should create", () => {
|
|
22
|
+
expect(component).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ElementRef,
|
|
5
|
+
Input,
|
|
6
|
+
inject,
|
|
7
|
+
type OnChanges,
|
|
8
|
+
type OnDestroy,
|
|
9
|
+
type SimpleChanges,
|
|
10
|
+
} from "@angular/core";
|
|
11
|
+
import { Uppy } from "@uppy/core";
|
|
12
|
+
import type { DashboardOptions } from "@uppy/dashboard";
|
|
13
|
+
import Dashboard from "@uppy/dashboard";
|
|
14
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
15
|
+
import { UppyAngularWrapper } from "../../utils/wrapper";
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: "uppy-dashboard",
|
|
19
|
+
template: "",
|
|
20
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
21
|
+
standalone: true,
|
|
22
|
+
})
|
|
23
|
+
export class DashboardComponent<M extends Meta, B extends Body>
|
|
24
|
+
extends UppyAngularWrapper<M, B, DashboardOptions<M, B>>
|
|
25
|
+
implements OnDestroy, OnChanges
|
|
26
|
+
{
|
|
27
|
+
el = inject(ElementRef);
|
|
28
|
+
|
|
29
|
+
@Input() uppy: Uppy<M, B> = new Uppy();
|
|
30
|
+
@Input() props: DashboardOptions<M, B> = {};
|
|
31
|
+
|
|
32
|
+
/** Inserted by Angular inject() migration for backwards compatibility */
|
|
33
|
+
constructor(...args: unknown[]);
|
|
34
|
+
|
|
35
|
+
constructor() {
|
|
36
|
+
super();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
ngOnInit() {
|
|
40
|
+
this.onMount(
|
|
41
|
+
{ id: "angular:Dashboard", inline: true, target: this.el.nativeElement },
|
|
42
|
+
Dashboard,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
47
|
+
this.handleChanges(changes, Dashboard);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ngOnDestroy(): void {
|
|
51
|
+
this.uninstall();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { moduleMetadata } from "@storybook/angular";
|
|
2
|
+
import { DashboardDemoComponent } from "./dashboard-demo.component";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "Dashboard",
|
|
6
|
+
decorators: [
|
|
7
|
+
moduleMetadata({
|
|
8
|
+
declarations: [DashboardDemoComponent],
|
|
9
|
+
}),
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Default = () => ({
|
|
14
|
+
component: DashboardDemoComponent,
|
|
15
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
2
|
+
import { Uppy } from "@uppy/core";
|
|
3
|
+
import type * as Dashboard from "@uppy/dashboard";
|
|
4
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
5
|
+
import { DashboardModalComponent } from "./dashboard-modal.component";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: "uppy-dashboard-demo",
|
|
10
|
+
template: `<uppy-dashboard-modal
|
|
11
|
+
[uppy]="uppy"
|
|
12
|
+
[props]="props"
|
|
13
|
+
></uppy-dashboard-modal>`,
|
|
14
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
15
|
+
standalone: true,
|
|
16
|
+
imports: [DashboardModalComponent],
|
|
17
|
+
})
|
|
18
|
+
export class DashboardModalDemoComponent<M extends Meta, B extends Body> {
|
|
19
|
+
uppy: Uppy<M, B> = new Uppy({ debug: true, autoProceed: true });
|
|
20
|
+
props: Dashboard.DashboardOptions<M, B> = {};
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { async, type ComponentFixture, TestBed } from "@angular/core/testing";
|
|
2
|
+
|
|
3
|
+
import { DashboardModalComponent } from "./dashboard-modal.component";
|
|
4
|
+
|
|
5
|
+
describe("DashboardComponent", () => {
|
|
6
|
+
let component: DashboardModalComponent;
|
|
7
|
+
let fixture: ComponentFixture<DashboardModalComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [DashboardModalComponent],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
fixture = TestBed.createComponent(DashboardModalComponent);
|
|
17
|
+
component = fixture.componentInstance;
|
|
18
|
+
fixture.detectChanges();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should create", () => {
|
|
22
|
+
expect(component).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ElementRef,
|
|
5
|
+
Input,
|
|
6
|
+
inject,
|
|
7
|
+
type OnChanges,
|
|
8
|
+
type OnDestroy,
|
|
9
|
+
type SimpleChanges,
|
|
10
|
+
} from "@angular/core";
|
|
11
|
+
import { Uppy } from "@uppy/core";
|
|
12
|
+
import type { DashboardOptions } from "@uppy/dashboard";
|
|
13
|
+
import Dashboard from "@uppy/dashboard";
|
|
14
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
15
|
+
import { UppyAngularWrapper } from "../../utils/wrapper";
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: "uppy-dashboard-modal",
|
|
19
|
+
template: "",
|
|
20
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
21
|
+
standalone: true,
|
|
22
|
+
})
|
|
23
|
+
export class DashboardModalComponent<M extends Meta, B extends Body>
|
|
24
|
+
extends UppyAngularWrapper<M, B, DashboardOptions<M, B>, Dashboard<M, B>>
|
|
25
|
+
implements OnDestroy, OnChanges
|
|
26
|
+
{
|
|
27
|
+
el = inject(ElementRef);
|
|
28
|
+
|
|
29
|
+
@Input() uppy: Uppy<M, B> = new Uppy();
|
|
30
|
+
@Input() props: DashboardOptions<M, B> = {};
|
|
31
|
+
@Input() open: boolean = false;
|
|
32
|
+
|
|
33
|
+
/** Inserted by Angular inject() migration for backwards compatibility */
|
|
34
|
+
constructor(...args: unknown[]);
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ngOnInit() {
|
|
41
|
+
this.onMount(
|
|
42
|
+
{
|
|
43
|
+
id: "angular:DashboardModal",
|
|
44
|
+
inline: false,
|
|
45
|
+
target: this.el.nativeElement,
|
|
46
|
+
},
|
|
47
|
+
Dashboard,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
52
|
+
this.handleChanges(changes, Dashboard);
|
|
53
|
+
// Handle dashboard-modal specific changes
|
|
54
|
+
if (changes["open"] && this.open !== changes["open"].previousValue) {
|
|
55
|
+
if (this.open && !changes["open"].previousValue) {
|
|
56
|
+
this.plugin!.openModal();
|
|
57
|
+
}
|
|
58
|
+
if (!this.open && changes["open"].previousValue) {
|
|
59
|
+
this.plugin!.closeModal();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ngOnDestroy(): void {
|
|
65
|
+
this.uninstall();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { moduleMetadata } from "@storybook/angular";
|
|
2
|
+
import { DashboardModalDemoComponent } from "./dashboard-modal-demo.component";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "Dashboard",
|
|
6
|
+
decorators: [
|
|
7
|
+
moduleMetadata({
|
|
8
|
+
declarations: [DashboardModalDemoComponent],
|
|
9
|
+
}),
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Default = () => ({
|
|
14
|
+
component: DashboardModalDemoComponent,
|
|
15
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
2
|
+
import { Uppy } from "@uppy/core";
|
|
3
|
+
import type * as DragDrop from "@uppy/drag-drop";
|
|
4
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
5
|
+
import { DragDropComponent } from "./drag-drop.component";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: "uppy-drag-drop-demo",
|
|
10
|
+
template: ` <uppy-drag-drop [uppy]="uppy" [props]="props"></uppy-drag-drop> `,
|
|
11
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
12
|
+
standalone: true,
|
|
13
|
+
imports: [DragDropComponent],
|
|
14
|
+
})
|
|
15
|
+
export class DragDropDemoComponent<M extends Meta, B extends Body> {
|
|
16
|
+
uppy: Uppy<M, B> = new Uppy({ debug: true, autoProceed: true });
|
|
17
|
+
props: DragDrop.DragDropOptions = {};
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { async, type ComponentFixture, TestBed } from "@angular/core/testing";
|
|
2
|
+
|
|
3
|
+
import { DragDropComponent } from "./drag-drop.component";
|
|
4
|
+
|
|
5
|
+
describe("DragDropComponent", () => {
|
|
6
|
+
let component: DragDropComponent;
|
|
7
|
+
let fixture: ComponentFixture<DragDropComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [DragDropComponent],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
fixture = TestBed.createComponent(DragDropComponent);
|
|
17
|
+
component = fixture.componentInstance;
|
|
18
|
+
fixture.detectChanges();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should create", () => {
|
|
22
|
+
expect(component).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ElementRef,
|
|
5
|
+
Input,
|
|
6
|
+
inject,
|
|
7
|
+
type OnChanges,
|
|
8
|
+
type OnDestroy,
|
|
9
|
+
type SimpleChanges,
|
|
10
|
+
} from "@angular/core";
|
|
11
|
+
import { Uppy } from "@uppy/core";
|
|
12
|
+
import type { DragDropOptions } from "@uppy/drag-drop";
|
|
13
|
+
import DragDrop from "@uppy/drag-drop";
|
|
14
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
15
|
+
import { UppyAngularWrapper } from "../../utils/wrapper";
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: "uppy-drag-drop",
|
|
19
|
+
template: "",
|
|
20
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
21
|
+
standalone: true,
|
|
22
|
+
})
|
|
23
|
+
export class DragDropComponent<M extends Meta, B extends Body>
|
|
24
|
+
extends UppyAngularWrapper<M, B, DragDropOptions>
|
|
25
|
+
implements OnDestroy, OnChanges
|
|
26
|
+
{
|
|
27
|
+
el = inject(ElementRef);
|
|
28
|
+
|
|
29
|
+
@Input() uppy: Uppy<M, B> = new Uppy();
|
|
30
|
+
@Input() props: DragDropOptions = {};
|
|
31
|
+
|
|
32
|
+
/** Inserted by Angular inject() migration for backwards compatibility */
|
|
33
|
+
constructor(...args: unknown[]);
|
|
34
|
+
|
|
35
|
+
constructor() {
|
|
36
|
+
super();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
ngOnInit() {
|
|
40
|
+
this.onMount(
|
|
41
|
+
{ id: "angular:DragDrop", target: this.el.nativeElement },
|
|
42
|
+
DragDrop,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
47
|
+
this.handleChanges(changes, DragDrop);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ngOnDestroy(): void {
|
|
51
|
+
this.uninstall();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { moduleMetadata } from "@storybook/angular";
|
|
2
|
+
import { DragDropDemoComponent } from "./drag-drop-demo.component";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "Drag Drop",
|
|
6
|
+
decorators: [
|
|
7
|
+
moduleMetadata({
|
|
8
|
+
declarations: [DragDropDemoComponent],
|
|
9
|
+
}),
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Default = () => ({
|
|
14
|
+
component: DragDropDemoComponent,
|
|
15
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
ChangeDetectorRef,
|
|
4
|
+
Component,
|
|
5
|
+
inject,
|
|
6
|
+
type OnInit,
|
|
7
|
+
} from "@angular/core";
|
|
8
|
+
import { Uppy } from "@uppy/core";
|
|
9
|
+
import type { ProgressBarOptions } from "@uppy/progress-bar";
|
|
10
|
+
import Tus from "@uppy/tus";
|
|
11
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
12
|
+
import { ProgressBarComponent } from "./progress-bar.component";
|
|
13
|
+
import { DragDropComponent } from "../drag-drop/drag-drop.component";
|
|
14
|
+
import { CommonModule } from "@angular/common";
|
|
15
|
+
|
|
16
|
+
@Component({
|
|
17
|
+
selector: "uppy-progress-bar-demo",
|
|
18
|
+
template: `
|
|
19
|
+
<section class="example-one">
|
|
20
|
+
<h5>autoProceed is on</h5>
|
|
21
|
+
|
|
22
|
+
<!-- Target DOM node #1 -->
|
|
23
|
+
<uppy-drag-drop [uppy]="uppyOne"></uppy-drag-drop>
|
|
24
|
+
|
|
25
|
+
<!-- Progress bar #1 -->
|
|
26
|
+
<uppy-progress-bar [uppy]="uppyOne" [props]="props"></uppy-progress-bar>
|
|
27
|
+
|
|
28
|
+
<!-- Uploaded files list #1 -->
|
|
29
|
+
<div class="uploaded-files" *ngIf="fileListOne?.length">
|
|
30
|
+
<h5>Uploaded files:</h5>
|
|
31
|
+
<ol>
|
|
32
|
+
<li *ngFor="let item of fileListOne">
|
|
33
|
+
<a [href]="item.url" target="_blank"> {{ item.fileName }}</a>
|
|
34
|
+
</li>
|
|
35
|
+
</ol>
|
|
36
|
+
</div>
|
|
37
|
+
</section>
|
|
38
|
+
|
|
39
|
+
<section class="example-two">
|
|
40
|
+
<h5>autoProceed is off</h5>
|
|
41
|
+
|
|
42
|
+
<!-- Target DOM node #1 -->
|
|
43
|
+
<uppy-drag-drop [uppy]="uppyTwo"></uppy-drag-drop>
|
|
44
|
+
|
|
45
|
+
<!-- Progress bar #1 -->
|
|
46
|
+
<uppy-progress-bar [uppy]="uppyTwo" [props]="props"></uppy-progress-bar>
|
|
47
|
+
|
|
48
|
+
<button (click)="upload()" class="upload-button">Upload</button>
|
|
49
|
+
|
|
50
|
+
<!-- Uploaded files list #2 -->
|
|
51
|
+
<div class="uploaded-files" *ngIf="fileListTwo?.length">
|
|
52
|
+
<h5>Uploaded files:</h5>
|
|
53
|
+
<ol>
|
|
54
|
+
<li *ngFor="let item of fileListTwo">
|
|
55
|
+
<a [href]="item.url" target="_blank"> {{ item.fileName }}</a>
|
|
56
|
+
</li>
|
|
57
|
+
</ol>
|
|
58
|
+
</div>
|
|
59
|
+
</section>
|
|
60
|
+
`,
|
|
61
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
62
|
+
standalone: true,
|
|
63
|
+
imports: [ProgressBarComponent, DragDropComponent, CommonModule],
|
|
64
|
+
})
|
|
65
|
+
export class ProgressBarDemoComponent<M extends Meta, B extends Body>
|
|
66
|
+
implements OnInit
|
|
67
|
+
{
|
|
68
|
+
private cdr = inject(ChangeDetectorRef);
|
|
69
|
+
|
|
70
|
+
uppyOne!: Uppy<M, B>;
|
|
71
|
+
uppyTwo!: Uppy<M, B>;
|
|
72
|
+
fileListOne: { url: string; fileName: string }[] = [];
|
|
73
|
+
fileListTwo: { url: string; fileName: string }[] = [];
|
|
74
|
+
props: ProgressBarOptions = {
|
|
75
|
+
hideAfterFinish: false,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
upload(): void {
|
|
79
|
+
this.uppyTwo.upload();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Inserted by Angular inject() migration for backwards compatibility */
|
|
83
|
+
constructor(...args: unknown[]);
|
|
84
|
+
|
|
85
|
+
constructor() {}
|
|
86
|
+
|
|
87
|
+
updateFileList =
|
|
88
|
+
(target: string) =>
|
|
89
|
+
(file: any, response: any): void => {
|
|
90
|
+
(this as any)[target] = [
|
|
91
|
+
...(this as any)[target],
|
|
92
|
+
{ url: response.uploadURL, fileName: file.name },
|
|
93
|
+
];
|
|
94
|
+
this.cdr.markForCheck();
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
ngOnInit(): void {
|
|
98
|
+
this.uppyOne = new Uppy<M, B>({ debug: true, autoProceed: true })
|
|
99
|
+
.use(Tus, { endpoint: "https://master.tus.io/files/" })
|
|
100
|
+
.on("upload-success", this.updateFileList("fileListOne"));
|
|
101
|
+
this.uppyTwo = new Uppy<M, B>({ debug: true, autoProceed: false })
|
|
102
|
+
.use(Tus, { endpoint: "https://master.tus.io/files/" })
|
|
103
|
+
.on("upload-success", this.updateFileList("fileListTwo"));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { async, type ComponentFixture, TestBed } from "@angular/core/testing";
|
|
2
|
+
|
|
3
|
+
import { ProgressBarComponent } from "./progress-bar.component";
|
|
4
|
+
|
|
5
|
+
describe("ProgressBarComponent", () => {
|
|
6
|
+
let component: ProgressBarComponent;
|
|
7
|
+
let fixture: ComponentFixture<ProgressBarComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ProgressBarComponent],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
fixture = TestBed.createComponent(ProgressBarComponent);
|
|
17
|
+
component = fixture.componentInstance;
|
|
18
|
+
fixture.detectChanges();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should create", () => {
|
|
22
|
+
expect(component).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ElementRef,
|
|
5
|
+
Input,
|
|
6
|
+
inject,
|
|
7
|
+
type OnChanges,
|
|
8
|
+
type OnDestroy,
|
|
9
|
+
type SimpleChanges,
|
|
10
|
+
} from "@angular/core";
|
|
11
|
+
import { Uppy } from "@uppy/core";
|
|
12
|
+
import type { ProgressBarOptions } from "@uppy/progress-bar";
|
|
13
|
+
import ProgressBar from "@uppy/progress-bar";
|
|
14
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
15
|
+
import { UppyAngularWrapper } from "../../utils/wrapper";
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: "uppy-progress-bar",
|
|
19
|
+
template: "",
|
|
20
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
21
|
+
standalone: true,
|
|
22
|
+
})
|
|
23
|
+
export class ProgressBarComponent<M extends Meta, B extends Body>
|
|
24
|
+
extends UppyAngularWrapper<M, B, ProgressBarOptions>
|
|
25
|
+
implements OnDestroy, OnChanges
|
|
26
|
+
{
|
|
27
|
+
el = inject(ElementRef);
|
|
28
|
+
|
|
29
|
+
@Input() uppy: Uppy<M, B> = new Uppy();
|
|
30
|
+
@Input() props: ProgressBarOptions = {};
|
|
31
|
+
|
|
32
|
+
/** Inserted by Angular inject() migration for backwards compatibility */
|
|
33
|
+
constructor(...args: unknown[]);
|
|
34
|
+
|
|
35
|
+
constructor() {
|
|
36
|
+
super();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
ngOnInit() {
|
|
40
|
+
this.onMount(
|
|
41
|
+
{ id: "angular:ProgressBar", target: this.el.nativeElement },
|
|
42
|
+
ProgressBar,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
47
|
+
this.handleChanges(changes, ProgressBar);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ngOnDestroy(): void {
|
|
51
|
+
this.uninstall();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CommonModule } from "@angular/common";
|
|
2
|
+
import { moduleMetadata } from "@storybook/angular";
|
|
3
|
+
import { ProgressBarDemoComponent } from "./progress-bar-demo.component";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Progress Bar",
|
|
7
|
+
decorators: [
|
|
8
|
+
moduleMetadata({
|
|
9
|
+
imports: [CommonModule],
|
|
10
|
+
declarations: [ProgressBarDemoComponent],
|
|
11
|
+
}),
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const Default = () => ({
|
|
16
|
+
component: ProgressBarDemoComponent,
|
|
17
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, type OnInit } from "@angular/core";
|
|
2
|
+
import { Uppy } from "@uppy/core";
|
|
3
|
+
import FileInput from "@uppy/file-input";
|
|
4
|
+
import type * as StatusBar from "@uppy/status-bar";
|
|
5
|
+
import Tus from "@uppy/tus";
|
|
6
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
7
|
+
import { StatusBarComponent } from "./status-bar.component";
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: "uppy-status-bar-demo",
|
|
11
|
+
template: `
|
|
12
|
+
<div class="UppyInput"></div>
|
|
13
|
+
<uppy-status-bar [uppy]="uppy" [props]="props"></uppy-status-bar>
|
|
14
|
+
`,
|
|
15
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
16
|
+
standalone: true,
|
|
17
|
+
imports: [StatusBarComponent],
|
|
18
|
+
})
|
|
19
|
+
export class StatusBarDemoComponent<M extends Meta, B extends Body>
|
|
20
|
+
implements OnInit
|
|
21
|
+
{
|
|
22
|
+
uppy: Uppy<M, B> = new Uppy({ debug: true, autoProceed: true });
|
|
23
|
+
props: StatusBar.StatusBarOptions = {
|
|
24
|
+
hideUploadButton: true,
|
|
25
|
+
hideAfterFinish: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
ngOnInit(): void {
|
|
29
|
+
this.uppy
|
|
30
|
+
.use(FileInput, { target: ".UppyInput", pretty: false })
|
|
31
|
+
.use(Tus, { endpoint: "https://master.tus.io/files/" });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { async, type ComponentFixture, TestBed } from "@angular/core/testing";
|
|
2
|
+
|
|
3
|
+
import { StatusBarComponent } from "./status-bar.component";
|
|
4
|
+
|
|
5
|
+
describe("StatusBarComponent", () => {
|
|
6
|
+
let component: StatusBarComponent;
|
|
7
|
+
let fixture: ComponentFixture<StatusBarComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [StatusBarComponent],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
fixture = TestBed.createComponent(StatusBarComponent);
|
|
17
|
+
component = fixture.componentInstance;
|
|
18
|
+
fixture.detectChanges();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should create", () => {
|
|
22
|
+
expect(component).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ElementRef,
|
|
5
|
+
Input,
|
|
6
|
+
inject,
|
|
7
|
+
type OnChanges,
|
|
8
|
+
type OnDestroy,
|
|
9
|
+
type SimpleChanges,
|
|
10
|
+
} from "@angular/core";
|
|
11
|
+
import { Uppy } from "@uppy/core";
|
|
12
|
+
import type { StatusBarOptions } from "@uppy/status-bar";
|
|
13
|
+
import StatusBar from "@uppy/status-bar";
|
|
14
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
15
|
+
import { UppyAngularWrapper } from "../../utils/wrapper";
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: "uppy-status-bar",
|
|
19
|
+
template: "",
|
|
20
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
21
|
+
standalone: true,
|
|
22
|
+
})
|
|
23
|
+
export class StatusBarComponent<M extends Meta, B extends Body>
|
|
24
|
+
extends UppyAngularWrapper<M, B, StatusBarOptions>
|
|
25
|
+
implements OnDestroy, OnChanges
|
|
26
|
+
{
|
|
27
|
+
el = inject(ElementRef);
|
|
28
|
+
|
|
29
|
+
@Input() uppy: Uppy<M, B> = new Uppy();
|
|
30
|
+
@Input() props: StatusBarOptions = {};
|
|
31
|
+
|
|
32
|
+
/** Inserted by Angular inject() migration for backwards compatibility */
|
|
33
|
+
constructor(...args: unknown[]);
|
|
34
|
+
|
|
35
|
+
constructor() {
|
|
36
|
+
super();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
ngOnInit() {
|
|
40
|
+
this.onMount(
|
|
41
|
+
{ id: "angular:StatusBar", target: this.el.nativeElement },
|
|
42
|
+
StatusBar,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
47
|
+
this.handleChanges(changes, StatusBar);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ngOnDestroy(): void {
|
|
51
|
+
this.uninstall();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { moduleMetadata } from "@storybook/angular";
|
|
2
|
+
import { StatusBarDemoComponent } from "./status-bar-demo.component";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "Status Bar",
|
|
6
|
+
decorators: [
|
|
7
|
+
moduleMetadata({
|
|
8
|
+
declarations: [StatusBarDemoComponent],
|
|
9
|
+
}),
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Default = () => ({
|
|
14
|
+
component: StatusBarDemoComponent,
|
|
15
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ElementRef, SimpleChanges } from "@angular/core";
|
|
2
|
+
import type { UIPlugin, UIPluginOptions, Uppy } from "@uppy/core";
|
|
3
|
+
import type { DragDropOptions } from "@uppy/drag-drop";
|
|
4
|
+
import type { ProgressBarOptions } from "@uppy/progress-bar";
|
|
5
|
+
import type { StatusBarOptions } from "@uppy/status-bar";
|
|
6
|
+
import type { Body, Meta } from "@uppy/utils/lib/UppyFile";
|
|
7
|
+
|
|
8
|
+
export abstract class UppyAngularWrapper<
|
|
9
|
+
M extends Meta,
|
|
10
|
+
B extends Body,
|
|
11
|
+
Opts extends UIPluginOptions,
|
|
12
|
+
PluginType extends UIPlugin<Opts, M, B> = UIPlugin<Opts, M, B>,
|
|
13
|
+
> {
|
|
14
|
+
abstract props: DragDropOptions | StatusBarOptions | ProgressBarOptions;
|
|
15
|
+
abstract el: ElementRef;
|
|
16
|
+
abstract uppy: Uppy<M, B>;
|
|
17
|
+
private options: any;
|
|
18
|
+
plugin: PluginType | undefined;
|
|
19
|
+
|
|
20
|
+
onMount(
|
|
21
|
+
defaultOptions: Partial<Opts>,
|
|
22
|
+
plugin: new (uppy: any, opts?: Opts) => UIPlugin<Opts, M, B>,
|
|
23
|
+
) {
|
|
24
|
+
this.options = {
|
|
25
|
+
...defaultOptions,
|
|
26
|
+
...this.props,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
this.uppy.use(plugin, this.options);
|
|
30
|
+
this.plugin = this.uppy.getPlugin(this.options.id) as PluginType;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
handleChanges(changes: SimpleChanges, plugin: any): void {
|
|
34
|
+
// Without the last part of this conditional, it tries to uninstall before the plugin is mounted
|
|
35
|
+
if (
|
|
36
|
+
changes["uppy"] &&
|
|
37
|
+
this.uppy !== changes["uppy"].previousValue &&
|
|
38
|
+
changes["uppy"].previousValue !== undefined
|
|
39
|
+
) {
|
|
40
|
+
this.uninstall(changes["uppy"].previousValue);
|
|
41
|
+
// @ts-expect-error The options correspond to the plugin, I swear
|
|
42
|
+
this.uppy.use(plugin, this.options);
|
|
43
|
+
}
|
|
44
|
+
this.options = { ...this.options, ...this.props };
|
|
45
|
+
this.plugin = this.uppy.getPlugin(this.options.id) as PluginType;
|
|
46
|
+
if (
|
|
47
|
+
changes["props"] &&
|
|
48
|
+
this.props !== changes["props"].previousValue &&
|
|
49
|
+
changes["props"].previousValue !== undefined
|
|
50
|
+
) {
|
|
51
|
+
this.plugin.setOptions({ ...this.options });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
uninstall(uppy = this.uppy): void {
|
|
56
|
+
uppy.removePlugin(this.plugin!);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of @uppy/angular
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { DashboardComponent } from './lib/components/dashboard/dashboard.component'
|
|
6
|
+
export { DashboardModalComponent } from './lib/components/dashboard-modal/dashboard-modal.component'
|
|
7
|
+
export { DragDropComponent } from './lib/components/drag-drop/drag-drop.component'
|
|
8
|
+
export { ProgressBarComponent } from './lib/components/progress-bar/progress-bar.component'
|
|
9
|
+
export { StatusBarComponent } from './lib/components/status-bar/status-bar.component'
|
|
@@ -0,0 +1,12 @@
|
|
|
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": ["**/*.spec.ts"]
|
|
12
|
+
}
|