igot-cb-tour-guide
Version:
Guided tour for your Angular6+ applications.
192 lines (185 loc) • 8.15 kB
TypeScript
import * as i0 from '@angular/core';
import { ErrorHandler, AfterViewInit, OnDestroy, TemplateRef, ElementRef } from '@angular/core';
import { Observable } from 'rxjs';
import * as i2 from '@angular/common';
import * as i3 from '@angular/material/icon';
interface TourStep {
icon?: string;
connectorDirection?: string;
nextBtnClass?: string;
backBtnClass?: string;
skipBtnClass?: string;
containerClass?: string;
isMobile?: boolean;
class?: string;
/** Selector for element that will be highlighted */
selector?: string;
/** Tour title text */
title?: string;
/** Tour step text */
content: string;
/** Where the tour step will appear next to the selected element */
orientation?: Orientation | OrientationConfiguration[];
/** Action that happens when the step is opened */
action?: () => void;
/** Action that happens when the step is closed */
closeAction?: () => void;
/** Skips this step, this is so you do not have create multiple tour configurations based on user settings/configuration */
skipStep?: boolean;
/** Adds some padding for things like sticky headers when scrolling to an element */
scrollAdjustment?: number;
/** Adds default padding around tour highlighting. Does not need to be true for highlightPadding to work */
useHighlightPadding?: boolean;
/** Adds padding around tour highlighting in pixels, this overwrites the default for this step. Is not dependent on useHighlightPadding being true */
highlightPadding?: number;
}
interface GuidedTour {
/** Identifier for tour */
tourId: string;
/** Use orb to start tour */
useOrb?: boolean;
/** Steps fo the tour */
steps: TourStep[];
nextCallback?: (currentStep: number, stepObject: object) => void;
prevCallback?: (currentStep: number, stepObject: object) => void;
/** Function will be called when tour is skipped */
skipCallback?: (stepSkippedOn: number) => void;
/** Function will be called when tour is completed */
completeCallback?: () => void;
/** Minimum size of screen in pixels before the tour is run, if the tour is resized below this value the user will be told to resize */
minimumScreenSize?: number;
/** Dialog shown if the window width is smaller than the defined minimum screen size. */
resizeDialog?: {
/** Resize dialog title text */
title?: string;
/** Resize dialog text */
content: string;
};
/**
* Prevents the tour from advancing by clicking the backdrop.
* This should only be set if you are completely sure your tour is displaying correctly on all screen sizes otherwise a user can get stuck.
*/
preventBackdropFromAdvancing?: boolean;
}
interface OrientationConfiguration {
/** Where the tour step will appear next to the selected element */
orientationDirection: Orientation;
/** When this orientation configuration starts in pixels */
maximumSize?: number;
}
declare class Orientation {
static readonly Bottom = "bottom";
static readonly BottomLeft = "bottom-left";
static readonly BottomRight = "bottom-right";
static readonly Center = "center";
static readonly Left = "left";
static readonly Right = "right";
static readonly Top = "top";
static readonly TopLeft = "top-left";
static readonly TopRight = "top-right";
}
declare enum ProgressIndicatorLocation {
InsideNextButton = "inside-next-button",
TopOfTourBlock = "top-of-tour-block",
None = "none",
Dots = "dots"
}
declare class WindowRefService {
private readonly isBrowser;
get nativeWindow(): any;
constructor(platformId: any);
static ɵfac: i0.ɵɵFactoryDeclaration<WindowRefService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<WindowRefService>;
}
declare class GuidedTourService {
errorHandler: ErrorHandler;
private windowRef;
private dom;
guidedTourCurrentStepStream: Observable<TourStep>;
guidedTourOrbShowingStream: Observable<boolean>;
private _guidedTourCurrentStepSubject;
private _guidedTourOrbShowingSubject;
private _currentTourStepIndex;
private _currentTour;
private _onFirstStep;
private _onLastStep;
private _onResizeMessage;
constructor(errorHandler: ErrorHandler, windowRef: WindowRefService, dom: any);
nextStep(): void;
backStep(): void;
skipTour(): void;
resetTour(): void;
startTour(tour: GuidedTour): void;
activateOrb(): void;
private _setFirstAndLast;
private _checkSelectorValidity;
get onLastStep(): boolean;
get onFirstStep(): boolean;
get onResizeMessage(): boolean;
get currentTourStepDisplay(): number;
get currentTourStepCount(): number;
get preventBackdropFromAdvancing(): boolean;
private getPreparedTourStep;
private setTourOrientation;
static ɵfac: i0.ɵɵFactoryDeclaration<GuidedTourService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<GuidedTourService>;
}
declare class GuidedTourComponent implements AfterViewInit, OnDestroy {
guidedTourService: GuidedTourService;
private windowRef;
private dom;
topOfPageAdjustment?: number;
tourStepWidth?: number;
minimalTourStepWidth?: number;
skipText?: string;
nextText?: string;
doneText?: string;
closeText?: string;
backText?: string;
progressIndicatorLocation?: ProgressIndicatorLocation;
progressIndicator?: TemplateRef<any>;
tourStep: ElementRef;
highlightPadding: number;
currentTourStep: TourStep;
selectedElementRect: DOMRect;
isOrbShowing: boolean;
progressIndicatorLocations: typeof ProgressIndicatorLocation;
private resizeSubscription;
private scrollSubscription;
constructor(guidedTourService: GuidedTourService, windowRef: WindowRefService, dom: any);
private get maxWidthAdjustmentForTourStep();
private get widthAdjustmentForScreenBound();
get calculatedTourStepWidth(): number;
ngAfterViewInit(): void;
ngOnDestroy(): void;
scrollToAndSetElement(): void;
handleOrb(): void;
private isTourOnScreen;
private elementInViewport;
backdropClick(event: Event): void;
updateStepLocation(): void;
private isBottom;
get topPosition(): number;
get orbTopPosition(): number;
private get calculatedLeftPosition();
get leftPosition(): number;
get orbLeftPosition(): number;
get transform(): string;
get orbTransform(): string;
get overlayTop(): number;
get overlayLeft(): number;
get overlayHeight(): number;
get overlayWidth(): number;
private getHighlightPadding;
private getStepScreenAdjustment;
static ɵfac: i0.ɵɵFactoryDeclaration<GuidedTourComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<GuidedTourComponent, "ngx-guided-tour", never, { "topOfPageAdjustment": { "alias": "topOfPageAdjustment"; "required": false; }; "tourStepWidth": { "alias": "tourStepWidth"; "required": false; }; "minimalTourStepWidth": { "alias": "minimalTourStepWidth"; "required": false; }; "skipText": { "alias": "skipText"; "required": false; }; "nextText": { "alias": "nextText"; "required": false; }; "doneText": { "alias": "doneText"; "required": false; }; "closeText": { "alias": "closeText"; "required": false; }; "backText": { "alias": "backText"; "required": false; }; "progressIndicatorLocation": { "alias": "progressIndicatorLocation"; "required": false; }; "progressIndicator": { "alias": "progressIndicator"; "required": false; }; }, {}, never, never, false, never>;
}
declare class GuidedTourModule {
static forRoot(): any;
static ɵfac: i0.ɵɵFactoryDeclaration<GuidedTourModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<GuidedTourModule, [typeof GuidedTourComponent], [typeof i2.CommonModule, typeof i3.MatIconModule], [typeof GuidedTourComponent]>;
static ɵinj: i0.ɵɵInjectorDeclaration<GuidedTourModule>;
}
export { GuidedTourComponent, GuidedTourModule, GuidedTourService, Orientation, ProgressIndicatorLocation, WindowRefService };
export type { GuidedTour, OrientationConfiguration, TourStep };