UNPKG

yuang-framework-ui-pc

Version:

yuang-framework-ui-pc Library

98 lines (97 loc) 3.58 kB
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeClass, createSlots, renderList, withCtx, renderSlot, normalizeProps, guardReactiveProps } from "vue"; import { ElPagination } from "element-plus"; import { paginationProps, paginationEmits } from "./props"; const _sfc_main = defineComponent({ name: "ElePagination", components: { ElPagination }, props: paginationProps, emits: paginationEmits, setup(props, { emit }) { const isInfinite = computed(() => "*" === props.total); const pageTotal = computed(() => { if (isInfinite.value) { if (props.hasNext) { return Number.MAX_SAFE_INTEGER; } return (props.currentPage || 1) * (props.pageSize || 10); } const num = props.total == null ? void 0 : Number(props.total); return num == null || isNaN(num) ? void 0 : num; }); const sizesPopperClass = computed(() => { const classes = ["ele-pagination-popper"]; if (props.isFixedPopper) { classes.push("is-fixed"); } if (typeof props.popperClass === "string" && props.popperClass) { classes.push(props.popperClass); } return classes.join(" "); }); const handleUpdateCurrentPage = (currentPage) => { emit("update:currentPage", currentPage); }; const handleUpdatePageSize = (pageSize) => { emit("update:pageSize", pageSize); }; return { isInfinite, pageTotal, sizesPopperClass, handleUpdateCurrentPage, handleUpdatePageSize }; } }); const _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_ElPagination = resolveComponent("ElPagination"); return openBlock(), createBlock(_component_ElPagination, { small: _ctx.small, size: _ctx.size, background: _ctx.type === "circle" ? false : _ctx.background, pageSize: _ctx.pageSize, defaultPageSize: _ctx.defaultPageSize, total: _ctx.pageTotal, pageCount: _ctx.pageCount, pagerCount: _ctx.pagerCount, currentPage: _ctx.currentPage, defaultCurrentPage: _ctx.defaultCurrentPage, layout: _ctx.layout, pageSizes: _ctx.pageSizes, popperClass: _ctx.sizesPopperClass, prevText: _ctx.prevText, prevIcon: _ctx.prevIcon, nextText: _ctx.nextText, nextIcon: _ctx.nextIcon, disabled: _ctx.disabled, teleported: _ctx.teleported, hideOnSinglePage: _ctx.hideOnSinglePage, class: normalizeClass([ "ele-pagination", { "is-circle": _ctx.type === "circle" }, { "is-infinite": _ctx.isInfinite } ]), "onUpdate:currentPage": _ctx.handleUpdateCurrentPage, "onUpdate:pageSize": _ctx.handleUpdatePageSize }, createSlots({ _: 2 }, [ renderList(Object.keys(_ctx.$slots), (name) => { return { name, fn: withCtx((slotProps) => [ renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps || {}))) ]) }; }) ]), 1032, ["small", "size", "background", "pageSize", "defaultPageSize", "total", "pageCount", "pagerCount", "currentPage", "defaultCurrentPage", "layout", "pageSizes", "popperClass", "prevText", "prevIcon", "nextText", "nextIcon", "disabled", "teleported", "hideOnSinglePage", "class", "onUpdate:currentPage", "onUpdate:pageSize"]); } const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { index as default };