jamis
Version:
一种支持通过JSON配置方式生成页面的组件库
129 lines (128 loc) • 3.45 kB
TypeScript
import type { PickClassStyleType, ReactPropsBase, RendererProps, SchemaClassName } from 'jamis-core';
import type { BaseSchema, BaseSchemaScoped, SchemaCollection } from '../types';
import type { IPaginationStore } from './PaginationStore';
export type MODE_TYPE = 'simple' | 'normal';
export type PaginationWidget = 'pager' | 'perpage' | 'total' | 'go' | 'statistics';
export interface BasicPaginationProps {
/**
* 通过控制layout属性的顺序,调整分页结构 total,perPage,pager,go
* @default ['pager']
*/
layout?: string | PaginationWidget[];
/**
* 最多显示多少个分页按钮。
*
* @default 5
*/
maxButtons: number;
/**
* 模式,默认normal,如果只想简单显示可以配置成 `simple`。
* @default 'normal'
*/
mode?: MODE_TYPE;
/**
* 当前页数
* @deprecated 请使用 `page`来指定
*/
activePage?: number;
/**
* 当前页数
*/
page?: number;
/**
* 总条数
*/
total?: number;
/**
* 最后一页,总页数(如果传入了total,会重新计算lastPage)
*/
lastPage?: number;
/**
* 每页显示条数
* @default 10
*/
perPage?: number;
/**
* 是否展示分页切换,也同时受layout控制
* @default false
*/
showPerPage?: boolean;
/**
* 指定每页可以显示多少条
* @default [5, 10, 20, 50, 100]
*/
perPageAvailable?: Array<number>;
/**
* 是否显示快速跳转输入框
* @default true
*/
showPageInput?: boolean;
/**
* 是否显示统计信息, 和在layout里配置total 或者 statistics 效果一样
*/
showStatistics?: boolean;
/**
* 是否禁用
* @default false
*/
disabled?: boolean;
hasNext?: boolean;
/**
* 弹层挂载节点
* @default false
*/
popOverContainerSelector?: string;
/**
* pageNum 改变事件
*/
onPageChange?: (page: number, perPage?: number) => void;
}
export interface PaginationCompProps extends BasicPaginationProps, ReactPropsBase, PickClassStyleType {
popOverContainer?: any;
}
export interface PaginationState {
pageNum: string;
perPage: number;
}
export interface PaginationSchema extends BaseSchema, Partial<BasicPaginationProps> {
type: 'pagination';
}
export interface PaginationProps extends RendererProps, Omit<PaginationSchema, 'type' | 'className'> {
popOverContainer?: any;
}
/**
* 分页容器功能性组件
*/
export interface PaginationWrapperSchema extends Omit<PaginationSchema, 'type'>, BaseSchemaScoped {
/**
* 指定为分页容器功能性组件
*/
type: 'pagination-wrapper';
/**
* 输入字段名
*
* @default items
*/
inputName?: string;
/**
* 输出字段名
*
* @default items
*/
outputName?: string;
/**
* 分页显示位置,如果配置为 none 则需要自己在内容区域配置 pagination 组件,否则不显示。
*/
position?: 'top' | 'bottom' | 'none';
/**
* 内容区域
*/
body?: SchemaCollection;
bodyClassName?: SchemaClassName;
}
export interface PaginationWrapProps extends RendererProps, Omit<PaginationWrapperSchema, 'type' | 'className' | 'data'> {
inputName: string;
outputName: string;
perPage: number;
store: IPaginationStore;
}