UNPKG

@aplus-frontend/ui

Version:

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