vue-admin-core
Version:
A Component Library for Vue 3
32 lines (29 loc) • 786 B
JavaScript
import { computed, toRefs } from 'vue';
import { pick } from 'lodash-es';
import { ElPagination } from 'element-plus';
const usePagination = (props, { attrs }, {
currentPage
}) => {
const pageCount = computed(() => {
if (props.total) {
return Math.ceil(props.total / (props.pageSize || 10));
}
return 1;
});
const result = {
...pick(toRefs(props), Object.keys(ElPagination.props)),
currentPage,
small: true,
pageCount,
layout: "total, prev, pager, next",
hideOnSinglePage: true,
onCurrentChange: (value) => {
var _a;
currentPage.value = value;
(_a = attrs.onCurrentChange) == null ? void 0 : _a.call(attrs, value);
}
};
return result;
};
export { usePagination };
//# sourceMappingURL=pagination.mjs.map