1 | import * as React from 'react';
|
2 | import {StyletronComponent} from 'styletron-react';
|
3 | import {Override} from '../overrides';
|
4 | import {Locale} from '../locale';
|
5 | import {SIZE} from '../input';
|
6 |
|
7 | export {SIZE};
|
8 |
|
9 | export interface STATE_CHANGE_TYPE {
|
10 | change: 'change';
|
11 | }
|
12 |
|
13 | export interface Labels {
|
14 | prevButton?: string;
|
15 | nextButton?: string;
|
16 | preposition?: string;
|
17 | }
|
18 |
|
19 | export interface State {
|
20 | currentPage: number;
|
21 | }
|
22 |
|
23 | export type StateReducer = (
|
24 | changeType: STATE_CHANGE_TYPE[keyof STATE_CHANGE_TYPE],
|
25 | changes: State,
|
26 | currentState: State,
|
27 | ) => State;
|
28 |
|
29 | export interface PaginationOverrides {
|
30 | Root?: Override<any>;
|
31 | PrevButton?: Override<any>;
|
32 | NextButton?: Override<any>;
|
33 | MaxLabel?: Override<any>;
|
34 | DropdownContainer?: Override<any>;
|
35 | Select?: Override<any>;
|
36 | }
|
37 |
|
38 | export interface Callbacks {
|
39 | onPrevClick?: (args: {event: any}) => any;
|
40 | onNextClick?: (args: {event: any}) => any;
|
41 | onPageChange?: (args: {nextPage: number; prevPage: number}) => any;
|
42 | }
|
43 |
|
44 | export interface PaginationProps extends Callbacks {
|
45 | numPages: number;
|
46 | currentPage: number;
|
47 | labels?: Labels;
|
48 | overrides?: PaginationOverrides;
|
49 | size?: SIZE[keyof SIZE];
|
50 | }
|
51 |
|
52 | export interface PageOption {
|
53 | label: number;
|
54 | }
|
55 |
|
56 | export class Pagination extends React.PureComponent<PaginationProps> {
|
57 | getMenuOptions(numPages: number): [];
|
58 | onMenuItemSelect(data: {value: ReadonlyArray<PageOption>}): void;
|
59 | onPrevClick(event: React.SyntheticEvent<any>): void;
|
60 | onNextClick(event: React.SyntheticEvent<any>): void;
|
61 | constructAriaWayfinderLabel(locale: Locale, prefix: string): string;
|
62 | }
|
63 |
|
64 | export interface StatefulPaginationProps extends Callbacks {
|
65 | numPages: number;
|
66 | labels?: Labels;
|
67 | stateReducer?: StateReducer;
|
68 | initialState?: State;
|
69 | overrides?: PaginationOverrides;
|
70 | }
|
71 |
|
72 | export const StatefulPagination: React.FC<StatefulPaginationProps>;
|
73 |
|
74 | export interface StatefulContainerProps {
|
75 | children: React.ReactNode;
|
76 | numPages: number;
|
77 | stateReducer?: StateReducer;
|
78 | initialState?: State;
|
79 | onPageChange?: Callbacks['onPageChange'];
|
80 | }
|
81 |
|
82 | export class StatefulContainer extends React.Component<
|
83 | StatefulContainerProps,
|
84 | State
|
85 | > {
|
86 | internalSetState(
|
87 | changeType: STATE_CHANGE_TYPE[keyof STATE_CHANGE_TYPE],
|
88 | changes: State,
|
89 | ): void;
|
90 | onPageChange(args: {nextPage: number}): void;
|
91 | }
|
92 |
|
93 | export const StyledRoot: StyletronComponent<any>;
|
94 | export const StyledMaxLabel: StyletronComponent<any>;
|
95 | export const StyledDropdownContainer: StyletronComponent<any>;
|
96 | export const STATE_CHANGE_TYPE: STATE_CHANGE_TYPE;
|