UNPKG

tav-ui

Version:
69 lines (64 loc) 2.07 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); require('../../../../locales/index2.js'); var is = require('../../../../utils/is2.js'); var _const = require('../const2.js'); var transfer = require('../../../../locales/transfer2.js'); function itemRender({ page, type, originalElement }) { if (type === "prev") { return transfer.tavI18n("Tav.tablePro.page.1"); } else if (type === "next") { return transfer.tavI18n("Tav.tablePro.page.2"); } return originalElement; } function usePagination(refProps) { const configRef = vue.ref({}); const show = vue.ref(true); vue.watch(() => vue.unref(refProps).pagination, (pagination) => { if (!is.isBoolean(pagination) && pagination) { configRef.value = { ...vue.unref(configRef), ...pagination ?? {} }; } }); const getPaginationInfo = vue.computed(() => { const { pagination } = vue.unref(refProps); if (!vue.unref(show) || is.isBoolean(pagination) && !pagination) { return false; } return { current: 1, pageSize: _const.PAGE_SIZE, size: "small", defaultPageSize: _const.PAGE_SIZE, showTotal: (total) => "\u5171 {total} \u6761\u6570\u636E".replace("{total}", `${total}`), showSizeChanger: true, pageSizeOptions: _const.PAGE_SIZE_OPTIONS, itemRender, ...is.isBoolean(pagination) ? {} : pagination, ...vue.unref(configRef) }; }); function setPagination(info) { const paginationInfo = vue.unref(getPaginationInfo); configRef.value = { ...!is.isBoolean(paginationInfo) ? paginationInfo : {}, ...info }; } function getPagination() { return vue.unref(getPaginationInfo); } function getShowPagination() { return vue.unref(show); } async function setShowPagination(flag) { show.value = flag; } return { getPagination, getPaginationInfo, setShowPagination, getShowPagination, setPagination }; } exports.usePagination = usePagination; //# sourceMappingURL=usePagination2.js.map