lucid-ui
Version:
A UI component library from AppNexus.
156 lines (155 loc) • 6.16 kB
TypeScript
import React from 'react';
import { StandardProps } from '../../util/component-types';
import * as reducers from './Paginator.reducers';
import { ISingleSelectOptionProps, ISingleSelectProps, ISingleSelectState } from '../SingleSelect/SingleSelect';
import { ITextFieldProps } from '../TextField/TextField';
import { IButtonProps } from '../Button/Button';
declare type IPaginatorSingleSelectProps = Partial<ISingleSelectProps>;
declare type ShowTotalObjects = (count: number) => string;
export interface IPaginatorProps extends StandardProps, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
/** Whether or not to show the page size selector. */
hasPageSizeSelector: boolean;
/** Disables the Paginator from being clicked or focused. */
isDisabled: boolean;
/** Label when showTotalObjects is true with 1 or fewer objects. */
objectLabel: string;
/** Label when showTotalObjects is true with more than 1 objects. */
objectLabelPlural?: string;
/** Called when a page is selected. */
onPageSelect: (pageIndex: number, totalPages: number, { props, event, }: {
props: IButtonProps | ITextFieldProps;
event: React.MouseEvent | React.FormEvent | React.FocusEvent;
}) => void;
/** Called when a page size is selected. */
onPageSizeSelect?: (pageSizeIndex: number | null, { props, event, }: {
props: ISingleSelectOptionProps | undefined;
event: React.MouseEvent | React.KeyboardEvent;
}) => void;
/** 0-indexed currently selected page number. */
selectedPageIndex: number;
/** Currently selected page size option index. */
selectedPageSizeIndex: number;
/** Show total count of objects. */
showTotalObjects: boolean | ShowTotalObjects;
/** Number to display in \`of \${totalPages}\`, calculated from
\`totalPages\` and selected page size by default. */
totalPages: number;
/** Total number of items across all pages. */
totalCount: number | null;
/** Array of numbers representing page size options. */
pageSizeOptions: number[];
/** Object of SingleSelect props which are passed thru to the underlying SingleSelect component for the page size selector. */
SingleSelect: IPaginatorSingleSelectProps;
/** Object of TextField props which are passed thru to the underlying TextField component. */
TextField: ITextFieldProps;
}
export interface IPaginatorState {
pageIndex: number;
totalPages: number;
totalCount: number;
selectedPageIndex: number;
selectedPageSizeIndex: number;
pageSizeOptions: number[];
SingleSelect: ISingleSelectState;
}
declare class Paginator extends React.Component<IPaginatorProps, IPaginatorState> {
static displayName: string;
static peek: {
description: string;
categories: string[];
madeFrom: string[];
};
static reducers: typeof reducers;
static selectors: {
totalPages: typeof import("./Paginator.selectors").totalPagesSelector;
};
static defaultProps: {
hasPageSizeSelector: boolean;
isDisabled: boolean;
objectLabel: string;
onPageSelect: (...args: any[]) => void;
selectedPageIndex: number;
selectedPageSizeIndex: number;
showTotalObjects: boolean;
totalCount: null;
totalPages: undefined;
pageSizeOptions: number[];
SingleSelect: {
selectedIndex: number;
hasReset: boolean;
isSelectionHighlighted: boolean;
isDisabled: boolean;
isInvisible: boolean;
showIcon: boolean;
DropMenu: {
isDisabled: boolean;
isExpanded: boolean;
direction: "down";
alignment: "start";
selectedIndices: never[];
focusedIndex: null;
flyOutStyle: {
maxHeight: string;
};
onExpand: (...args: any[]) => void;
onCollapse: (...args: any[]) => void;
onSelect: (...args: any[]) => void;
onFocusNext: (...args: any[]) => void;
onFocusPrev: (...args: any[]) => void;
onFocusOption: (...args: any[]) => void;
portalId: string;
optionContainerStyle: {};
ContextMenu: {
direction: string;
directonOffset: number;
minWidthOffset: number;
alignment: string;
getAlignmentOffset: () => number;
isExpanded: boolean;
onClickOut: null;
portalId: null;
};
};
};
TextField: {
style: undefined;
isDisabled: boolean;
isMultiLine: boolean;
onBlur: (...args: any[]) => void;
onChange: (...args: any[]) => void;
onChangeDebounced: (...args: any[]) => void;
onSubmit: (...args: any[]) => void;
onKeyDown: (...args: any[]) => void;
rows: number;
debounceLevel: number;
lazyLevel: number;
value: string;
};
};
static propTypes: {
className: any;
style: any;
isDisabled: any;
hasPageSizeSelector: any;
selectedPageIndex: any;
selectedPageSizeIndex: any;
SingleSelect: any;
showTotalObjects: any;
objectLabel: any;
objectLabelPlural: any;
totalPages: any;
totalCount: any;
pageSizeOptions: any;
TextField: any;
onPageSelect: any;
onPageSizeSelect: any;
};
handleTextFieldChange: (pageNum: string, { props, event, }: {
props: ITextFieldProps;
event: React.FocusEvent | React.FormEvent;
}) => void;
render(): React.ReactNode;
}
declare const _default: typeof Paginator & import("../../util/state-management").IHybridComponent<IPaginatorProps, IPaginatorState>;
export default _default;
export { Paginator as PaginatorDumb };