import { t } from "../../src/locale";
import snippets from "./snippets";
import { CComputedSetter } from "../_setters";
import { ConditionRenderService } from "../_utils/conditionRenderService";
import componentKey from "../_com-props/componentKey";
import componentName from "../_com-props/componentName";
export default {
  componentName: "Progress",
  label: t("progress.key_BZW9haNv6fsV"),
  group: t("progress.key_BZW9haNv6fsV"),
  category: "Element",
  props: [componentKey, componentName, {
    name: "percent",
    title: {
      label: t("progress.key_BZW9haNv6ftrc"),
      tip: t("progress.key_l3WSkTFaxqjba")
    },
    propType: "string",
    setter: {
      componentName: "NumberSetter",
      props: {
        precision: 2
      }
    },
    defaultValue: "30"
  }, {
    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("percent", exp);
        }
      }
    }
  }, {
    name: "type",
    title: {
      label: t("progress.key_BZW9haNv6fsc"),
      tip: t("progress.key_l3WSkTFaxqjaC")
    },
    propType: {
      type: "oneOf",
      value: ["line", "circle", "dashboard"]
    },
    setter: [{
      componentName: "RadioGroupSetter",
      props: {
        options: [{
          title: t("line"),
          value: "line"
        }, {
          title: t("circle"),
          value: "circle"
        }, {
          title: t("dashboard"),
          value: "dashboard"
        }]
      }
    }, "VariableSetter"],
    extraProps: {
      setValue: function setValue(target, value) {
        if (value !== undefined && value !== "" && value !== "line") {
          target.parent.setPropValue("vertical", "right");
        }
      }
    },
    defaultValue: "line"
  }, {
    name: "vertical",
    title: {
      label: t("progress.key_BZW9hvertical"),
      tip: t("progress.key_BZverticaltip")
    },
    propType: {
      type: "oneOf",
      value: ["top", "bottom", "left", "right"]
    },
    setter: [{
      componentName: "RadioGroupSetter",
      props: {
        options: [{
          title: t("top"),
          value: "top"
        }, {
          title: t("bottom"),
          value: "bottom"
        }, {
          title: t("left"),
          value: "left"
        }, {
          title: t("right"),
          value: "right"
        }]
      }
    }, "VariableSetter"],
    condition: function condition(target) {
      var type = target.parent.getPropValue("type");
      return type === "line";
    },
    defaultValue: "right"
  }, {
    name: "trailStyle",
    title: t("progress.key_BZW9haNv6fshs"),
    type: "group",
    extraProps: {
      display: "entry"
    },
    items: [{
      name: "trailStyle",
      title: {
        label: t("progress.key_BZW9haNv6fshs"),
        tip: t("progress.key_l3WSkTFaxqjaA")
      },
      setter: "CStyleSetter",
      extraProps: {
        display: "block"
      }
    }],
    defaultValue: {
      backgroundColor: "#F5F5F5"
    }
  }, {
    name: "strokeStyle",
    title: t("progress.key_BZW9haNv6fsb"),
    type: "group",
    extraProps: {
      display: "entry"
    },
    items: [{
      name: "strokeStyle",
      title: {
        label: t("progress.key_BZW9haNv6fsb"),
        tip: t("progress.key_l3WSkTFaxqjaB")
      },
      setter: "CStyleSetter",
      extraProps: {
        display: "block"
      }
    }]
  }, {
    name: "textStyle",
    title: t("progress.key_BZW9haNv6ftba"),
    type: "group",
    extraProps: {
      display: "entry"
    },
    items: [{
      name: "textStyle",
      title: {
        label: t("progress.key_BZW9haNv6ftba"),
        tip: t("progress.key_l3WSkTFaxqjad")
      },
      setter: "CStyleSetter",
      extraProps: {
        display: "block"
      }
    }]
  }],
  configure: {
    supports: {
      events: false,
      style: true,
      loop: false,
      condition: false
    }
  },
  snippets: snippets
};