Skip to content

Commit b89043f

Browse files
author
Carlos Hernández
committed
- Fix inconsistent quote styles to maintain coding standards.
- Format array declarations for better readability in `controller.ts`. - Correct typos in `CHANGELOG.md`. - Adjust imports for consistency in `vitest.config.mjs`. - Refactor `vitest.setup.js` for improved code structure. # Conflicts: # src/Dropzone/CHANGELOG.md # src/Dropzone/assets/src/controller.ts
1 parent f222244 commit b89043f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/Dropzone/assets/src/controller.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* file that was distributed with this source code.
88
*/
99

10-
import {Controller} from '@hotwired/stimulus';
10+
import { Controller } from '@hotwired/stimulus';
1111

1212
export default class extends Controller {
1313
declare readonly inputTarget: HTMLInputElement;
@@ -22,7 +22,8 @@ export default class extends Controller {
2222
'previewClearButton',
2323
'previewFilename',
2424
'previewImage',
25-
'previewContainer',
25+
'previewContainer'
26+
,
2627
];
2728

2829
files: Map<string, File> = new Map<string, File>();
@@ -66,13 +67,13 @@ export default class extends Controller {
6667
}
6768
}
6869
if (!this.inputTarget || !this.inputTarget.files || this.inputTarget?.files?.length === 0) {
69-
this.placeholderTarget.style.display = "block";
70+
this.placeholderTarget.style.display = 'block';
7071
if (!this.isMultiple) {
71-
this.inputTarget.style.display = "block";
72+
this.inputTarget.style.display = 'block';
7273
}
7374
}
7475

75-
this.dispatchEvent("clear");
76+
this.dispatchEvent('clear');
7677
}
7778

7879
onInputChange() {
@@ -83,14 +84,14 @@ export default class extends Controller {
8384
}
8485

8586
if (!this.isMultiple && this.files.size > 0) {
86-
this.inputTarget.style.display = "none";
87+
this.inputTarget.style.display = 'none';
8788
}
8889

8990
const selectedFiles = this.isMultiple ? Array.from(files) : Array.from(files).slice(0, 1);
9091
this.addFiles(selectedFiles);
9192
this.updateFileInput();
9293
this.renderPreview();
93-
this.dispatchEvent("change", files);
94+
this.dispatchEvent('change', files);
9495
}
9596

9697
private renderPreview() {
@@ -114,7 +115,7 @@ export default class extends Controller {
114115

115116
private clearPreviewContainer() {
116117
const previews = this.previewTargets;
117-
previews.slice(1).forEach(el => el.remove());
118+
previews.slice(1).forEach((el) => el.remove());
118119
}
119120

120121
private buildPreview(file: File, element?: HTMLElement): HTMLElement {
@@ -125,7 +126,7 @@ export default class extends Controller {
125126

126127
const fileName = element.querySelector('.dropzone-preview-filename');
127128
if (fileName) {
128-
fileName.textContent = file.name
129+
fileName.textContent = file.name;
129130
}
130131

131132
const button = element.querySelector('.dropzone-preview-button');
@@ -184,6 +185,6 @@ export default class extends Controller {
184185
}
185186

186187
private dispatchEvent(name: string, payload: any = {}) {
187-
this.dispatch(name, {detail: payload, prefix: 'dropzone'});
188+
this.dispatch(name, { detail: payload, prefix: 'dropzone' });
188189
}
189190
}

0 commit comments

Comments
 (0)