UNPKG

@aplus-frontend/ui

Version:

38 lines (37 loc) 1.07 kB
import { ref as c, computed as g, unref as n } from "vue"; import { isDef as f } from "../../utils/index.mjs"; import { isUndefined as p } from "lodash-unified"; const w = (e) => { const i = c( e.pagination && e.pagination.defaultCurrent || 1 ), o = c( e.pagination && e.pagination.defaultPageSize || 10 ); function s(t, a) { i.value = t, o.value = a; } const d = g(() => e.dataSource ? e.pagination === !1 ? [...e.dataSource] : e.dataSource.slice( (n(i) - 1) * n(o), n(i) * n(o) ) : []); return { pagination: g(() => { const { showLessItems: t, showSizeChanger: a, showQuickJumper: r, pageSizeOptions: u } = e.pagination || {}; return { current: n(i), pageSize: n(o), total: e.dataSource?.length || 0, showSizeChanger: f(a) ? a : !t, showQuickJumper: f(r) ? r : !t, showLessItems: t, size: "default", pageSizeOptions: p(u) ? ["10", "20", "50", "100"] : u }; }), dataSource: d, onChange: s }; }; export { w as useOfflineList };