<?php
use function App\Core\e;

$id = $id ?? uniqid('dropzone-', false);
$name = $name ?? 'file';
$label = $label ?? 'Dosya sec';
$hint = $hint ?? '';
$accept = $accept ?? '';
$multiple = !empty($multiple);
$kind = $kind ?? 'file';
$existing = $existing ?? '';
$required = !empty($required);
?>
<div
    class="upload-dropzone"
    data-dropzone
    data-dropzone-kind="<?= e($kind) ?>"
    data-dropzone-id="<?= e($id) ?>"
>
    <input
        id="<?= e($id) ?>"
        name="<?= e($name) ?>"
        type="file"
        <?= $accept !== '' ? 'accept="' . e($accept) . '"' : '' ?>
        <?= $multiple ? 'multiple' : '' ?>
        <?= $required ? 'required' : '' ?>
        data-upload-input
    >
    <label for="<?= e($id) ?>" class="upload-dropzone-inner">
        <span class="upload-dropzone-icon" aria-hidden="true">+</span>
        <strong><?= e($label) ?></strong>
        <?php if ($hint !== ''): ?><small><?= e($hint) ?></small><?php endif; ?>
    </label>
    <div class="field-error" data-error-for="<?= e($name) ?>"></div>
    <?php if ($existing !== ''): ?>
        <div class="single-upload-preview is-filled" data-dropzone-preview>
            <img src="<?= e($existing) ?>" alt="">
            <button type="button" data-clear-dropzone>Sil</button>
        </div>
    <?php else: ?>
        <div class="single-upload-preview" data-dropzone-preview hidden></div>
    <?php endif; ?>
</div>
