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, reactive, watch, ref, createElementBlock, openBlock, createElementVNode, createVNode, withCtx, normalizeClass, createBlock, createCommentVNode, unref, toDisplayString, nextTick } from "vue";
import { getEditConfigData } from "../utils/common.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 { ElDivider } from "../../../../node_modules/element-plus/es/components/divider/index.mjs";
import { ElSelect, ElOption } from "../../../../node_modules/element-plus/es/components/select/index.mjs";
import { ElPagination } from "../../../../node_modules/element-plus/es/components/pagination/index.mjs";
const _hoisted_1 = { class: "table-pagination-config" };
const _hoisted_2 = { class: "config-row" };
const _hoisted_3 = {
  key: 0,
  class: "page-slot"
};
const _sfc_main = {
  __name: "tablePagination",
  setup(__props) {
    var _a;
    const editConfigData = computed(() => getEditConfigData());
    const paginationConfig = reactive({
      enabled: true,
      pageSize: 15,
      pageSizes: [15, 20, 50, 100, 200, 500],
      layout: "full",
      background: true,
      size: "small",
      ...((_a = editConfigData.value) == null ? void 0 : _a.paginationConfig) || {}
    });
    watch(
      paginationConfig,
      (val) => {
        editConfigData.value.paginationConfig = val;
      },
      { deep: true }
    );
    const layoutMap = {
      simple: "->,prev, pager, next",
      standard: "total, ->, prev, pager, next, jumper",
      full: "total, slot, ->,sizes, prev, pager, next, jumper"
    };
    function getLayout(layout) {
      return layoutMap[layout] || layoutMap.full;
    }
    const showPagination = ref(true);
    function pageSizeChange() {
      showPagination.value = false;
      nextTick(() => {
        showPagination.value = true;
      });
    }
    return (_ctx, _cache) => {
      const _component_el_switch = ElSwitch;
      const _component_el_divider = ElDivider;
      const _component_el_option = ElOption;
      const _component_el_select = ElSelect;
      const _component_el_pagination = ElPagination;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          _cache[2] || (_cache[2] = createElementVNode("span", { class: "config-label" }, "开启分页:", -1)),
          createVNode(_component_el_switch, {
            modelValue: paginationConfig.enabled,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => paginationConfig.enabled = $event),
            size: "small"
          }, null, 8, ["modelValue"]),
          createVNode(_component_el_divider, { direction: "vertical" }),
          _cache[3] || (_cache[3] = createElementVNode("span", { class: "config-label" }, "每页条数:", -1)),
          createVNode(_component_el_select, {
            modelValue: paginationConfig.pageSize,
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => paginationConfig.pageSize = $event),
            size: "small",
            style: { "width": "100px" },
            onChange: pageSizeChange
          }, {
            default: withCtx(() => [
              createVNode(_component_el_option, {
                label: "15",
                value: 15
              }),
              createVNode(_component_el_option, {
                label: "20",
                value: 20
              }),
              createVNode(_component_el_option, {
                label: "50",
                value: 50
              }),
              createVNode(_component_el_option, {
                label: "100",
                value: 100
              }),
              createVNode(_component_el_option, {
                label: "200",
                value: 200
              }),
              createVNode(_component_el_option, {
                label: "500",
                value: 500
              })
            ]),
            _: 1
          }, 8, ["modelValue"])
        ]),
        createElementVNode("div", {
          class: normalizeClass(["preview-section", { disabled: !paginationConfig.enabled }])
        }, [
          unref(showPagination) ? (openBlock(), createBlock(_component_el_pagination, {
            key: 0,
            style: { "width": "100%" },
            "page-sizes": [15, 20, 50, 100, 200, 500],
            "default-page-size": paginationConfig.pageSize,
            layout: getLayout(paginationConfig.layout),
            total: 100,
            background: paginationConfig.background,
            size: paginationConfig.size === "default" ? "" : paginationConfig.size,
            disabled: !paginationConfig.enabled
          }, {
            default: withCtx(() => [
              getLayout(paginationConfig.layout).includes("slot") ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(1) + "/" + toDisplayString(Math.ceil(100 / paginationConfig.pageSize)) + "页 ", 1)) : createCommentVNode("", true)
            ]),
            _: 1
          }, 8, ["default-page-size", "layout", "background", "size", "disabled"])) : createCommentVNode("", true)
        ], 2)
      ]);
    };
  }
};
const TablePagination = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-12c51ab8"]]);
export {
  TablePagination as default
};
