@vrx-arco/pro-components
Version:
<p align="center"> <img src="https://vrx-arco.github.io/arco-design-pro/favicon.svg" width="200" height="250"> </p>
50 lines (49 loc) • 2.14 kB
JavaScript
import { style } from "../style/var.js";
import { proPaginationProps } from "./props.js";
import { createVNode, defineComponent, isVNode, mergeProps, toRef } from "vue";
import { Layout, Pagination } from "@arco-design/web-vue";
import { useProPagination } from "@vrx-arco/use";
function _isSlot(s) {
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
const ProPagination = /* @__PURE__ */ defineComponent({
name: "vrx-arco-pro-pagination",
props: proPaginationProps(),
emits: {
currentChange: (current) => true,
pageSizeChange: (pageSize) => true
},
setup: (props, { emit, slots }) => {
const { bemClass } = style("pro-pagination");
const data = toRef(props, "data");
const pagination = toRef(props, "pagination");
const paginationProps = toRef(props, "paginationProps");
const { total, current, pageSize, data: list, pageChange, pageSizeChange } = useProPagination(data, pagination, paginationProps);
return () => {
const slotsHeader = slots.header?.();
return pagination.value ? createVNode(Layout, { "class": bemClass() }, { default: () => [
slotsHeader && createVNode(Layout.Header, { "class": bemClass("__header") }, _isSlot(slotsHeader) ? slotsHeader : { default: () => [slotsHeader] }),
createVNode(Layout.Content, { "class": bemClass("__content") }, { default: () => [slots.default?.(list.value)] }),
createVNode(Layout.Footer, { "class": bemClass("__footer") }, { default: () => [createVNode(Pagination, mergeProps({
"class": bemClass("__pagination"),
"showTotal": true,
"showPageSize": true,
"showJumper": true
}, paginationProps.value, {
"total": total.value,
"current": current.value,
"pageSize": pageSize.value,
"onChange": (current$1) => {
pageChange(current$1);
emit("currentChange", current$1);
},
"onPageSizeChange": (pageSize$1) => {
pageSizeChange(pageSize$1);
emit("pageSizeChange", pageSize$1);
}
}), null)] })
] }) : createVNode("div", { "class": bemClass() }, [slots.default?.(list.value)]);
};
}
});
export { ProPagination };