zent
Version:
一套前端设计语言和基于React的实现
24 lines (23 loc) • 683 B
JavaScript
import { getPageRange } from './getPageRange';
export default function liteLayout(options) {
var current = options.current, total = options.total;
var _a = getPageRange(options), min = _a.min, max = _a.max;
var len = max - min + 1 + 2;
var layout = new Array(len);
layout[0] = {
type: 'left-arrow',
disabled: current <= 1 || total <= 0,
};
for (var i = min; i <= max; i++) {
layout[i - min + 1] = {
type: 'number',
page: i,
selected: current === i,
};
}
layout[len - 1] = {
type: 'right-arrow',
disabled: current >= max || total <= 0,
};
return layout;
}