@symfony/ux-dropzone 2.27.0 → 2.28.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/dist/controller.d.ts +4 -1
- package/dist/controller.js +76 -75
- package/package.json +17 -9
package/dist/controller.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
declare class export_default extends Controller {
|
|
3
4
|
readonly inputTarget: HTMLInputElement;
|
|
4
5
|
readonly placeholderTarget: HTMLDivElement;
|
|
5
6
|
readonly previewTarget: HTMLDivElement;
|
|
@@ -17,3 +18,5 @@ export default class extends Controller {
|
|
|
17
18
|
onDragLeave(event: any): void;
|
|
18
19
|
private dispatchEvent;
|
|
19
20
|
}
|
|
21
|
+
|
|
22
|
+
export { export_default as default };
|
package/dist/controller.js
CHANGED
|
@@ -1,79 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
class
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
// src/controller.ts
|
|
2
|
+
import { Controller } from "@hotwired/stimulus";
|
|
3
|
+
var controller_default = class extends Controller {
|
|
4
|
+
initialize() {
|
|
5
|
+
this.clear = this.clear.bind(this);
|
|
6
|
+
this.onInputChange = this.onInputChange.bind(this);
|
|
7
|
+
this.onDragEnter = this.onDragEnter.bind(this);
|
|
8
|
+
this.onDragLeave = this.onDragLeave.bind(this);
|
|
9
|
+
}
|
|
10
|
+
connect() {
|
|
11
|
+
this.clear();
|
|
12
|
+
this.previewClearButtonTarget.addEventListener("click", this.clear);
|
|
13
|
+
this.inputTarget.addEventListener("change", this.onInputChange);
|
|
14
|
+
this.element.addEventListener("dragenter", this.onDragEnter);
|
|
15
|
+
this.element.addEventListener("dragleave", this.onDragLeave);
|
|
16
|
+
this.dispatchEvent("connect");
|
|
17
|
+
}
|
|
18
|
+
disconnect() {
|
|
19
|
+
this.previewClearButtonTarget.removeEventListener("click", this.clear);
|
|
20
|
+
this.inputTarget.removeEventListener("change", this.onInputChange);
|
|
21
|
+
this.element.removeEventListener("dragenter", this.onDragEnter);
|
|
22
|
+
this.element.removeEventListener("dragleave", this.onDragLeave);
|
|
23
|
+
}
|
|
24
|
+
clear() {
|
|
25
|
+
this.inputTarget.value = "";
|
|
26
|
+
this.inputTarget.style.display = "block";
|
|
27
|
+
this.placeholderTarget.style.display = "block";
|
|
28
|
+
this.previewTarget.style.display = "none";
|
|
29
|
+
this.previewImageTarget.style.display = "none";
|
|
30
|
+
this.previewImageTarget.style.backgroundImage = "none";
|
|
31
|
+
this.previewFilenameTarget.textContent = "";
|
|
32
|
+
this.dispatchEvent("clear");
|
|
33
|
+
}
|
|
34
|
+
onInputChange(event) {
|
|
35
|
+
const file = event.target.files[0];
|
|
36
|
+
if (typeof file === "undefined") {
|
|
37
|
+
return;
|
|
9
38
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
39
|
+
this.inputTarget.style.display = "none";
|
|
40
|
+
this.placeholderTarget.style.display = "none";
|
|
41
|
+
this.previewFilenameTarget.textContent = file.name;
|
|
42
|
+
this.previewTarget.style.display = "flex";
|
|
43
|
+
this.previewImageTarget.style.display = "none";
|
|
44
|
+
if (file.type && file.type.indexOf("image") !== -1) {
|
|
45
|
+
this._populateImagePreview(file);
|
|
17
46
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
47
|
+
this.dispatchEvent("change", file);
|
|
48
|
+
}
|
|
49
|
+
_populateImagePreview(file) {
|
|
50
|
+
if (typeof FileReader === "undefined") {
|
|
51
|
+
return;
|
|
23
52
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
const reader = new FileReader();
|
|
54
|
+
reader.addEventListener("load", (event) => {
|
|
55
|
+
this.previewImageTarget.style.display = "block";
|
|
56
|
+
this.previewImageTarget.style.backgroundImage = `url("${event.target.result}")`;
|
|
57
|
+
});
|
|
58
|
+
reader.readAsDataURL(file);
|
|
59
|
+
}
|
|
60
|
+
onDragEnter() {
|
|
61
|
+
this.inputTarget.style.display = "block";
|
|
62
|
+
this.placeholderTarget.style.display = "block";
|
|
63
|
+
this.previewTarget.style.display = "none";
|
|
64
|
+
}
|
|
65
|
+
onDragLeave(event) {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
if (!this.element.contains(event.relatedTarget)) {
|
|
68
|
+
this.inputTarget.style.display = "none";
|
|
69
|
+
this.placeholderTarget.style.display = "none";
|
|
70
|
+
this.previewTarget.style.display = "block";
|
|
33
71
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.previewImageTarget.style.display = 'none';
|
|
44
|
-
if (file.type && file.type.indexOf('image') !== -1) {
|
|
45
|
-
this._populateImagePreview(file);
|
|
46
|
-
}
|
|
47
|
-
this.dispatchEvent('change', file);
|
|
48
|
-
}
|
|
49
|
-
_populateImagePreview(file) {
|
|
50
|
-
if (typeof FileReader === 'undefined') {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const reader = new FileReader();
|
|
54
|
-
reader.addEventListener('load', (event) => {
|
|
55
|
-
this.previewImageTarget.style.display = 'block';
|
|
56
|
-
this.previewImageTarget.style.backgroundImage = `url("${event.target.result}")`;
|
|
57
|
-
});
|
|
58
|
-
reader.readAsDataURL(file);
|
|
59
|
-
}
|
|
60
|
-
onDragEnter() {
|
|
61
|
-
this.inputTarget.style.display = 'block';
|
|
62
|
-
this.placeholderTarget.style.display = 'block';
|
|
63
|
-
this.previewTarget.style.display = 'none';
|
|
64
|
-
}
|
|
65
|
-
onDragLeave(event) {
|
|
66
|
-
event.preventDefault();
|
|
67
|
-
if (!this.element.contains(event.relatedTarget)) {
|
|
68
|
-
this.inputTarget.style.display = 'none';
|
|
69
|
-
this.placeholderTarget.style.display = 'none';
|
|
70
|
-
this.previewTarget.style.display = 'block';
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
dispatchEvent(name, payload = {}) {
|
|
74
|
-
this.dispatch(name, { detail: payload, prefix: 'dropzone' });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
default_1.targets = ['input', 'placeholder', 'preview', 'previewClearButton', 'previewFilename', 'previewImage'];
|
|
78
|
-
|
|
79
|
-
export { default_1 as default };
|
|
72
|
+
}
|
|
73
|
+
dispatchEvent(name, payload = {}) {
|
|
74
|
+
this.dispatch(name, { detail: payload, prefix: "dropzone" });
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
controller_default.targets = ["input", "placeholder", "preview", "previewClearButton", "previewFilename", "previewImage"];
|
|
78
|
+
export {
|
|
79
|
+
controller_default as default
|
|
80
|
+
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symfony/ux-dropzone",
|
|
3
3
|
"description": "File input dropzones for Symfony Forms",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.28.1",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"symfony-ux"
|
|
8
8
|
],
|
|
@@ -17,13 +17,6 @@
|
|
|
17
17
|
"config": {
|
|
18
18
|
"css_source": "src/style.css"
|
|
19
19
|
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "node ../../../bin/build_package.js .",
|
|
22
|
-
"watch": "node ../../../bin/build_package.js . --watch",
|
|
23
|
-
"test": "../../../bin/test_package.sh .",
|
|
24
|
-
"check": "biome check",
|
|
25
|
-
"ci": "biome ci"
|
|
26
|
-
},
|
|
27
20
|
"symfony": {
|
|
28
21
|
"controllers": {
|
|
29
22
|
"dropzone": {
|
|
@@ -44,6 +37,21 @@
|
|
|
44
37
|
"@hotwired/stimulus": "^3.0.0"
|
|
45
38
|
},
|
|
46
39
|
"devDependencies": {
|
|
47
|
-
"@hotwired/stimulus": "^3.0.0"
|
|
40
|
+
"@hotwired/stimulus": "^3.0.0",
|
|
41
|
+
"@testing-library/dom": "^10.4.0",
|
|
42
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
43
|
+
"@testing-library/user-event": "^14.6.1",
|
|
44
|
+
"jsdom": "^26.1.0",
|
|
45
|
+
"tslib": "^2.8.1",
|
|
46
|
+
"tsx": "^4.20.3",
|
|
47
|
+
"typescript": "^5.8.3",
|
|
48
|
+
"vitest": "^3.2.4"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsx ../../../bin/build_package.ts .",
|
|
52
|
+
"watch": "tsx ../../../bin/build_package.ts . --watch",
|
|
53
|
+
"test": "../../../bin/test_package.sh .",
|
|
54
|
+
"check": "biome check",
|
|
55
|
+
"ci": "biome ci"
|
|
48
56
|
}
|
|
49
57
|
}
|