// This file was generated by build-components.mjs
// ANY EDITS WILL BE OVERWRITTEN!

import {
  type FilesGridProps,
  FilesGrid as PreactFilesGrid,
} from '@uppy/components'
import { h as preactH, render as preactRender } from '@uppy/core/utils/preact'
import { defineComponent, h, onMounted, ref, watch } from 'vue'
import { useUppyContext } from '../useUppyContext.js'

export default defineComponent({
  name: 'FilesGrid',
  props: ['editFile', 'columns', 'imageThumbnail'],
  setup(props) {
    const containerRef = ref<HTMLElement | null>(null)
    const ctx = useUppyContext()

    function renderFilesGrid() {
      if (containerRef.value) {
        preactRender(
          preactH(PreactFilesGrid, {
            ...props,
            ctx,
          } satisfies FilesGridProps),
          containerRef.value,
        )
      }
    }

    onMounted(() => {
      renderFilesGrid()
    })

    watch(ctx, () => {
      renderFilesGrid()
    })

    watch(
      () => props,
      () => {
        renderFilesGrid()
      },
      { deep: true },
    )

    return () => h('div', { ref: containerRef })
  },
})
