Skip to content

Commit 3fca53a

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.
1 parent bff77ec commit 3fca53a

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

src/Dropzone/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 2.31
44

5-
- Suport for multiple files drag and drop and peviews
5+
- Support for multiple files drag and drop and peviews
66

77
## 2.30
88

src/Dropzone/assets/src/controller.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@
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;
1414
declare readonly placeholderTarget: HTMLDivElement;
1515
declare readonly previewTargets: HTMLDivElement[];
1616
declare readonly previewContainerTarget: HTMLDivElement;
1717

18-
static targets = ['input', 'placeholder', 'preview', 'previewClearButton', 'previewFilename', 'previewImage', 'previewContainer'];
18+
static targets = [
19+
'input',
20+
'placeholder',
21+
'preview',
22+
'previewClearButton',
23+
'previewFilename',
24+
'previewImage',
25+
'previewContainer'
26+
];
1927

2028
files: Map<string, File> = new Map<string, File>();
2129

@@ -58,13 +66,13 @@ export default class extends Controller {
5866
}
5967
}
6068
if (!this.inputTarget || !this.inputTarget.files || this.inputTarget?.files?.length === 0) {
61-
this.placeholderTarget.style.display = "block";
69+
this.placeholderTarget.style.display = 'block';
6270
if (!this.isMultiple) {
63-
this.inputTarget.style.display = "block";
71+
this.inputTarget.style.display = 'block';
6472
}
6573
}
6674

67-
this.dispatchEvent("clear");
75+
this.dispatchEvent('clear');
6876
}
6977

7078
onInputChange() {
@@ -75,14 +83,14 @@ export default class extends Controller {
7583
}
7684

7785
if (!this.isMultiple && this.files.size > 0) {
78-
this.inputTarget.style.display = "none";
86+
this.inputTarget.style.display = 'none';
7987
}
8088

8189
const selectedFiles = this.isMultiple ? Array.from(files) : Array.from(files).slice(0, 1);
8290
this.addFiles(selectedFiles);
8391
this.updateFileInput();
8492
this.renderPreview();
85-
this.dispatchEvent("change", files);
93+
this.dispatchEvent('change', files);
8694
}
8795

8896
private renderPreview() {
@@ -106,7 +114,7 @@ export default class extends Controller {
106114

107115
private clearPreviewContainer() {
108116
const previews = this.previewTargets;
109-
previews.slice(1).forEach(el => el.remove());
117+
previews.slice(1).forEach((el) => el.remove());
110118
}
111119

112120
private buildPreview(file: File, element?: HTMLElement): HTMLElement {
@@ -117,7 +125,7 @@ export default class extends Controller {
117125

118126
const fileName = element.querySelector('.dropzone-preview-filename');
119127
if (fileName) {
120-
fileName.textContent = file.name
128+
fileName.textContent = file.name;
121129
}
122130

123131
const button = element.querySelector('.dropzone-preview-button');
@@ -176,6 +184,6 @@ export default class extends Controller {
176184
}
177185

178186
private dispatchEvent(name: string, payload: any = {}) {
179-
this.dispatch(name, {detail: payload, prefix: 'dropzone'});
187+
this.dispatch(name, { detail: payload, prefix: 'dropzone' });
180188
}
181189
}

src/Dropzone/assets/test/vitest.setup.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class MockDataTransfer {
2323
}
2424

2525
setData() {}
26-
getData() { return ''; }
26+
getData() {
27+
return '';
28+
}
2729
clearData() {
2830
this.files.length = 0;
2931
}

src/Dropzone/assets/vitest.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mergeConfig, defineConfig } from 'vitest/config';
1+
import { defineConfig, mergeConfig } from 'vitest/config';
22
import configShared from '../../../vitest.config.base.mjs';
33

44
export default mergeConfig(

0 commit comments

Comments
 (0)