@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>
86 lines (85 loc) • 2.84 kB
JavaScript
import { defineComponent, toRef, createVNode, mergeProps, isVNode } from "vue";
import { Layout, Pagination } from "@arco-design/web-vue";
import { useProPagination } from "@vrx-arco/use";
import { style } from "../style/var.mjs";
import { proPaginationProps } from "./props.mjs";
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: {
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
currentChange: (current) => true,
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
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 () => {
var _a, _b;
const slotsHeader = (_a = slots.header) == null ? void 0 : _a.call(slots);
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: () => {
var _a2;
return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots, 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": (current2) => {
pageChange(current2);
emit("currentChange", current2);
},
"onPageSizeChange": (pageSize2) => {
pageSizeChange(pageSize2);
emit("pageSizeChange", pageSize2);
}
}), null)]
})]
}) : createVNode("div", {
"class": bemClass()
}, [(_b = slots.default) == null ? void 0 : _b.call(slots, list.value)]);
};
}
});
export {
ProPagination
};