1
0
mirror of https://github.com/flarum/core.git synced 2025-08-13 11:54:32 +02:00

Bundled output for commit 3537f76eab

Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
This commit is contained in:
flarum-bot
2021-05-12 23:29:46 +00:00
parent 3537f76eab
commit c3a684c7ed
213 changed files with 6462 additions and 30 deletions

View File

@@ -0,0 +1,36 @@
import Mithril from 'mithril';
import Alert, { AlertAttrs } from '../components/Alert';
/**
* Returned by `AlertManagerState.show`. Used to dismiss alerts.
*/
export declare type AlertIdentifier = number;
export interface AlertState {
componentClass: typeof Alert;
attrs: AlertAttrs;
children: Mithril.Children;
}
export default class AlertManagerState {
protected activeAlerts: {
[id: number]: AlertState;
};
protected alertId: number;
getActiveAlerts(): {
[id: number]: AlertState;
};
/**
* Show an Alert in the alerts area.
*
* @returns The alert's ID, which can be used to dismiss the alert.
*/
show(children: Mithril.Children): AlertIdentifier;
show(attrs: AlertAttrs, children: Mithril.Children): AlertIdentifier;
show(componentClass: Alert, attrs: AlertAttrs, children: Mithril.Children): AlertIdentifier;
/**
* Dismiss an alert.
*/
dismiss(key: AlertIdentifier): void;
/**
* Clear all alerts.
*/
clear(): void;
}

View File

@@ -0,0 +1,19 @@
export default class ModalManagerState {
modal: {
componentClass: any;
attrs: any;
} | null;
/**
* Show a modal dialog.
*
* @public
*/
public show(componentClass: any, attrs: any): void;
/**
* Close the modal dialog.
*
* @public
*/
public close(): void;
closeTimeout: number | undefined;
}

View File

@@ -0,0 +1,16 @@
export default class PageState {
constructor(type: any, data?: {});
type: any;
data: {};
/**
* Determine whether the page matches the given class and data.
*
* @param {object} type The page class to check against. Subclasses are
* accepted as well.
* @param {object} data
* @return {boolean}
*/
matches(type: object, data?: object): boolean;
get(key: any): any;
set(key: any, value: any): void;
}

View File

@@ -0,0 +1,78 @@
import Model from '../Model';
export interface Page<TModel> {
number: number;
items: TModel[];
hasPrev?: boolean;
hasNext?: boolean;
}
export interface PaginationLocation {
page: number;
startIndex?: number;
endIndex?: number;
}
export default abstract class PaginatedListState<T extends Model> {
protected location: PaginationLocation;
protected pageSize: number;
protected pages: Page<T>[];
protected params: any;
protected initialLoading: boolean;
protected loadingPrev: boolean;
protected loadingNext: boolean;
protected constructor(params?: any, page?: number, pageSize?: number);
abstract get type(): string;
clear(): void;
loadPrev(): Promise<void>;
loadNext(): Promise<void>;
protected parseResults(pg: number, results: T[]): void;
/**
* Load a new page of results.
*/
protected loadPage(page?: number): Promise<T[]>;
/**
* Get the parameters that should be passed in the API request.
* Do not include page offset unless subclass overrides loadPage.
*
* @abstract
* @see loadPage
*/
protected requestParams(): any;
/**
* Update the `this.params` object, calling `refresh` if they have changed.
* Use `requestParams` for converting `this.params` into API parameters
*
* @param newParams
* @param page
* @see requestParams
*/
refreshParams(newParams: any, page: number): any;
refresh(page?: number): any;
getPages(): Page<T>[];
getLocation(): PaginationLocation;
isLoading(): boolean;
isInitialLoading(): boolean;
isLoadingPrev(): boolean;
isLoadingNext(): boolean;
/**
* Returns true when the number of items across all loaded pages is not 0.
*
* @see isEmpty
*/
hasItems(): boolean;
/**
* Returns true when there aren't any items *and* the state has already done its initial loading.
* If you want to know whether there are items regardless of load state, use `hasItems()` instead
*
* @see hasItems
*/
isEmpty(): boolean;
hasPrev(): boolean;
hasNext(): boolean;
/**
* Stored state parameters.
*/
getParams(): any;
protected getNextPageNumber(): number;
protected getPrevPageNumber(): number;
protected paramsChanged(newParams: any): boolean;
protected getAllItems(): T[];
}