Variable compat

compat: {
    Application: typeof Application;
    Component: typeof Component;
    Fragment: typeof Fragment;
    Model: typeof Model;
    Session: typeof Session;
    Store: typeof Store;
    Translator: typeof Translator;
    components/Alert: typeof Alert;
    components/AlertManager: typeof AlertManager;
    components/Badge: typeof Badge;
    components/Button: typeof Button;
    components/Checkbox: typeof Checkbox;
    components/ColorPreviewInput: typeof ColorPreviewInput;
    components/Dropdown: typeof Dropdown;
    components/EditUserModal: typeof EditUserModal;
    components/FieldSet: typeof FieldSet;
    components/GroupBadge: typeof GroupBadge;
    components/Link: typeof Link;
    components/LinkButton: typeof LinkButton;
    components/LoadingIndicator: typeof LoadingIndicator;
    components/Modal: typeof Modal;
    components/ModalManager: typeof ModalManager;
    components/Navigation: typeof Navigation;
    components/Page: typeof Page;
    components/Placeholder: typeof Placeholder;
    components/RequestErrorModal: typeof RequestErrorModal;
    components/Select: typeof Select;
    components/SelectDropdown: typeof SelectDropdown;
    components/Separator: typeof Separator;
    components/SplitDropdown: typeof SplitDropdown;
    components/Switch: typeof Switch;
    components/TextEditor: typeof TextEditor;
    components/TextEditorButton: typeof TextEditorButton;
    components/Tooltip: typeof Tooltip;
    extend: common/extend;
    extenders: {
        Model: typeof Model;
        PostTypes: typeof PostTypes;
        Routes: typeof Routes;
        Store: typeof Store;
    };
    helpers/avatar: ((user: null | User, attrs?: ComponentAttrs) => Mithril.Vnode);
    helpers/fullTime: ((time: Date) => Mithril.Vnode);
    helpers/highlight: ((string: string, phrase?: string | RegExp, length?: number) => Mithril.Vnode<any, any> | string);
    helpers/humanTime: ((time: Date) => Mithril.Vnode);
    helpers/icon: ((fontClass: string, attrs?: Attributes) => Mithril.Vnode);
    helpers/listItems: (<Attrs>(rawItems: ModdedChildrenWithItemName[], customTag?: VnodeElementTag<Attrs, Component<Attrs, {}>>, attributes?: Attrs) => Mithril.Vnode[]);
    helpers/punctuateSeries: ((items: Children[]) => Children);
    helpers/textContrastClass: ((hexcolor: string) => string);
    helpers/userOnline: ((user: User) => Mithril.Vnode<{}, {}> | null);
    helpers/username: ((user: undefined | null | false | User) => Mithril.Vnode);
    models/Discussion: typeof Discussion;
    models/Forum: typeof Forum;
    models/Group: typeof Group;
    models/Notification: typeof Notification;
    models/Post: typeof Post;
    models/User: typeof User;
    resolvers/DefaultResolver: typeof DefaultResolver;
    states/AlertManagerState: typeof AlertManagerState;
    states/ModalManagerState: typeof ModalManagerState;
    states/PageState: typeof PageState;
    states/PaginatedListState: typeof PaginatedListState;
    utils/BasicEditorDriver: typeof BasicEditorDriver;
    utils/Drawer: typeof Drawer;
    utils/ItemList: typeof ItemList;
    utils/KeyboardNavigatable: typeof KeyboardNavigatable;
    utils/RequestError: typeof RequestError;
    utils/ScrollListener: typeof ScrollListener;
    utils/Stream: typeof Stream;
    utils/SubtreeRetainer: typeof SubtreeRetainer;
    utils/abbreviateNumber: ((number: number) => string);
    utils/anchorScroll: ((element: string | HTMLElement | Element | SVGElement, callback: (() => void)) => void);
    utils/classList: ((...inputs: ClassValue[]) => string);
    utils/computed: (<T, M>(...args: [...string[], ((this: M, ...args: unknown[]) => T)]) => (() => T));
    utils/escapeRegExp: ((input: string) => string);
    utils/evented: {
        handlers: Record<string, unknown>;
        getHandlers(event: string): Function[];
        off(event: string, handler: Function): void;
        on(event: string, handler: Function): void;
        one(event: string, handler: Function): void;
        trigger(event: string, ...args: any[]): void;
    };
    utils/extract: (<T, K>(object: T, property: K) => T[K]);
    utils/extractText: ((vdom: Children) => string);
    utils/focusTrap: common/utils/focusTrap;
    utils/formatNumber: ((number: number, locale?: string) => string);
    utils/humanTime: ((time: undefined | null | string | number | Date | Dayjs) => string);
    utils/insertText: ((textarea: HTMLTextAreaElement, __namedParameters: SelectionRange) => void);
    utils/isDark: ((hexcolor: string) => boolean);
    utils/isObject: ((obj: unknown) => obj is object);
    utils/liveHumanTimes: (() => void);
    utils/mapRoutes: ((routes: Record<string, FlarumGenericRoute>, basePath?: string) => Record<string, RouteResolver<Record<string, unknown>, Component<{
        routeName: string;
        [key: string]: unknown;
    }, undefined>, Record<string, unknown>>>);
    utils/mixin: ((Parent: object, ...mixins: Record<string, any>[]) => object);
    utils/patchMithril: ((global: any) => void);
    utils/proxifyCompat: ((compat: Record<string, unknown>, namespace: string) => Record<string, unknown>);
    utils/setRouteWithForcedRefresh: ((route: string, params?: null, options?: RouteOptions) => void);
    utils/string: common/utils/string;
    utils/stringToColor: ((string: string) => string);
    utils/styleSelectedText: ((textarea: HTMLTextAreaElement, styleArgs: StyleArgs) => void);
    utils/subclassOf: ((A: any, B: any) => any);
    utils/throttleDebounce: common/utils/throttleDebounce;
    utils/withAttr: ((key: string, cb: Function) => ((this: Element) => void));
}

Type declaration

  • Application: typeof Application
  • Component: typeof Component
  • Fragment: typeof Fragment
  • Model: typeof Model
  • Session: typeof Session
  • Store: typeof Store
  • Translator: typeof Translator
  • components/Alert: typeof Alert
  • components/AlertManager: typeof AlertManager
  • components/Badge: typeof Badge
  • components/Button: typeof Button
  • components/Checkbox: typeof Checkbox
  • components/ColorPreviewInput: typeof ColorPreviewInput
  • components/Dropdown: typeof Dropdown
  • components/EditUserModal: typeof EditUserModal
  • components/FieldSet: typeof FieldSet
  • components/GroupBadge: typeof GroupBadge
  • components/Link: typeof Link
  • components/LinkButton: typeof LinkButton
  • components/LoadingIndicator: typeof LoadingIndicator
  • components/Modal: typeof Modal
  • components/ModalManager: typeof ModalManager
  • components/Navigation: typeof Navigation
  • components/Page: typeof Page
  • components/Placeholder: typeof Placeholder
  • components/RequestErrorModal: typeof RequestErrorModal
  • components/Select: typeof Select
  • components/SelectDropdown: typeof SelectDropdown
  • components/Separator: typeof Separator
  • components/SplitDropdown: typeof SplitDropdown
  • components/Switch: typeof Switch
  • components/TextEditor: typeof TextEditor
  • components/TextEditorButton: typeof TextEditorButton
  • components/Tooltip: typeof Tooltip
  • extend: common/extend
  • extenders: {
        Model: typeof Model;
        PostTypes: typeof PostTypes;
        Routes: typeof Routes;
        Store: typeof Store;
    }
  • helpers/avatar: ((user: null | User, attrs?: ComponentAttrs) => Mithril.Vnode)
      • (user: null | User, attrs?: ComponentAttrs): Mithril.Vnode
      • The avatar helper displays a user's avatar.

        Parameters

        Returns Mithril.Vnode

  • helpers/fullTime: ((time: Date) => Mithril.Vnode)
      • (time: Date): Mithril.Vnode
      • The fullTime helper displays a formatted time string wrapped in a

        Parameters

        Returns Mithril.Vnode

  • helpers/highlight: ((string: string, phrase?: string | RegExp, length?: number) => Mithril.Vnode<any, any> | string)
      • (string: string, phrase?: string | RegExp, length?: number): Mithril.Vnode<any, any> | string
      • The highlight helper searches for a word phrase in a string, and wraps matches with the tag.

        Parameters

        • string: string

          The string to highlight.

        • Optional phrase: string | RegExp

          The word or words to highlight.

        • Optional length: number

          The number of characters to truncate the string to. The string will be truncated surrounding the first match.

        Returns Mithril.Vnode<any, any> | string

  • helpers/humanTime: ((time: Date) => Mithril.Vnode)
      • (time: Date): Mithril.Vnode
      • The humanTime helper displays a time in a human-friendly time-ago format (e.g. '12 days ago'), wrapped in a

        Parameters

        Returns Mithril.Vnode

  • helpers/icon: ((fontClass: string, attrs?: Attributes) => Mithril.Vnode)
      • (fontClass: string, attrs?: Attributes): Mithril.Vnode
      • The icon helper displays an icon.

        Parameters

        • fontClass: string

          The full icon class, prefix and the icon’s name.

        • attrs: Attributes = {}

          Any other attributes to apply.

        Returns Mithril.Vnode

  • helpers/listItems: (<Attrs>(rawItems: ModdedChildrenWithItemName[], customTag?: VnodeElementTag<Attrs, Component<Attrs, {}>>, attributes?: Attrs) => Mithril.Vnode[])
      • <Attrs>(rawItems: ModdedChildrenWithItemName[], customTag?: VnodeElementTag<Attrs, Component<Attrs, {}>>, attributes?: Attrs): Mithril.Vnode[]
      • The listItems helper wraps an array of components in the provided tag, stripping out any unnecessary Separator components.

        By default, this tag is an <li> tag, but this is customisable through the second function parameter, customTag.

        Type Parameters

        Parameters

        Returns Mithril.Vnode[]

  • helpers/punctuateSeries: ((items: Children[]) => Children)
      • (items: Children[]): Children
      • The punctuateSeries helper formats a list of strings (e.g. names) to read fluently in the application's locale.

        punctuateSeries(['Toby', 'Franz', 'Dominion']) // Toby, Franz, and Dominion
        

        Returns

        ')}

        Parameters

        • items: Children[]

        Returns Children

  • helpers/textContrastClass: ((hexcolor: string) => string)
      • (hexcolor: string): string
      • Parameters

        • hexcolor: string

        Returns string

  • helpers/userOnline: ((user: User) => Mithril.Vnode<{}, {}> | null)
      • (user: User): Mithril.Vnode<{}, {}> | null
      • The useronline helper displays a green circle if the user is online.

        Parameters

        Returns Mithril.Vnode<{}, {}> | null

  • helpers/username: ((user: undefined | null | false | User) => Mithril.Vnode)
      • (user: undefined | null | false | User): Mithril.Vnode
      • The username helper displays a user's username in a tag. If the user doesn't exist, the username will be displayed as [deleted].

        Parameters

        • user: undefined | null | false | User

        Returns Mithril.Vnode

  • models/Discussion: typeof Discussion
  • models/Forum: typeof Forum
  • models/Group: typeof Group
  • models/Notification: typeof Notification
  • models/Post: typeof Post
  • models/User: typeof User
  • resolvers/DefaultResolver: typeof DefaultResolver
  • states/AlertManagerState: typeof AlertManagerState
  • states/ModalManagerState: typeof ModalManagerState
  • states/PageState: typeof PageState
  • states/PaginatedListState: typeof PaginatedListState
  • utils/BasicEditorDriver: typeof BasicEditorDriver
  • utils/Drawer: typeof Drawer
  • utils/ItemList: typeof ItemList
  • utils/KeyboardNavigatable: typeof KeyboardNavigatable
  • utils/RequestError: typeof RequestError
  • utils/ScrollListener: typeof ScrollListener
  • utils/Stream: typeof Stream
  • utils/SubtreeRetainer: typeof SubtreeRetainer
  • utils/abbreviateNumber: ((number: number) => string)
      • (number: number): string
      • The abbreviateNumber utility converts a number to a shorter localized form.

        Example

        abbreviateNumber(1234);
        // "1.2K"

        Parameters

        • number: number

        Returns string

  • utils/anchorScroll: ((element: string | HTMLElement | Element | SVGElement, callback: (() => void)) => void)
      • (element: string | HTMLElement | Element | SVGElement, callback: (() => void)): void
      • The anchorScroll utility saves the scroll position relative to an element, and then restores it after a callback has been run.

        This is useful if a redraw will change the page's content above the viewport. Normally doing this will result in the content in the viewport being pushed down or pulled up. By wrapping the redraw with this utility, the scroll position can be anchor to an element that is in or below the viewport, so the content in the viewport will stay the same.

        Parameters

        • element: string | HTMLElement | Element | SVGElement

          The element to anchor the scroll position to.

        • callback: (() => void)

          The callback to run that will change page content.

            • (): void
            • Returns void

        Returns void

  • utils/classList: ((...inputs: ClassValue[]) => string)
      • (...inputs: ClassValue[]): string
      • Parameters

        • Rest ...inputs: ClassValue[]

        Returns string

  • utils/computed: (<T, M>(...args: [...string[], ((this: M, ...args: unknown[]) => T)]) => (() => T))
      • <T, M>(...args: [...string[], ((this: M, ...args: unknown[]) => T)]): (() => T)
      • The computed utility creates a function that will cache its output until any of the dependent values are dirty.

        Type Parameters

        Parameters

        • Rest ...args: [...string[], ((this: M, ...args: unknown[]) => T)]

        Returns (() => T)

          • (): T
          • Returns T

  • utils/escapeRegExp: ((input: string) => string)
  • utils/evented: {
        handlers: Record<string, unknown>;
        getHandlers(event: string): Function[];
        off(event: string, handler: Function): void;
        on(event: string, handler: Function): void;
        one(event: string, handler: Function): void;
        trigger(event: string, ...args: any[]): void;
    }
    • Protected handlers: Record<string, unknown>

      Arrays of registered event handlers, grouped by the event name.

      Deprecated

    • getHandlers:function
    • off:function
      • Unregister an event handler.

        Deprecated

        Parameters

        • event: string

          The name of the event.

        • handler: Function

          The function that handles the event.

        Returns void

    • on:function
      • Register an event handler.

        Deprecated

        Parameters

        • event: string

          The name of the event.

        • handler: Function

          The function to handle the event.

        Returns void

    • one:function
      • Register an event handler so that it will run only once, and then unregister itself.

        Deprecated

        Parameters

        • event: string

          The name of the event.

        • handler: Function

          The function to handle the event.

        Returns void

    • trigger:function
      • Trigger an event.

        Deprecated

        Parameters

        • event: string

          The name of the event.

        • Rest ...args: any[]

          Arguments to pass to event handlers.

        Returns void

  • utils/extract: (<T, K>(object: T, property: K) => T[K])
      • <T, K>(object: T, property: K): T[K]
      • The extract utility deletes a property from an object and returns its value.

        Returns

        The value of the property

        Type Parameters

        • T

        • K extends string | number | symbol

        Parameters

        • object: T

          The object that owns the property

        • property: K

          The name of the property to extract

        Returns T[K]

  • utils/extractText: ((vdom: Children) => string)
      • (vdom: Children): string
      • Extract the text nodes from a virtual element.

        Parameters

        • vdom: Children

        Returns string

  • utils/focusTrap: common/utils/focusTrap
  • utils/formatNumber: ((number: number, locale?: string) => string)
      • (number: number, locale?: string): string
      • The formatNumber utility localizes a number into a string with the appropriate punctuation based on the provided locale otherwise will default to the users locale.

        Example

        formatNumber(1234);
        // 1,234

        Parameters

        • number: number
        • locale: string = app.data.locale

        Returns string

  • utils/humanTime: ((time: undefined | null | string | number | Date | Dayjs) => string)
      • (time: undefined | null | string | number | Date | Dayjs): string
      • The humanTime utility converts a date to a localized, human-readable time- ago string.

        Parameters

        • time: undefined | null | string | number | Date | Dayjs

        Returns string

  • utils/insertText: ((textarea: HTMLTextAreaElement, __namedParameters: SelectionRange) => void)
  • utils/isDark: ((hexcolor: string) => boolean)
      • (hexcolor: string): boolean
      • The isDark utility converts a hex color to rgb, and then calculates a YIQ value in order to get the appropriate brightness value. See https://www.w3.org/TR/AERT/#color-contrast for references.

        A YIQ value >= 128 corresponds to a light color according to the W3C standards, but we use a custom threshold for each light and dark modes to preserve design consistency.

        Parameters

        • hexcolor: string

        Returns boolean

  • utils/isObject: ((obj: unknown) => obj is object)
      • (obj: unknown): obj is object
      • Returns if the passed value is an object.

        In this context, "object" refers to any non-primitive value, including arrays, function, maps, dates, and more.

        Example

        isObject({}); // true
        

        Example

        isObject([]); // true
        

        Example

        isObject(function () {}); // true
        

        Example

        isObject(Object(1)); // true
        

        Example

        isObject(null); // false
        

        Example

        isObject(1); // false
        

        Example

        isObject("hello world"); // false
        

        See

        https://github.com/jashkenas/underscore/blob/943977e34e2279503528a71ddcc2dd5f96483945/underscore.js#L87-L91

        Parameters

        • obj: unknown

        Returns obj is object

  • utils/liveHumanTimes: (() => void)
      • (): void
      • The liveHumanTimes initializer sets up a loop every 1 second to update timestamps rendered with the humanTime helper.

        Returns void

  • utils/mapRoutes: ((routes: Record<string, FlarumGenericRoute>, basePath?: string) => Record<string, RouteResolver<Record<string, unknown>, Component<{
        routeName: string;
        [key: string]: unknown;
    }, undefined>, Record<string, unknown>>>)
      • (routes: Record<string, FlarumGenericRoute>, basePath?: string): Record<string, RouteResolver<Record<string, unknown>, Component<{
            routeName: string;
            [key: string]: unknown;
        }, undefined>, Record<string, unknown>>>
      • The mapRoutes utility converts a map of named application routes into a format that can be understood by Mithril, and wraps them in route resolvers to provide each route with the current route name.

        See

        https://mithril.js.org/route.html#signature

        Parameters

        Returns Record<string, RouteResolver<Record<string, unknown>, Component<{
            routeName: string;
            [key: string]: unknown;
        }, undefined>, Record<string, unknown>>>

  • utils/mixin: ((Parent: object, ...mixins: Record<string, any>[]) => object)
      • (Parent: object, ...mixins: Record<string, any>[]): object
      • The mixin utility assigns the properties of a set of 'mixin' objects to the prototype of a parent object.

        Example

        class MyClass extends mixin(ExistingClass, evented, etc) {}
        

        Returns

        A new class that extends Parent and contains the mixins.

        Parameters

        • Parent: object

          The class to extend the new class from.

        • Rest ...mixins: Record<string, any>[]

          The objects to mix in.

        Returns object

  • utils/patchMithril: ((global: any) => void)
      • (global: any): void
      • Parameters

        • global: any

        Returns void

  • utils/proxifyCompat: ((compat: Record<string, unknown>, namespace: string) => Record<string, unknown>)
      • (compat: Record<string, unknown>, namespace: string): Record<string, unknown>
      • Parameters

        • compat: Record<string, unknown>
        • namespace: string

        Returns Record<string, unknown>

  • utils/setRouteWithForcedRefresh: ((route: string, params?: null, options?: RouteOptions) => void)
      • (route: string, params?: null, options?: RouteOptions): void
      • Mithril 2 does not completely rerender the page if a route change leads to the same route (or the same component handling a different route). This util calls m.route.set, forcing a reonit.

        See

        https://mithril.js.org/route.html#key-parameter

        Parameters

        • route: string
        • params: null = null
        • options: RouteOptions = {}

        Returns void

  • utils/string: common/utils/string
  • utils/stringToColor: ((string: string) => string)
      • (string: string): string
      • Convert the given string to a unique color.

        Parameters

        • string: string

        Returns string

  • utils/styleSelectedText: ((textarea: HTMLTextAreaElement, styleArgs: StyleArgs) => void)
  • utils/subclassOf: ((A: any, B: any) => any)
      • (A: any, B: any): any
      • Check if class A is the same as or a subclass of class B.

        Parameters

        • A: any
        • B: any

        Returns any

  • utils/throttleDebounce: common/utils/throttleDebounce
  • utils/withAttr: ((key: string, cb: Function) => ((this: Element) => void))

Generated using TypeDoc v0.23.24