@symfony/ux-dropzone 2.32.0 → 2.33.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 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 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.
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
- - [Documentation](https://symfony.com/bundles/ux-dropzone/current/index.html)
22
- - [Report issues](https://github.com/symfony/ux/issues) and
23
- [send Pull Requests](https://github.com/symfony/ux/pulls)
24
- in the [main Symfony UX repository](https://github.com/symfony/ux)
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)
@@ -1,22 +1,20 @@
1
- import { Controller } from '@hotwired/stimulus';
2
-
1
+ import { Controller } from "@hotwired/stimulus";
3
2
  declare class export_default extends Controller {
4
- readonly inputTarget: HTMLInputElement;
5
- readonly placeholderTarget: HTMLDivElement;
6
- readonly previewTarget: HTMLDivElement;
7
- readonly previewClearButtonTarget: HTMLButtonElement;
8
- readonly previewFilenameTarget: HTMLDivElement;
9
- readonly previewImageTarget: HTMLDivElement;
10
- static targets: string[];
11
- initialize(): void;
12
- connect(): void;
13
- disconnect(): void;
14
- clear(): void;
15
- onInputChange(event: any): void;
16
- _populateImagePreview(file: Blob): void;
17
- onDragEnter(): void;
18
- onDragLeave(event: any): void;
19
- private dispatchEvent;
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 };
@@ -1,80 +1,81 @@
1
- // src/controller.ts
2
1
  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;
38
- }
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);
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
- 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/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.32.0",
5
+ "version": "2.33.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-dropzone",
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": "^3.2.4"
47
+ "vitest": "^4.1.0"
49
48
  },
50
49
  "scripts": {
51
- "build": "tsx ../../../bin/build_package.ts .",
52
- "watch": "tsx ../../../bin/build_package.ts . --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
  }