import snippets from './snippets';
import {
  formItemGeneralDataGroup,
  getFormItemGeneralInfoGroup,
  generalItemMap,
  getFormItemValidateGroup,
} from '../_utils/defaultSchema';

export default {
  snippets,
  componentName: 'FormItemSwitch',
  title: '开关(高级)',
  category: '无代码表单',
  group: '无代码组件',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: '@pisell/materials',
    version: '1.0.1',
    exportName: 'FormItemSwitch',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  generalProps: [
    // 数据分组
    formItemGeneralDataGroup,
    // 信息分组
    getFormItemGeneralInfoGroup([
      generalItemMap['label'],
      generalItemMap['tooltip'],
      generalItemMap['extra'],
      generalItemMap['hideLabel'],
      generalItemMap['renderMode'],
    ]),
    // 校验分组
    getFormItemValidateGroup([generalItemMap['requiredobj']]),
  ],
  configure: {
    props: [
      {
        name: 'checkedChildren',
        title: { label: '选中时内容', tip: '选中时的内容' },
        propType: 'string',
        setter: 'PisellI18nSetter',
        supportVariable: true,
      },
      {
        name: 'unCheckedChildren',
        title: { label: '非选中时内容', tip: '非选中时的内容' },
        propType: 'string',
        setter: 'PisellI18nSetter',
        supportVariable: true,
      },
      {
        name: 'autoFocus',
        title: { label: '自动聚焦', tip: '自动获取焦点' },
        propType: 'bool',
        defaultValue: false,
        setter: 'BoolSetter',
        supportVariable: true,
      },
      {
        name: 'checked',
        title: { label: '当前值', tip: '指定当前是否选中' },
        propType: 'bool',
        defaultValue: false,
        setter: 'BoolSetter',
        supportVariable: true,
      },
      {
        name: 'defaultChecked',
        title: { label: '默认值', tip: '初始是否选中' },
        propType: 'bool',
        defaultValue: false,
        setter: 'BoolSetter',
        supportVariable: true,
      },
      {
        name: 'disabled',
        title: { label: '是否禁用', tip: '是否为禁用状态' },
        propType: 'bool',
        defaultValue: false,
        setter: 'BoolSetter',
        supportVariable: true,
      },
      {
        name: 'loading',
        title: { label: '加载中', tip: '加载中' },
        propType: 'bool',
        defaultValue: false,
        setter: 'BoolSetter',
        supportVariable: true,
      },
      {
        name: 'size',
        title: { label: '尺寸', tip: '开关大小' },
        propType: { type: 'oneOf', value: ['default', 'small'] },
        setter: {
          componentName: 'RadioGroupSetter',
          props: {
            options: [
              {
                title: '默认',
                value: 'default',
              },
              {
                title: '小',
                value: 'small',
              },
            ],
          },
        },
        defaultValue: 'default',
      },
      {
        name: 'onChange',
        title: { label: '变化时回调函数', tip: '变化时回调函数' },
        propType: 'func',
      },
      {
        name: 'onClick',
        title: { label: '点击时回调函数', tip: '点击时回调函数' },
        propType: 'func',
      },
    ],
    supports: {
      style: true,
      events: [
        {
          name: 'onChange',
          template:
            "onChange(checked,event,${extParams}){\n// 变化时回调函数\nconsole.log('onChange', checked, event);}",
        },
        {
          name: 'onClick',
          template:
            "onClick(checked,event,${extParams}){\n// 点击时回调函数\nconsole.log('onClick', checked, event);}",
        },
      ],
    },
  },
};

