UNPKG

ideaz-element

Version:

<p align="center"> <a href="" target="_blank" rel="noopener noreferrer"> <img src="./docs/public/logo.svg" alt="Ideaz Element" width="180" style="width: 180px;" /> </a> </p>

81 lines (80 loc) 3.17 kB
import "../../../../utils/index.mjs"; import "../../../../node_modules/.pnpm/@vueuse_core@10.11.0_@vue_composition-api@1.7.2_vue@3.4.27_typescript@5.4.5___vue@3.4.27_typescript@5.4.5_/node_modules/@vueuse/core/index.mjs"; import "../../../../node_modules/.pnpm/lodash-unified@1.0.3_@types_lodash-es@4.17.12_lodash-es@4.17.21_lodash@4.17.21/node_modules/lodash-unified/import.mjs"; import { ref as y, useAttrs as P, computed as g, watch as m } from "vue"; import { isObject as b } from "../../../../utils/is.mjs"; import { reactiveOmit as D } from "../../../../node_modules/.pnpm/@vueuse_shared@10.11.0_@vue_composition-api@1.7.2_vue@3.4.27_typescript@5.4.5___vue@3.4.27_typescript@5.4.5_/node_modules/@vueuse/shared/index.mjs"; import w from "../../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/set.mjs"; import { uid as O } from "../../../../utils/uid.mjs"; function $(n, o) { const r = y([]), z = P(), a = g({ get() { return b(n.pagination) && !n.editable ? n.pagination : {}; }, set(e) { o("update:pagination", e); } }), i = g(() => { const e = D(n, ["pagination", "columns", "draggable", "toolBar", "loading"]); return { ...z, ...e }; }), p = g(() => ({ ...a.value, layout: a.value.layout || "total, sizes, prev, pager, next, jumper", pageSizes: a.value.pageSizes || [100, 200, 300, 400, 500] })), v = g(() => !!(i.value.data && p.value.type === "front")); m( () => i.value.data, () => { if (n.editable) { const e = b(n.editable) && n.editable.type || "single", u = n.columns.map((t) => t.prop).filter((t) => t); r.value = i.value.data.map((t) => { const s = {}; return u.forEach((l) => { Object.hasOwnProperty.call(t, l) && !Object.hasOwnProperty.call(t, `${l}Prop`) && (s[`${l}Prop`] = t[l]); }), { __isEdit: e !== "single", ...t, ...s }; }); } else r.value = i.value.data; }, { immediate: !0 } ), m(() => i.value.totalData, () => { a.value.total && p.value.type === "front" && c(a.value); }); const S = () => { const e = { __isEdit: !0 }; n.rowKey && w(e, String(n.rowKey), O()), r.value.push(e); }; function c(e) { const u = e.page, t = e.pageSize, s = i.value.totalData, l = i.value.totalData.length; let d = (u - 1) * t, f = u * t; d >= l && (d = 0), f >= l && (f = l), r.value = s.slice(d, f), o("update:data", r.value); } const h = (e) => { o("update:pagination", { ...a.value, page: e }), v.value ? c({ page: e, pageSize: a.value.pageSize }) : o("refresh", { page: e, pageSize: a.value.pageSize }); }; return { paginationAttrs: p, tableAttributes: i, tableData: r, pagination: a, addTableData: S, handleCurrentChange: h, handleSizeChange: (e) => { o("update:pagination", { ...a.value, pageSize: e }), v.value ? c({ page: 1, pageSize: e }) : o("refresh", { page: 1, pageSize: e }); }, handleRefresh: () => { const e = a.value.page ? a.value.page : 1; h(e); } }; } export { $ as usePagination }; //# sourceMappingURL=usePagination.mjs.map