The User configuration application.

Mixes

HandlebarsApplication

Alias

UserConfig

Hierarchy (view full)

Properties

Application instance configuration options.

tabGroups: Record<string, 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. Subclasses may override this property to define default tabs for each group.

position: ApplicationPosition = ...

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

#id: string
#renderable: boolean = true

Flag that this Application instance is renderable. Applications are not renderable unless a subclass defines the _renderHTML and _replaceHTML methods.

#element: HTMLDivElement

The outermost HTMLElement of this rendered Application. For window applications this is ApplicationV2##frame. For non-window applications this ApplicationV2##content.

#content: HTMLElement

The HTMLElement within which inner HTML is rendered. For non-window applications this is the same as ApplicationV2##element.

#minimization: {
    active: boolean;
} = ...

Data pertaining to the minimization status of the Application.

Type declaration

  • active: boolean
#position: ApplicationPosition = ...

The rendered position of the Application.

#state: Readonly<{
    ERROR: -3;
    CLOSING: -2;
    CLOSED: -1;
    NONE: 0;
    RENDERING: 1;
    RENDERED: 2;
}> = ApplicationV2.RENDER_STATES.NONE

Type declaration

  • ERROR: -3
  • CLOSING: -2
  • CLOSED: -1
  • NONE: 0
  • RENDERING: 1
  • RENDERED: 2
#semaphore: Semaphore = ...

A Semaphore used to enqueue asynchronous operations.

#controlsExpanded: boolean = false

Is the window control buttons menu currently expanded?

#events: Record<string, Map<EmittedEventListener, {
    fn: EmittedEventListener;
    once: boolean;
}>> = {}

A mapping of registered events.

DEFAULT_OPTIONS: {
    classes: string[];
    position: {
        width: number;
        height: string;
    };
    actions: {
        releaseCharacter: ((event) => void);
    };
    form: {
        closeOnSubmit: boolean;
    };
} = ...

The default configuration options which are assigned to every instance of this Application class.

Type declaration

  • classes: string[]
  • position: {
        width: number;
        height: string;
    }
    • width: number
    • height: string
  • actions: {
        releaseCharacter: ((event) => void);
    }
    • releaseCharacter: ((event) => void)
        • (event): void
        • Handle button clicks to release the currently selected character.

          Parameters

          • event: PointerEvent

          Returns void

  • form: {
        closeOnSubmit: boolean;
    }
    • closeOnSubmit: boolean
PARTS: {
    form: {
        id: string;
        template: string;
    };
} = ...

Type declaration

  • form: {
        id: string;
        template: string;
    }
    • id: string
    • template: string
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.

RENDER_STATES: Readonly<{
    ERROR: -3;
    CLOSING: -2;
    CLOSED: -1;
    NONE: 0;
    RENDERING: 1;
    RENDERED: 2;
}> = ...

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

Type declaration

  • ERROR: -3
  • CLOSING: -2
  • CLOSED: -1
  • NONE: 0
  • RENDERING: 1
  • RENDERED: 2
emittedEvents: readonly string[] = ...

Accessors

  • get title(): string
  • Returns string

  • get document(): ClientDocument
  • The Document instance associated with the application

    Returns ClientDocument

  • 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 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 window(): {
        header: HTMLElement;
        resize: HTMLElement;
        title: HTMLHeadingElement;
        icon: HTMLElement;
        close: HTMLButtonElement;
        controls: HTMLButtonElement;
        controlsDropdown: HTMLDivElement;
        onDrag: Function;
        onResize: Function;
        pointerStartPosition: ApplicationPosition;
        pointerMoveThrottle: boolean;
    }
  • Convenience references to window header elements.

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

    • header: HTMLElement
    • resize: HTMLElement
    • title: HTMLHeadingElement
    • icon: HTMLElement
    • close: HTMLButtonElement
    • controls: HTMLButtonElement
    • controlsDropdown: HTMLDivElement
    • onDrag: Function
    • onResize: Function
    • pointerStartPosition: ApplicationPosition
    • pointerMoveThrottle: boolean
  • get classList(): DOMTokenList
  • The CSS class list of this Application instance

    Returns DOMTokenList

  • get id(): string
  • The HTML element ID of this Application instance.

    Returns string

  • get element(): HTMLElement
  • The HTMLElement which renders this Application into the DOM.

    Returns HTMLElement

  • get minimized(): boolean
  • Is this Application instance currently minimized?

    Returns boolean

  • get rendered(): boolean
  • Is this Application instance currently rendered?

    Returns boolean

  • get state(): Readonly<{
        ERROR: -3;
        CLOSING: -2;
        CLOSED: -1;
        NONE: 0;
        RENDERING: 1;
        RENDERED: 2;
    }>
  • The current render state of the Application.

    Returns Readonly<{
        ERROR: -3;
        CLOSING: -2;
        CLOSED: -1;
        NONE: 0;
        RENDERING: 1;
        RENDERED: 2;
    }>

  • get hasFrame(): boolean
  • Does this Application instance render within an outer window frame?

    Returns boolean

Methods

  • Parameters

    • _options: any

    Returns Promise<{
        user: ClientDocument;
        source: any;
        fields: any;
        characterWidget: any;
    }>

  • Initialize configuration options for the Application instance. The default behavior of this method is to intelligently merge options for each class with those of their parents.

    • Array-based options are concatenated
    • Inner objects are merged
    • Otherwise, properties in the subclass replace those defined by a parent

    Parameters

    • options: any

      Options provided directly to the constructor

    Returns any

    Configured options for the application instance

  • Render the outer framing HTMLElement which wraps the inner HTML of the Application.

    Parameters

    • options: any

      Options which configure application rendering behavior

    Returns Promise<HTMLElement>

  • Actions performed after a first render of the Application. Post-render steps are not awaited by the render process.

    Parameters

    • context: any

      Prepared context data

    • options: any

      Provided render options

    Returns void

  • Customize how form data is extracted into an expanded object.

    Parameters

    • event: 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

    Throws

    Subclasses may throw validation errors here to prevent form submission

  • Programmatically submit a DocumentSheetV2 instance, providing additional data to be merged with form data.

    Parameters

    • options: {
          updateData: object;
      } = {}
      • updateData: object

        Additional data merged with processed form data

    Returns Promise<void>

  • Render the Application, creating its HTMLElement and replacing its innerHTML. Add it to the DOM if it is not currently rendered and rendering is forced. Otherwise, re-render its contents.

    Parameters

    Returns Promise<ApplicationV2<any, any>>

    A Promise which resolves to the rendered Application instance

  • Render an HTMLElement for the Application. An Application subclass must implement this method in order for the Application to be renderable.

    Parameters

    Returns Promise<any>

    The result of HTML rendering may be implementation specific. Whatever value is returned here is passed to _replaceHTML

    Abstract

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

    Parameters

    • Optional expanded: boolean

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

    Returns void

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

    Returns Promise<void>

  • Restore the Application to its original dimensions.

    Returns Promise<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

    • Optional options: {
          event: Event;
          navElement: HTMLElement;
          force: boolean;
          updatePosition: boolean;
      } = {}

      Additional options which affect tab navigation

      • event: Event

        An interaction event which caused the tab change, if any

      • navElement: HTMLElement

        An explicit navigation element being modified

      • force: boolean

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

      • updatePosition: boolean

        Update application position after changing the tab?

    Returns void

  • Handle changes to an input element within the form.

    Parameters

    • formConfig: ApplicationFormConfiguration

      The form configuration for which this handler is bound

    • event: Event

      An input change event within the form

    Returns void

  • 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>

  • Protected

    Prepare data used to update the Item upon form submission. This data is cleaned and validated before being returned for further processing.

    Parameters

    • event: SubmitEvent

      The originating form submission event

    • form: HTMLFormElement

      The form element that was submitted

    • formData: FormDataExtended

      Processed data for the submitted form

    Returns object

    Prepared submission data as an object

    Throws

    Subclasses may throw validation errors here to prevent form submission

  • Protected

    Submit a document update 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

    Returns Promise<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

    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

    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

    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

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

    Parameters

    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 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>

  • Render the Character field as a choice between observed Actors.

    Parameters

    • field: any
    • _groupConfig: any
    • inputConfig: any

    Returns HTMLDivElement

  • Manage the closing step of the Application life-cycle. This private method delegates out to several protected methods which can be defined by the subclass.

    Parameters

    Returns Promise<ApplicationV2<any, any>>

    A Promise which resolves to the rendered Application instance

  • 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;
          handlerArgs: any[];
          debugText: string;
          eventName: string;
          hookName: string;
          hookArgs: any[];
      } = {}

      Options which configure event handling

      • async: boolean

        Await the result of the handler function?

      • handlerArgs: any[]

        Arguments passed to the handler function

      • debugText: string

        Debugging text to log for the event

      • eventName: string

        An event name to dispatch for registered listeners

      • hookName: string

        A hook name to dispatch for this and all parent classes

      • hookArgs: any[]

        Arguments passed to the requested hook function

    Returns Promise<void>

    A promise which resoles once the handler is complete

  • Handle initial pointerdown events inside a rendered Application.

    Parameters

    • event: PointerEvent

    Returns Promise<void>

  • Centralized handling of click events which occur on or within the Application frame.

    Parameters

    • event: PointerEvent

    Returns Promise<void>

  • Handle a click event on an element which defines a [data-action] handler.

    Parameters

    • event: PointerEvent

      The originating click event

    • target: HTMLElement

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

    Returns void

  • Handle click events on a tab within the Application.

    Parameters

    • event: PointerEvent

    Returns void

  • Begin capturing pointer events on the application frame.

    Parameters

    • event: PointerEvent

      The triggering event.

    • callback: Function

      The callback to attach to pointer move events.

    Returns void

  • End capturing pointer events on the application frame.

    Parameters

    • event: PointerEvent

      The triggering event.

    • callback: Function

      The callback to remove from pointer move events.

    Returns void

  • Handle a pointer move event while dragging or resizing the window frame.

    Parameters

    • event: PointerEvent

    Returns void | {
        dx: number;
        dy: number;
    }

    The amount the cursor has moved since the last frame, or undefined if the movement occurred between frames.

  • Drag the Application position during mouse movement.

    Parameters

    • event: PointerEvent

    Returns void

  • Double-click events on the window title are used to minimize or maximize the application.

    Parameters

    • event: PointerEvent

    Returns void

  • 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>

    See

    ApplicationV2.BASE_APPLICATION

    Generator

    Yields

  • 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

    The parsed style dimension in pixels

  • Handle button clicks to release the currently selected character.

    Parameters

    • event: PointerEvent

    Returns void