• Enables using papi.dialogs.showDialog in React more easily. Returns a callback to run that will open a dialog with the provided dialogType and options then run the resolveCallback with the dialog response or rejectCallback if there is an error. By default, only one dialog can be open at a time.

    If you need to open multiple dialogs and track which dialog is which, you can set options.shouldOpenMultipleDialogs to true and add a counter to the options when calling the callback. Then resolveCallback will be resolved with that options object including your counter.

    Type Parameters

    Parameters

    • dialogType: DialogTabType

      Dialog type you want to show on the screen

      Note: this parameter is internally assigned to a ref, so changing it will not cause any hooks to re-run with its new value. This means that updating this parameter will not cause a new callback to be returned. However, because of the nature of calling dialogs, this has no adverse effect on the functionality of this hook. Calling the callback will always use the latest dialogType.

    • options: DialogOptions & UseDialogCallbackOptions

      Various options for configuring the dialog that shows and this hook. If an options parameter is also provided to the returned showDialog callback, those callback-provided options merge over these hook-provided options

      Note: this parameter is internally assigned to a ref, so changing it will not cause any hooks to re-run with its new value. This means that updating this parameter will not cause a new callback to be returned. However, because of the nature of calling dialogs, this has no adverse effect on the functionality of this hook. Calling the callback will always use the latest options.

    • resolveCallback: (
          response: undefined | DialogTypes[DialogTabType]["responseType"],
          dialogType: DialogTabType,
          options: DialogOptions,
      ) => void

      (response, dialogType, options) The function that will be called if the dialog request resolves properly

      • response - the resolved value of the dialog call. Either the user's response or undefined if the user cancels
      • dialogType - the value of dialogType at the time that this dialog was called
      • options the options provided to the dialog at the time that this dialog was called. This consists of the options provided to the returned showDialog callback merged over the options provided to the hook and additionally contains UseDialogCallbackOptions properties

      Note: this parameter is internally assigned to a ref, so changing it will not cause any hooks to re-run with its new value. This means that updating this parameter will not cause a new callback to be returned. However, because of the nature of calling dialogs, this has no adverse effect on the functionality of this hook. When the dialog resolves, it will always call the latest resolveCallback.

    • rejectCallback: (error: unknown, dialogType: DialogTabType, options: DialogOptions) => void

      (error, dialogType, options) The function that will be called if the dialog request throws an error

      • error - the error thrown while calling the dialog
      • dialogType - the value of dialogType at the time that this dialog was called
      • options the options provided to the dialog at the time that this dialog was called. This consists of the options provided to the returned showDialog callback merged over the options provided to the hook and additionally contains UseDialogCallbackOptions properties

      Note: this parameter is internally assigned to a ref, so changing it will not cause any hooks to re-run with its new value. This means that updating this parameter will not cause a new callback to be returned. However, because of the nature of calling dialogs, this has no adverse effect on the functionality of this hook. If the dialog throws an error, it will always call the latest rejectCallback.

    Returns (
        optionOverrides?: Partial<DialogOptions & UseDialogCallbackOptions>,
    ) => Promise<void>

    showDialog(options?) - callback to run to show the dialog to prompt the user for a response

    • optionsOverrides? - options object you may specify that will merge over the options you provide to the hook before passing to the dialog. All properties are optional, so you may specify as many or as few properties here as you want to overwrite the properties in the options you provide to the hook
  • Enables using papi.dialogs.showDialog in React more easily. Returns a callback to run that will open a dialog with the provided dialogType and options then run the resolveCallback with the dialog response or rejectCallback if there is an error. By default, only one dialog can be open at a time.

    If you need to open multiple dialogs and track which dialog is which, you can set options.shouldOpenMultipleDialogs to true and add a counter to the options when calling the callback. Then resolveCallback will be resolved with that options object including your counter.

    Type Parameters

    Parameters

    • dialogType: DialogTabType

      Dialog type you want to show on the screen

      Note: this parameter is internally assigned to a ref, so changing it will not cause any hooks to re-run with its new value. This means that updating this parameter will not cause a new callback to be returned. However, because of the nature of calling dialogs, this has no adverse effect on the functionality of this hook. Calling the callback will always use the latest dialogType.

    • options: DialogOptions & UseDialogCallbackOptions

      Various options for configuring the dialog that shows and this hook. If an options parameter is also provided to the returned showDialog callback, those callback-provided options merge over these hook-provided options

      Note: this parameter is internally assigned to a ref, so changing it will not cause any hooks to re-run with its new value. This means that updating this parameter will not cause a new callback to be returned. However, because of the nature of calling dialogs, this has no adverse effect on the functionality of this hook. Calling the callback will always use the latest options.

    • resolveCallback: (
          response: undefined | DialogTypes[DialogTabType]["responseType"],
          dialogType: DialogTabType,
          options: DialogOptions,
      ) => void

      (response, dialogType, options) The function that will be called if the dialog request resolves properly

      • response - the resolved value of the dialog call. Either the user's response or undefined if the user cancels
      • dialogType - the value of dialogType at the time that this dialog was called
      • options the options provided to the dialog at the time that this dialog was called. This consists of the options provided to the returned showDialog callback merged over the options provided to the hook and additionally contains UseDialogCallbackOptions properties

      Note: this parameter is internally assigned to a ref, so changing it will not cause any hooks to re-run with its new value. This means that updating this parameter will not cause a new callback to be returned. However, because of the nature of calling dialogs, this has no adverse effect on the functionality of this hook. When the dialog resolves, it will always call the latest resolveCallback.

    Returns (
        optionOverrides?: Partial<DialogOptions & UseDialogCallbackOptions>,
    ) => Promise<void>

    showDialog(options?) - callback to run to show the dialog to prompt the user for a response

    • optionsOverrides? - options object you may specify that will merge over the options you provide to the hook before passing to the dialog. All properties are optional, so you may specify as many or as few properties here as you want to overwrite the properties in the options you provide to the hook