The Application responsible for editing, displaying, and using a single RollTable document.

HandlebarsApplication

Hierarchy (View Summary)

Constructors

  • Parameters

    • options: any
    • ...args: any[]

    Returns RollTableSheet

Properties

Application instance configuration options.

position: ApplicationPosition = ...

The current position of the application with respect to the window.document.body.

tabGroups: Record<string, null | string> = ...

If this Application uses tabbed navigation groups, this mapping is updated whenever the changeTab method is called. Reports the active tab for each group, with a value of null indicating no tab is active. Subclasses may override this property to define default tabs for each group.

_appId: number = 0

An incrementing integer Application ID.

_maxZ: number = ...

The current maximum z-index of any displayed Application.

BASE_APPLICATION: typeof ApplicationV2 = ApplicationV2

Designates which upstream Application class in this class' inheritance chain is the base application. Any DEFAULT_OPTIONS of super-classes further upstream of the BASE_APPLICATION are ignored. Hook events for super-classes further upstream of the BASE_APPLICATION are not dispatched.

DEFAULT_OPTIONS: {
    actions: {
        changeMode: (
            event: PointerEvent,
            target: HTMLElement,
        ) => void | Promise<void>;
        createResult: (
            event: PointerEvent,
            target: HTMLElement,
        ) => void | Promise<void>;
        deleteResult: (
            event: PointerEvent,
            target: HTMLElement,
        ) => void | Promise<void>;
        drawResult: (
            event: PointerEvent,
            target: HTMLElement,
        ) => void | Promise<void>;
        drawSpecificResult: (
            event: PointerEvent,
            target: HTMLElement,
        ) => void | Promise<void>;
        lockResult: (
            event: PointerEvent,
            target: HTMLElement,
        ) => void | Promise<void>;
        normalizeResults: (
            event: PointerEvent,
            target: HTMLElement,
        ) => void | Promise<void>;
        openResultSheet: (
            event: PointerEvent,
            target: HTMLElement,
        ) => void | Promise<void>;
        resetResults: (
            event: PointerEvent,
            target: HTMLElement,
        ) => void | Promise<void>;
    };
    classes: string[];
    form: { closeOnSubmit: boolean };
    position: { width: number };
    window: { contentClasses: string[]; icon: string; resizable: boolean };
} = ...
emittedEvents: readonly ["render", "close", "position"] = ...
MODE_PARTS: { edit: string[]; view: string[] } = ...

Parts for each view

PARTS: {
    footer: { template: string };
    header: { template: string };
    results: { scrollable: string[]; template: string; templates: string[] };
    sheet: {
        root: boolean;
        scrollable: string[];
        template: string;
        templates: string[];
    };
    summary: { template: string };
    tabs: { template: string };
} = ...
RENDER_STATES: Record<string, number> = ...

The sequence of rendering states that describe the Application life-cycle.

TABS: {
    sheet: {
        initial: string;
        labelPrefix: string;
        tabs: { icon: string; id: string }[];
    };
} = ...

Accessors

  • get classList(): DOMTokenList

    The CSS class list of this Application instance

    Returns DOMTokenList

  • get document(): ClientDocument

    The Document instance associated with the application

    Returns ClientDocument

  • get element(): HTMLElement

    The HTMLElement which renders this Application into the DOM.

    Returns HTMLElement

  • get form(): null | HTMLFormElement

    Does this Application have a top-level form element?

    Returns null | HTMLFormElement

  • get hasFrame(): boolean

    Does this Application instance render within an outer window frame?

    Returns boolean

  • get id(): string

    The HTML element ID of this Application instance. This provides a readonly view into the internal ID used by this application. This getter should not be overridden by subclasses, which should instead configure the ID in DEFAULT_OPTIONS or by defining a uniqueId during _initializeApplicationOptions.

    Returns string

  • get isEditable(): boolean

    Is this Document sheet editable by the current User? This is governed by the editPermission threshold configured for the class.

    Returns boolean

  • get isEditMode(): boolean

    Is the sheet in edit mode?

    Returns boolean

  • get isVisible(): boolean

    Is this Document sheet visible to the current User? This is governed by the viewPermission threshold configured for the class.

    Returns boolean

  • get minimized(): boolean

    Is this Application instance currently minimized?

    Returns boolean

  • get mode(): "view" | "edit"

    The operational mode of this sheet

    Returns "view" | "edit"

  • set mode(value: "view" | "edit"): void

    Change the operational mode of this sheet. Changing this value will also change the mode in which subsequent RollTableSheet instances first render.

    Parameters

    • value: "view" | "edit"

    Returns void

  • get rendered(): boolean

    Is this Application instance currently rendered?

    Returns boolean

  • get state(): number

    The current render state of the Application.

    Returns number

  • get title(): string

    Returns string

  • get window(): {
        close: HTMLButtonElement;
        content: HTMLElement;
        controls: HTMLButtonElement;
        controlsDropdown: HTMLDivElement;
        header: HTMLElement;
        icon: HTMLElement;
        onDrag: Function;
        onResize: Function;
        pointerMoveThrottle: boolean;
        pointerStartPosition: ApplicationPosition;
        resize: HTMLElement;
        title: HTMLHeadingElement;
    }

    Convenience references to window header elements.

    Returns {
        close: HTMLButtonElement;
        content: HTMLElement;
        controls: HTMLButtonElement;
        controlsDropdown: HTMLDivElement;
        header: HTMLElement;
        icon: HTMLElement;
        onDrag: Function;
        onResize: Function;
        pointerMoveThrottle: boolean;
        pointerStartPosition: ApplicationPosition;
        resize: HTMLElement;
        title: HTMLHeadingElement;
    }

Methods

  • Internal

    Wait for a CSS transition to complete for an element.

    Parameters

    • element: HTMLElement

      The element which is transitioning

    • timeout: number

      A timeout in milliseconds in case the transitionend event does not occur

    Returns Promise<void>

  • Parameters

    • _options: any

    Returns void

  • Parameters

    • options: any

    Returns void

  • Parameters

    • options: any

    Returns any

  • Internal

    Perform an event in the application life-cycle. Await an internal life-cycle method defined by the class. Optionally dispatch an event for any registered listeners.

    Parameters

    • handler: Function

      A handler function to call

    • options: {
          async?: boolean;
          debugText?: string;
          eventName?: string;
          handlerArgs?: any[];
          hookArgs?: any[];
          hookName?: string;
          hookResponse?: boolean;
          parentClassHooks?: boolean;
      } = {}

      Options which configure event handling

      • Optionalasync?: boolean

        Await the result of the handler function?

      • OptionaldebugText?: string

        Debugging text to log for the event

      • OptionaleventName?: string

        An event name to dispatch for registered listeners

      • OptionalhandlerArgs?: any[]

        Arguments passed to the handler function

      • OptionalhookArgs?: any[]

        Arguments passed to the requested hook function

      • OptionalhookName?: string

        A hook name to dispatch for this and all parent classes

      • OptionalhookResponse?: boolean

        Add the handler response to hookArgs

      • OptionalparentClassHooks?: boolean

        Call hooks for parent classes in the inheritance chain?

    Returns void | Promise<void>

    A promise which resoles once the handler is complete if async is true

  • Parameters

    • options: any

    Returns any

  • Parameters

    • formConfig: any
    • event: any

    Returns void

  • Parameters

    • options: any

    Returns void

  • Parameters

    • context: any
    • options: any

    Returns Promise<void>

  • Parameters

    • context: any
    • options: any

    Returns Promise<void>

  • Parameters

    • event: any

    Returns void

  • Parameters

    • options: any

    Returns Promise<
        ApplicationRenderContext & {
            document: ClientDocument;
            editable: boolean;
            fields: any;
            rootId: string;
            source: any;
            user: null
            | documents.User;
        },
    >

  • Parameters

    • partId: any
    • context: any
    • options: any

    Returns Promise<any>

  • Parameters

    • event: any
    • form: any
    • formData: any
    • updateData: any

    Returns object

  • Parameters

    • group: any

    Returns Record<string, ApplicationTab> | { tabs: {} }

  • Parameters

    • context: any
    • options: any

    Returns Promise<void>

  • Parameters

    • options: any

    Returns Promise<HTMLElement>

  • Add a new event listener for a certain type of event.

    Parameters

    • type: string

      The type of event being registered for

    • listener: EmittedEventListener

      The listener function called when the event occurs

    • Optionaloptions: { once?: boolean } = {}

      Options which configure the event listener

      • Optionalonce?: boolean

        Should the event only be responded to once and then removed

    Returns void

  • Bring this Application window to the front of the rendering stack by increasing its z-index. Once ApplicationV1 is deprecated we should switch from _maxZ to ApplicationV2#maxZ We should also eliminate ui.activeWindow in favor of only ApplicationV2#frontApp

    Returns void

  • Change the active tab within a tab group in this Application instance.

    Parameters

    • tab: string

      The name of the tab which should become active

    • group: string

      The name of the tab group which defines the set of tabs

    • Optionaloptions: {
          event?: Event;
          force?: boolean;
          navElement?: HTMLElement;
          updatePosition?: boolean;
      } = {}

      Additional options which affect tab navigation

      • Optionalevent?: Event

        An interaction event which caused the tab change, if any

      • Optionalforce?: boolean

        Force changing the tab even if the new tab is already active

      • OptionalnavElement?: HTMLElement

        An explicit navigation element being modified

      • OptionalupdatePosition?: boolean

        Update application position after changing the tab?

    Returns void

  • Close the Application, removing it from the DOM.

    Parameters

    Returns Promise<RollTableSheet>

    A Promise which resolves to the closed Application instance

  • Restore the Application to its original dimensions.

    Returns Promise<void>

  • Minimize the Application, collapsing it to a minimal header.

    Returns Promise<void>

  • Update the Application element position using provided data which is merged with the prior position.

    Parameters

    Returns void | ApplicationPosition

    The updated application position

  • Parameters

    • options: any

    Returns Promise<any>

  • Toggle display of the Application controls menu. Only applicable to window Applications.

    Parameters

    • Optionalexpanded: boolean

      Set the controls visibility to a specific state. Otherwise, the visible state is toggled from its current value

    • Optionaloptions: { animate?: boolean } = {}

      Options to configure the toggling behavior.

      • Optionalanimate?: boolean

        Animate the controls toggling.

    Returns Promise<void>

    A Promise which resolves once the control expansion animation is complete

  • Protected

    Display a roulette style animation when a Roll Table result is drawn from the sheet.

    Parameters

    • results: TableResult[]

      An Array of drawn table results to highlight

    Returns Promise<void>

    A Promise that resolves once the animation is complete

  • Protected

    Animate a "roulette" through the table until arriving at the final loop and a drawn result

    Parameters

    • resultsTable: HTMLElement

      The list element being iterated

    • drawnIds: Set<string>

      The result IDs which have already been drawn

    • nLoops: number

      The number of times to loop through the animation

    • animTime: number

      The desired animation time in milliseconds

    • animOffset: number

      The desired pixel offset of the result within the list

    Returns Promise<void>

    A Promise that resolves once the animation is complete

  • Protected

    Attach event listeners to the Application frame.

    Returns void

  • Protected

    Create a ContextMenu instance used in this Application.

    Parameters

    • handler: () => ContextMenuEntry[]

      A handler function that provides initial context options

    • selector: string

      A CSS selector to which the ContextMenu will be bound

    • Optionaloptions: { container?: HTMLElement; hookName?: string; parentClassHooks?: boolean } = {}

      Additional options which affect ContextMenu construction

      • Optionalcontainer?: HTMLElement

        A parent HTMLElement which contains the selector target

      • OptionalhookName?: string

        The hook name

      • OptionalparentClassHooks?: boolean

        Whether to call hooks for the parent classes in the inheritance chain.

    Returns null | ContextMenu

    A created ContextMenu or null if no menu items were defined

  • Protected

    Create a Table Result from initial data and with reasonable defaults.

    Parameters

    • initialData: DeepPartial<TableResultData> = {}

    Returns Promise<void>

  • Protected

    Display a flashing animation on the selected result to emphasize the draw

    Parameters

    • item: HTMLElement

      The HTML li item of the winning result

    Returns Promise<void>

    A Promise that resolves once the animation is complete

  • Protected

    Insert the application HTML element into the DOM. Subclasses may override this method to customize how the application is inserted.

    Parameters

    • element: HTMLElement

      The element to insert

    Returns void

  • Protected

    A generic event handler for action clicks which can be extended by subclasses. Action handlers defined in DEFAULT_OPTIONS are called first. This method is only called for actions which have no defined handler.

    Parameters

    • event: PointerEvent

      The originating click event

    • target: HTMLElement

      The capturing HTML element which defined a [data-action]

    Returns void

  • Protected

    Handle click events on a tab within the Application.

    Parameters

    • event: PointerEvent

    Returns void

  • Protected

    Create a Compendium or Document result from a dropped document.

    Parameters

    • event: DragEvent

      The triggering drop event

    Returns Promise<void>

  • Protected

    Actions performed after the Application is re-positioned.

    Parameters

    Returns void

  • Protected

    Handle submission for an Application which uses the form element.

    Parameters

    • formConfig: ApplicationFormConfiguration

      The form configuration for which this handler is bound

    • event: Event | SubmitEvent

      The form submission event

    Returns Promise<void>

  • Protected

    Prepare sheet data for a single TableResult.

    Parameters

    • result: TableResult

      The result from which to prepare

    Returns Promise<object>

    The sheet data for this result

  • Protected

    Actions performed before the Application is re-positioned. Pre-position steps are not awaited because setPosition is synchronous.

    Parameters

    Returns void

  • Protected

    Customize how form data is extracted into an expanded object.

    Parameters

    • event: null | SubmitEvent

      The originating form submission event

    • form: HTMLFormElement

      The form element that was submitted

    • formData: FormDataExtended

      Processed data for the submitted form

    Returns object

    An expanded object of processed form data

    Subclasses may throw validation errors here to prevent form submission

  • Protected

    Submit a document update or creation request based on the processed form data.

    Parameters

    • event: SubmitEvent

      The originating form submission event

    • form: HTMLFormElement

      The form element that was submitted

    • submitData: object

      Processed and validated form data to be used for a document update

    • Optionaloptions: Partial<DatabaseCreateOperation | DatabaseUpdateOperation> = {}

      Additional options altering the request

    Returns Promise<void>

  • Protected

    Remove the application HTML element from the DOM. Subclasses may override this method to customize how the application element is removed.

    Parameters

    • element: HTMLElement

      The element to be removed

    Returns void

  • Protected

    Replace the HTML of the application with the result provided by the rendering backend. An Application subclass should implement this method in order for the Application to be renderable.

    Parameters

    • result: any

      The result returned by the application rendering backend

    • content: HTMLElement

      The content element into which the rendered result must be inserted

    • options: ApplicationRenderOptions & DocumentSheetRenderOptions

      Options which configure application rendering behavior

    Returns void

  • Protected

    Compare a pair of results for sorted display in this sheet.

    Parameters

    • resultA: object

      Sheet data for a result

    • resultB: object

      Sheet data for a different result

    Returns number

    A comparator return value expected by Array#sort

  • Protected

    Remove elements from the DOM and trigger garbage collection as part of application closure.

    Parameters

    Returns void

  • Protected

    Disable or reenable all form fields in this application.

    Parameters

    • disabled: boolean

      Should the fields be disabled?

    Returns void

  • Protected

    Translate a requested application position updated into a resolved allowed position for the Application. Subclasses may override this method to implement more advanced positioning behavior.

    Parameters

    Returns ApplicationPosition

    Resolved Application positioning data

  • Protected

    Prepare the details HTML for a single result.

    Parameters

    • result: TableResult

    Returns Promise<string>

  • Iterate over the inheritance chain of this Application. The chain includes this Application itself and all parents until the base application is encountered.

    Returns Generator<typeof ApplicationV2, void, unknown>

  • Parse a CSS style rule into a number of pixels which apply to that dimension.

    Parameters

    • style: string

      The CSS style rule

    • parentDimension: number

      The relevant dimension of the parent element

    Returns number | void

    The parsed style dimension in pixels

  • Wait for any images in the given element to load.

    Parameters

    • element: HTMLElement

      The element.

    Returns Promise<void>