import { t } from "../../src/locale";
import loopData from "../_com-props/loopData";
import { CLoopDataSetter } from "../_setters";
import snippets from "./snippets";
import { DataSourceType } from "../_utils/formKeyType";
import { SchemaService } from "../_utils/schemaService";
import componentKey from "../_com-props/componentKey";
import componentName from "../_com-props/componentName";
import { groupModeType } from "../_setters/cGroupManage-setter/type";
var schemaService = new SchemaService();
export default {
  snippets: snippets,
  componentName: 'LoopBox',
  group: t('loop-box.key_s5YrGwKlmn9K'),
  title: t('loop-box.key_siQx85hXtMfC'),
  category: t('loop-box.key_bn4LnpfQBhcX'),
  props: [loopData, componentKey, componentName, {
    name: "moveUpChildrenStyle",
    title: {
      label: t("loop-box.key_s5YrGwKlmn1K"),
      tip: t("loop-box.key_s5YrGwKlmn2K")
    },
    propType: "bool",
    setter: "BoolSetter",
    defaultValue: false
  }, {
    name: "noWalletConnect",
    title: {
      label: t("loop-box.key_s5YrGwKlmn8K"),
      tip: t("loop-box.key_s5YrGwKlmn7K")
    },
    propType: "bool",
    setter: "BoolSetter",
    defaultValue: false
  }, {
    name: "hiddenScroll",
    title: {
      label: t('loop-box.hiddenScroll'),
      tip: t('loop-box.hiddenScroll')
    },
    setter: 'BoolSetter',
    defaultValue: false
  }, {
    name: 'mode',
    title: {
      label: t('loop-box.mode'),
      tip: t('loop-box.modeTip')
    },
    propType: {
      type: 'oneOf',
      value: [groupModeType.none, groupModeType.single, groupModeType.multipleChoice]
    },
    defaultValue: groupModeType.none,
    setter: [{
      componentName: 'RadioGroupSetter',
      props: {
        options: [{
          title: t('loop-box.none'),
          value: groupModeType.none
        }, {
          title: t('loop-box.single'),
          value: groupModeType.single
        }, {
          title: t('loop-box.multipleChoice'),
          value: groupModeType.multipleChoice
        }]
      }
    }, 'VariableSetter']
  }, {
    name: 'multipleNumber',
    title: {
      label: t('loop-box.multipleNumber'),
      tip: t('loop-box.multipleNumberTip')
    },
    setter: [{
      componentName: 'NumberSetter',
      initialValue: 10,
      props: {
        min: 0,
        placeholder: "请输入"
      }
    }],
    condition: function condition(target) {
      return target.getProps().getPropValue('mode') === groupModeType.multipleChoice;
    }
  }, {
    name: 'selectFirst',
    title: {
      label: t('loop-box.selectFirst'),
      tip: t('loop-box.selectFirstTip')
    },
    propType: 'bool',
    setter: 'BoolSetter',
    defaultValue: false,
    condition: function condition(target) {
      var mode = target.getProps().getPropValue('mode');
      return mode === groupModeType.multipleChoice || mode === groupModeType.single;
    }
  }, {
    name: 'dataSourceConfig',
    title: t('loop-box.key_PLbJownRQiBE'),
    display: 'accordion',
    setter: CLoopDataSetter,
    supportVariable: true
  }, {
    type: 'field',
    name: 'paginationProps',
    title: t('loop-box.key_nP1VFMVjGr9K'),
    condition: function condition(target) {
      var dataSourceConfig = target.getProps().getPropValue('dataSourceConfig');
      return dataSourceConfig && dataSourceConfig.type === DataSourceType.dataSourceType;
    },
    extraProps: {
      display: 'accordion',
      defaultCollapsed: true
    },
    setter: {
      componentName: 'ObjectSetter',
      display: 'inline',
      props: {
        config: {
          items: [{
            type: 'field',
            name: 'visible',
            title: t('loop-box.key_9Ko0HL10R0ac'),
            setter: [{
              componentName: 'RadioGroupSetter',
              props: {
                defaultValue: false,
                options: [{
                  label: t('loop-box.key_x6cA8g037R4i'),
                  value: false
                }, {
                  label: t('loop-box.key_56Q97e9u6U3z'),
                  value: 'page'
                }, {
                  label: t('loop-box.key_5r6542t5e3Q'),
                  value: 'foot'
                }]
              }
            }]
          }, {
            name: 'pageSize',
            title: t('loop-box.key_hS5USP97nIJw'),
            setter: [{
              componentName: 'NumberSetter',
              initialValue: 10,
              props: {
                min: 1
              }
            }]
          }, {
            name: 'size',
            title: t('loop-box.key_lXlsoPbI5NCH'),
            setter: [{
              componentName: 'SelectSetter',
              initialValue: "medium",
              props: {
                options: [{
                  title: 'small',
                  value: "small"
                }, {
                  title: 'medium',
                  value: 'medium'
                }, {
                  title: 'large',
                  value: 'large'
                }]
              }
            }],
            condition: function condition(target) {
              var paginationProps = target.getProps().getPropValue('paginationProps');
              return paginationProps.visible === 'page';
            }
          }, {
            name: 'type',
            title: t('loop-box.key_vDtn7DD6I0Im'),
            setter: [{
              componentName: 'SelectSetter',
              initialValue: "normal",
              props: {
                options: [{
                  title: 'normal',
                  value: 'normal'
                }, {
                  title: 'simple',
                  value: "simple"
                }, {
                  title: 'mini',
                  value: "mini"
                }]
              }
            }],
            condition: function condition(target) {
              var paginationProps = target.getProps().getPropValue('paginationProps');
              return paginationProps.visible === 'page';
            }
          }]
        }
      }
    }
  }, {
    type: 'field',
    name: 'paginationStyle',
    title: t('loop-box.key_jh7laTfw9qyG'),
    extraProps: {
      display: 'accordion',
      defaultCollapsed: true
    },
    condition: function condition(target) {
      var paginationProps = target.getProps().getPropValue('paginationProps');
      var dataSourceConfig = target.getProps().getPropValue('dataSourceConfig');
      return paginationProps.visible === 'page' && dataSourceConfig && dataSourceConfig.type === DataSourceType.dataSourceType;
    },
    setter: {
      componentName: 'ObjectSetter',
      display: 'inline',
      props: {
        config: {
          items: [{
            name: 'itemBg',
            title: {
              label: t('loop-box.key_V6nWBfpJMEOu'),
              tip: t('loop-box.key_eilnd7S8NwVq')
            },
            setter: 'ColorSetter'
          }, {
            name: 'itemBc',
            title: {
              label: t('loop-box.key_jomU17pshIdC'),
              tip: t('loop-box.key_HXRFoZC8jynH')
            },
            setter: 'ColorSetter'
          }, {
            name: 'itemText',
            title: {
              label: t('loop-box.key_4VkdQBRJgbta'),
              tip: t('loop-box.key_csSEyuLr7yMC')
            },
            setter: 'ColorSetter'
          }, {
            name: 'itemActiveBg',
            title: {
              label: t('loop-box.key_9ggfzlAaj6Lw'),
              tip: t('loop-box.key_nu3P44dXVW3E')
            },
            setter: 'ColorSetter'
          }, {
            name: 'itemActiveBc',
            title: {
              label: t('loop-box.key_p9ht6lQknozO'),
              tip: t('loop-box.key_kyDGloaHor5n')
            },
            setter: 'ColorSetter'
          }, {
            name: 'itemActiveText',
            title: {
              label: t('loop-box.key_E2grVtzHSHIq'),
              tip: t('loop-box.key_TI6BDsW0gMYb')
            },
            setter: 'ColorSetter'
          }]
        }
      }
    }
  }, {
    name: 'paginationBoxStyle',
    title: t('loop-box.key_H4vJ2CVaV5fi'),
    type: 'group',
    extraProps: {
      display: 'entry'
    },
    condition: function condition(target) {
      var paginationProps = target.getProps().getPropValue('paginationProps');
      var dataSourceConfig = target.getProps().getPropValue('dataSourceConfig');
      return paginationProps.visible === 'page' && dataSourceConfig && dataSourceConfig.type === DataSourceType.dataSourceType;
    },
    items: [{
      name: 'paginationBoxStyle',
      title: {
        label: t('loop-box.key_YioMrF8yW7JK'),
        tip: 'paginationBoxStyle | paginationBoxStyle'
      },
      setter: 'CStyleSetter',
      extraProps: {
        display: 'block'
      }
    }]
  }, {
    name: 'noDataContent',
    title: {
      label: t('loop-box.noDataContext'),
      tip: t('loop-box.noDataContext')
    },
    isRequired: true,
    propType: 'string',
    setter: 'StringSetter',
    defaultValue: function defaultValue() {
      return "No Data";
    },
    supportVariable: false
  }, {
    name: 'noDataContentBoxStyle',
    title: t('loop-box.noDataContextBoxStyle'),
    type: 'group',
    extraProps: {
      display: 'entry'
    },
    items: [{
      name: 'noDataContentBoxStyle',
      title: {
        label: t('loop-box.noDataContextBoxStyle'),
        tip: 'noDataContextBoxStyle | noDataContextBoxStyle'
      },
      setter: 'CStyleSetter',
      extraProps: {
        display: 'block'
      }
    }]
  }],
  configure: {
    component: {
      isContainer: true
    },
    supports: {
      events: false,
      style: true,
      "loop": false,
      "condition": false
    },
    advanced: {
      callbacks: {
        // onNodeAdd: (dragNode: any, currentNode: any) => {
        //   setTimeout(() => {
        //     schemaService.handleLoopBoxComponent(dragNode, currentNode)
        //   }, 1)
        // },
      }
    }
  }
};