import { t } from "../../src/locale";
import { CStringOnlySetter, CTreeDataRelationSetter } from "../_setters";
import snippets from "./snippets";
import { PageStateFlag } from "../_utils/treeDataRelationFn/type";
import { uuid } from "../_utils/utils";
import componentName from "../_com-props/componentName";
export default {
  snippets: snippets,
  componentName: 'ModalDefault',
  "group": t('modal-default.key_s3RC1K1yvIpG'),
  title: t('modal-default.key_31LKuM8WQbh4'),
  category: t('modal-default.key_IOKH2HjSVvxX'),
  props: [{
    name: 'name',
    title: {
      label: t('modal-default.key_qojkRsjJK6py'),
      tip: t('modal-default.key_tdZMJoMN2gND')
    },
    isRequired: true,
    propType: 'string',
    setter: CStringOnlySetter,
    defaultValue: function defaultValue() {
      return "cr_" + uuid();
    },
    supportVariable: false,
    extraProps: {
      type: PageStateFlag.Modal,
      setValue: function setValue(target, value) {
        if (value !== undefined && value !== '') {
          var exp = {
            "type": "JSExpression",
            "value": "this.state?." + PageStateFlag.Modal + "?." + value + "?.visible",
            "mock": true
          };
          target.parent.setPropValue('open', exp);
          target.parent.setPropValue('componentName', value);
        }
      }
    }
  }, {
    name: 'open',
    title: {
      label: t('modal-default.key_Iji7pXOqTnJP'),
      tip: t('modal-default.key_ndqX7F1Ty4ix')
    },
    propType: 'bool',
    setter: 'BoolSetter',
    supportVariable: true,
    condition: function condition() {
      return false;
    }
  }, componentName, {
    name: 'title',
    title: {
      label: t('modal-default.key_ycOwukpENA7M'),
      tip: t('modal-default.key_fUw5uFQpiAs6')
    },
    propType: {
      type: 'oneOfType',
      value: ['string', 'node']
    }
  }, {
    name: 'apiParams',
    title: {
      label: t('modal-default.key_dTxjwIh3VhjR'),
      tip: t('modal-default.key_xfWtbCjOuQ0A')
    },
    setter: CTreeDataRelationSetter,
    extraProps: {
      componentName: 'ModalDefault'
    }
  }, {
    name: 'closeConfig',
    title: {
      label: t('modal-default.key_HJ5dlbSuGXWn'),
      tip: t('modal-default.key_YuYBBcrQnTcN')
    },
    supportVariable: false,
    propType: {
      type: 'oneOf',
      value: ['open', 'close', 'default']
    },
    defaultValue: 'open',
    setter: [{
      componentName: 'RadioGroupSetter',
      props: {
        options: [{
          title: t('modal-default.key_46DeyGpRTYn0'),
          value: 'open'
        }, {
          title: t('modal-default.key_406eyCjRbpWV'),
          value: 'close'
        }, {
          title: t('modal-default.key_BjxwjM46HO3L'),
          value: 'default'
        }]
      }
    }]
  }, {
    name: 'defaultConfigStyle',
    title: t('modal-default.key_MqNHx7TJPjiR'),
    extraProps: {
      display: 'entry'
    },
    type: 'group',
    items: [{
      name: 'imageUrl',
      title: {
        label: t('modal-default.key_7cvR8ZbiJ1AD'),
        tip: t('modal-default.key_SZ3vfaGJ2qqF')
      },
      setter: 'CUploadImageDefaultSetter',
      defaultValue: ''
    }, {
      name: 'defaultImageStyle',
      display: 'accordion',
      title: {
        label: t('modal-default.key_Hec8xhuViulK'),
        tip: t('modal-default.key_ZSmuPxkL91Tc')
      },
      setter: 'CStyleSetter',
      defaultValue: {
        width: '14px',
        height: '14px'
      }
    }],
    condition: function condition(target) {
      return target.parent.getPropValue('closeConfig') === 'default';
    }
  }, {
    name: 'centered',
    title: {
      label: t('modal.key_TGAepPCH64ax'),
      tip: t('modal.key_DJ3kaih4JRKd')
    },
    propType: 'bool',
    defaultValue: false,
    setter: 'BoolSetter',
    supportVariable: true
  },
  // {
  //   name: 'closable',
  //   title: { label: t('modal-default.key_blyh6EDCZC1g'), tip: t('modal-default.key_fUoRP3OItcP8') },
  //   propType: 'bool',
  //   defaultValue: true,
  //   setter: 'BoolSetter',
  //   supportVariable: true
  // },
  // {
  //   name: 'closeIcon',
  //   title: { label: t('modal-default.key_52MOSQsgxFlo'), tip: t('modal-default.key_GMjflGENr726') },
  //   propType: 'node',
  // },
  // {
  //   name: 'confirmLoading',
  //   title: { label: t('modal-default.key_cUZyV9FeIESy'), tip: t('modal-default.key_eVYpUTtDtEKc') },
  //   propType: 'bool',
  //   defaultValue: false,
  //   setter: 'BoolSetter',
  //   supportVariable: true
  // },
  {
    name: 'destroyOnClose',
    title: {
      label: t('modal-default.key_z6SdXYCTHtnt'),
      tip: t('modal-default.key_uOAvXYx6me85')
    },
    propType: 'bool',
    defaultValue: true,
    setter: 'BoolSetter',
    condition: function condition() {
      return false;
    }
  }, {
    name: 'refreshType',
    title: {
      label: t('drawer.refreshType'),
      tip: t('drawer.refreshTypeTip')
    },
    defaultValue: function defaultValue() {
      return "refresh";
    },
    setter: {
      componentName: 'SelectSetter',
      props: {
        options: [{
          title: t('drawer.refreshOption'),
          value: 'refresh'
        }, {
          title: t('drawer.dataRefreshOption'),
          value: 'dataRefresh'
        }, {
          title: t('drawer.noRefreshOption'),
          value: 'noRefresh'
        }]
      }
    },
    extraProps: {
      setValue: function setValue(target, value) {
        if (value) {
          var res = value === 'refresh';
          target.parent.setPropValue('destroyOnClose', res);
        }
      }
    }
  },
  // {
  //   name: 'containerName',
  //   title: { label: t('drawer.key_ghNpxbkvaFUE'), tip: t('drawer.key_qaIpQikiVXSC') },
  //   propType: 'string',
  //   setter: 'StringSetter',
  // },
  {
    name: 'forceRender',
    title: {
      label: t('modal-default.key_pZpa38QCx9Yf'),
      tip: t('modal-default.key_AlLlyGncfrjs')
    },
    propType: 'bool',
    defaultValue: false,
    setter: 'BoolSetter',
    supportVariable: true
  }, {
    name: 'keyboard',
    title: {
      label: t('modal-default.key_lWCXAfIhmQIM'),
      tip: t('modal-default.key_cICnrJGLzACr')
    },
    propType: 'bool',
    defaultValue: true,
    setter: 'BoolSetter',
    supportVariable: true
  }, {
    name: 'mask',
    title: {
      label: t('modal-default.key_81SKTaLP4RX4'),
      tip: t('modal-default.key_3b94ZDTzapFO')
    },
    propType: 'bool',
    defaultValue: true,
    setter: 'BoolSetter',
    supportVariable: true
  }, {
    name: 'maskClosable',
    title: {
      label: t('modal-default.key_93tyFSZbUyLO'),
      tip: t('modal-default.key_rT80Wcd8FKAB')
    },
    propType: 'bool',
    defaultValue: false,
    setter: 'BoolSetter',
    supportVariable: true
  }],
  configure: {
    component: {
      isContainer: true,
      isModal: true,
      rootSelector: '.modalDefaultBox',
      nestingRule: {
        parentWhitelist: ['Page', 'Component']
      }
    },
    supports: {
      events: false,
      style: true,
      "loop": false,
      "condition": false
    }
  }
};