"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _snippets = _interopRequireDefault(require("./snippets.design"));
var _adaptor = require("./adaptor");
var _default = {
  group: '原子组件',
  componentName: 'Step',
  title: '步骤条',
  docUrl: '',
  screenshot: '',
  npm: {
    "package": '@alilc/lowcode-materials',
    version: '{{version}}',
    exportName: 'Step',
    main: '',
    destructuring: true,
    subName: ''
  },
  props: [{
    name: 'prefix',
    propType: 'string',
    defaultValue: 'next-'
  }, {
    name: 'rtl',
    propType: 'bool'
  }, {
    name: 'current',
    propType: 'number',
    description: '当前步骤',
    defaultValue: 0
  }, {
    name: 'direction',
    propType: {
      type: 'oneOf',
      value: ['hoz', 'ver']
    },
    description: '展示方向',
    defaultValue: 'hoz'
  }, {
    name: 'labelPlacement',
    propType: {
      type: 'oneOf',
      value: ['hoz', 'ver']
    },
    description: '横向布局时( direction 为 hoz )的内容排列',
    defaultValue: 'ver'
  }, {
    name: 'shape',
    propType: {
      type: 'oneOf',
      value: ['circle', 'arrow', 'dot']
    },
    description: '类型',
    defaultValue: 'circle'
  }, {
    name: 'readOnly',
    propType: 'bool',
    description: '是否只读模式'
  }, {
    name: 'animation',
    propType: 'bool',
    description: '是否开启动效',
    defaultValue: true
  }, {
    name: 'className',
    propType: 'string',
    description: '自定义样式名'
  }, {
    name: 'style',
    propType: 'object'
  }],
  configure: {
    component: {
      isContainer: true,
      isMinimalRenderUnit: true
    },
    props: [{
      name: 'shape',
      setter: {
        componentName: 'RadioGroupSetter',
        props: {
          options: [{
            label: '圆圈',
            value: 'circle'
          }, {
            label: '箭头',
            value: 'arrow'
          }, {
            label: '点',
            value: 'dot'
          }]
        }
      },
      title: '类型',
      defaultValue: 'circle',
      setValue: function setValue(target, value) {
        if (value === 'dot') {
          var _target$parent, _target$parent$setPro;
          target === null || target === void 0 ? void 0 : (_target$parent = target.parent) === null || _target$parent === void 0 ? void 0 : (_target$parent$setPro = _target$parent.setPropValue) === null || _target$parent$setPro === void 0 ? void 0 : _target$parent$setPro.call(_target$parent, 'labelPlacement', 'ver');
        }
      }
    }, {
      name: 'direction',
      setter: {
        componentName: 'RadioGroupSetter',
        props: {
          options: [{
            label: '水平',
            value: 'hoz'
          }, {
            label: '垂直',
            value: 'ver'
          }]
        }
      },
      title: '方向',
      defaultValue: 'hoz',
      condition: function condition(target) {
        var _target$parent2, _target$parent2$getPr;
        return (target === null || target === void 0 ? void 0 : (_target$parent2 = target.parent) === null || _target$parent2 === void 0 ? void 0 : (_target$parent2$getPr = _target$parent2.getPropValue) === null || _target$parent2$getPr === void 0 ? void 0 : _target$parent2$getPr.call(_target$parent2, 'shape')) !== 'arrow';
      }
    }, {
      name: 'labelPlacement',
      setter: {
        componentName: 'RadioGroupSetter',
        props: {
          options: [{
            label: '右侧',
            value: 'hoz'
          }, {
            label: '底侧',
            value: 'ver'
          }]
        }
      },
      title: '内容位置',
      defaultValue: 'ver',
      condition: function condition(target) {
        var _target$parent3, _target$parent3$getPr;
        return (target === null || target === void 0 ? void 0 : (_target$parent3 = target.parent) === null || _target$parent3 === void 0 ? void 0 : (_target$parent3$getPr = _target$parent3.getPropValue) === null || _target$parent3$getPr === void 0 ? void 0 : _target$parent3$getPr.call(_target$parent3, 'shape')) === 'circle';
      }
    }, {
      name: 'style.width',
      title: '宽度',
      condition: function condition(target) {
        var _target$parent4, _target$parent4$getPr;
        return (target === null || target === void 0 ? void 0 : (_target$parent4 = target.parent) === null || _target$parent4 === void 0 ? void 0 : (_target$parent4$getPr = _target$parent4.getPropValue) === null || _target$parent4$getPr === void 0 ? void 0 : _target$parent4$getPr.call(_target$parent4, 'direction')) !== 'ver';
      },
      setter: 'NumberSetter'
    },
    // {
    //   name: 'style.height',
    //   title: '高度',
    //   setter: 'NumberSetter'
    // },
    {
      name: 'plainData',
      display: 'block',
      title: '内容',
      setValue: function setValue(target, value) {
        var _getDataFromPlainText = (0, _adaptor.getDataFromPlainText)(value),
          children = _getDataFromPlainText.children,
          current = _getDataFromPlainText.current;
        if (children) {
          var map = {};
          children.forEach(function (item) {
            var props = item.props;
            map[props.key] = props;
          });
          // target.parent.setPropValue('children', children);
          var _children = target.node["export"]().children;
          target.node.children.mergeChildren(function (child) {
            var primaryKey = String(child.getPropValue('key'));
            return Object.hasOwnProperty.call(map, primaryKey);
          }, function () {
            var items = [];
            var _loop = function _loop(key) {
              var originChild = _children.find(function (child) {
                var found = child.props.key === key;
                return found;
              }) || {
                children: []
              };
              if (Object.hasOwnProperty.call(map, key)) {
                items.push({
                  componentName: 'Step.Item',
                  props: map[key],
                  children: originChild.children
                });
              }
            };
            for (var key in map) {
              _loop(key);
            }
            return items;
          }, function (child1, child2) {
            var a = children.findIndex(function (item) {
              return String(item.props.key) === String(child1.getPropValue('key'));
            });
            var b = children.findIndex(function (item) {
              return String(item.props.key) === String(child2.getPropValue('key'));
            });
            return a - b;
          });
        }
        if (typeof current !== 'undefined') {
          target.parent.setPropValue('current', current);
        }
      },
      setter: {
        componentName: 'MagicEditorSetter',
        props: {
          toolbar: ['normal', 'active', 'disable']
        }
      }
    }]
  },
  icon: '',
  category: '导航',
  snippets: _snippets["default"]
};
exports["default"] = _default;