UNPKG

ll-package

Version:

2 lines (1 loc) 1.25 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("../../../../@babel/runtime/helpers/esm/extends.js"),b=require("../../_util/hooks/useState.js"),c=require("vue"),m=require("../../_util/extendsObject.js"),g=10;function p(n,t){const o={current:n.current,pageSize:n.pageSize};return Object.keys(t&&typeof t=="object"?t:{}).forEach(l=>{const r=n[l];typeof r!="function"&&(o[l]=r)}),o}function _(n,t,o){const a=c.computed(()=>t.value&&typeof t.value=="object"?t.value:{}),l=c.computed(()=>a.value.total||0),[r,P]=b.default(()=>({current:"defaultCurrent"in a.value?a.value.defaultCurrent:1,pageSize:"defaultPageSize"in a.value?a.value.defaultPageSize:g})),i=c.computed(()=>{const e=m.default(r.value,a.value,{total:l.value>0?l.value:n.value}),u=Math.ceil((l.value||n.value)/e.pageSize);return e.current>u&&(e.current=u||1),e}),s=(e,u)=>{t.value!==!1&&P({current:e??1,pageSize:u||i.value.pageSize})},S=(e,u)=>{var d,v;t.value&&((v=(d=a.value).onChange)===null||v===void 0||v.call(d,e,u)),s(e,u),o(e,u||i.value.pageSize)};return[c.computed(()=>t.value===!1?{}:f.default(f.default({},i.value),{onChange:S})),s]}exports.DEFAULT_PAGE_SIZE=g;exports.default=_;exports.getPaginationParam=p;