<script setup lang="ts">
import { buildTree } from "@/utils/recusive";

const _props = defineProps<{
  content?: any;
  component?: any;
}>();

const SETTING_OPTIONS = {
  MAX_ELEMENT: 4,
};
</script>

<template>
  <div class="mt-4">
    <div class="gap-5 grid" :style="`grid-template-columns: repeat(${SETTING_OPTIONS.MAX_ELEMENT}, minmax(0, 1fr));`">
      <template v-if="_props.content">
        <div v-for="item, index in buildTree(_props.content)" :key="index">
          <div class="submenu-container">
            <h4 class="mb-0" @click="selectNavigationComponent">{{ item.title }}</h4>
            <h4 
              v-for="_item, _index in item.childs ? item.childs : []" 
              :key="_index" 
              class="mb-0"
              @click="selectNavigationComponent"
            >
              {{ _item.title }}
            </h4>
          </div>
        </div>
      </template>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.submenu-container {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  h4 {
    font-size: 14px;
    font-weight: normal;
    cursor: pointer;
  }
}
</style>
