-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathoption.ts
163 lines (157 loc) · 5.01 KB
/
option.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import {
HintPosition,
HintStep,
IntroStep,
ScrollTo,
TooltipPosition,
} from "./core/steps";
export interface Options {
steps: Partial<IntroStep>[];
hints: Partial<HintStep>[];
/* Is this tour instance active? Don't show the tour again if this flag is set to false */
isActive: boolean;
/* Next button label in tooltip box */
nextLabel: string;
/* Previous button label in tooltip box */
prevLabel: string;
/* Skip button label in tooltip box */
skipLabel: string;
/* Done button label in tooltip box */
doneLabel: string;
/* Hide previous button in the first step? Otherwise, it will be disabled button. */
hidePrev: boolean;
/* Hide next button in the last step? Otherwise, it will be disabled button (note: this will also hide the "Done" button) */
hideNext: boolean;
/* Change the Next button to Done in the last step of the intro? otherwise, it will render a disabled button */
nextToDone: boolean;
/* Default tooltip box position */
tooltipPosition: string;
/* Next CSS class for tooltip boxes */
tooltipClass: string;
/* Start intro for a group of elements */
group: string;
/* CSS class that is added to the helperLayer */
highlightClass: string;
/* Close introduction when pressing Escape button? */
exitOnEsc: boolean;
/* Close introduction when clicking on overlay layer? */
exitOnOverlayClick: boolean;
/* Display the pagination detail */
showStepNumbers: boolean;
/* Pagination "of" label */
stepNumbersOfLabel: string;
/* Let user use keyboard to navigate the tour? */
keyboardNavigation: boolean;
/* Show tour control buttons? */
showButtons: boolean;
/* Show tour bullets? */
showBullets: boolean;
/* Show tour progress? */
showProgress: boolean;
/* Scroll to highlighted element? */
scrollToElement: boolean;
/*
* Should we scroll the tooltip or target element?
* Options are: 'element', 'tooltip' or 'off'
*/
scrollTo: ScrollTo;
/* Padding to add after scrolling when element is not in the viewport (in pixels) */
scrollPadding: number;
/* Set the overlay opacity */
overlayOpacity: number;
/* To determine the tooltip position automatically based on the window.width/height */
autoPosition: boolean;
/* Precedence of positions, when auto is enabled */
positionPrecedence: TooltipPosition[];
/* Disable an interaction with element? */
disableInteraction: boolean;
/* To display the "Don't show again" checkbox in the tour */
dontShowAgain: boolean;
dontShowAgainLabel: string;
/* "Don't show again" cookie name and expiry (in days) */
dontShowAgainCookie: string;
dontShowAgainCookieDays: number;
/* Set how much padding to be used around helper element */
helperElementPadding: number;
/* Default hint position */
hintPosition: HintPosition;
/* Hint button label */
hintButtonLabel: string;
/* Display the "Got it" button? */
hintShowButton: boolean;
/* Hints auto-refresh interval in ms (set to -1 to disable) */
hintAutoRefreshInterval: number;
/* Adding animation to hints? */
hintAnimation: boolean;
/* additional classes to put on the buttons */
buttonClass: string;
/* additional classes to put on progress bar */
progressBarAdditionalClass: boolean;
/* function for creating stepNumber label */
getStepNumber:(stepIndex:number,stepsCount:number,stepNumbersOfLabel:string)=>string
}
export function getDefaultOptions(): Options {
return {
steps: [],
hints: [],
isActive: true,
nextLabel: "Next",
prevLabel: "Back",
skipLabel: "×",
doneLabel: "Done",
hidePrev: false,
hideNext: false,
nextToDone: true,
tooltipPosition: "bottom",
tooltipClass: "",
group: "",
highlightClass: "",
exitOnEsc: true,
exitOnOverlayClick: true,
showStepNumbers: false,
stepNumbersOfLabel: "of",
keyboardNavigation: true,
showButtons: true,
showBullets: true,
showProgress: false,
scrollToElement: true,
scrollTo: "element",
scrollPadding: 30,
overlayOpacity: 0.5,
autoPosition: true,
positionPrecedence: ["bottom", "top", "right", "left"],
disableInteraction: false,
dontShowAgain: false,
dontShowAgainLabel: "Don't show this again",
dontShowAgainCookie: "introjs-dontShowAgain",
dontShowAgainCookieDays: 365,
helperElementPadding: 10,
hintPosition: "top-middle",
hintButtonLabel: "Got it",
hintShowButton: true,
hintAutoRefreshInterval: 10,
hintAnimation: true,
buttonClass: "introjs-button",
progressBarAdditionalClass: false,
getStepNumber(stepIndex,stepsCount,stepNumbersOfLabel){
return `${stepIndex} ${stepNumbersOfLabel} ${stepsCount}`;
}
};
}
export function setOption<K extends keyof Options>(
options: Options,
key: K,
value: Options[K]
): Options {
options[key] = value;
return options;
}
export function setOptions(
options: Options,
partialOptions: Partial<Options>
): Options {
for (const [key, value] of Object.entries(partialOptions)) {
options = setOption(options, key as keyof Options, value);
}
return options;
}