import type { ErrorObject } from 'ajv'; import type { ISettingRegistry } from '@jupyterlab/settingregistry'; import type { ITranslator, TranslationBundle } from '@jupyterlab/translation'; import type { Notebook } from '@jupyterlab/notebook'; import { Token } from '@lumino/coreutils'; import type { IDisposable } from '@lumino/disposable'; import type { ISignal } from '@lumino/signaling'; import type { LabIcon, RankedMenu } from '@jupyterlab/ui-components'; import type React from 'react'; import type { CallBackProps, Placement, Props as JoyrideProps, Step } from 'react-joyride'; /** * Namespace for everything */ export declare const NS: string; /** * Core Extension ID */ export declare const PLUGIN_ID: string; /** * User-defined tours extension ID */ export declare const USER_PLUGIN_ID: string; /** * Notebook-defined tours extension ID */ export declare const NOTEBOOK_PLUGIN_ID: string; /** * First-party curated tours, like Notebook and Welcomes */ export declare const DEFAULTS_PLUGIN_ID: string; /** * Token to get a reference to the tours manager */ export declare const ITourManager: Token; /** * Token to get a reference to the user tours manager */ export declare const IUserTourManager: Token; /** * Token to get a reference to the notebook tours manager */ export declare const INotebookTourManager: Token; /** * Step placement, as it's mostly used here, can have a few extra values than * other uses. */ export type StepPlacement = Placement | 'center' | 'auto'; /** * Serialized step interface */ export interface IStep { /** * Step content */ content: React.ReactNode; /** * CSS selector */ target: string; /** * Pop-up position */ placement?: StepPlacement; /** * Pop-up title */ title?: string; } /** * Serialized tour interface */ export interface ITour { /** * Tour unique ID */ id: string; /** * Tour label */ label: string; /** * Should this tour be added as entry in the Help menu. User-added tours always are. */ hasHelpEntry: boolean; /** * The `name` of a LabIcon to show next to this tour */ icon?: string; /** * Tour steps */ steps: Array; /** * Tour options * * @see https://github.com/gilbarbara/react-joyride/blob/v2.9.3/docs/props.md * * #### Notes * * All options are accepted except the steps entry. */ options?: Omit; /** * Tour version * * If a newer tour is available, it will be proposed to the user. * * #### Notes * Prefer calendar versioning (YYYYMMDD) */ version?: number; /** * Translation domain for this tour */ translation?: string; /** * When true, the tour step is driven by {@link ITourHandler.currentStepIndex}. * Default is false, which leaves Joyride uncontrolled. */ controlled?: boolean; } /** * Tour handler interface */ export interface ITourHandler extends IDisposable { /** * Adds a step to the tour. * * @param step Step - The step to add to the current tour. */ addStep(step: Step): void; /** * Creates a tour step and adds it to this tour. * * @param target A css selector that will specify which area/component to highlight with this step. * @param content The text content to use for this tour step. * @param placement The position of the content when it is displayed for this step. * @param title The title to use for the the tour step. * * @returns The create step */ createAndAddStep(target: string, content: React.ReactNode, placement?: StepPlacement, title?: string): Step; /** * The index of the current step of the tour. Returns -1 if tour isn't active. * Setting this moves the tour only when {@link controlled} is true. */ currentStepIndex: number; /** * Is the tour running? */ isRunning(): boolean; /** * A signal emitted when all the steps of the tour have been seen and tour is finished. */ readonly finished: ISignal; /** * True if the tour has steps, otherwise false. Launching a tour without steps is a no-op. */ readonly hasSteps: boolean; /** * The tour id, used by the tour manager to track different tours. */ readonly id: string; /** * The tour label */ readonly label: string; /** * The tour icon */ readonly icon: LabIcon | null; /** * Each tour can have it's behavior, attributes and css styling customized * by accessing and setting its options. */ options: Omit; /** * This will replace the tour step at the specified index with a new step * @param index The index of the step to update. * @param newStep The new step that will replace the old step. */ replaceStep(index: number, newStep: Step): void; /** * Removes a step from the tour, no-op if the index is out of range. * @param index The index of the step to remove. */ removeStep(index: number): Step | null; /** * A signal emitted if the user skips or ends the tour prematurely. */ readonly skipped: ISignal; /** * A signal emitted when the tour is first launched. */ readonly started: ISignal; /** * A signal emitted when the tour step has changed. */ readonly stepChanged: ISignal; /** * When true, Joyride is controlled by {@link currentStepIndex}. * When false, Joyride advances on its own. */ readonly controlled: boolean; /** * A signal emitted when {@link currentStepIndex} changes. */ readonly currentStepIndexChanged: ISignal; /** * The array of steps the tour currently contains. Each step will be followed * in order as the tour progresses. */ steps: Step[]; /** * Tour version * * If a newer tour is available, it will be proposed to the user. * * #### Notes * Prefer calendar versioning (YYYYMMDD) */ version?: number; } /** * Tours manager interface */ export interface ITourManager extends IDisposable { /** * The currently active tour. undefined if no tour is currently running. */ readonly activeTour: ITourHandler | undefined; /** * Promise that resolves when the manager state is restored. */ readonly ready: Promise; /** * Extension translation bundle */ readonly translator: TranslationBundle; /** * Creates an interactive TourHandler object that can be customized and run by the TourManager. * @param tour The tour to be created. * * @returns The tour created or null in case of errors */ addTour(tour: ITour): ITourHandler | null; /** * Creates an interactive TourHandler object that can be customized and run by the TourManager. * @param id The id used to track the tour. * @param label The label to use for the tour. If added to help menu, this would be the button text. * @param addToHelpMenu If true, the tour will be added as a button on the help menu. Default = True. * @param options Tour options * @param icon An optional icon to display in the Help Menu and Command Palette * @param version Tour version * * @returns The tour created */ createTour(options: Omit & { icon?: LabIcon; }): ITourHandler; /** * Launches a tour or series of tours one after another in order of the array provided. * If the array is empty or no tours have steps, this will be a no-op. * * @param tours An array of tours or tutorialIDs to launch. * @param force Force the tour execution */ launch(tours: ITourHandler[] | string[], force: boolean): Promise; /** * Removes the tour and its associated command from the application. * * @param tour The TourHandler object or the id of the tour object to remove */ removeTour(tour: string | ITourHandler): void; /** * Return a copy of * * @param tours an unordered list of tours * @returns an ordered list of tours */ sortTours(tours: ITour[]): ITour[]; /** * A key/value map of the tours that the tour manager contains. * Key: ID of the tour, value: tour object. */ readonly tours: Map; } /** * Tour state saved */ export interface ITourState { /** * Tour ID */ id: string; /** * Tour extension version */ version: number; } /** * Tours tracker */ export interface ITourTracker { /** * Promise resolving with the tour states */ restored: Promise; /** * Save the tour states. * * @param state Tour states */ save(state: ITourState[]): Promise; } /** * Tour manager options */ export interface ITourManagerOptions { /** * Help menu where the tour are added */ helpMenu?: RankedMenu; /** * Tour states tracker */ tracker?: ITourTracker; /** * Application translator */ translator?: ITranslator; } /** * User Tours manager interface */ export interface IUserTourManager { /** * Promise resolved when the user tour manager is ready. */ readonly ready: Promise; /** * Tour manager */ readonly tourManager: ITourManager; } /** * Namespace for user tour interfaces */ export declare namespace IUserTourManager { /** * UserTourManager constructor options */ interface IOptions { /** * Tour manager */ tourManager: ITourManager; /** * Extension settings getter */ getSettings: () => Promise; } } /** * Notebook Tours manager interface */ export interface INotebookTourManager { /** * Tour manager */ readonly tourManager: ITourManager; /** * The current notebook */ addNotebook(notebook: Notebook): Promise; /** * Get the list of full tour ids for this notebook * * @param notebook the notebook * @returns the ids of tours in this notebook */ getNotebookTourIds(notebook: Notebook): string[]; /** * Get errors found in the notebook metadata */ getNotebookValidationErrors(notebook: Notebook): ErrorObject[]; /** * A signal that emits when a particular notebooks tours change */ notebookToursChanged: ISignal; } /** * Namespace for notebook tour interfaces */ export declare namespace INotebookTourManager { /** * NotebookTourManager constructor options */ interface IOptions { /** * Tour manager */ tourManager: ITourManager; } }