Update types
Browse files- package.json +1 -0
- types/{index.d.ts.todo → index.d.ts} +49 -47
package.json
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
"version": "0.3.2",
|
4 |
"description": "A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page",
|
5 |
"main": "dist/driver.min.js",
|
|
|
6 |
"scripts": {
|
7 |
"start": "node server.js",
|
8 |
"build": "webpack --config webpack.config.prod.js"
|
|
|
3 |
"version": "0.3.2",
|
4 |
"description": "A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page",
|
5 |
"main": "dist/driver.min.js",
|
6 |
+
"types": "types/index.d.ts",
|
7 |
"scripts": {
|
8 |
"start": "node server.js",
|
9 |
"build": "webpack --config webpack.config.prod.js"
|
types/{index.d.ts.todo → index.d.ts}
RENAMED
@@ -1,5 +1,5 @@
|
|
1 |
declare module 'driver.js' {
|
2 |
-
|
3 |
/**
|
4 |
* Refers to the global document object
|
5 |
*/
|
@@ -38,38 +38,38 @@ declare module 'driver.js' {
|
|
38 |
/**
|
39 |
* Does the required bindings for DOM Events
|
40 |
*/
|
41 |
-
private bind();
|
42 |
|
43 |
/**
|
44 |
* Listener for the click event, to decide if
|
45 |
* to next/previous step, reset the overlay etc
|
46 |
* @param {Event} e
|
47 |
*/
|
48 |
-
private onClick(e: Event);
|
49 |
|
50 |
/**
|
51 |
* Refreshes the driver and resets the position for stage
|
52 |
* and popover on resizing the window
|
53 |
*/
|
54 |
-
private onResize();
|
55 |
|
56 |
/**
|
57 |
* Makes it operable with keyboard
|
58 |
* @param {Event} e
|
59 |
*/
|
60 |
-
private onKeyUp(e: Event);
|
61 |
|
62 |
/**
|
63 |
* Moves to the previous step if possible
|
64 |
* otherwise resets the overlay
|
65 |
*/
|
66 |
-
public movePrevious();
|
67 |
|
68 |
/**
|
69 |
* Moves to the next step if possible
|
70 |
* otherwise resets the overlay
|
71 |
*/
|
72 |
-
public moveNext();
|
73 |
|
74 |
/**
|
75 |
* Checks if can be moved to next step
|
@@ -86,7 +86,7 @@ declare module 'driver.js' {
|
|
86 |
/**
|
87 |
* Resets the steps and clears the overlay
|
88 |
*/
|
89 |
-
public reset();
|
90 |
|
91 |
/**
|
92 |
* Checks if there is any highlighted element or not
|
@@ -110,7 +110,7 @@ declare module 'driver.js' {
|
|
110 |
* Defines the steps to be used in multi-step driver
|
111 |
* @param {Array<Driver.Step>} steps
|
112 |
*/
|
113 |
-
public defineSteps(steps: Array<Driver.Step>);
|
114 |
|
115 |
/**
|
116 |
* Prepares {Driver.Element} from the given step definition
|
@@ -118,19 +118,19 @@ declare module 'driver.js' {
|
|
118 |
* @param {Array<Driver.Step>} allSteps all the given steps
|
119 |
* @param {number} stepIndex array index for the current step
|
120 |
*/
|
121 |
-
private prepareElementFromStep(step: Driver.Step | string, allSteps: Array<Driver.Step>, stepIndex: number);
|
122 |
|
123 |
/**
|
124 |
* Starts presenting the set steps from the given index
|
125 |
* @param {number} index
|
126 |
*/
|
127 |
-
public start(index?: number);
|
128 |
|
129 |
/**
|
130 |
* Highlights the given element. Element can be a query selector or a step definition
|
131 |
* @param {string | Driver.Step} element
|
132 |
*/
|
133 |
-
public highlight(element: string | Driver.Step);
|
134 |
}
|
135 |
|
136 |
namespace Driver {
|
@@ -214,7 +214,7 @@ declare module 'driver.js' {
|
|
214 |
/**
|
215 |
* Brings the current DOMElement in view
|
216 |
*/
|
217 |
-
public bringInView();
|
218 |
|
219 |
/**
|
220 |
* Gets the position of element on screen
|
@@ -225,38 +225,38 @@ declare module 'driver.js' {
|
|
225 |
/**
|
226 |
* Manually scrolls to current element if scrollInToView is not supported
|
227 |
*/
|
228 |
-
private scrollManually();
|
229 |
|
230 |
/**
|
231 |
* Is called when the current element is deselected
|
232 |
* @param {boolean} hideStage
|
233 |
*/
|
234 |
-
private onDeselected(hideStage?: boolean
|
235 |
|
236 |
/**
|
237 |
* Is called when element is about to be highlighted
|
238 |
*/
|
239 |
-
private onHighlightStarted();
|
240 |
|
241 |
/**
|
242 |
* Is called when element has been successfully highlighted
|
243 |
*/
|
244 |
-
private onHighlighted();
|
245 |
|
246 |
/**
|
247 |
* Shows the stage on the current element
|
248 |
*/
|
249 |
-
private showStage();
|
250 |
|
251 |
/**
|
252 |
* Hides the popover from the current element if visible
|
253 |
*/
|
254 |
-
private hidePopover();
|
255 |
|
256 |
/**
|
257 |
* Shows the popover on current element if possible
|
258 |
*/
|
259 |
-
private showPopover();
|
260 |
|
261 |
/**
|
262 |
* Gets the full page size
|
@@ -267,7 +267,7 @@ declare module 'driver.js' {
|
|
267 |
* Checks if the current element is same as passed element
|
268 |
* @param {Driver.Element} element
|
269 |
*/
|
270 |
-
private isSame(element: Driver.Element);
|
271 |
|
272 |
/**
|
273 |
* Gets the node that this element refers to
|
@@ -316,18 +316,18 @@ declare module 'driver.js' {
|
|
316 |
/**
|
317 |
* Prepares the DOM element for overlay and appends to body
|
318 |
*/
|
319 |
-
private makeNode();
|
320 |
|
321 |
/**
|
322 |
* Highlights the given Element while resetting the existing one
|
323 |
* @param {Driver.Element} element
|
324 |
*/
|
325 |
-
public highlight(element: Driver.Element);
|
326 |
|
327 |
/**
|
328 |
* Shows the overlay while appending to body if it is not there already
|
329 |
*/
|
330 |
-
public show();
|
331 |
|
332 |
/**
|
333 |
* Gets the highlighted element in overlay if any
|
@@ -346,18 +346,18 @@ declare module 'driver.js' {
|
|
346 |
* by default or without animation if immediate is set to false
|
347 |
* @param {boolean} immediate
|
348 |
*/
|
349 |
-
public clear(immediate
|
350 |
|
351 |
/**
|
352 |
* Removes the overlay node if it exists
|
353 |
*/
|
354 |
-
private removeNode();
|
355 |
|
356 |
/**
|
357 |
* Refreshes the overlay i.e. sets the size according to current window size
|
358 |
* And moves the highlight around if necessary
|
359 |
*/
|
360 |
-
public refresh();
|
361 |
}
|
362 |
|
363 |
export class Popover {
|
@@ -384,58 +384,58 @@ declare module 'driver.js' {
|
|
384 |
/**
|
385 |
* Prepares the DOM element for popover and appends to the body
|
386 |
*/
|
387 |
-
private makeNode();
|
388 |
|
389 |
/**
|
390 |
* Hides the popover if visible
|
391 |
*/
|
392 |
-
public hide();
|
393 |
|
394 |
/**
|
395 |
* Sets the initial state for popover before changing position
|
396 |
*/
|
397 |
-
private setInitialState();
|
398 |
|
399 |
/**
|
400 |
* Shows the popover at the given position
|
401 |
* @param {Driver.Position} position
|
402 |
*/
|
403 |
-
public show(position: Driver.Position);
|
404 |
|
405 |
/**
|
406 |
* Renders the buttons in the footer of the popover
|
407 |
*/
|
408 |
-
private renderButtons();
|
409 |
|
410 |
/**
|
411 |
* Positions the popover to the left of the given element position
|
412 |
* @param {Driver.Position} position
|
413 |
*/
|
414 |
-
private positionOnLeft(position: Driver.Position);
|
415 |
|
416 |
/**
|
417 |
* Positions the popover to the right of the given element position
|
418 |
* @param {Driver.Position} position
|
419 |
*/
|
420 |
-
private positionOnRight(position: Driver.Position);
|
421 |
|
422 |
/**
|
423 |
* Positions the popover to the top of the given element position
|
424 |
* @param {Driver.Position} position
|
425 |
*/
|
426 |
-
private positionOnTop(position: Driver.Position);
|
427 |
|
428 |
/**
|
429 |
* Positions the popover to the bottom of the given element position
|
430 |
* @param {Driver.Position} position
|
431 |
*/
|
432 |
-
private positionOnBottom(position: Driver.Position);
|
433 |
|
434 |
/**
|
435 |
* Positions the popover automatically around the element position
|
436 |
* @param {Driver.Position} position
|
437 |
*/
|
438 |
-
private autoPosition(position: Driver.Position);
|
439 |
}
|
440 |
|
441 |
export class Stage extends Element {
|
@@ -455,23 +455,23 @@ declare module 'driver.js' {
|
|
455 |
/**
|
456 |
* Prepares the node and appends to body if not there already
|
457 |
*/
|
458 |
-
private makeNode();
|
459 |
|
460 |
/**
|
461 |
* Hides the stage by removing the node
|
462 |
*/
|
463 |
-
public hide();
|
464 |
|
465 |
/**
|
466 |
* Sets the default properties on the node
|
467 |
*/
|
468 |
-
private setInitialStyle();
|
469 |
|
470 |
/**
|
471 |
* Shows the stage at provided position
|
472 |
* @param {Driver.Position} position
|
473 |
*/
|
474 |
-
public show(position: Driver.Position);
|
475 |
}
|
476 |
|
477 |
export class Position {
|
@@ -481,11 +481,11 @@ declare module 'driver.js' {
|
|
481 |
bottom: number;
|
482 |
|
483 |
constructor({
|
484 |
-
left: number
|
485 |
-
top: number
|
486 |
-
bottom: number
|
487 |
-
right: number
|
488 |
-
}
|
489 |
|
490 |
/**
|
491 |
* Checks if the given position is valid and can be highlighted
|
@@ -497,7 +497,7 @@ declare module 'driver.js' {
|
|
497 |
* Checks if the given position is same as the passed position
|
498 |
* @param {Driver.Position} position
|
499 |
*/
|
500 |
-
equals(position: Driver.Position);
|
501 |
}
|
502 |
|
503 |
interface ScreenCoordinates {
|
@@ -648,4 +648,6 @@ declare module 'driver.js' {
|
|
648 |
interface StageOptions extends ElementOptions {
|
649 |
}
|
650 |
}
|
|
|
|
|
651 |
}
|
|
|
1 |
declare module 'driver.js' {
|
2 |
+
class Driver {
|
3 |
/**
|
4 |
* Refers to the global document object
|
5 |
*/
|
|
|
38 |
/**
|
39 |
* Does the required bindings for DOM Events
|
40 |
*/
|
41 |
+
private bind(): void;
|
42 |
|
43 |
/**
|
44 |
* Listener for the click event, to decide if
|
45 |
* to next/previous step, reset the overlay etc
|
46 |
* @param {Event} e
|
47 |
*/
|
48 |
+
private onClick(e: Event): void;
|
49 |
|
50 |
/**
|
51 |
* Refreshes the driver and resets the position for stage
|
52 |
* and popover on resizing the window
|
53 |
*/
|
54 |
+
private onResize(): void;
|
55 |
|
56 |
/**
|
57 |
* Makes it operable with keyboard
|
58 |
* @param {Event} e
|
59 |
*/
|
60 |
+
private onKeyUp(e: Event): void;
|
61 |
|
62 |
/**
|
63 |
* Moves to the previous step if possible
|
64 |
* otherwise resets the overlay
|
65 |
*/
|
66 |
+
public movePrevious(): void;
|
67 |
|
68 |
/**
|
69 |
* Moves to the next step if possible
|
70 |
* otherwise resets the overlay
|
71 |
*/
|
72 |
+
public moveNext(): void;
|
73 |
|
74 |
/**
|
75 |
* Checks if can be moved to next step
|
|
|
86 |
/**
|
87 |
* Resets the steps and clears the overlay
|
88 |
*/
|
89 |
+
public reset(): void;
|
90 |
|
91 |
/**
|
92 |
* Checks if there is any highlighted element or not
|
|
|
110 |
* Defines the steps to be used in multi-step driver
|
111 |
* @param {Array<Driver.Step>} steps
|
112 |
*/
|
113 |
+
public defineSteps(steps: Array<Driver.Step>): void;
|
114 |
|
115 |
/**
|
116 |
* Prepares {Driver.Element} from the given step definition
|
|
|
118 |
* @param {Array<Driver.Step>} allSteps all the given steps
|
119 |
* @param {number} stepIndex array index for the current step
|
120 |
*/
|
121 |
+
private prepareElementFromStep(step: Driver.Step | string, allSteps: Array<Driver.Step>, stepIndex: number): void;
|
122 |
|
123 |
/**
|
124 |
* Starts presenting the set steps from the given index
|
125 |
* @param {number} index
|
126 |
*/
|
127 |
+
public start(index?: number): void;
|
128 |
|
129 |
/**
|
130 |
* Highlights the given element. Element can be a query selector or a step definition
|
131 |
* @param {string | Driver.Step} element
|
132 |
*/
|
133 |
+
public highlight(element: string | Driver.Step): void;
|
134 |
}
|
135 |
|
136 |
namespace Driver {
|
|
|
214 |
/**
|
215 |
* Brings the current DOMElement in view
|
216 |
*/
|
217 |
+
public bringInView(): void;
|
218 |
|
219 |
/**
|
220 |
* Gets the position of element on screen
|
|
|
225 |
/**
|
226 |
* Manually scrolls to current element if scrollInToView is not supported
|
227 |
*/
|
228 |
+
private scrollManually(): void;
|
229 |
|
230 |
/**
|
231 |
* Is called when the current element is deselected
|
232 |
* @param {boolean} hideStage
|
233 |
*/
|
234 |
+
private onDeselected(hideStage?: boolean): void;
|
235 |
|
236 |
/**
|
237 |
* Is called when element is about to be highlighted
|
238 |
*/
|
239 |
+
private onHighlightStarted(): void;
|
240 |
|
241 |
/**
|
242 |
* Is called when element has been successfully highlighted
|
243 |
*/
|
244 |
+
private onHighlighted(): void;
|
245 |
|
246 |
/**
|
247 |
* Shows the stage on the current element
|
248 |
*/
|
249 |
+
private showStage(): void;
|
250 |
|
251 |
/**
|
252 |
* Hides the popover from the current element if visible
|
253 |
*/
|
254 |
+
private hidePopover(): void;
|
255 |
|
256 |
/**
|
257 |
* Shows the popover on current element if possible
|
258 |
*/
|
259 |
+
private showPopover(): void;
|
260 |
|
261 |
/**
|
262 |
* Gets the full page size
|
|
|
267 |
* Checks if the current element is same as passed element
|
268 |
* @param {Driver.Element} element
|
269 |
*/
|
270 |
+
private isSame(element: Driver.Element): void;
|
271 |
|
272 |
/**
|
273 |
* Gets the node that this element refers to
|
|
|
316 |
/**
|
317 |
* Prepares the DOM element for overlay and appends to body
|
318 |
*/
|
319 |
+
private makeNode(): void;
|
320 |
|
321 |
/**
|
322 |
* Highlights the given Element while resetting the existing one
|
323 |
* @param {Driver.Element} element
|
324 |
*/
|
325 |
+
public highlight(element: Driver.Element): void;
|
326 |
|
327 |
/**
|
328 |
* Shows the overlay while appending to body if it is not there already
|
329 |
*/
|
330 |
+
public show(): void;
|
331 |
|
332 |
/**
|
333 |
* Gets the highlighted element in overlay if any
|
|
|
346 |
* by default or without animation if immediate is set to false
|
347 |
* @param {boolean} immediate
|
348 |
*/
|
349 |
+
public clear(immediate?: boolean): void;
|
350 |
|
351 |
/**
|
352 |
* Removes the overlay node if it exists
|
353 |
*/
|
354 |
+
private removeNode(): void;
|
355 |
|
356 |
/**
|
357 |
* Refreshes the overlay i.e. sets the size according to current window size
|
358 |
* And moves the highlight around if necessary
|
359 |
*/
|
360 |
+
public refresh(): void;
|
361 |
}
|
362 |
|
363 |
export class Popover {
|
|
|
384 |
/**
|
385 |
* Prepares the DOM element for popover and appends to the body
|
386 |
*/
|
387 |
+
private makeNode(): void;
|
388 |
|
389 |
/**
|
390 |
* Hides the popover if visible
|
391 |
*/
|
392 |
+
public hide(): void;
|
393 |
|
394 |
/**
|
395 |
* Sets the initial state for popover before changing position
|
396 |
*/
|
397 |
+
private setInitialState(): void;
|
398 |
|
399 |
/**
|
400 |
* Shows the popover at the given position
|
401 |
* @param {Driver.Position} position
|
402 |
*/
|
403 |
+
public show(position: Driver.Position): void;
|
404 |
|
405 |
/**
|
406 |
* Renders the buttons in the footer of the popover
|
407 |
*/
|
408 |
+
private renderButtons(): void;
|
409 |
|
410 |
/**
|
411 |
* Positions the popover to the left of the given element position
|
412 |
* @param {Driver.Position} position
|
413 |
*/
|
414 |
+
private positionOnLeft(position: Driver.Position): void;
|
415 |
|
416 |
/**
|
417 |
* Positions the popover to the right of the given element position
|
418 |
* @param {Driver.Position} position
|
419 |
*/
|
420 |
+
private positionOnRight(position: Driver.Position): void;
|
421 |
|
422 |
/**
|
423 |
* Positions the popover to the top of the given element position
|
424 |
* @param {Driver.Position} position
|
425 |
*/
|
426 |
+
private positionOnTop(position: Driver.Position): void;
|
427 |
|
428 |
/**
|
429 |
* Positions the popover to the bottom of the given element position
|
430 |
* @param {Driver.Position} position
|
431 |
*/
|
432 |
+
private positionOnBottom(position: Driver.Position): void;
|
433 |
|
434 |
/**
|
435 |
* Positions the popover automatically around the element position
|
436 |
* @param {Driver.Position} position
|
437 |
*/
|
438 |
+
private autoPosition(position: Driver.Position): void;
|
439 |
}
|
440 |
|
441 |
export class Stage extends Element {
|
|
|
455 |
/**
|
456 |
* Prepares the node and appends to body if not there already
|
457 |
*/
|
458 |
+
private makeNode(): void;
|
459 |
|
460 |
/**
|
461 |
* Hides the stage by removing the node
|
462 |
*/
|
463 |
+
public hide(): void;
|
464 |
|
465 |
/**
|
466 |
* Sets the default properties on the node
|
467 |
*/
|
468 |
+
private setInitialStyle(): void;
|
469 |
|
470 |
/**
|
471 |
* Shows the stage at provided position
|
472 |
* @param {Driver.Position} position
|
473 |
*/
|
474 |
+
public show(position: Driver.Position): void;
|
475 |
}
|
476 |
|
477 |
export class Position {
|
|
|
481 |
bottom: number;
|
482 |
|
483 |
constructor({
|
484 |
+
left: number,
|
485 |
+
top: number,
|
486 |
+
bottom: number,
|
487 |
+
right: number,
|
488 |
+
});
|
489 |
|
490 |
/**
|
491 |
* Checks if the given position is valid and can be highlighted
|
|
|
497 |
* Checks if the given position is same as the passed position
|
498 |
* @param {Driver.Position} position
|
499 |
*/
|
500 |
+
equals(position: Driver.Position): void;
|
501 |
}
|
502 |
|
503 |
interface ScreenCoordinates {
|
|
|
648 |
interface StageOptions extends ElementOptions {
|
649 |
}
|
650 |
}
|
651 |
+
|
652 |
+
export = Driver;
|
653 |
}
|