/* eslint-disable @typescript-eslint/no-explicit-any */ /// /// /** * Type declarations for package `@orange-marmalade/paginate-this`, * base type signatures */ declare module '@orange-marmalade/paginate-this' { // @ts-check: This path is generated at build time and conflicts otherwise // import { ReactElementTypeInferred } from '../dist/src/typings/global' TODO:current typescript doesn't allow importing from path // @ts-check: This path is generated at build time and conflicts otherwise // import { RecordProps, FlipProps, PaginateProps } from '../dist/src/typings/decorators' TODO: current typescript doesn't allow importing from path import { Store, Reducer, Action, AnyAction, ActionCreator, ActionCreatorsMapObject } from 'redux' // type utilities // -------------- /** * Infers component's props witch omit common props * and return its signature type */ declare type ReactElementTypeInferred< C extends React.ElementType, CommonProps = {} > = C extends React.ElementType ? React.ComponentType> : React.ComponentType declare type MapObjImmutable = Immutable.Map // InitialSettings export interface InitPageSettings { preloaded: boolean initialized: boolean page: number pageSize: number totalCount: number sort: string sortReverse: boolean isLoading: boolean stale: boolean results: Record[] updating: Array massUpdating: Array removing: Array requestId: number | string | null loadError: any filters: { [key: string]: any } } /** * Like ConfigPageParams typing, but these are translate to work internally */ export interface PageParams { pageParam: string // as page in ConfigPageParams pageSizeParam: string // as perPage in ConfigPageParams sortParam: string // as sort in ConfigPageParams sortOrderParam: string // as sortOrder in ConfigPageParams useBooleanOrdering: boolean // // as sortReverse in ConfigPageParams totalCountProp: string // as totalCount in ConfigPageParams resultsProp: string // as results in ConfigPageParams idProp: string // as id in ConfigPageParams } /** * Type signature for paginate's global configuration parameters */ export interface ConfigPageParams { page?: string perPage?: string sort?: string sortOrder?: string sortReverse?: boolean totalCount?: string results?: string id?: string } /** * Configuration type when it's created a paginator */ export type PaginatorConfig = { listId: string fetch: (...args: any[]) => any cache?: boolean sticky?: boolean initialSettings?: Partial pageParams?: Partial locator?: (S: any) => any augmentWith?: ActionCreatorsMapObject } /** * Settings which the paginate works with them at payload internally */ export interface PaginatorSettings extends InitPageSettings { results: Immutable.List updating: Immutable.Set massUpdating: Immutable.Set removing: Immutable.Set filters: Immutable.Map } export interface ComposablesConfig { listId: string } export interface AnyComposablesConfig extends ComposablesConfig { [extraConf: string]: any } export interface PageInfo { query: { [anyFilter: string]: any } } export type FetchActionCreator = { (pageInfo: PageInfo, config: any): A } export type Paginator = MapObjImmutable export type PropsWithPaginator

= P & { paginator: Paginator } // pagination's composed action creators export interface PageActionCreators { expire: ActionCreator updatingItem: ActionCreator updateItem: ActionCreator updatingItems: ActionCreator updateItems: ActionCreator updateComplete: ActionCreator updateFailed: ActionCreator massUpdateComplete: ActionCreator massUpdateFailed: ActionCreator resetItem: ActionCreator updatingAll: ActionCreator updateAll: ActionCreator resetResults: ActionCreator removingItem: ActionCreator removeItem: ActionCreator // Async updateAsync: ActionCreator<(...args: any[]) => void | Promise> updateItemsAsync: ActionCreator<(...args: any[]) => void | Promise> removeAsync: ActionCreator<(...args: any[]) => void | Promise> reload: ActionCreator<(...args: any[]) => void | Promise> // Fetch actions initialize: ActionCreator reset: ActionCreator next: ActionCreator prev: ActionCreator goTo: ActionCreator setPageSize: ActionCreator toggleFilterItem: ActionCreator setFilter: ActionCreator setFilters: ActionCreator resetFilters: ActionCreator sort: ActionCreator } export type WithPageActions = T & { pageActions: PageActionCreators } /** * type definition for decorators components */ // selected props for paginate and list export type RecordProps = { record: Record updating: boolean removing: boolean } export type FlipProps = { hasPreviousPage: boolean hasNextPage: boolean } export type PaginateProps = { currentPage: number totalPages: number } & FlipProps /* declare interface Decorate< T extends React.ComponentType, F = ( props: T extends React.ComponentType ? PropsWithPaginator

: PropsWithPaginator ) => Record > { (Component: T, decorator: F): T extends React.ComponentType ? React.ExoticComponent> : React.ExoticComponent> } */ /** * Pagination's Store */ export interface PaginationStore extends Store { decorate(...args: any[]): any [extraApi: string]: any } declare interface Decorators> { flip(Component: C): ReactElementTypeInferred> paginate( Component: C ): ReactElementTypeInferred> stretch(Component: C): ReactElementTypeInferred> sort(Component: C): ReactElementTypeInferred> tabulate(Component: C): ReactElementTypeInferred> tabulateLean( Component: C ): ReactElementTypeInferred> paginateThis( Component: C ): ReactElementTypeInferred> withRecordProps( Component: C ): ReactElementTypeInferred> withListId(Component: C): ReactElementTypeInferred> decorate< C extends T = T, F = ( props: C extends React.ComponentType ? PropsWithPaginator

: PropsWithPaginator ) => Record >( Component: C, decorator: F ): ReactElementTypeInferred & { listActions: any }> } export const decorators: Decorators export function configurePageParams(config: ConfigPageParams): void export function composables( config: C ): PageActionCreators export function actionFactory( listId: string ): { [k: string]: (...args: any[]) => any } export function expireAll(): Action export function createPaginator(config: PaginatorConfig): Reducer // hook functions to manage paginate state export function getPaginator(listId: string, state: S): Paginator export function getItem( state: S, listId: string, itemId: I ): Immutable.Collection export function isUpdating( state: S, listId: string, itemId: I ): boolean export function isRemoving( state: S, listId: string, itemId: I ): boolean export function currentQuery(state: S, listId: string): PageInfo declare interface Middleware { spill(...args: any[]): any jelly(...args: any[]): any } export const middleware = Middleware export function debug(shouldDebug: boolean): void export function initializeStore(store: S): void export function pageData( currentPage: number, totalPages: number, maxPages?: number ): { firstPage: { page: number current: boolean } hasLeftSeparator: boolean middlePages: { page: number; current: boolean }[] hasRightSeparator: boolean lastPage: { page: number current: boolean } } // Premade components for pagination export type NextProps = { pageActions: { next: PageActionCreators['next'] } hasNextPage: boolean } export const Next: ReturnType>['flip']> export type PrevProps = { pageActions: { prev: PageActionCreators['prev'] } hasPreviousPage: boolean } export const Prev: ReturnType>['flip']> } /** * Type declaration for package `@orange-marmalade/paginate-this/dist/pageInfoTranslator` */ declare module '@orange-marmalade/paginate-this/dist/pageInfoTranslator' { export function responseProps(): [C, P] export function recordProps(): I } declare module '@orange-marmalade/paginate-this/dist/lib/stateManagement' { import { PaginatorConfig, PageParams } from '@orange-marmalade/paginate-this' declare type Config = { params: PageParams } & Pick> export function listConfig(listId: string): Config }