import "../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                          */
/* empty css                                                              */
/* empty css                                                                    */
/* empty css                                                                     */
/* empty css                                                                  */
/* empty css                                                               */
/* empty css                                                            */
/* empty css                                                               */
/* empty css                                                                     */
/* empty css                                                               */
/* empty css                                                               */
import { computed, createElementBlock, openBlock, Fragment, createElementVNode, createVNode, withCtx, createTextVNode, unref, isRef } from "vue";
import { getEditConfigData } from "../utils/common.mjs";
import { useDataSourceDialog } from "../dataSource/useDataSourceDialog.mjs";
/* empty css                  */
import _export_sfc from "../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElSwitch } from "../../../../node_modules/element-plus/es/components/switch/index.mjs";
import { ElSelect, ElOption } from "../../../../node_modules/element-plus/es/components/select/index.mjs";
import { ElRadioGroup, ElRadioButton } from "../../../../node_modules/element-plus/es/components/radio/index.mjs";
const _hoisted_1 = { class: "form-setting" };
const _hoisted_2 = { class: "setting-left" };
const _hoisted_3 = { class: "setting-right" };
const _sfc_main = {
  __name: "formSetting",
  setup(__props) {
    const { dataSourceDialogVisible, DataSourceDialog } = useDataSourceDialog();
    const formConfig = computed(() => {
      const config = getEditConfigData();
      if (config.navigationEnabled ?? true) {
        config.navigationEnabled = true;
      }
      return config;
    });
    const dataSources = computed(() => {
      return formConfig.value.dataSources || [];
    });
    const selectedDataSource = computed({
      get: () => formConfig.value.dataSourceId,
      set: (val) => {
        formConfig.value.dataSourceId = val;
      }
    });
    computed(() => {
      if (!selectedDataSource.value) return "";
      const dataSource = dataSources.value.find(
        (ds) => ds.id === selectedDataSource.value
      );
      return dataSource ? dataSource.name : "";
    });
    computed(() => {
      return formConfig.value.validationRules || [];
    });
    return (_ctx, _cache) => {
      const _component_el_switch = ElSwitch;
      const _component_el_option = ElOption;
      const _component_el_select = ElSelect;
      const _component_el_radio_button = ElRadioButton;
      const _component_el_radio_group = ElRadioGroup;
      return openBlock(), createElementBlock(Fragment, null, [
        createElementVNode("div", _hoisted_1, [
          createElementVNode("div", _hoisted_2, [
            _cache[11] || (_cache[11] = createElementVNode("span", { class: "text-label" }, "启用导航", -1)),
            createVNode(_component_el_switch, {
              modelValue: formConfig.value.navigationEnabled,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formConfig.value.navigationEnabled = $event),
              size: "small"
            }, null, 8, ["modelValue"]),
            _cache[12] || (_cache[12] = createElementVNode("div", { class: "setting-divider" }, null, -1)),
            _cache[13] || (_cache[13] = createElementVNode("span", { class: "text-label" }, "列数", -1)),
            createVNode(_component_el_select, {
              modelValue: formConfig.value.columns,
              "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => formConfig.value.columns = $event),
              size: "small",
              style: { "width": "100px" }
            }, {
              default: withCtx(() => [
                createVNode(_component_el_option, {
                  label: "一列",
                  value: 1
                }),
                createVNode(_component_el_option, {
                  label: "二列",
                  value: 2
                }),
                createVNode(_component_el_option, {
                  label: "三列",
                  value: 3
                }),
                createVNode(_component_el_option, {
                  label: "四列",
                  value: 4
                })
              ]),
              _: 1
            }, 8, ["modelValue"]),
            _cache[14] || (_cache[14] = createElementVNode("div", { class: "setting-divider" }, null, -1)),
            _cache[15] || (_cache[15] = createElementVNode("span", { class: "text-label" }, "标签位置", -1)),
            createVNode(_component_el_radio_group, {
              modelValue: formConfig.value.labelPosition,
              "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => formConfig.value.labelPosition = $event),
              size: "small"
            }, {
              default: withCtx(() => [
                createVNode(_component_el_radio_button, { value: "left" }, {
                  default: withCtx(() => _cache[6] || (_cache[6] = [
                    createTextVNode("左对齐")
                  ])),
                  _: 1
                }),
                createVNode(_component_el_radio_button, { value: "right" }, {
                  default: withCtx(() => _cache[7] || (_cache[7] = [
                    createTextVNode("右对齐")
                  ])),
                  _: 1
                }),
                createVNode(_component_el_radio_button, { value: "top" }, {
                  default: withCtx(() => _cache[8] || (_cache[8] = [
                    createTextVNode("顶部对齐")
                  ])),
                  _: 1
                })
              ]),
              _: 1
            }, 8, ["modelValue"]),
            _cache[16] || (_cache[16] = createElementVNode("div", { class: "setting-divider" }, null, -1)),
            _cache[17] || (_cache[17] = createElementVNode("span", { class: "text-label" }, "表单模式", -1)),
            createVNode(_component_el_radio_group, {
              modelValue: formConfig.value.formMode,
              "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => formConfig.value.formMode = $event),
              size: "small"
            }, {
              default: withCtx(() => [
                createVNode(_component_el_radio_button, { value: "edit" }, {
                  default: withCtx(() => _cache[9] || (_cache[9] = [
                    createTextVNode("编辑")
                  ])),
                  _: 1
                }),
                createVNode(_component_el_radio_button, { value: "query" }, {
                  default: withCtx(() => _cache[10] || (_cache[10] = [
                    createTextVNode("查看")
                  ])),
                  _: 1
                })
              ]),
              _: 1
            }, 8, ["modelValue"])
          ]),
          createElementVNode("div", _hoisted_3, [
            _cache[18] || (_cache[18] = createElementVNode("span", { class: "text-label" }, "显示字段名", -1)),
            createVNode(_component_el_switch, {
              modelValue: formConfig.value.showFieldName,
              "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => formConfig.value.showFieldName = $event),
              size: "small"
            }, null, 8, ["modelValue"])
          ])
        ]),
        createVNode(unref(DataSourceDialog), {
          modelValue: unref(dataSourceDialogVisible),
          "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => isRef(dataSourceDialogVisible) ? dataSourceDialogVisible.value = $event : null)
        }, null, 8, ["modelValue"])
      ], 64);
    };
  }
};
const FormSetting = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-152eb837"]]);
export {
  FormSetting as default
};
