"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _locale = require("../../src/locale");
var _snippets = _interopRequireDefault(require("./snippets"));
var _getRowInitChildrenByColNumber = require("../_com-props/getRowInitChildrenByColNumber");
var _loopData = _interopRequireDefault(require("../_com-props/loopData"));
var _default = exports["default"] = {
  snippets: _snippets["default"],
  componentName: 'Row',
  "group": (0, _locale.t)('gridRow.key_fNHoMV6X2eBP'),
  title: (0, _locale.t)('gridRow.key_xnexalZpHVYs'),
  category: (0, _locale.t)('gridRow.key_tUXz9lZdYQqE'),
  props: [_loopData["default"], {
    name: 'fold',
    title: {
      label: (0, _locale.t)('gridRow.key_eghxHsYQ2UTG'),
      tip: (0, _locale.t)('gridRow.key_eghxHsYQ3UTG')
    },
    propType: 'bool',
    defaultValue: false,
    extraProps: {
      setValue: function setValue(target, value) {
        if (value) {
          target.parent.setPropValue('activeIndex', 0);
        }
      }
    }
  }, {
    name: 'activeIndex',
    title: {
      label: (0, _locale.t)('gridRow.key_eghxHsYQ4UTG'),
      tip: (0, _locale.t)('gridRow.key_eghxHsYQ5UTG')
    },
    defaultValue: 0,
    setter: {
      componentName: 'SelectSetter',
      props: {
        options: []
      }
    },
    extraProps: {
      getValue: function getValue(target, value) {
        var childRenNameList = target.node.children.map(function (item, index) {
          return {
            title: item.propsData.componentName || "col_" + index,
            key: item.propsData.componentKey,
            value: index
          };
        }) || [];
        target.setter.props.options = childRenNameList;
        return value || 0;
      }
    },
    condition: function condition(target) {
      return target.parent.getPropValue('fold');
    }
  }, {
    name: 'align',
    title: {
      label: (0, _locale.t)('gridRow.key_6dtOHABw8kxj'),
      tip: (0, _locale.t)('gridRow.key_wwYlJllNltIp')
    },
    propType: {
      type: 'oneOf',
      value: ['top', 'middle', 'bottom']
    }
  }, {
    name: 'h-gutter',
    title: {
      label: (0, _locale.t)('gridRow.key_eghxHsYQ1UTG'),
      tip: (0, _locale.t)('gridRow.key_kU6aNo9RIWuc')
    },
    propType: 'number',
    setter: {
      componentName: 'NumberSetter',
      props: {
        min: 0
      }
    },
    defaultValue: 0,
    extraProps: {
      getValue: function getValue(target) {
        var node = target.node;
        var gutter = node.getPropValue('gutter');
        if (typeof gutter === 'number') {
          return gutter;
        } else if (Array.isArray(gutter)) {
          return gutter[0];
        }
        return 0;
      },
      setValue: function setValue(target, value) {
        var node = target.node;
        var gutter = node.getPropValue('gutter');
        if (Array.isArray(gutter)) {
          gutter[0] = value;
          node.setPropValue('gutter', gutter);
        } else {
          node.setPropValue('gutter', [value, 0]);
        }
      }
    }
  }, {
    name: 'v-gutter',
    title: {
      label: (0, _locale.t)('gridRow.key_0rL2khJGxyAr'),
      tip: (0, _locale.t)('gridRow.key_21oMUXzzR4Me')
    },
    propType: 'number',
    setter: {
      componentName: 'NumberSetter',
      props: {
        min: 0
      }
    },
    defaultValue: 0,
    extraProps: {
      getValue: function getValue(target) {
        var node = target.node;
        var gutter = node.getPropValue('gutter');
        if (typeof gutter === 'number') {
          return 0;
        } else if (Array.isArray(gutter)) {
          return gutter[1];
        }
        return 0;
      },
      setValue: function setValue(target, value) {
        var node = target.node;
        var gutter = node.getPropValue('gutter');
        if (Array.isArray(gutter)) {
          gutter[1] = value;
          node.setPropValue('gutter', gutter);
        } else {
          node.setPropValue('gutter', [gutter, value]);
        }
      }
    }
  }, {
    name: 'justify',
    title: {
      label: (0, _locale.t)('gridRow.key_RFFQIZhoOIbf'),
      tip: (0, _locale.t)('gridRow.key_6urKg3LUUSYa')
    },
    propType: {
      type: 'oneOf',
      value: ['start', 'end', 'center', 'space-around', 'space-between']
    }
  }, {
    name: 'wrap',
    title: {
      label: (0, _locale.t)('gridRow.key_FAr6jUiyP7z3'),
      tip: (0, _locale.t)('gridRow.key_tcUnf2iinPga')
    },
    propType: 'bool',
    defaultValue: true
  }, {
    name: 'styleWebOS',
    title: {
      label: (0, _locale.t)('gridRow.key_FAr6jUiyP7z4'),
      tip: (0, _locale.t)('gridRow.key_tcUnf2iinPgb')
    },
    propType: 'bool',
    setter: "BoolSetter",
    defaultValue: false
  }],
  configure: {
    component: {
      isContainer: true,
      nestingRule: {
        childWhitelist: ['Col']
      }
    },
    supports: {
      events: false,
      style: true,
      loop: false,
      condition: false
    },
    advanced: {
      initialChildren: function initialChildren(target) {
        var colNum = target.propsData.colNum || 2;
        return (0, _getRowInitChildrenByColNumber.getRowInitChildrenByColNumber)(colNum);
      }
    }
  }
};