@seemusic/ui-components
Version:
A Vue 3 UI Library. Uses Composable.
78 lines (77 loc) • 2.09 kB
JavaScript
import { defineComponent, toRefs, createVNode, mergeProps, isVNode } from "vue";
import { ElPagination } from "element-plus";
import { useLocale } from "../../composables/useLocale.mjs";
function _isSlot(s) {
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
const SopPagination = /* @__PURE__ */ defineComponent({
name: "SopPagination",
components: {
ElPagination
},
props: {
currentPage: {
type: Number,
default: 1
},
pageSize: {
type: Number,
default: 20
},
total: {
type: Number,
default: 0
}
},
emits: ["current-change", "size-change", "update:current-page", "update:page-size"],
setup(props, {
attrs,
emit,
slots
}) {
const {
t
} = useLocale();
const {
currentPage,
pageSize,
total
} = toRefs(props);
function renderSlots() {
if (typeof slots.default === "function") {
return {
default: () => {
var _a;
return (_a = slots.default) == null ? void 0 : _a.call(slots);
}
};
}
return {
default: () => createVNode("span", {
"class": "el-pagination__text"
}, [t("sop.pagination.total", {
total: total.value
})])
};
}
return () => {
let _slot;
return createVNode(ElPagination, mergeProps({
"currentPage": currentPage.value,
"pageSize": pageSize.value,
"onUpdate:current-page": (page) => emit("update:current-page", page),
"onUpdate:page-size": (size) => emit("update:page-size", size),
"layout": "slot, prev, pager, next, jumper, sizes",
"total": props.total,
"onSize-change": (sizeNum) => emit("size-change", sizeNum),
"onCurrent-change": (pageNum) => emit("current-change", pageNum)
}, attrs), _isSlot(_slot = renderSlots()) ? _slot : {
default: () => [_slot]
});
};
}
});
export {
SopPagination as default
};
//# sourceMappingURL=SopPagination.mjs.map