mirror of
https://github.com/flarum/framework.git
synced 2025-01-26 14:44:58 +08:00
Bundled output for commit f5cab714e1
Includes transpiled JS/TS, and Typescript declaration files (typings). [skip ci]
This commit is contained in:
parent
f5cab714e1
commit
74b2258ae7
|
@ -98,3 +98,10 @@ interface JSX {
|
|||
attrs: Record<string, unknown>;
|
||||
};
|
||||
}
|
||||
|
||||
interface Event {
|
||||
/**
|
||||
* Whether this event should trigger a Mithril redraw.
|
||||
*/
|
||||
redraw: boolean;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,30 @@
|
|||
import Application from '../common/Application';
|
||||
import ExtensionData from './utils/ExtensionData';
|
||||
export declare type Extension = {
|
||||
id: string;
|
||||
version: string;
|
||||
description?: string;
|
||||
icon?: {
|
||||
name: string;
|
||||
};
|
||||
links: {
|
||||
authors?: {
|
||||
name?: string;
|
||||
link?: string;
|
||||
}[];
|
||||
discuss?: string;
|
||||
documentation?: string;
|
||||
support?: string;
|
||||
website?: string;
|
||||
donate?: string;
|
||||
source?: string;
|
||||
};
|
||||
extra: {
|
||||
'flarum-extension': {
|
||||
title: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
export default class AdminApplication extends Application {
|
||||
extensionData: ExtensionData;
|
||||
extensionCategories: {
|
||||
|
@ -13,10 +38,24 @@ export default class AdminApplication extends Application {
|
|||
backUrl: () => any;
|
||||
back: () => void;
|
||||
};
|
||||
/**
|
||||
* Settings are serialized to the admin dashboard as strings.
|
||||
* Additional encoding/decoding is possible, but must take
|
||||
* place on the client side.
|
||||
*
|
||||
* @inheritdoc
|
||||
*/
|
||||
data: Application['data'] & {
|
||||
extensions: Record<string, Extension>;
|
||||
settings: Record<string, string>;
|
||||
modelStatistics: Record<string, {
|
||||
total: number;
|
||||
}>;
|
||||
};
|
||||
constructor();
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
mount(): void;
|
||||
getRequiredPermissions(permission: any): string[];
|
||||
getRequiredPermissions(permission: string): string[];
|
||||
}
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
export default class ExtensionPage extends AdminPage<import("../../common/components/Page").IPageAttrs> {
|
||||
constructor();
|
||||
extension: any;
|
||||
changingState: boolean | undefined;
|
||||
import ItemList from '../../common/utils/ItemList';
|
||||
import AdminPage from './AdminPage';
|
||||
import RequestError from '../../common/utils/RequestError';
|
||||
import { Extension } from '../AdminApplication';
|
||||
import { IPageAttrs } from '../../common/components/Page';
|
||||
import type Mithril from 'mithril';
|
||||
export interface ExtensionPageAttrs extends IPageAttrs {
|
||||
id: string;
|
||||
}
|
||||
export default class ExtensionPage<Attrs extends ExtensionPageAttrs = ExtensionPageAttrs> extends AdminPage<Attrs> {
|
||||
extension: Extension;
|
||||
changingState: boolean;
|
||||
infoFields: {
|
||||
discuss: string;
|
||||
documentation: string;
|
||||
|
@ -9,14 +17,16 @@ export default class ExtensionPage extends AdminPage<import("../../common/compon
|
|||
website: string;
|
||||
donate: string;
|
||||
source: string;
|
||||
} | undefined;
|
||||
};
|
||||
oninit(vnode: Mithril.Vnode<Attrs, this>): void;
|
||||
className(): string;
|
||||
sections(): ItemList;
|
||||
view(vnode: Mithril.VnodeDOM<Attrs, this>): JSX.Element | null;
|
||||
header(): JSX.Element[];
|
||||
sections(vnode: Mithril.VnodeDOM<Attrs, this>): ItemList;
|
||||
content(vnode: Mithril.VnodeDOM<Attrs, this>): JSX.Element;
|
||||
topItems(): ItemList;
|
||||
infoItems(): ItemList;
|
||||
toggle(): void;
|
||||
isEnabled(): any;
|
||||
onerror(e: any): void;
|
||||
onerror(e: RequestError): void;
|
||||
}
|
||||
import AdminPage from "./AdminPage";
|
||||
import ItemList from "../../common/utils/ItemList";
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
export default class LoadingModal extends Modal<any> {
|
||||
import Modal from '../../common/components/Modal';
|
||||
export default class LoadingModal<ModalAttrs = {}> extends Modal<ModalAttrs> {
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
static isDismissible: boolean;
|
||||
constructor();
|
||||
static readonly isDismissible: boolean;
|
||||
className(): string;
|
||||
title(): any;
|
||||
content(): string;
|
||||
onsubmit(e: Event): void;
|
||||
}
|
||||
import Modal from "../../common/components/Modal";
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import DefaultResolver from '../../common/resolvers/DefaultResolver';
|
||||
import ExtensionPage, { ExtensionPageAttrs } from '../components/ExtensionPage';
|
||||
/**
|
||||
* A custom route resolver for ExtensionPage that generates handles routes
|
||||
* to default extension pages or a page provided by an extension.
|
||||
*/
|
||||
export default class ExtensionPageResolver extends DefaultResolver {
|
||||
export default class ExtensionPageResolver<Attrs extends ExtensionPageAttrs = ExtensionPageAttrs, RouteArgs extends Record<string, unknown> = {}> extends DefaultResolver<Attrs, ExtensionPage<Attrs>, RouteArgs> {
|
||||
static extension: string | null;
|
||||
onmatch(args: any, requestedPath: any, route: any): any;
|
||||
onmatch(args: Attrs & RouteArgs, requestedPath: string, route: string): any;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import Translator from './Translator';
|
|||
import Store from './Store';
|
||||
import Session from './Session';
|
||||
import Drawer from './utils/Drawer';
|
||||
import RequestError, { InternalFlarumRequestOptions } from './utils/RequestError';
|
||||
import Forum from './models/Forum';
|
||||
import PageState from './states/PageState';
|
||||
import ModalManagerState from './states/ModalManagerState';
|
||||
|
@ -17,20 +18,20 @@ export declare type FlarumGenericRoute = RouteItem<Record<string, unknown>, Comp
|
|||
[key: string]: unknown;
|
||||
}>, Record<string, unknown>>;
|
||||
export interface FlarumRequestOptions<ResponseType> extends Omit<Mithril.RequestOptions<ResponseType>, 'extract'> {
|
||||
errorHandler: (errorMessage: string) => void;
|
||||
errorHandler?: (error: RequestError) => void;
|
||||
url: string;
|
||||
/**
|
||||
* Manipulate the response text before it is parsed into JSON.
|
||||
*
|
||||
* @deprecated Please use `modifyText` instead.
|
||||
*/
|
||||
extract: (responseText: string) => string;
|
||||
extract?: (responseText: string) => string;
|
||||
/**
|
||||
* Manipulate the response text before it is parsed into JSON.
|
||||
*
|
||||
* This overrides any `extract` method provided.
|
||||
*/
|
||||
modifyText: (responseText: string) => string;
|
||||
modifyText?: (responseText: string) => string;
|
||||
}
|
||||
/**
|
||||
* A valid route definition.
|
||||
|
@ -192,7 +193,7 @@ export default class Application {
|
|||
bootExtensions(extensions: Record<string, {
|
||||
extend?: unknown[];
|
||||
}>): void;
|
||||
mount(basePath?: string): void;
|
||||
protected mount(basePath?: string): void;
|
||||
/**
|
||||
* Get the API response document that has been preloaded into the application.
|
||||
*/
|
||||
|
@ -214,6 +215,7 @@ export default class Application {
|
|||
*/
|
||||
setTitleCount(count: number): void;
|
||||
updateTitle(): void;
|
||||
protected transformRequestOptions<ResponseType>(flarumOptions: FlarumRequestOptions<ResponseType>): InternalFlarumRequestOptions<ResponseType>;
|
||||
/**
|
||||
* Make an AJAX request, handling any low-level errors that may occur.
|
||||
*
|
||||
|
|
114
framework/core/js/dist-typings/common/Component.d.ts
vendored
Normal file
114
framework/core/js/dist-typings/common/Component.d.ts
vendored
Normal file
|
@ -0,0 +1,114 @@
|
|||
import type Mithril from 'mithril';
|
||||
export interface ComponentAttrs extends Mithril.Attributes {
|
||||
}
|
||||
/**
|
||||
* The `Component` class defines a user interface 'building block'. A component
|
||||
* generates a virtual DOM to be rendered on each redraw.
|
||||
*
|
||||
* Essentially, this is a wrapper for Mithril's components that adds several useful features:
|
||||
*
|
||||
* - In the `oninit` and `onbeforeupdate` lifecycle hooks, we store vnode attrs in `this.attrs.
|
||||
* This allows us to use attrs across components without having to pass the vnode to every single
|
||||
* method.
|
||||
* - The static `initAttrs` method allows a convenient way to provide defaults (or to otherwise modify)
|
||||
* the attrs that have been passed into a component.
|
||||
* - When the component is created in the DOM, we store its DOM element under `this.element`; this lets
|
||||
* us use jQuery to modify child DOM state from internal methods via the `this.$()` method.
|
||||
* - A convenience `component` method, which serves as an alternative to hyperscript and JSX.
|
||||
*
|
||||
* As with other Mithril components, components extending Component can be initialized
|
||||
* and nested using JSX, hyperscript, or a combination of both. The `component` method can also
|
||||
* be used.
|
||||
*
|
||||
* @example
|
||||
* return m('div', <MyComponent foo="bar"><p>Hello World</p></MyComponent>);
|
||||
*
|
||||
* @example
|
||||
* return m('div', MyComponent.component({foo: 'bar'), m('p', 'Hello World!'));
|
||||
*
|
||||
* @see https://mithril.js.org/components.html
|
||||
*/
|
||||
export default abstract class Component<Attrs extends ComponentAttrs = ComponentAttrs, State = undefined> implements Mithril.ClassComponent<Attrs> {
|
||||
/**
|
||||
* The root DOM element for the component.
|
||||
*/
|
||||
protected element: Element;
|
||||
/**
|
||||
* The attributes passed into the component.
|
||||
*
|
||||
* @see https://mithril.js.org/components.html#passing-data-to-components
|
||||
*/
|
||||
protected attrs: Attrs;
|
||||
/**
|
||||
* Class component state that is persisted between redraws.
|
||||
*
|
||||
* Updating this will **not** automatically trigger a redraw, unlike
|
||||
* other frameworks.
|
||||
*
|
||||
* This is different to Vnode state, which is always an instance of your
|
||||
* class component.
|
||||
*
|
||||
* This is `undefined` by default.
|
||||
*/
|
||||
protected state: State;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
abstract view(vnode: Mithril.Vnode<Attrs, this>): Mithril.Children;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
oninit(vnode: Mithril.Vnode<Attrs, this>): void;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
oncreate(vnode: Mithril.VnodeDOM<Attrs, this>): void;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
onbeforeupdate(vnode: Mithril.VnodeDOM<Attrs, this>): void;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
onupdate(vnode: Mithril.VnodeDOM<Attrs, this>): void;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
onbeforeremove(vnode: Mithril.VnodeDOM<Attrs, this>): void;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
onremove(vnode: Mithril.VnodeDOM<Attrs, this>): void;
|
||||
/**
|
||||
* Returns a jQuery object for this component's element. If you pass in a
|
||||
* selector string, this method will return a jQuery object, using the current
|
||||
* element as its buffer.
|
||||
*
|
||||
* For example, calling `component.$('li')` will return a jQuery object
|
||||
* containing all of the `li` elements inside the DOM element of this
|
||||
* component.
|
||||
*
|
||||
* @param [selector] a jQuery-compatible selector string
|
||||
* @returns the jQuery object for the DOM node
|
||||
* @final
|
||||
*/
|
||||
protected $(selector?: string): JQuery;
|
||||
/**
|
||||
* Convenience method to attach a component without JSX.
|
||||
* Has the same effect as calling `m(THIS_CLASS, attrs, children)`.
|
||||
*
|
||||
* @see https://mithril.js.org/hyperscript.html#mselector,-attributes,-children
|
||||
*/
|
||||
static component<SAttrs extends ComponentAttrs = ComponentAttrs>(attrs?: SAttrs, children?: Mithril.Children): Mithril.Vnode;
|
||||
/**
|
||||
* Saves a reference to the vnode attrs after running them through initAttrs,
|
||||
* and checking for common issues.
|
||||
*/
|
||||
private setAttrs;
|
||||
/**
|
||||
* Initialize the component's attrs.
|
||||
*
|
||||
* This can be used to assign default values for missing, optional attrs.
|
||||
*/
|
||||
protected static initAttrs<T>(attrs: T): void;
|
||||
}
|
|
@ -32,7 +32,7 @@ export default abstract class Fragment {
|
|||
* @returns {jQuery} the jQuery object for the DOM node
|
||||
* @final
|
||||
*/
|
||||
$(selector: any): JQuery<any>;
|
||||
$(selector?: string): JQuery;
|
||||
/**
|
||||
* Get the renderable virtual DOM that represents the fragment's view.
|
||||
*
|
||||
|
|
|
@ -15,5 +15,5 @@ export interface AlertAttrs extends ComponentAttrs {
|
|||
* some controls, and may be dismissible.
|
||||
*/
|
||||
export default class Alert<T extends AlertAttrs = AlertAttrs> extends Component<T> {
|
||||
view(vnode: Mithril.Vnode): JSX.Element;
|
||||
view(vnode: Mithril.VnodeDOM<T, this>): JSX.Element;
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ export interface IButtonAttrs extends ComponentAttrs {
|
|||
* styles can be applied by providing `className="Button"` to the Button component.
|
||||
*/
|
||||
export default class Button<CustomAttrs extends IButtonAttrs = IButtonAttrs> extends Component<CustomAttrs> {
|
||||
view(vnode: Mithril.Vnode<IButtonAttrs, never>): JSX.Element;
|
||||
oncreate(vnode: Mithril.VnodeDOM<IButtonAttrs, this>): void;
|
||||
view(vnode: Mithril.VnodeDOM<CustomAttrs, this>): JSX.Element;
|
||||
oncreate(vnode: Mithril.VnodeDOM<CustomAttrs, this>): void;
|
||||
/**
|
||||
* Get the template for the button's content.
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ export default abstract class Modal<ModalAttrs = {}> extends Component<ModalAttr
|
|||
/**
|
||||
* Determine whether or not the modal should be dismissible via an 'x' button.
|
||||
*/
|
||||
static readonly isDismissible = true;
|
||||
static readonly isDismissible: boolean;
|
||||
protected loading: boolean;
|
||||
/**
|
||||
* Attributes for an alert component to show below the header.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import type Mithril from 'mithril';
|
||||
import Component from '../Component';
|
||||
export interface IPageAttrs {
|
||||
key?: number;
|
||||
|
@ -9,7 +10,19 @@ export interface IPageAttrs {
|
|||
* @abstract
|
||||
*/
|
||||
export default abstract class Page<CustomAttrs extends IPageAttrs = IPageAttrs> extends Component<CustomAttrs> {
|
||||
oninit(vnode: any): void;
|
||||
oncreate(vnode: any): void;
|
||||
onremove(vnode: any): void;
|
||||
/**
|
||||
* A class name to apply to the body while the route is active.
|
||||
*/
|
||||
protected bodyClass: string;
|
||||
/**
|
||||
* Whether we should scroll to the top of the page when its rendered.
|
||||
*/
|
||||
protected scrollTopOnCreate: boolean;
|
||||
/**
|
||||
* Whether the browser should restore scroll state on refreshes.
|
||||
*/
|
||||
protected useBrowserScrollRestoration: boolean;
|
||||
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
|
||||
oncreate(vnode: Mithril.VnodeDOM<CustomAttrs, this>): void;
|
||||
onremove(vnode: Mithril.VnodeDOM<CustomAttrs, this>): void;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import type Mithril from 'mithril';
|
||||
import type { ComponentAttrs } from '../Component';
|
||||
import User from '../models/User';
|
||||
export interface AvatarAttrs extends ComponentAttrs {
|
||||
}
|
||||
/**
|
||||
* The `avatar` helper displays a user's avatar.
|
||||
*
|
||||
* @param user
|
||||
* @param attrs Attributes to apply to the avatar element
|
||||
*/
|
||||
export default function avatar(user: User, attrs?: Object): Mithril.Vnode;
|
||||
export default function avatar(user: User, attrs?: ComponentAttrs): Mithril.Vnode;
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
import type Mithril from 'mithril';
|
||||
import type * as Component from '../Component';
|
||||
import Component, { ComponentAttrs } from '../Component';
|
||||
export interface ModdedVnodeAttrs {
|
||||
itemClassName?: string;
|
||||
key?: string;
|
||||
}
|
||||
export declare type ModdedVnode<Attrs> = Mithril.Vnode<ModdedVnodeAttrs, Component.default<Attrs> | {}> & {
|
||||
export declare type ModdedVnode<Attrs> = Mithril.Vnode<ModdedVnodeAttrs, Component<Attrs> | {}> & {
|
||||
itemName?: string;
|
||||
itemClassName?: string;
|
||||
tag: Mithril.Vnode['tag'] & {
|
||||
isListItem?: boolean;
|
||||
isActive?: (attrs: ComponentAttrs) => boolean;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* The `listItems` helper wraps an array of components in the provided tag,
|
||||
|
@ -15,4 +19,4 @@ export declare type ModdedVnode<Attrs> = Mithril.Vnode<ModdedVnodeAttrs, Compone
|
|||
* By default, this tag is an `<li>` tag, but this is customisable through the
|
||||
* second function parameter, `customTag`.
|
||||
*/
|
||||
export default function listItems<Attrs extends Record<string, unknown>>(items: ModdedVnode<Attrs> | ModdedVnode<Attrs>[], customTag?: string | Component.default<Attrs>, attributes?: Attrs): Mithril.Vnode[];
|
||||
export default function listItems<Attrs extends Record<string, unknown>>(rawItems: ModdedVnode<Attrs> | ModdedVnode<Attrs>[], customTag?: string | Component<Attrs>, attributes?: Attrs): Mithril.Vnode[];
|
||||
|
|
|
@ -3,4 +3,4 @@ import User from '../models/User';
|
|||
/**
|
||||
* The `useronline` helper displays a green circle if the user is online
|
||||
*/
|
||||
export default function userOnline(user: User): Mithril.Vnode;
|
||||
export default function userOnline(user: User): Mithril.Vnode<{}, {}> | null;
|
||||
|
|
|
@ -10,15 +10,18 @@ export interface PaginationLocation {
|
|||
startIndex?: number;
|
||||
endIndex?: number;
|
||||
}
|
||||
export default abstract class PaginatedListState<T extends Model> {
|
||||
export interface PaginatedListParams {
|
||||
[key: string]: any;
|
||||
}
|
||||
export default abstract class PaginatedListState<T extends Model, P extends PaginatedListParams = PaginatedListParams> {
|
||||
protected location: PaginationLocation;
|
||||
protected pageSize: number;
|
||||
protected pages: Page<T>[];
|
||||
protected params: any;
|
||||
protected params: P;
|
||||
protected initialLoading: boolean;
|
||||
protected loadingPrev: boolean;
|
||||
protected loadingNext: boolean;
|
||||
protected constructor(params?: any, page?: number, pageSize?: number);
|
||||
protected constructor(params?: P, page?: number, pageSize?: number);
|
||||
abstract get type(): string;
|
||||
clear(): void;
|
||||
loadPrev(): Promise<void>;
|
||||
|
@ -44,7 +47,7 @@ export default abstract class PaginatedListState<T extends Model> {
|
|||
* @param page
|
||||
* @see requestParams
|
||||
*/
|
||||
refreshParams(newParams: any, page: number): Promise<void> | undefined;
|
||||
refreshParams(newParams: P, page: number): Promise<void>;
|
||||
refresh(page?: number): Promise<void>;
|
||||
getPages(): Page<T>[];
|
||||
getLocation(): PaginationLocation;
|
||||
|
@ -73,6 +76,6 @@ export default abstract class PaginatedListState<T extends Model> {
|
|||
getParams(): any;
|
||||
protected getNextPageNumber(): number;
|
||||
protected getPrevPageNumber(): number;
|
||||
protected paramsChanged(newParams: any): boolean;
|
||||
protected paramsChanged(newParams: P): boolean;
|
||||
protected getAllItems(): T[];
|
||||
}
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
export default class RequestError {
|
||||
import type Mithril from 'mithril';
|
||||
export declare type InternalFlarumRequestOptions<ResponseType> = Mithril.RequestOptions<ResponseType> & {
|
||||
errorHandler: (error: RequestError) => void;
|
||||
url: string;
|
||||
};
|
||||
export default class RequestError<ResponseType = string> {
|
||||
status: number;
|
||||
options: Record<string, unknown>;
|
||||
options: InternalFlarumRequestOptions<ResponseType>;
|
||||
xhr: XMLHttpRequest;
|
||||
responseText: string | null;
|
||||
response: Record<string, unknown> | null;
|
||||
response: {
|
||||
[key: string]: unknown;
|
||||
errors?: {
|
||||
detail?: string;
|
||||
code?: string;
|
||||
[key: string]: unknown;
|
||||
}[];
|
||||
} | null;
|
||||
alert: any;
|
||||
constructor(status: number, responseText: string | null, options: Record<string, unknown>, xhr: XMLHttpRequest);
|
||||
constructor(status: number, responseText: string | null, options: InternalFlarumRequestOptions<ResponseType>, xhr: XMLHttpRequest);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import dayjs from 'dayjs';
|
||||
/**
|
||||
* The `humanTime` utility converts a date to a localized, human-readable time-
|
||||
* ago string.
|
||||
*/
|
||||
export default function humanTime(time: Date): string;
|
||||
export default function humanTime(time: dayjs.ConfigType): string;
|
||||
|
|
|
@ -7,6 +7,7 @@ import DiscussionListState from './states/DiscussionListState';
|
|||
import ComposerState from './states/ComposerState';
|
||||
import type Notification from './components/Notification';
|
||||
import type Post from './components/Post';
|
||||
import Discussion from '../common/models/Discussion';
|
||||
export default class ForumApplication extends Application {
|
||||
/**
|
||||
* A map of notification types to their components.
|
||||
|
@ -50,11 +51,8 @@ export default class ForumApplication extends Application {
|
|||
mount(): void;
|
||||
/**
|
||||
* Check whether or not the user is currently viewing a discussion.
|
||||
*
|
||||
* @param {Discussion} discussion
|
||||
* @return {Boolean}
|
||||
*/
|
||||
viewingDiscussion(discussion: any): boolean;
|
||||
viewingDiscussion(discussion: Discussion): boolean;
|
||||
/**
|
||||
* Callback for when an external authenticator (social login) action has
|
||||
* completed.
|
||||
|
@ -62,11 +60,6 @@ export default class ForumApplication extends Application {
|
|||
* If the payload indicates that the user has been logged in, then the page
|
||||
* will be reloaded. Otherwise, a SignUpModal will be opened, prefilled
|
||||
* with the provided details.
|
||||
*
|
||||
* @param {Object} payload A dictionary of attrs to pass into the sign up
|
||||
* modal. A truthy `loggedIn` attr indicates that the user has logged
|
||||
* in, and thus the page is reloaded.
|
||||
* @public
|
||||
*/
|
||||
authenticationComplete(payload: any): void;
|
||||
authenticationComplete(payload: Record<string, unknown>): void;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,33 @@
|
|||
import type Mithril from 'mithril';
|
||||
import Page, { IPageAttrs } from '../../common/components/Page';
|
||||
import ItemList from '../../common/utils/ItemList';
|
||||
import PostStreamState from '../states/PostStreamState';
|
||||
import Discussion from '../../common/models/Discussion';
|
||||
export interface IDiscussionPageAttrs extends IPageAttrs {
|
||||
id: string;
|
||||
near?: number;
|
||||
}
|
||||
/**
|
||||
* The `DiscussionPage` component displays a whole discussion page, including
|
||||
* the discussion list pane, the hero, the posts, and the sidebar.
|
||||
*/
|
||||
export default class DiscussionPage extends Page<import("../../common/components/Page").IPageAttrs> {
|
||||
constructor();
|
||||
useBrowserScrollRestoration: boolean | undefined;
|
||||
export default class DiscussionPage<CustomAttrs extends IDiscussionPageAttrs = IDiscussionPageAttrs> extends Page<CustomAttrs> {
|
||||
/**
|
||||
* The discussion that is being viewed.
|
||||
*
|
||||
* @type {Discussion}
|
||||
*/
|
||||
discussion: any;
|
||||
protected discussion: Discussion | null;
|
||||
/**
|
||||
* A public API for interacting with the post stream.
|
||||
*/
|
||||
protected stream: PostStreamState | null;
|
||||
/**
|
||||
* The number of the first post that is currently visible in the viewport.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
near: number | undefined;
|
||||
bodyClass: string | undefined;
|
||||
protected near: number;
|
||||
protected useBrowserScrollRestoration: boolean;
|
||||
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
|
||||
onremove(vnode: Mithril.VnodeDOM<CustomAttrs, this>): void;
|
||||
view(): JSX.Element;
|
||||
/**
|
||||
* List of components shown while the discussion is loading.
|
||||
*
|
||||
|
@ -29,13 +39,13 @@ export default class DiscussionPage extends Page<import("../../common/components
|
|||
*
|
||||
* @returns {import('mithril').Children}
|
||||
*/
|
||||
sidebar(): import('mithril').Children;
|
||||
sidebar(): JSX.Element;
|
||||
/**
|
||||
* Renders the discussion's hero.
|
||||
*
|
||||
* @returns {import('mithril').Children}
|
||||
*/
|
||||
hero(): import('mithril').Children;
|
||||
hero(): JSX.Element;
|
||||
/**
|
||||
* List of items rendered as the main page content.
|
||||
*
|
||||
|
@ -58,14 +68,16 @@ export default class DiscussionPage extends Page<import("../../common/components
|
|||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
requestParams(): Object;
|
||||
requestParams(): {
|
||||
bySlug: boolean;
|
||||
page: {
|
||||
near: number;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Initialize the component to display the given discussion.
|
||||
*
|
||||
* @param {Discussion} discussion
|
||||
*/
|
||||
show(discussion: any): void;
|
||||
stream: PostStreamState | undefined;
|
||||
show(discussion: Discussion): void;
|
||||
/**
|
||||
* Build an item list for the contents of the sidebar.
|
||||
*
|
||||
|
@ -75,12 +87,6 @@ export default class DiscussionPage extends Page<import("../../common/components
|
|||
/**
|
||||
* When the posts that are visible in the post stream change (i.e. the user
|
||||
* scrolls up or down), then we update the URL and mark the posts as read.
|
||||
*
|
||||
* @param {Integer} startNumber
|
||||
* @param {Integer} endNumber
|
||||
*/
|
||||
positionChanged(startNumber: any, endNumber: any): void;
|
||||
positionChanged(startNumber: number, endNumber: number): void;
|
||||
}
|
||||
import Page from "../../common/components/Page";
|
||||
import ItemList from "../../common/utils/ItemList";
|
||||
import PostStreamState from "../states/PostStreamState";
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { SearchSource } from './Search';
|
||||
import type Mithril from 'mithril';
|
||||
import Discussion from '../../common/models/Discussion';
|
||||
/**
|
||||
* The `DiscussionsSearchSource` finds and displays discussion search results in
|
||||
* the search dropdown.
|
||||
*/
|
||||
export default class DiscussionsSearchSource implements SearchSource {
|
||||
protected results: Map<string, unknown[]>;
|
||||
search(query: string): Promise<Map<string, unknown[]>>;
|
||||
protected results: Map<string, Discussion[]>;
|
||||
search(query: string): Promise<void>;
|
||||
view(query: string): Array<Mithril.Vnode>;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ export default class IndexPage extends Page<import("../../common/components/Page
|
|||
static providesInitialSearch: boolean;
|
||||
constructor();
|
||||
lastDiscussion: any;
|
||||
bodyClass: string | undefined;
|
||||
scrollTopOnCreate: boolean | undefined;
|
||||
setTitle(): void;
|
||||
/**
|
||||
* Get the component to display as the hero.
|
||||
|
|
|
@ -4,6 +4,5 @@
|
|||
*/
|
||||
export default class NotificationsPage extends Page<import("../../common/components/Page").IPageAttrs> {
|
||||
constructor();
|
||||
bodyClass: string | undefined;
|
||||
}
|
||||
import Page from "../../common/components/Page";
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/// <reference types="node" />
|
||||
import Component, { ComponentAttrs } from '../../common/Component';
|
||||
import ItemList from '../../common/utils/ItemList';
|
||||
import KeyboardNavigatable from '../utils/KeyboardNavigatable';
|
||||
|
@ -16,8 +17,9 @@ import type Mithril from 'mithril';
|
|||
export interface SearchSource {
|
||||
/**
|
||||
* Make a request to get results for the given query.
|
||||
* The results will be updated internally in the search source, not exposed.
|
||||
*/
|
||||
search(query: string): any;
|
||||
search(query: string): Promise<void>;
|
||||
/**
|
||||
* Get an array of virtual <li>s that list the search results for the given
|
||||
* query.
|
||||
|
@ -45,7 +47,7 @@ export default class Search<T extends SearchAttrs = SearchAttrs> extends Compone
|
|||
* The minimum query length before sources are searched.
|
||||
*/
|
||||
protected static MIN_SEARCH_LEN: number;
|
||||
protected state: SearchState;
|
||||
protected searchState: SearchState;
|
||||
/**
|
||||
* Whether or not the search input has focus.
|
||||
*/
|
||||
|
@ -66,14 +68,14 @@ export default class Search<T extends SearchAttrs = SearchAttrs> extends Compone
|
|||
*/
|
||||
protected index: number;
|
||||
protected navigator: KeyboardNavigatable;
|
||||
protected searchTimeout?: number;
|
||||
protected searchTimeout?: NodeJS.Timeout;
|
||||
private updateMaxHeightHandler?;
|
||||
oninit(vnode: Mithril.Vnode<T, this>): void;
|
||||
view(): JSX.Element;
|
||||
updateMaxHeight(): void;
|
||||
onupdate(vnode: any): void;
|
||||
oncreate(vnode: any): void;
|
||||
onremove(vnode: any): void;
|
||||
onupdate(vnode: Mithril.VnodeDOM<T, this>): void;
|
||||
oncreate(vnode: Mithril.VnodeDOM<T, this>): void;
|
||||
onremove(vnode: Mithril.VnodeDOM<T, this>): void;
|
||||
/**
|
||||
* Navigate to the currently selected search result and close the list.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,6 @@ export default class UserPage extends Page<import("../../common/components/Page"
|
|||
* @type {User}
|
||||
*/
|
||||
user: any;
|
||||
bodyClass: string | undefined;
|
||||
/**
|
||||
* Get the content to display in the user page.
|
||||
*
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { SearchSource } from './Search';
|
||||
import type Mithril from 'mithril';
|
||||
import { SearchSource } from './Search';
|
||||
import User from '../../common/models/User';
|
||||
/**
|
||||
* The `UsersSearchSource` finds and displays user search results in the search
|
||||
* dropdown.
|
||||
*/
|
||||
export default class UsersSearchResults implements SearchSource {
|
||||
protected results: Map<string, unknown[]>;
|
||||
protected results: Map<string, User[]>;
|
||||
search(query: string): Promise<void>;
|
||||
view(query: string): Array<Mithril.Vnode>;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import type Mithril from 'mithril';
|
||||
import DefaultResolver from '../../common/resolvers/DefaultResolver';
|
||||
import DiscussionPage, { IDiscussionPageAttrs } from '../components/DiscussionPage';
|
||||
/**
|
||||
* A custom route resolver for DiscussionPage that generates the same key to all posts
|
||||
* on the same discussion. It triggers a scroll when going from one post to another
|
||||
* in the same discussion.
|
||||
*/
|
||||
export default class DiscussionPageResolver extends DefaultResolver {
|
||||
static scrollToPostNumber: string | null;
|
||||
export default class DiscussionPageResolver<Attrs extends IDiscussionPageAttrs = IDiscussionPageAttrs, RouteArgs extends Record<string, unknown> = {}> extends DefaultResolver<Attrs, DiscussionPage<Attrs>, RouteArgs> {
|
||||
static scrollToPostNumber: number | null;
|
||||
/**
|
||||
* Remove optional parts of a discussion's slug to keep the substring
|
||||
* that bijectively maps to a discussion object. By default this just
|
||||
|
@ -18,6 +20,6 @@ export default class DiscussionPageResolver extends DefaultResolver {
|
|||
* @inheritdoc
|
||||
*/
|
||||
makeKey(): string;
|
||||
onmatch(args: any, requestedPath: any, route: any): any;
|
||||
render(vnode: any): any;
|
||||
onmatch(args: Attrs & RouteArgs, requestedPath: string, route: string): new () => DiscussionPage<Attrs>;
|
||||
render(vnode: Mithril.Vnode<Attrs, DiscussionPage<Attrs>>): Mithril.Children;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import PaginatedListState, { Page } from '../../common/states/PaginatedListState';
|
||||
import PaginatedListState, { Page, PaginatedListParams } from '../../common/states/PaginatedListState';
|
||||
import Discussion from '../../common/models/Discussion';
|
||||
export interface IRequestParams {
|
||||
include: string[];
|
||||
filter: Record<string, string>;
|
||||
sort?: string;
|
||||
}
|
||||
export default class DiscussionListState extends PaginatedListState<Discussion> {
|
||||
export interface DiscussionListParams extends PaginatedListParams {
|
||||
sort?: string;
|
||||
}
|
||||
export default class DiscussionListState<P extends DiscussionListParams = DiscussionListParams> extends PaginatedListState<Discussion, P> {
|
||||
protected extraDiscussions: Discussion[];
|
||||
constructor(params: any, page?: number);
|
||||
constructor(params: P, page?: number);
|
||||
get type(): string;
|
||||
requestParams(): IRequestParams;
|
||||
protected loadPage(page?: number): Promise<Discussion[]>;
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
export interface HistoryEntry {
|
||||
name: string;
|
||||
title: string;
|
||||
url: string;
|
||||
}
|
||||
/**
|
||||
* The `History` class keeps track and manages a stack of routes that the user
|
||||
* has navigated to in their session.
|
||||
|
@ -10,61 +15,41 @@
|
|||
* rather than the previous discussion.
|
||||
*/
|
||||
export default class History {
|
||||
constructor(defaultRoute: any);
|
||||
/**
|
||||
* The stack of routes that have been navigated to.
|
||||
*
|
||||
* @type {Array}
|
||||
* @protected
|
||||
*/
|
||||
protected stack: any[];
|
||||
protected stack: HistoryEntry[];
|
||||
/**
|
||||
* Get the item on the top of the stack.
|
||||
*
|
||||
* @return {Object}
|
||||
* @public
|
||||
*/
|
||||
public getCurrent(): Object;
|
||||
getCurrent(): HistoryEntry;
|
||||
/**
|
||||
* Get the previous item on the stack.
|
||||
*
|
||||
* @return {Object}
|
||||
* @public
|
||||
*/
|
||||
public getPrevious(): Object;
|
||||
getPrevious(): HistoryEntry;
|
||||
/**
|
||||
* Push an item to the top of the stack.
|
||||
*
|
||||
* @param {String} name The name of the route.
|
||||
* @param {String} title The title of the route.
|
||||
* @param {String} [url] The URL of the route. The current URL will be used if
|
||||
* @param {string} name The name of the route.
|
||||
* @param {string} title The title of the route.
|
||||
* @param {string} [url] The URL of the route. The current URL will be used if
|
||||
* not provided.
|
||||
* @public
|
||||
*/
|
||||
public push(name: string, title: string, url?: string | undefined): void;
|
||||
push(name: string, title: string, url?: string): void;
|
||||
/**
|
||||
* Check whether or not the history stack is able to be popped.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
public canGoBack(): boolean;
|
||||
canGoBack(): boolean;
|
||||
/**
|
||||
* Go back to the previous route in the history stack.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
public back(): void;
|
||||
back(): void;
|
||||
/**
|
||||
* Get the URL of the previous page.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
public backUrl(): any;
|
||||
backUrl(): string;
|
||||
/**
|
||||
* Go to the first route in the history stack.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
public home(): void;
|
||||
home(): void;
|
||||
}
|
||||
|
|
2
framework/core/js/dist/admin.js
generated
vendored
2
framework/core/js/dist/admin.js
generated
vendored
File diff suppressed because one or more lines are too long
2
framework/core/js/dist/admin.js.map
generated
vendored
2
framework/core/js/dist/admin.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
framework/core/js/dist/forum.js
generated
vendored
2
framework/core/js/dist/forum.js
generated
vendored
File diff suppressed because one or more lines are too long
2
framework/core/js/dist/forum.js.map
generated
vendored
2
framework/core/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user