demarches-normaliennes/app/javascript/controllers/file_input_reset_controller.ts
2023-10-25 09:52:49 +02:00

19 lines
484 B
TypeScript

import { ApplicationController } from './application_controller';
import { hide, show } from '@utils';
export class FileInputResetController extends ApplicationController {
static targets = ['input', 'reset'];
declare readonly inputTarget: HTMLInputElement;
declare readonly resetTarget: HTMLElement;
reset(event: Event) {
event.preventDefault();
this.inputTarget.value = '';
hide(this.resetTarget);
}
showResetButton() {
show(this.resetTarget);
}
}