"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _input = _interopRequireDefault(require("@alifd/next/lib/input"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _switch = _interopRequireDefault(require("@alifd/next/lib/switch"));
var _react = _interopRequireWildcard(require("react"));
var _lowcodeEngineExt = _interopRequireDefault(require("@alilc/lowcode-engine-ext"));
var _type = require("../cDataSource-setter/type");
var _boxSlotComponent = _interopRequireDefault(require("./boxSlotComponent"));
var _boxGroup = _interopRequireDefault(require("./boxGroup"));
var _locale = require("../../../src/locale");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
var ColorSetter = _lowcodeEngineExt["default"].setters.ColorSetter;
var selectArr = [{
  label: (0, _locale.t)("setter.loadDefault"),
  value: _type.LoadingConfigOpenMode["default"]
}, {
  label: (0, _locale.t)("setter.loadCustom"),
  value: _type.LoadingConfigOpenMode.custom
}];
var CLoadingConfigSetter = function CLoadingConfigSetter(props) {
  var value = props.value,
    onChange = props.onChange;
  var _useState = (0, _react.useState)(value.openType || false),
    openType = _useState[0],
    setOpenType = _useState[1];
  var _useState2 = (0, _react.useState)(value.openMode || _type.LoadingConfigOpenMode["default"]),
    openMode = _useState2[0],
    setOpenMode = _useState2[1];
  var _useState3 = (0, _react.useState)(value.defaultConfig || {
      loadText: "loading...",
      loadColor: "#03c1fd",
      loadBgColor: "#fff",
      loadBgOverlay: "rgba(122, 122, 122, 0.8)"
    }),
    defaultConfig = _useState3[0],
    setDefaultConfig = _useState3[1];
  (0, _react.useEffect)(function () {
    onChange({
      openType: openType,
      openMode: openMode,
      defaultConfig: defaultConfig
    });
  }, [openType, openMode, defaultConfig]);
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "cLoadingConfigSetter-box"
  }, /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("setter.openLoad")
  }, /*#__PURE__*/_react["default"].createElement(_switch["default"], {
    checked: openType,
    onChange: function onChange(v) {
      setOpenType(v);
    }
  })), openType && /*#__PURE__*/_react["default"].createElement(_boxGroup["default"], {
    title: (0, _locale.t)("setter.openMode"),
    value: openMode,
    groupList: selectArr,
    onChange: function onChange(e) {
      setOpenMode(e);
    }
  }), openType && openMode === _type.LoadingConfigOpenMode["default"] && /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("setter.tipText")
  }, /*#__PURE__*/_react["default"].createElement(_input["default"], {
    style: {
      width: "100%"
    },
    name: "urlData",
    placeholder: (0, _locale.t)("setter.inputPlaceHolder"),
    value: defaultConfig.loadText,
    onChange: function onChange(e) {
      setDefaultConfig((0, _extends2["default"])({}, defaultConfig, {
        loadText: e
      }));
    }
  })), openType && openMode === _type.LoadingConfigOpenMode["default"] && /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("setter.tipColor")
  }, /*#__PURE__*/_react["default"].createElement(ColorSetter, {
    value: defaultConfig.loadColor,
    onChange: function onChange(v) {
      setDefaultConfig((0, _extends2["default"])({}, defaultConfig, {
        loadColor: v
      }));
    }
  })), openType && openMode === _type.LoadingConfigOpenMode["default"] && /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("setter.tipBgColor")
  }, /*#__PURE__*/_react["default"].createElement(ColorSetter, {
    value: defaultConfig.loadBgColor,
    onChange: function onChange(v) {
      setDefaultConfig((0, _extends2["default"])({}, defaultConfig, {
        loadBgColor: v
      }));
    }
  })), openType && openMode === _type.LoadingConfigOpenMode["default"] && /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("setter.tipOverlay")
  }, /*#__PURE__*/_react["default"].createElement(ColorSetter, {
    value: defaultConfig.loadBgOverlay,
    onChange: function onChange(v) {
      setDefaultConfig((0, _extends2["default"])({}, defaultConfig, {
        loadBgOverlay: v
      }));
    }
  })), openType && openMode === _type.LoadingConfigOpenMode.custom && /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("setter.selectDialog")
  }, (0, _locale.t)("setter.undeveloped")));
};
var _default = exports["default"] = /*#__PURE__*/function (_Component) {
  function _default() {
    return _Component.apply(this, arguments) || this;
  }
  (0, _inheritsLoose2["default"])(_default, _Component);
  var _proto = _default.prototype;
  _proto.render = function render() {
    return /*#__PURE__*/_react["default"].createElement(CLoadingConfigSetter, this.props);
  };
  return _default;
}(_react.Component);