<template>
    <div class="row no-margin">
        <div class="col b-a " :class="[{'b-grey': !validator.$error}, {'b-danger': validator.$error}]">
            <div class="row align-items-center b-b b-grey b-dashed">
                <div class="col p-t-10 p-b-10">
                    <slot name="label"></slot>
                </div>
                <div class="col-auto">
                    <div class="row align-items-center">
                        <div class="col-auto no-padding">
                            <validation-error-component :validator="validator"></validation-error-component>
                        </div>
                        <div class="col-auto">
                            <div class="fs-12 icon-thumbnail btn-rounded icon-25 m-r-0" :class="[{'bg-master-lightest': !validator.$error}, {'bg-danger': validator.$error}, {'text-white': validator.$error}]" v-show="!files.length">!</div>
                            <div class="bg-success fs-11 text-white icon-thumbnail btn-rounded icon-25 m-r-0" v-show="!!files.length">
                                <i class="fa fa-check fs-11"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col p-t-15 p-b-15">
                    <div class="row"  v-show="!files.length">
                        <div class="col">
                            <slot name="tips"></slot>
                        </div>
                    </div>
                    <file-upload-component v-model="files" :value="value" v-on:input="$emit('input', $event)"></file-upload-component>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        props: {
            value: {
                type: Array,
                required: false
            },
            validator: {
                required: true
            }
        },
        data(){
            return {
                files: []
            }
        }
    }
</script>