@symfony/ux-dropzone 2.32.0 → 2.34.0
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/README.md +6 -5
- package/dist/controller.d.ts +18 -20
- package/dist/controller.js +79 -78
- package/dist/style.min.css +1 -1
- package/package.json +6 -9
package/README.md
CHANGED
|
@@ -6,9 +6,10 @@ JavaScript assets of the [symfony/ux-dropzone](https://packagist.org/packages/sy
|
|
|
6
6
|
|
|
7
7
|
This npm package is **reserved for advanced users** who want to decouple their JavaScript dependencies from their PHP dependencies (e.g., when building Docker images, running JavaScript-only pipelines, etc.).
|
|
8
8
|
|
|
9
|
-
We **strongly recommend not installing this package directly**, but instead
|
|
9
|
+
We **strongly recommend not installing this package directly**, but instead install the PHP package [symfony/ux-dropzone](https://packagist.org/packages/symfony/ux-dropzone) in your Symfony application with [Flex](https://github.com/symfony/flex) enabled.
|
|
10
10
|
|
|
11
11
|
If you still want to install this package directly, please make sure its version exactly matches [symfony/ux-dropzone](https://packagist.org/packages/symfony/ux-dropzone) PHP package version:
|
|
12
|
+
|
|
12
13
|
```shell
|
|
13
14
|
composer require symfony/ux-dropzone:2.23.0
|
|
14
15
|
npm add @symfony/ux-dropzone@2.23.0
|
|
@@ -18,7 +19,7 @@ npm add @symfony/ux-dropzone@2.23.0
|
|
|
18
19
|
|
|
19
20
|
## Resources
|
|
20
21
|
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
- [Documentation](https://symfony.com/bundles/ux-dropzone/current/index.html)
|
|
23
|
+
- [Report issues](https://github.com/symfony/ux/issues) and
|
|
24
|
+
[send Pull Requests](https://github.com/symfony/ux/pulls)
|
|
25
|
+
in the [main Symfony UX repository](https://github.com/symfony/ux)
|
package/dist/controller.d.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import { Controller } from
|
|
2
|
-
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
3
2
|
declare class export_default extends Controller {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
readonly inputTarget: HTMLInputElement;
|
|
4
|
+
readonly placeholderTarget: HTMLDivElement;
|
|
5
|
+
readonly previewTarget: HTMLDivElement;
|
|
6
|
+
readonly previewClearButtonTarget: HTMLButtonElement;
|
|
7
|
+
readonly previewFilenameTarget: HTMLDivElement;
|
|
8
|
+
readonly previewImageTarget: HTMLDivElement;
|
|
9
|
+
static targets: string[];
|
|
10
|
+
initialize(): void;
|
|
11
|
+
connect(): void;
|
|
12
|
+
disconnect(): void;
|
|
13
|
+
clear(): void;
|
|
14
|
+
onInputChange(event: any): void;
|
|
15
|
+
_populateImagePreview(file: Blob): void;
|
|
16
|
+
onDragEnter(): void;
|
|
17
|
+
onDragLeave(event: any): void;
|
|
18
|
+
private dispatchEvent;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
export { export_default as default };
|
|
20
|
+
export { export_default as default };
|
package/dist/controller.js
CHANGED
|
@@ -1,80 +1,81 @@
|
|
|
1
|
-
// src/controller.ts
|
|
2
1
|
import { Controller } from "@hotwired/stimulus";
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
2
|
+
var _Class = class extends Controller {
|
|
3
|
+
initialize() {
|
|
4
|
+
this.clear = this.clear.bind(this);
|
|
5
|
+
this.onInputChange = this.onInputChange.bind(this);
|
|
6
|
+
this.onDragEnter = this.onDragEnter.bind(this);
|
|
7
|
+
this.onDragLeave = this.onDragLeave.bind(this);
|
|
8
|
+
}
|
|
9
|
+
connect() {
|
|
10
|
+
this.clear();
|
|
11
|
+
this.previewClearButtonTarget.addEventListener("click", this.clear);
|
|
12
|
+
this.inputTarget.addEventListener("change", this.onInputChange);
|
|
13
|
+
this.element.addEventListener("dragenter", this.onDragEnter);
|
|
14
|
+
this.element.addEventListener("dragleave", this.onDragLeave);
|
|
15
|
+
this.dispatchEvent("connect");
|
|
16
|
+
}
|
|
17
|
+
disconnect() {
|
|
18
|
+
this.previewClearButtonTarget.removeEventListener("click", this.clear);
|
|
19
|
+
this.inputTarget.removeEventListener("change", this.onInputChange);
|
|
20
|
+
this.element.removeEventListener("dragenter", this.onDragEnter);
|
|
21
|
+
this.element.removeEventListener("dragleave", this.onDragLeave);
|
|
22
|
+
}
|
|
23
|
+
clear() {
|
|
24
|
+
this.inputTarget.value = "";
|
|
25
|
+
this.inputTarget.style.display = "block";
|
|
26
|
+
this.placeholderTarget.style.display = "block";
|
|
27
|
+
this.previewTarget.style.display = "none";
|
|
28
|
+
this.previewImageTarget.style.display = "none";
|
|
29
|
+
this.previewImageTarget.style.backgroundImage = "none";
|
|
30
|
+
this.previewFilenameTarget.textContent = "";
|
|
31
|
+
this.dispatchEvent("clear");
|
|
32
|
+
}
|
|
33
|
+
onInputChange(event) {
|
|
34
|
+
const file = event.target.files[0];
|
|
35
|
+
if (typeof file === "undefined") return;
|
|
36
|
+
this.inputTarget.style.display = "none";
|
|
37
|
+
this.placeholderTarget.style.display = "none";
|
|
38
|
+
this.previewFilenameTarget.textContent = file.name;
|
|
39
|
+
this.previewTarget.style.display = "flex";
|
|
40
|
+
this.previewImageTarget.style.display = "none";
|
|
41
|
+
if (file.type && file.type.indexOf("image") !== -1) this._populateImagePreview(file);
|
|
42
|
+
this.dispatchEvent("change", file);
|
|
43
|
+
}
|
|
44
|
+
_populateImagePreview(file) {
|
|
45
|
+
if (typeof FileReader === "undefined") return;
|
|
46
|
+
const reader = new FileReader();
|
|
47
|
+
reader.addEventListener("load", (event) => {
|
|
48
|
+
this.previewImageTarget.style.display = "block";
|
|
49
|
+
this.previewImageTarget.style.backgroundImage = `url("${event.target.result}")`;
|
|
50
|
+
});
|
|
51
|
+
reader.readAsDataURL(file);
|
|
52
|
+
}
|
|
53
|
+
onDragEnter() {
|
|
54
|
+
this.inputTarget.style.display = "block";
|
|
55
|
+
this.placeholderTarget.style.display = "block";
|
|
56
|
+
this.previewTarget.style.display = "none";
|
|
57
|
+
}
|
|
58
|
+
onDragLeave(event) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
if (!this.element.contains(event.relatedTarget)) {
|
|
61
|
+
this.inputTarget.style.display = "none";
|
|
62
|
+
this.placeholderTarget.style.display = "none";
|
|
63
|
+
this.previewTarget.style.display = "block";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
dispatchEvent(name, payload = {}) {
|
|
67
|
+
this.dispatch(name, {
|
|
68
|
+
detail: payload,
|
|
69
|
+
prefix: "dropzone"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
80
72
|
};
|
|
73
|
+
_Class.targets = [
|
|
74
|
+
"input",
|
|
75
|
+
"placeholder",
|
|
76
|
+
"preview",
|
|
77
|
+
"previewClearButton",
|
|
78
|
+
"previewFilename",
|
|
79
|
+
"previewImage"
|
|
80
|
+
];
|
|
81
|
+
export { _Class as default };
|
package/dist/style.min.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.dropzone-container{border:2px dashed #bbb;align-items:center;min-height:100px;padding:20px 10px;display:flex;position:relative}.dropzone-input{opacity:0;cursor:pointer;z-index:1;width:100%;height:100%;display:block;position:absolute;top:0;left:0}.dropzone-preview{align-items:center;max-width:100%;display:flex}.dropzone-preview-image{background-position:50%;background-repeat:no-repeat;background-size:contain;flex-basis:0;min-width:50px;max-width:50px;height:50px;margin-right:10px}.dropzone-preview-filename{word-wrap:anywhere}.dropzone-preview-button{z-index:1;width:auto;color:inherit;font:inherit;-webkit-font-smoothing:inherit;-moz-osx-font-smoothing:inherit;-webkit-appearance:none;background:0 0;border:none;margin:0;padding:0;line-height:normal;position:absolute;top:0;right:0;overflow:visible}.dropzone-preview-button:before{content:"×";cursor:pointer;padding:3px 7px}.dropzone-placeholder{text-align:center;color:#999;flex-grow:1}
|
|
1
|
+
.dropzone-container{border:2px dashed #bbb;align-items:center;min-height:100px;padding:20px 10px;display:flex;position:relative}.dropzone-input{opacity:0;cursor:pointer;z-index:1;width:100%;height:100%;display:block;position:absolute;top:0;left:0}.dropzone-preview{align-items:center;max-width:100%;display:flex}.dropzone-preview-image{background-position:50%;background-repeat:no-repeat;background-size:contain;flex-basis:0;min-width:50px;max-width:50px;height:50px;margin-right:10px}.dropzone-preview-filename{word-wrap:anywhere}.dropzone-preview-button{z-index:1;width:auto;color:inherit;font:inherit;-webkit-font-smoothing:inherit;-moz-osx-font-smoothing:inherit;-webkit-appearance:none;background:0 0;border:none;margin:0;padding:0;line-height:normal;position:absolute;top:0;right:0;overflow:visible}.dropzone-preview-button:before{content:"×";cursor:pointer;padding:3px 7px}.dropzone-placeholder{text-align:center;color:#999;flex-grow:1}
|
package/package.json
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
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.34.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"symfony-ux"
|
|
8
8
|
],
|
|
9
9
|
"homepage": "https://ux.symfony.com/dropzone",
|
|
10
|
-
"repository": "https://github.com/symfony/ux
|
|
10
|
+
"repository": "https://github.com/symfony/ux",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"files": [
|
|
13
13
|
"dist"
|
|
@@ -43,18 +43,15 @@
|
|
|
43
43
|
"@testing-library/user-event": "^14.6.1",
|
|
44
44
|
"jsdom": "^26.1.0",
|
|
45
45
|
"tslib": "^2.8.1",
|
|
46
|
-
"tsx": "^4.20.3",
|
|
47
46
|
"typescript": "^5.8.3",
|
|
48
|
-
"vitest": "^
|
|
47
|
+
"vitest": "^4.1.0"
|
|
49
48
|
},
|
|
50
49
|
"scripts": {
|
|
51
|
-
"build": "
|
|
52
|
-
"watch": "
|
|
50
|
+
"build": "node ../../../bin/build_package.ts .",
|
|
51
|
+
"watch": "node ../../../bin/build_package.ts . --watch",
|
|
53
52
|
"test": "pnpm run test:unit && pnpm run test:browser",
|
|
54
53
|
"test:unit": "../../../bin/unit_test_package.sh .",
|
|
55
54
|
"test:browser": "playwright test",
|
|
56
|
-
"test:browser:ui": "playwright test --ui"
|
|
57
|
-
"check": "biome check",
|
|
58
|
-
"ci": "biome ci"
|
|
55
|
+
"test:browser:ui": "playwright test --ui"
|
|
59
56
|
}
|
|
60
57
|
}
|