import Led from './Led.vue'
import icon from '../assets/icon/icon_23Led.svg'
import { flagOptions, stateOptions } from '@/constants'
import type { IComponentModelConfig } from '../type'
import i18n from '@/locales'

export default {
  label: i18n.global.t('led'),
  icon,
  component: Led,
  key: 'lv_led',
  group: i18n.global.t('display'),
  sort: 1,
  hasChildren: false,
  parts: [],
  defaultSchema: {
    name: 'led',
    props: {
      x: 0,
      y: 0,
      width: 40,
      height: 40,
      flags: [
        'LV_OBJ_FLAG_CLICKABLE',
        'LV_OBJ_FLAG_CLICK_FOCUSABLE',
        'LV_OBJ_FLAG_SCROLL_ELASTIC',
        'LV_OBJ_FLAG_SCROLL_MOMENTUM',
        'LV_OBJ_FLAG_SCROLL_CHAIN_HOR',
        'LV_OBJ_FLAG_SCROLL_CHAIN_VER',
        'LV_OBJ_FLAG_SCROLL_CHAIN',
        'LV_OBJ_FLAG_SCROLL_WITH_ARROW',
        'LV_OBJ_FLAG_SNAPPABLE',
        'LV_OBJ_FLAG_PRESS_LOCK',
        'LV_OBJ_FLAG_GESTURE_BUBBLE'
      ],
      states: [],
      led_color: '#2196f3',
      led_set_bright: 255
    },
    styles: []
  },
  config: {
    // 组件属性
    props: [
      {
        label: '名称',
        field: 'name',
        valueType: 'text',
        componentProps: {
          placeholder: '请输入名称',
          type: 'text'
        }
      },
      {
        label: '位置/大小',
        valueType: 'group',
        children: [
          {
            label: '',
            field: 'props.x',
            valueType: 'number',
            componentProps: {
              span: 12,
              min: -10000,
              max: 10000
            },
            slots: { prefix: 'X' },
            canUseEventSet: true
          },
          {
            label: '',
            field: 'props.y',
            valueType: 'number',
            componentProps: {
              span: 12,
              min: -10000,
              max: 10000
            },
            slots: { prefix: 'Y' },
            canUseEventSet: true
          },
          {
            label: '',
            field: 'props.width',
            valueType: 'number',
            componentProps: {
              span: 12,
              min: 1,
              max: 10000
            },
            slots: { prefix: 'W' },
            canUseEventSet: true
          },
          {
            label: '',
            field: 'props.height',
            valueType: 'number',
            componentProps: {
              span: 12,
              min: 1,
              max: 10000
            },
            slots: { prefix: 'H' },
            canUseEventSet: true
          }
        ]
      },
      {
        label: '标识',
        field: 'props.flags',
        valueType: 'checkbox',
        componentProps: {
          options: flagOptions,
          defaultCollapsed: true
        },
        canUseEventSet: true
      },
      {
        label: '状态',
        field: 'props.states',
        valueType: 'checkbox',
        componentProps: {
          options: stateOptions,
          defaultCollapsed: true
        },
        canUseEventSet: true
      }
    ],
    coreProps: [
      {
        label: '颜色',
        field: 'props.led_color',
        valueType: 'color',
        componentProps: {
          format: 'hex',
          disableAlpha: true
        },
        canUseEventSet: true
      },
      {
        label: '亮度',
        field: 'props.led_set_bright',
        valueType: 'slider',
        componentProps: {
          min: 0,
          max: 255,
          step: 1
        },
        canUseEventSet: true
      }
    ],
    // 组件样式
    styles: []
  }
} as IComponentModelConfig
