@diabolic/pointy 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +810 -0
- package/dist/pointy.d.ts +851 -0
- package/dist/pointy.esm.js +2175 -0
- package/dist/pointy.js +2183 -0
- package/dist/pointy.min.js +2 -0
- package/dist/pointy.min.js.map +1 -0
- package/package.json +67 -0
- package/src/pointy.d.ts +851 -0
- package/src/pointy.js +2174 -0
package/dist/pointy.d.ts
ADDED
|
@@ -0,0 +1,851 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pointy - A lightweight tooltip library with animated pointer
|
|
3
|
+
* TypeScript definitions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
declare module '@diabolic/pointy' {
|
|
7
|
+
export = Pointy;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Step configuration for tour steps
|
|
12
|
+
*/
|
|
13
|
+
interface PointyStep {
|
|
14
|
+
/** CSS selector or HTMLElement to point to */
|
|
15
|
+
target: string | HTMLElement;
|
|
16
|
+
/** Content to display - can be string, HTML, array of messages, or React element */
|
|
17
|
+
content: string | string[] | React.ReactNode | React.ReactNode[];
|
|
18
|
+
/** Pointer direction: 'up', 'down', or null for auto */
|
|
19
|
+
direction?: 'up' | 'down' | null;
|
|
20
|
+
/** Step-specific autoplay duration in ms (overrides global autoplay) */
|
|
21
|
+
duration?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Class name suffixes configuration
|
|
26
|
+
*/
|
|
27
|
+
interface PointyClassSuffixes {
|
|
28
|
+
container?: string;
|
|
29
|
+
pointer?: string;
|
|
30
|
+
bubble?: string;
|
|
31
|
+
bubbleText?: string;
|
|
32
|
+
hidden?: string;
|
|
33
|
+
visible?: string;
|
|
34
|
+
moving?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Full class names configuration
|
|
39
|
+
*/
|
|
40
|
+
interface PointyClassNames {
|
|
41
|
+
container: string;
|
|
42
|
+
pointer: string;
|
|
43
|
+
bubble: string;
|
|
44
|
+
bubbleText: string;
|
|
45
|
+
hidden: string;
|
|
46
|
+
visible: string;
|
|
47
|
+
moving: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Initial position presets
|
|
52
|
+
*/
|
|
53
|
+
type PointyInitialPosition =
|
|
54
|
+
| 'center'
|
|
55
|
+
| 'top-left'
|
|
56
|
+
| 'top-center'
|
|
57
|
+
| 'top-right'
|
|
58
|
+
| 'middle-left'
|
|
59
|
+
| 'middle-right'
|
|
60
|
+
| 'bottom-left'
|
|
61
|
+
| 'bottom-center'
|
|
62
|
+
| 'bottom-right'
|
|
63
|
+
| 'first-step';
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Easing presets
|
|
67
|
+
*/
|
|
68
|
+
type PointyEasing =
|
|
69
|
+
| 'default'
|
|
70
|
+
| 'standard'
|
|
71
|
+
| 'decelerate'
|
|
72
|
+
| 'accelerate'
|
|
73
|
+
| 'bounce'
|
|
74
|
+
| 'elastic'
|
|
75
|
+
| 'smooth'
|
|
76
|
+
| 'snap'
|
|
77
|
+
| 'expo-out'
|
|
78
|
+
| 'circ-out'
|
|
79
|
+
| 'back-out'
|
|
80
|
+
| 'ease'
|
|
81
|
+
| 'ease-in'
|
|
82
|
+
| 'ease-out'
|
|
83
|
+
| 'ease-in-out'
|
|
84
|
+
| 'linear'
|
|
85
|
+
| string; // Custom cubic-bezier
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Pointy constructor options
|
|
89
|
+
*/
|
|
90
|
+
interface PointyOptions {
|
|
91
|
+
// Steps
|
|
92
|
+
/** Array of tour steps */
|
|
93
|
+
steps?: PointyStep[];
|
|
94
|
+
/** Initial target element (for single-step use) */
|
|
95
|
+
target?: string | HTMLElement;
|
|
96
|
+
/** Initial content (for single-step use) */
|
|
97
|
+
content?: string | string[] | React.ReactNode;
|
|
98
|
+
|
|
99
|
+
// Animation
|
|
100
|
+
/** Move animation duration in ms (default: 1000) */
|
|
101
|
+
animationDuration?: number;
|
|
102
|
+
/** Initial fade-in duration in ms (default: 1000) */
|
|
103
|
+
introFadeDuration?: number;
|
|
104
|
+
/** Bubble fade-in duration in ms (default: 500) */
|
|
105
|
+
bubbleFadeDuration?: number;
|
|
106
|
+
/** Message change animation duration in ms (default: 500) */
|
|
107
|
+
messageTransitionDuration?: number;
|
|
108
|
+
/** Easing preset name or custom cubic-bezier (default: 'default') */
|
|
109
|
+
easing?: PointyEasing;
|
|
110
|
+
/** Enable floating/bobbing animation (default: true) */
|
|
111
|
+
floatingAnimation?: boolean;
|
|
112
|
+
|
|
113
|
+
// Position
|
|
114
|
+
/** Horizontal offset from target in px (default: 20) */
|
|
115
|
+
offsetX?: number;
|
|
116
|
+
/** Vertical offset from target in px (default: 16) */
|
|
117
|
+
offsetY?: number;
|
|
118
|
+
/** Starting position preset, CSS selector, or element (default: 'center') */
|
|
119
|
+
initialPosition?: PointyInitialPosition | string | HTMLElement;
|
|
120
|
+
/** Offset from edges for position presets in px (default: 32) */
|
|
121
|
+
initialPositionOffset?: number;
|
|
122
|
+
/** Reset position when hiding (default: false) */
|
|
123
|
+
resetPositionOnHide?: boolean;
|
|
124
|
+
|
|
125
|
+
// Tracking
|
|
126
|
+
/** Enable real-time target tracking (default: true) */
|
|
127
|
+
tracking?: boolean;
|
|
128
|
+
/** Tracking frame rate, 0 = unlimited (default: 60) */
|
|
129
|
+
trackingFps?: number;
|
|
130
|
+
|
|
131
|
+
// Messages
|
|
132
|
+
/** Auto-cycle messages interval in ms, null = manual (default: null) */
|
|
133
|
+
messageInterval?: number | null;
|
|
134
|
+
|
|
135
|
+
// Autoplay
|
|
136
|
+
/** Auto-advance interval in ms, null = manual (default: null) */
|
|
137
|
+
autoplay?: number | null;
|
|
138
|
+
/** Whether autoplay is initially enabled (default: false) */
|
|
139
|
+
autoplayEnabled?: boolean;
|
|
140
|
+
/** Wait for all messages before advancing (default: true) */
|
|
141
|
+
autoplayWaitForMessages?: boolean;
|
|
142
|
+
|
|
143
|
+
// Completion
|
|
144
|
+
/** Reset to initial position on complete (default: true) */
|
|
145
|
+
resetOnComplete?: boolean;
|
|
146
|
+
/** Auto-hide after tour completes (default: true) */
|
|
147
|
+
hideOnComplete?: boolean;
|
|
148
|
+
/** Delay before auto-hide in ms, null = use animationDuration (default: null) */
|
|
149
|
+
hideOnCompleteDelay?: number | null;
|
|
150
|
+
|
|
151
|
+
// Styling
|
|
152
|
+
/** CSS class prefix (default: 'pointy') */
|
|
153
|
+
classPrefix?: string;
|
|
154
|
+
/** Custom class suffixes to override defaults */
|
|
155
|
+
classSuffixes?: PointyClassSuffixes;
|
|
156
|
+
/** Full override of class names */
|
|
157
|
+
classNames?: Partial<PointyClassNames>;
|
|
158
|
+
/** CSS variable prefix (default: classPrefix) */
|
|
159
|
+
cssVarPrefix?: string;
|
|
160
|
+
/** Custom SVG markup for pointer or React element */
|
|
161
|
+
pointerSvg?: string | React.ReactNode;
|
|
162
|
+
|
|
163
|
+
// Callbacks
|
|
164
|
+
/** Called when step changes */
|
|
165
|
+
onStepChange?: (index: number, step: PointyStep) => void;
|
|
166
|
+
/** Called when tour completes */
|
|
167
|
+
onComplete?: () => void;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Event data base interface
|
|
172
|
+
*/
|
|
173
|
+
interface PointyEventData {
|
|
174
|
+
/** Event type name */
|
|
175
|
+
type: string;
|
|
176
|
+
/** Pointy instance reference */
|
|
177
|
+
pointy: Pointy;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Lifecycle event data
|
|
182
|
+
*/
|
|
183
|
+
interface PointyLifecycleEventData extends PointyEventData {
|
|
184
|
+
target?: HTMLElement;
|
|
185
|
+
isIntro?: boolean;
|
|
186
|
+
isFirstStep?: boolean;
|
|
187
|
+
currentStep?: number;
|
|
188
|
+
stepIndex?: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Navigation event data
|
|
193
|
+
*/
|
|
194
|
+
interface PointyNavigationEventData extends PointyEventData {
|
|
195
|
+
fromIndex?: number;
|
|
196
|
+
toIndex?: number;
|
|
197
|
+
step?: PointyStep;
|
|
198
|
+
fromTarget?: HTMLElement;
|
|
199
|
+
target?: HTMLElement;
|
|
200
|
+
totalSteps?: number;
|
|
201
|
+
source?: 'manual' | 'autoplay';
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Animation event data
|
|
206
|
+
*/
|
|
207
|
+
interface PointyAnimationEventData extends PointyEventData {
|
|
208
|
+
fromTarget?: HTMLElement;
|
|
209
|
+
toTarget?: HTMLElement;
|
|
210
|
+
type?: 'step' | 'pointTo';
|
|
211
|
+
stepIndex?: number;
|
|
212
|
+
content?: string | string[];
|
|
213
|
+
index?: number;
|
|
214
|
+
step?: PointyStep;
|
|
215
|
+
target?: HTMLElement;
|
|
216
|
+
duration?: number;
|
|
217
|
+
initialPosition?: { x: number; y: number };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Content event data
|
|
222
|
+
*/
|
|
223
|
+
interface PointyContentEventData extends PointyEventData {
|
|
224
|
+
messages?: (string | React.ReactNode)[];
|
|
225
|
+
total?: number;
|
|
226
|
+
animated?: boolean;
|
|
227
|
+
cyclePaused?: boolean;
|
|
228
|
+
fromIndex?: number;
|
|
229
|
+
toIndex?: number;
|
|
230
|
+
message?: string | React.ReactNode;
|
|
231
|
+
isAuto?: boolean;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Message cycle event data
|
|
236
|
+
*/
|
|
237
|
+
interface PointyMessageCycleEventData extends PointyEventData {
|
|
238
|
+
interval?: number;
|
|
239
|
+
totalMessages?: number;
|
|
240
|
+
currentIndex?: number;
|
|
241
|
+
stepIndex?: number;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Pointing event data
|
|
246
|
+
*/
|
|
247
|
+
interface PointyPointingEventData extends PointyEventData {
|
|
248
|
+
target?: HTMLElement;
|
|
249
|
+
content?: string | string[];
|
|
250
|
+
direction?: 'up' | 'down' | null;
|
|
251
|
+
fromTarget?: HTMLElement;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Tracking event data
|
|
256
|
+
*/
|
|
257
|
+
interface PointyTrackingEventData extends PointyEventData {
|
|
258
|
+
target?: HTMLElement;
|
|
259
|
+
timestamp?: number;
|
|
260
|
+
from?: HTMLElement | boolean | number;
|
|
261
|
+
to?: HTMLElement | boolean | number;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Autoplay event data
|
|
266
|
+
*/
|
|
267
|
+
interface PointyAutoplayEventData extends PointyEventData {
|
|
268
|
+
fromIndex?: number;
|
|
269
|
+
duration?: number;
|
|
270
|
+
afterMessages?: boolean;
|
|
271
|
+
totalSteps?: number;
|
|
272
|
+
delay?: number;
|
|
273
|
+
source?: 'manual' | 'autoplay';
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Config change event data
|
|
278
|
+
*/
|
|
279
|
+
interface PointyConfigChangeEventData extends PointyEventData {
|
|
280
|
+
from: any;
|
|
281
|
+
to: any;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Event types union
|
|
286
|
+
*/
|
|
287
|
+
type PointyEventCallback<T = PointyEventData> = (data: T) => void;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Event names
|
|
291
|
+
*/
|
|
292
|
+
type PointyLifecycleEvent = 'beforeShow' | 'show' | 'beforeHide' | 'hide' | 'destroy' | 'beforeRestart' | 'restart' | 'beforeReset' | 'reset';
|
|
293
|
+
type PointyNavigationEvent = 'beforeStepChange' | 'stepChange' | 'next' | 'prev' | 'complete';
|
|
294
|
+
type PointyAnimationEvent = 'animationStart' | 'animationEnd' | 'move' | 'moveComplete' | 'introAnimationStart' | 'introAnimationEnd';
|
|
295
|
+
type PointyContentEvent = 'contentSet' | 'messagesSet' | 'messageChange';
|
|
296
|
+
type PointyMessageCycleEvent = 'messageCycleStart' | 'messageCycleStop' | 'messageCyclePause' | 'messageCycleResume' | 'messageCycleComplete';
|
|
297
|
+
type PointyPointingEvent = 'beforePointTo' | 'pointTo' | 'pointToComplete';
|
|
298
|
+
type PointyTrackingEvent = 'track' | 'targetChange' | 'trackingChange' | 'trackingFpsChange';
|
|
299
|
+
type PointyAutoplayEvent = 'autoplayStart' | 'autoplayStop' | 'autoplayPause' | 'autoplayResume' | 'autoplayNext' | 'autoplayComplete' | 'autoHide' | 'autoplayChange' | 'autoplayWaitForMessagesChange';
|
|
300
|
+
type PointyConfigEvent = 'easingChange' | 'animationDurationChange' | 'introFadeDurationChange' | 'bubbleFadeDurationChange' | 'messageIntervalChange' | 'messageTransitionDurationChange' | 'offsetChange' | 'resetOnCompleteChange' | 'hideOnCompleteChange' | 'hideOnCompleteDelayChange' | 'floatingAnimationChange' | 'initialPositionChange' | 'initialPositionOffsetChange' | 'pointerSvgChange';
|
|
301
|
+
|
|
302
|
+
type PointyEvent = PointyLifecycleEvent | PointyNavigationEvent | PointyAnimationEvent | PointyContentEvent | PointyMessageCycleEvent | PointyPointingEvent | PointyTrackingEvent | PointyAutoplayEvent | PointyConfigEvent;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Event group names
|
|
306
|
+
*/
|
|
307
|
+
type PointyEventGroup = 'lifecycle' | 'navigation' | 'animation' | 'content' | 'messageCycle' | 'pointing' | 'tracking' | 'autoplay' | 'config' | '*' | 'all';
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Event groups object type
|
|
311
|
+
*/
|
|
312
|
+
interface PointyEventGroups {
|
|
313
|
+
lifecycle: PointyLifecycleEvent[];
|
|
314
|
+
navigation: PointyNavigationEvent[];
|
|
315
|
+
animation: PointyAnimationEvent[];
|
|
316
|
+
content: PointyContentEvent[];
|
|
317
|
+
messageCycle: PointyMessageCycleEvent[];
|
|
318
|
+
pointing: PointyPointingEvent[];
|
|
319
|
+
tracking: PointyTrackingEvent[];
|
|
320
|
+
autoplay: PointyAutoplayEvent[];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Pointy - Main class
|
|
325
|
+
*/
|
|
326
|
+
declare class Pointy {
|
|
327
|
+
// Static properties
|
|
328
|
+
/** Named easing presets */
|
|
329
|
+
static EASINGS: Record<string, string>;
|
|
330
|
+
/** Default pointer SVG markup */
|
|
331
|
+
static POINTER_SVG: string;
|
|
332
|
+
/** Default CSS class prefix */
|
|
333
|
+
static DEFAULT_CLASS_PREFIX: string;
|
|
334
|
+
/** Default class name suffixes */
|
|
335
|
+
static DEFAULT_CLASS_SUFFIXES: PointyClassSuffixes;
|
|
336
|
+
/** Default CSS variable prefix */
|
|
337
|
+
static DEFAULT_CSS_VAR_PREFIX: string;
|
|
338
|
+
/** Event groups for generic listeners */
|
|
339
|
+
static EVENT_GROUPS: PointyEventGroups;
|
|
340
|
+
|
|
341
|
+
// Static methods
|
|
342
|
+
/**
|
|
343
|
+
* Generate class names from prefix and suffixes
|
|
344
|
+
* @param prefix - Class prefix
|
|
345
|
+
* @param suffixes - Custom suffixes to override defaults
|
|
346
|
+
*/
|
|
347
|
+
static generateClassNames(prefix?: string, suffixes?: PointyClassSuffixes): PointyClassNames;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Generate CSS styles with custom class names
|
|
351
|
+
* @param classNames - Class names object
|
|
352
|
+
* @param cssVarPrefix - CSS variable prefix
|
|
353
|
+
*/
|
|
354
|
+
static generateStyles(classNames: PointyClassNames, cssVarPrefix?: string): string;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Inject CSS styles into document
|
|
358
|
+
* @param classNames - Class names object
|
|
359
|
+
* @param cssVarPrefix - CSS variable prefix
|
|
360
|
+
*/
|
|
361
|
+
static injectStyles(classNames: PointyClassNames, cssVarPrefix?: string): void;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Get DOM element from selector or element
|
|
365
|
+
* @param target - CSS selector string or HTMLElement
|
|
366
|
+
*/
|
|
367
|
+
static getTargetElement(target: string | HTMLElement): HTMLElement | null;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Animate text content change
|
|
371
|
+
* @param element - Target text element
|
|
372
|
+
* @param newContent - New content to display
|
|
373
|
+
* @param duration - Animation duration in ms
|
|
374
|
+
* @param bubble - Bubble element for size animation
|
|
375
|
+
* @param onComplete - Callback when animation completes
|
|
376
|
+
*/
|
|
377
|
+
static animateText(
|
|
378
|
+
element: HTMLElement,
|
|
379
|
+
newContent: string | React.ReactNode,
|
|
380
|
+
duration?: number,
|
|
381
|
+
bubble?: HTMLElement | null,
|
|
382
|
+
onComplete?: () => void
|
|
383
|
+
): void;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Render content to an element - supports string (HTML) and React elements
|
|
387
|
+
* @param element - Target element
|
|
388
|
+
* @param content - String (HTML) or React element
|
|
389
|
+
*/
|
|
390
|
+
static renderContent(element: HTMLElement, content: string | React.ReactNode): void;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Get list of available easing presets
|
|
394
|
+
*/
|
|
395
|
+
static getEasingPresets(): string[];
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Get list of available initial position presets
|
|
399
|
+
*/
|
|
400
|
+
static getInitialPositions(): PointyInitialPosition[];
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Get the group name for an event
|
|
404
|
+
* @param event - Event name
|
|
405
|
+
*/
|
|
406
|
+
static getEventGroup(event: string): string | null;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Get all events in a group
|
|
410
|
+
* @param group - Group name
|
|
411
|
+
*/
|
|
412
|
+
static getEventsInGroup(group: string): string[];
|
|
413
|
+
|
|
414
|
+
// Instance properties (readonly)
|
|
415
|
+
/** Main container element */
|
|
416
|
+
readonly container: HTMLDivElement;
|
|
417
|
+
/** Pointer element */
|
|
418
|
+
readonly pointer: HTMLDivElement;
|
|
419
|
+
/** Bubble element */
|
|
420
|
+
readonly bubble: HTMLDivElement;
|
|
421
|
+
/** Bubble text element */
|
|
422
|
+
readonly bubbleText: HTMLSpanElement;
|
|
423
|
+
/** Current class names */
|
|
424
|
+
readonly classNames: PointyClassNames;
|
|
425
|
+
/** Current class prefix */
|
|
426
|
+
readonly classPrefix: string;
|
|
427
|
+
/** Current CSS variable prefix */
|
|
428
|
+
readonly cssVarPrefix: string;
|
|
429
|
+
|
|
430
|
+
// Configurable properties
|
|
431
|
+
/** Tour steps */
|
|
432
|
+
steps: PointyStep[];
|
|
433
|
+
/** Current target element */
|
|
434
|
+
targetElement: HTMLElement | null;
|
|
435
|
+
/** Horizontal offset from target */
|
|
436
|
+
offsetX: number;
|
|
437
|
+
/** Vertical offset from target */
|
|
438
|
+
offsetY: number;
|
|
439
|
+
/** Enable position tracking */
|
|
440
|
+
tracking: boolean;
|
|
441
|
+
/** Tracking frame rate */
|
|
442
|
+
trackingFps: number;
|
|
443
|
+
/** Move animation duration in ms */
|
|
444
|
+
animationDuration: number;
|
|
445
|
+
/** Intro fade duration in ms */
|
|
446
|
+
introFadeDuration: number;
|
|
447
|
+
/** Bubble fade duration in ms */
|
|
448
|
+
bubbleFadeDuration: number;
|
|
449
|
+
/** Message transition duration in ms */
|
|
450
|
+
messageTransitionDuration: number;
|
|
451
|
+
/** Current easing */
|
|
452
|
+
easing: string;
|
|
453
|
+
/** Reset to initial position on complete */
|
|
454
|
+
resetOnComplete: boolean;
|
|
455
|
+
/** Enable floating animation */
|
|
456
|
+
floatingAnimation: boolean;
|
|
457
|
+
/** Initial position preset or element */
|
|
458
|
+
initialPosition: PointyInitialPosition | string | HTMLElement;
|
|
459
|
+
/** Initial position offset from edges */
|
|
460
|
+
initialPositionOffset: number;
|
|
461
|
+
/** Reset position on hide */
|
|
462
|
+
resetPositionOnHide: boolean;
|
|
463
|
+
/** Autoplay interval in ms */
|
|
464
|
+
autoplay: number | null;
|
|
465
|
+
/** Autoplay enabled state */
|
|
466
|
+
autoplayEnabled: boolean;
|
|
467
|
+
/** Wait for messages before autoplay advance */
|
|
468
|
+
autoplayWaitForMessages: boolean;
|
|
469
|
+
/** Auto-hide after complete */
|
|
470
|
+
hideOnComplete: boolean;
|
|
471
|
+
/** Delay before auto-hide */
|
|
472
|
+
hideOnCompleteDelay: number | null;
|
|
473
|
+
/** Message auto-cycle interval */
|
|
474
|
+
messageInterval: number | null;
|
|
475
|
+
/** Current pointer SVG or React element */
|
|
476
|
+
pointerSvg: string | React.ReactNode;
|
|
477
|
+
|
|
478
|
+
// State properties (readonly)
|
|
479
|
+
/** Whether pointer is currently visible */
|
|
480
|
+
readonly isVisible: boolean;
|
|
481
|
+
/** Current step index */
|
|
482
|
+
readonly currentStepIndex: number;
|
|
483
|
+
/** Current message index within step */
|
|
484
|
+
readonly currentMessageIndex: number;
|
|
485
|
+
/** Current messages array */
|
|
486
|
+
readonly currentMessages: (string | React.ReactNode)[];
|
|
487
|
+
/** Whether pointer is pointing up */
|
|
488
|
+
readonly isPointingUp: boolean;
|
|
489
|
+
/** Manual direction override */
|
|
490
|
+
readonly manualDirection: 'up' | 'down' | null;
|
|
491
|
+
|
|
492
|
+
// Callbacks
|
|
493
|
+
/** Step change callback */
|
|
494
|
+
onStepChange?: (index: number, step: PointyStep) => void;
|
|
495
|
+
/** Complete callback */
|
|
496
|
+
onComplete?: () => void;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Create a new Pointy instance
|
|
500
|
+
* @param options - Configuration options
|
|
501
|
+
*/
|
|
502
|
+
constructor(options?: PointyOptions);
|
|
503
|
+
|
|
504
|
+
// Lifecycle methods
|
|
505
|
+
/** Show the pointer */
|
|
506
|
+
show(): void;
|
|
507
|
+
/** Hide the pointer */
|
|
508
|
+
hide(): void;
|
|
509
|
+
/** Destroy the instance and cleanup */
|
|
510
|
+
destroy(): void;
|
|
511
|
+
/** Restart from initial position with intro animation */
|
|
512
|
+
restart(): void;
|
|
513
|
+
|
|
514
|
+
// Navigation methods
|
|
515
|
+
/** Go to next step */
|
|
516
|
+
next(): void;
|
|
517
|
+
/** Go to previous step */
|
|
518
|
+
prev(): void;
|
|
519
|
+
/**
|
|
520
|
+
* Go to a specific step by index
|
|
521
|
+
* @param index - Step index (0-based)
|
|
522
|
+
*/
|
|
523
|
+
goToStep(index: number): void;
|
|
524
|
+
/**
|
|
525
|
+
* Reset to initial position
|
|
526
|
+
* @param goToFirstStep - Whether to reset step index to 0 (default: true)
|
|
527
|
+
*/
|
|
528
|
+
reset(goToFirstStep?: boolean): void;
|
|
529
|
+
|
|
530
|
+
// Custom target
|
|
531
|
+
/**
|
|
532
|
+
* Point to any element without changing current step
|
|
533
|
+
* @param target - Target element or CSS selector
|
|
534
|
+
* @param content - Optional content to display
|
|
535
|
+
* @param direction - Optional direction: 'up', 'down', or null for auto
|
|
536
|
+
*/
|
|
537
|
+
pointTo(target: string | HTMLElement, content?: string | string[], direction?: 'up' | 'down' | null): void;
|
|
538
|
+
|
|
539
|
+
// Content methods
|
|
540
|
+
/**
|
|
541
|
+
* Set content programmatically
|
|
542
|
+
* @param content - Single message or array of messages
|
|
543
|
+
* @param animate - Whether to animate the change (default: true)
|
|
544
|
+
*/
|
|
545
|
+
setContent(content: string | string[] | React.ReactNode, animate?: boolean): void;
|
|
546
|
+
/**
|
|
547
|
+
* Go to next message in current step
|
|
548
|
+
* @param isAuto - Whether this is from auto-cycle (internal)
|
|
549
|
+
* @returns True if moved to next, false if at end
|
|
550
|
+
*/
|
|
551
|
+
nextMessage(isAuto?: boolean): boolean;
|
|
552
|
+
/**
|
|
553
|
+
* Go to previous message in current step
|
|
554
|
+
* @returns True if moved to previous, false if at start
|
|
555
|
+
*/
|
|
556
|
+
prevMessage(): boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Go to a specific message by index
|
|
559
|
+
* @param index - Message index (0-based)
|
|
560
|
+
*/
|
|
561
|
+
goToMessage(index: number): void;
|
|
562
|
+
/** Get current message index */
|
|
563
|
+
getCurrentMessage(): number;
|
|
564
|
+
/** Get total messages in current step */
|
|
565
|
+
getTotalMessages(): number;
|
|
566
|
+
/**
|
|
567
|
+
* Update displayed content
|
|
568
|
+
* @param content - New content
|
|
569
|
+
* @param animate - Whether to animate (default: true)
|
|
570
|
+
*/
|
|
571
|
+
updateContent(content: string | React.ReactNode, animate?: boolean): void;
|
|
572
|
+
/**
|
|
573
|
+
* Update target element
|
|
574
|
+
* @param target - New target element or selector
|
|
575
|
+
*/
|
|
576
|
+
updateTarget(target: string | HTMLElement): void;
|
|
577
|
+
/** Update pointer position based on current target */
|
|
578
|
+
updatePosition(): void;
|
|
579
|
+
|
|
580
|
+
// Message cycle methods
|
|
581
|
+
/**
|
|
582
|
+
* Start auto-cycling through messages
|
|
583
|
+
* @param interval - Optional interval in ms
|
|
584
|
+
* @returns True if started, false if already running or no messages
|
|
585
|
+
*/
|
|
586
|
+
startMessageCycle(interval?: number): boolean;
|
|
587
|
+
/**
|
|
588
|
+
* Stop message cycling completely
|
|
589
|
+
* @returns True if stopped, false if not running
|
|
590
|
+
*/
|
|
591
|
+
stopMessageCycle(): boolean;
|
|
592
|
+
/** Pause message cycling (can be resumed) */
|
|
593
|
+
pauseMessageCycle(): void;
|
|
594
|
+
/**
|
|
595
|
+
* Resume paused message cycling
|
|
596
|
+
* @returns True if resumed, false if not paused
|
|
597
|
+
*/
|
|
598
|
+
resumeMessageCycle(): boolean;
|
|
599
|
+
/** Check if message cycling is active */
|
|
600
|
+
isMessageCycleActive(): boolean;
|
|
601
|
+
/** Check if message cycling is paused */
|
|
602
|
+
isMessageCyclePaused(): boolean;
|
|
603
|
+
|
|
604
|
+
// Autoplay methods
|
|
605
|
+
/** Start autoplay */
|
|
606
|
+
startAutoplay(): void;
|
|
607
|
+
/** Stop autoplay */
|
|
608
|
+
stopAutoplay(): void;
|
|
609
|
+
/** Pause autoplay (can be resumed) */
|
|
610
|
+
pauseAutoplay(): void;
|
|
611
|
+
/** Resume autoplay after pause */
|
|
612
|
+
resumeAutoplay(): void;
|
|
613
|
+
/** Check if autoplay is currently active */
|
|
614
|
+
isAutoplayActive(): boolean;
|
|
615
|
+
/** Check if autoplay is paused */
|
|
616
|
+
isAutoplayPaused(): boolean;
|
|
617
|
+
|
|
618
|
+
// Animation methods
|
|
619
|
+
/** Animate to initial position (teleport hidden, fade in, move to target) */
|
|
620
|
+
animateToInitialPosition(): void;
|
|
621
|
+
|
|
622
|
+
// State methods
|
|
623
|
+
/** Get current step index */
|
|
624
|
+
getCurrentStep(): number;
|
|
625
|
+
/** Get total number of steps */
|
|
626
|
+
getTotalSteps(): number;
|
|
627
|
+
/** Check if floating animation is enabled */
|
|
628
|
+
isFloatingAnimationEnabled(): boolean;
|
|
629
|
+
/** Check if tracking is enabled */
|
|
630
|
+
isTrackingEnabled(): boolean;
|
|
631
|
+
|
|
632
|
+
// Setter methods
|
|
633
|
+
/**
|
|
634
|
+
* Set the animation easing
|
|
635
|
+
* @param easing - Easing preset name or custom cubic-bezier
|
|
636
|
+
*/
|
|
637
|
+
setEasing(easing: PointyEasing): void;
|
|
638
|
+
/**
|
|
639
|
+
* Set the animation duration
|
|
640
|
+
* @param duration - Duration in milliseconds
|
|
641
|
+
*/
|
|
642
|
+
setAnimationDuration(duration: number): void;
|
|
643
|
+
/**
|
|
644
|
+
* Set the intro fade duration
|
|
645
|
+
* @param duration - Duration in milliseconds
|
|
646
|
+
*/
|
|
647
|
+
setIntroFadeDuration(duration: number): void;
|
|
648
|
+
/**
|
|
649
|
+
* Set the bubble fade duration
|
|
650
|
+
* @param duration - Duration in milliseconds
|
|
651
|
+
*/
|
|
652
|
+
setBubbleFadeDuration(duration: number): void;
|
|
653
|
+
/**
|
|
654
|
+
* Set the message transition duration
|
|
655
|
+
* @param duration - Duration in milliseconds
|
|
656
|
+
*/
|
|
657
|
+
setMessageTransitionDuration(duration: number): void;
|
|
658
|
+
/**
|
|
659
|
+
* Set the message auto-cycle interval
|
|
660
|
+
* @param interval - Interval in ms, null to disable
|
|
661
|
+
*/
|
|
662
|
+
setMessageInterval(interval: number | null): void;
|
|
663
|
+
/**
|
|
664
|
+
* Set the offset from target
|
|
665
|
+
* @param offsetX - Horizontal offset
|
|
666
|
+
* @param offsetY - Vertical offset
|
|
667
|
+
*/
|
|
668
|
+
setOffset(offsetX: number, offsetY: number): void;
|
|
669
|
+
/**
|
|
670
|
+
* Set reset on complete option
|
|
671
|
+
* @param reset - Whether to reset on complete
|
|
672
|
+
*/
|
|
673
|
+
setResetOnComplete(reset: boolean): void;
|
|
674
|
+
/**
|
|
675
|
+
* Set hide on complete option
|
|
676
|
+
* @param hide - Whether to hide on complete
|
|
677
|
+
*/
|
|
678
|
+
setHideOnComplete(hide: boolean): void;
|
|
679
|
+
/**
|
|
680
|
+
* Set hide on complete delay
|
|
681
|
+
* @param delay - Delay in ms, null to use animationDuration
|
|
682
|
+
*/
|
|
683
|
+
setHideOnCompleteDelay(delay: number | null): void;
|
|
684
|
+
/**
|
|
685
|
+
* Set floating animation enabled/disabled
|
|
686
|
+
* @param enabled - Whether floating animation is enabled
|
|
687
|
+
*/
|
|
688
|
+
setFloatingAnimation(enabled: boolean): void;
|
|
689
|
+
/**
|
|
690
|
+
* Set tracking enabled/disabled
|
|
691
|
+
* @param enabled - Whether tracking is enabled
|
|
692
|
+
*/
|
|
693
|
+
setTracking(enabled: boolean): void;
|
|
694
|
+
/**
|
|
695
|
+
* Set tracking FPS
|
|
696
|
+
* @param fps - Frames per second (0 = unlimited)
|
|
697
|
+
*/
|
|
698
|
+
setTrackingFps(fps: number): void;
|
|
699
|
+
/**
|
|
700
|
+
* Set the initial position
|
|
701
|
+
* @param position - Position preset, CSS selector, or element
|
|
702
|
+
*/
|
|
703
|
+
setInitialPosition(position: PointyInitialPosition | string | HTMLElement): void;
|
|
704
|
+
/**
|
|
705
|
+
* Set the initial position offset from edges
|
|
706
|
+
* @param offset - Offset in pixels
|
|
707
|
+
*/
|
|
708
|
+
setInitialPositionOffset(offset: number): void;
|
|
709
|
+
/**
|
|
710
|
+
* Set autoplay interval (does not start autoplay)
|
|
711
|
+
* @param interval - Interval in ms, or null to disable
|
|
712
|
+
*/
|
|
713
|
+
setAutoplayInterval(interval: number | null): void;
|
|
714
|
+
/**
|
|
715
|
+
* Set autoplay interval and start autoplay
|
|
716
|
+
* @param interval - Interval in ms, or null to disable
|
|
717
|
+
* @deprecated Use setAutoplayInterval() + startAutoplay() instead
|
|
718
|
+
*/
|
|
719
|
+
setAutoplay(interval: number | null): void;
|
|
720
|
+
/**
|
|
721
|
+
* Set whether autoplay waits for messages
|
|
722
|
+
* @param wait - Whether to wait for all messages
|
|
723
|
+
*/
|
|
724
|
+
setAutoplayWaitForMessages(wait: boolean): void;
|
|
725
|
+
/**
|
|
726
|
+
* Set custom pointer SVG
|
|
727
|
+
* @param svg - SVG markup string or React element
|
|
728
|
+
*/
|
|
729
|
+
setPointerSvg(svg: string | React.ReactNode): void;
|
|
730
|
+
|
|
731
|
+
// Getter methods
|
|
732
|
+
/** Get current pointer SVG or React element */
|
|
733
|
+
getPointerSvg(): string | React.ReactNode;
|
|
734
|
+
/** Get class names object */
|
|
735
|
+
getClassNames(): PointyClassNames;
|
|
736
|
+
/** Get class prefix */
|
|
737
|
+
getClassPrefix(): string;
|
|
738
|
+
/** Get CSS variable prefix */
|
|
739
|
+
getCssVarPrefix(): string;
|
|
740
|
+
|
|
741
|
+
// Event methods
|
|
742
|
+
/**
|
|
743
|
+
* Subscribe to an event or event group
|
|
744
|
+
* @param event - Event name, group name ('lifecycle', 'navigation', etc.), or wildcard ('*', 'all')
|
|
745
|
+
* @param callback - Callback function
|
|
746
|
+
* @returns This instance for chaining
|
|
747
|
+
*/
|
|
748
|
+
on(event: PointyEvent | PointyEventGroup | string, callback: PointyEventCallback<any>): this;
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Subscribe to a lifecycle event
|
|
752
|
+
*/
|
|
753
|
+
on(event: PointyLifecycleEvent, callback: PointyEventCallback<PointyLifecycleEventData>): this;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Subscribe to a navigation event
|
|
757
|
+
*/
|
|
758
|
+
on(event: PointyNavigationEvent, callback: PointyEventCallback<PointyNavigationEventData>): this;
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Subscribe to an animation event
|
|
762
|
+
*/
|
|
763
|
+
on(event: PointyAnimationEvent, callback: PointyEventCallback<PointyAnimationEventData>): this;
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Subscribe to a content event
|
|
767
|
+
*/
|
|
768
|
+
on(event: PointyContentEvent, callback: PointyEventCallback<PointyContentEventData>): this;
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Subscribe to a message cycle event
|
|
772
|
+
*/
|
|
773
|
+
on(event: PointyMessageCycleEvent, callback: PointyEventCallback<PointyMessageCycleEventData>): this;
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Subscribe to a pointing event
|
|
777
|
+
*/
|
|
778
|
+
on(event: PointyPointingEvent, callback: PointyEventCallback<PointyPointingEventData>): this;
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Subscribe to a tracking event
|
|
782
|
+
*/
|
|
783
|
+
on(event: PointyTrackingEvent, callback: PointyEventCallback<PointyTrackingEventData>): this;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Subscribe to an autoplay event
|
|
787
|
+
*/
|
|
788
|
+
on(event: PointyAutoplayEvent, callback: PointyEventCallback<PointyAutoplayEventData>): this;
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Subscribe to a config change event
|
|
792
|
+
*/
|
|
793
|
+
on(event: PointyConfigEvent, callback: PointyEventCallback<PointyConfigChangeEventData>): this;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Subscribe to an event group
|
|
797
|
+
*/
|
|
798
|
+
on(event: 'lifecycle', callback: PointyEventCallback<PointyLifecycleEventData>): this;
|
|
799
|
+
on(event: 'navigation', callback: PointyEventCallback<PointyNavigationEventData>): this;
|
|
800
|
+
on(event: 'animation', callback: PointyEventCallback<PointyAnimationEventData>): this;
|
|
801
|
+
on(event: 'content', callback: PointyEventCallback<PointyContentEventData>): this;
|
|
802
|
+
on(event: 'messageCycle', callback: PointyEventCallback<PointyMessageCycleEventData>): this;
|
|
803
|
+
on(event: 'pointing', callback: PointyEventCallback<PointyPointingEventData>): this;
|
|
804
|
+
on(event: 'tracking', callback: PointyEventCallback<PointyTrackingEventData>): this;
|
|
805
|
+
on(event: 'autoplay', callback: PointyEventCallback<PointyAutoplayEventData>): this;
|
|
806
|
+
on(event: 'config', callback: PointyEventCallback<PointyConfigChangeEventData>): this;
|
|
807
|
+
on(event: '*' | 'all', callback: PointyEventCallback<PointyEventData>): this;
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Unsubscribe from an event
|
|
811
|
+
* @param event - Event name
|
|
812
|
+
* @param callback - Callback function to remove (omit to remove all)
|
|
813
|
+
* @returns This instance for chaining
|
|
814
|
+
*/
|
|
815
|
+
off(event: string, callback?: PointyEventCallback<any>): this;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
export default Pointy;
|
|
819
|
+
|
|
820
|
+
export {
|
|
821
|
+
Pointy,
|
|
822
|
+
PointyOptions,
|
|
823
|
+
PointyStep,
|
|
824
|
+
PointyClassNames,
|
|
825
|
+
PointyClassSuffixes,
|
|
826
|
+
PointyInitialPosition,
|
|
827
|
+
PointyEasing,
|
|
828
|
+
PointyEvent,
|
|
829
|
+
PointyEventGroup,
|
|
830
|
+
PointyEventGroups,
|
|
831
|
+
PointyEventData,
|
|
832
|
+
PointyEventCallback,
|
|
833
|
+
PointyLifecycleEvent,
|
|
834
|
+
PointyLifecycleEventData,
|
|
835
|
+
PointyNavigationEvent,
|
|
836
|
+
PointyNavigationEventData,
|
|
837
|
+
PointyAnimationEvent,
|
|
838
|
+
PointyAnimationEventData,
|
|
839
|
+
PointyContentEvent,
|
|
840
|
+
PointyContentEventData,
|
|
841
|
+
PointyMessageCycleEvent,
|
|
842
|
+
PointyMessageCycleEventData,
|
|
843
|
+
PointyPointingEvent,
|
|
844
|
+
PointyPointingEventData,
|
|
845
|
+
PointyTrackingEvent,
|
|
846
|
+
PointyTrackingEventData,
|
|
847
|
+
PointyAutoplayEvent,
|
|
848
|
+
PointyAutoplayEventData,
|
|
849
|
+
PointyConfigEvent,
|
|
850
|
+
PointyConfigChangeEventData,
|
|
851
|
+
};
|