Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DocumentChooser<SS>

DocumentChooser enables the user to start a new session by loading a new document. This can be done in threee different ways:

  1. Upload a document from the local filesystem
  2. Provide a URL pointing to an existing document
  3. Selecting a document which already exists on the server

In the first two cases, upon submit, the component sends the data to the server and receives a new document ID. With this, the assignDocumentId callback is invoked to let the parent know that a document has been selected. In the third case, the document does not need to be allocated on the server, since it already exists. In that case, assignDocumentId is invoked immediately.

param

Callback invoked when a document ID has been selected

param

Callback invoked when the user updates the trigger mode

param

The current trigger mode

Type parameters

  • SS

Hierarchy

Index

Constructors

constructor

Properties

context

context: any

Private fileInput

fileInput: Nullable<HTMLInputElement>

Private idInput

idInput: Nullable<HTMLSelectElement>

props

props: Readonly<object> & Readonly<DocumentChooserProps>

refs

refs: object

Type declaration

  • [key: string]: ReactInstance

state

state: Readonly<DocumentChooserState>

Private urlInput

urlInput: Nullable<HTMLInputElement>

Methods

Optional UNSAFE_componentWillMount

  • UNSAFE_componentWillMount(): void

Optional UNSAFE_componentWillReceiveProps

  • UNSAFE_componentWillReceiveProps(nextProps: Readonly<DocumentChooserProps>, nextContext: any): void

Optional UNSAFE_componentWillUpdate

Optional componentDidCatch

  • componentDidCatch(error: Error, errorInfo: ErrorInfo): void
  • Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.

    Parameters

    • error: Error
    • errorInfo: ErrorInfo

    Returns void

componentDidMount

  • componentDidMount(): Promise<void>
  • Invoked after the component is first mounted. Launches an API request to retrieve the list of existing documents from the server and update the state.

    Returns Promise<void>

Optional componentDidUpdate

  • Called immediately after updating occurs. Not called for the initial render.

    The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.

    Parameters

    Returns void

Optional componentWillMount

  • componentWillMount(): void

Optional componentWillReceiveProps

Optional componentWillUnmount

  • componentWillUnmount(): void
  • Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as cancelled network requests, or cleaning up any DOM elements created in componentDidMount.

    Returns void

Optional componentWillUpdate

forceUpdate

  • forceUpdate(callBack?: undefined | function): void
  • Parameters

    • Optional callBack: undefined | function

    Returns void

Optional getSnapshotBeforeUpdate

  • Runs before React applies the result of render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before render causes changes to it.

    Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated lifecycle events from running.

    Parameters

    Returns SS | null

Private methodUpdated

  • methodUpdated(ev: ChangeEvent<HTMLSelectElement>): void
  • Callback invoked in response to the user updating the selected upload method. Stores the new value to local storage and updates the state.

    Parameters

    • ev: ChangeEvent<HTMLSelectElement>

      The original change event

    Returns void

render

  • render(): Element
  • Renders the component

    Returns Element

setState

  • setState<K>(state: function | null | S | object, callback?: undefined | function): void
  • Type parameters

    • K: keyof DocumentChooserState

    Parameters

    • state: function | null | S | object
    • Optional callback: undefined | function

    Returns void

Optional shouldComponentUpdate

  • Called to determine whether the change in props and state should trigger a re-render.

    Component always returns true. PureComponent implements a shallow comparison on props and state and returns true if any props or states have changed.

    If false is returned, Component#render, componentWillUpdate and componentDidUpdate will not be called.

    Parameters

    Returns boolean

Private submitForm

  • submitForm(ev: FormEvent<HTMLFormElement>): Promise<void>
  • Callback invoked in response to the user submitting the form. This function checks the selected input method and formats the data, chooses the request endpoint accordingly and submits the data to the server. If the request completes successfully, a new session using the newly created document ID is initialised.

    Parameters

    • ev: FormEvent<HTMLFormElement>

      The original form event

    Returns Promise<void>

Generated using TypeDoc