import loopData from "../_com-props/loopData";
import componentKey from "../_com-props/componentKey";
import componentName from "../_com-props/componentName";
import { getFlowEventConfig } from "../_com-props/flowEventConfig";
import snippets from "./snippets";
import { CComputedSetter } from "../_setters";
import { ConditionRenderService } from "../_utils/conditionRenderService";
import { t } from "../../src/locale";
export default {
  componentName: 'Button',
  title: t('button.title'),
  category: t('button.category'),
  group: t('button.group'),
  props: [loopData, componentKey, componentName, {
    title: t('button.feature'),
    display: 'block',
    type: 'group',
    items: [{
      name: 'dictionaryKey',
      title: {
        label: t('typographyText.key_kbMeuiEtQtNa'),
        tip: t('typographyText.key_kbMeuiEtQtNb')
      },
      setter: 'DictionarySetter',
      props: {
        type: 'text'
      }
    }, {
      name: 'children',
      title: {
        label: t('button.children'),
        tip: t('button.childrenTip')
      },
      propType: "string",
      setter: 'StringSetter'
    }, {
      name: 'defaultValue',
      title: {
        label: t('button.defaultValue'),
        tip: t('button.defaultValueTip')
      },
      propType: 'string',
      defaultValue: '',
      setter: CComputedSetter,
      extraProps: {
        setValue: function setValue(target, value) {
          if (value !== undefined && value !== '') {
            var conditionRenderService = new ConditionRenderService();
            conditionRenderService.load(value.data);
            var exp = conditionRenderService.getConditionExpression();
            target.parent.setPropValue('children', exp);
          }
        }
      }
    }]
  }, getFlowEventConfig({
    label: t('gridCol.clickFlowEvent'),
    tip: t('gridCol.clickFlowEventTip'),
    props: {}
  }),
  // getFlowEventConfig({
  //   name: "mouseDownFlowEvent",
  //   label: t('button.mouseDownFlowEvent'),
  //   tip: t('button.mouseDownFlowEventTip'),
  //   props: {}
  // }),
  // getFlowEventConfig({
  //   name: "mouseUpFlowEvent",
  //   label: t('button.mouseUpFlowEvent'),
  //   tip: t('button.mouseUpFlowEventTip'),
  //   props: {}
  // }),
  {
    title: t('button.appearance'),
    display: 'block',
    type: 'group',
    items: [{
      name: 'type',
      title: {
        label: t('button.type'),
        tip: t('button.typeTip')
      },
      propType: {
        type: 'oneOf',
        value: ['primary', 'ghost', 'dashed', 'danger', 'link', 'text']
      },
      setter: [{
        componentName: 'SelectSetter',
        props: {
          options: [{
            title: t('button.typeOptionPrimary'),
            value: 'primary'
          }, {
            title: t('button.typeOptionDashed'),
            value: 'dashed'
          }, {
            title: t('button.typeOptionDanger'),
            value: 'danger'
          }, {
            title: t('button.typeOptionLink'),
            value: 'link'
          }, {
            title: t('button.typeOptionText'),
            value: 'text'
          }]
        }
      }, 'VariableSetter']
    }, {
      name: 'size',
      title: {
        label: t('button.size'),
        tip: t('button.sizeTip')
      },
      propType: {
        type: 'oneOf',
        value: ['large', 'middle', 'small']
      },
      setter: [{
        componentName: 'RadioGroupSetter',
        props: {
          options: [{
            title: t('button.sizeOptionLarge'),
            value: 'large'
          }, {
            title: t('button.sizeOptionMiddle'),
            value: 'middle'
          }, {
            title: t('button.sizeOptionSmall'),
            value: 'small'
          }]
        }
      }, 'VariableSetter'],
      defaultValue: 'middle'
    }, {
      name: 'shape',
      title: {
        label: t('button.shape'),
        tip: t('button.shapeTip')
      },
      propType: {
        type: 'oneOf',
        value: ['default', 'circle', 'round']
      },
      defaultValue: 'default',
      setter: [{
        componentName: 'RadioGroupSetter',
        props: {
          options: [{
            title: t('button.shapeOptionDefault'),
            value: 'default'
          }, {
            title: t('button.shapeOptionCircle'),
            value: 'circle'
          }, {
            title: t('button.shapeOptionRound'),
            value: 'round'
          }]
        }
      }, 'VariableSetter']
    }, {
      name: 'block',
      title: {
        label: t('button.block'),
        tip: t('button.blockTip')
      },
      propType: 'bool',
      setter: 'BoolSetter',
      defaultValue: false
    }]
  }, {
    title: t('button.statusTitle'),
    display: 'block',
    type: 'group',
    items: [{
      name: 'disabled',
      title: {
        label: t('button.disabled'),
        tip: t('button.disabledTip')
      },
      propType: 'bool',
      setter: ['BoolSetter', 'VariableSetter'],
      defaultValue: false
    }]
  }, {
    title: t('button.buttonStatus'),
    display: 'block',
    type: 'group',
    items: [{
      name: 'hoverStyle',
      title: t('button.hoverStyle'),
      type: 'group',
      extraProps: {
        display: 'entry'
      },
      items: [{
        name: 'hoverStyle',
        title: {
          label: t('button.hoverStyle'),
          tip: t('button.hoverStyleTip')
        },
        setter: 'CStyleSetter',
        extraProps: {
          display: 'block'
        }
      }]
    }, {
      name: 'clickStyle',
      title: t('button.clickStyle'),
      type: 'group',
      extraProps: {
        display: 'entry'
      },
      items: [{
        name: 'clickStyle',
        title: {
          label: t('button.clickStyle'),
          tip: t('button.clickStyleTip')
        },
        setter: 'CStyleSetter',
        extraProps: {
          display: 'block'
        }
      }]
    }, {
      name: 'selectStyle',
      title: t('button.selectStyle'),
      type: 'group',
      extraProps: {
        display: 'entry'
      },
      items: [{
        name: 'selectStyle',
        title: {
          label: t('button.selectStyle'),
          tip: t('button.selectStyleTip')
        },
        setter: 'CStyleSetter',
        extraProps: {
          display: 'block'
        }
      }]
    }, {
      name: 'loadingStyle',
      title: t('button.loadingStyle'),
      type: 'group',
      extraProps: {
        display: 'entry'
      },
      items: [{
        name: 'loadingStyle',
        title: {
          label: t('button.loadingStyle'),
          tip: t('button.loadingStyleTip')
        },
        setter: 'CStyleSetter',
        extraProps: {
          display: 'block'
        }
      }]
    }, {
      name: 'errorStyle',
      title: t('button.errorStyle'),
      type: 'group',
      extraProps: {
        display: 'entry'
      },
      items: [{
        name: 'errorStyle',
        title: {
          label: t('button.errorStyle'),
          tip: t('button.errorStyleTip')
        },
        setter: 'CStyleSetter',
        extraProps: {
          display: 'block'
        }
      }]
    }]
  }],
  configure: {
    supports: {
      events: false,
      style: true,
      loop: false,
      condition: false
    }
  },
  snippets: snippets
};