<template>
  <s-code-editor v-model="textJSON" lang="json"></s-code-editor>

  <s-check-group v-model="tag"
                 mode="tag"
                 :has-key="true"
                 :options="options"
  />
</template>

<script lang="ts" setup>
import { computed, ref } from 'vue'

const tag = ref()
const textJSON = computed({
  get () {
    return JSON.stringify(tag.value, null, '\t')
  },
  set (value) {
    model.value = JSON.parse(value)
  }
})
const options = [
  {
    label: '分组1',
    key: 'type',
    options: [
      {
        label: '折线图',
        value: 'line'
      },
      {
        label: '柱状图',
        value: 'bar'
      },
      {
        label: '饼图',
        value: 'pie'
      },
      {
        label: '雷达图',
        value: 'radar'
      },
      {
        label: '散点图',
        value: 'scatter'
      }
    ]
  },
  {
    label: '分组2',
    key: 'fruits',
    options: [
      {
        label: '苹果',
        value: 'apple'
      },
      {
        label: '香蕉',
        value: 'banana'
      },
      {
        label: '橘子',
        value: 'orange'
      },
      {
        label: '梨',
        value: 'pear'
      }
    ]
  }
]
</script>

<style lang="scss" scoped>
</style>
