tooltip-tour
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,9 +0,9 @@ | ||
declare class GuideMe { | ||
declare class TooltipTour { | ||
private elements; | ||
private options?; | ||
private guideMe; | ||
private tooltipTourElement; | ||
private trap; | ||
private currentElementIndex; | ||
constructor(elements: GuideStep[], options?: GuideOptions | undefined); | ||
update(elements: GuideStep[], options?: GuideOptions): void; | ||
constructor(elements: TooltipTourStep[], options?: TooltipTourOptions | undefined); | ||
update(elements: TooltipTourStep[], options?: TooltipTourOptions): void; | ||
prev(): void; | ||
@@ -20,4 +20,4 @@ next(): void; | ||
declare const createGuide: (elements: GuideStep[], options?: GuideOptions) => GuideMe; | ||
type GuideOptions = { | ||
declare const createTooltipTour: (elements: TooltipTourStep[], options?: TooltipTourOptions) => TooltipTour; | ||
type TooltipTourOptions = { | ||
disableOverlay?: boolean; | ||
@@ -28,3 +28,3 @@ disableFocusTrap?: boolean; | ||
}; | ||
type GuideStep = { | ||
type TooltipTourStep = { | ||
element: HTMLElement; | ||
@@ -34,2 +34,2 @@ tooltip: Node; | ||
export { type GuideOptions, type GuideStep, createGuide }; | ||
export { type TooltipTourOptions, type TooltipTourStep, createTooltipTour }; |
@@ -33,9 +33,9 @@ "use strict"; | ||
__export(src_exports, { | ||
createGuide: () => createGuide | ||
createTooltipTour: () => createTooltipTour | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/GuideMe.ts | ||
// src/TooltipTour.ts | ||
var focusTrap = __toESM(require("focus-trap")); | ||
var GuideMe = class { | ||
var TooltipTour = class { | ||
constructor(elements, options) { | ||
@@ -63,8 +63,8 @@ this.elements = elements; | ||
var _a, _b, _c; | ||
if (!this.guideMe) { | ||
throw new Error("There is no GuideMeElement"); | ||
if (!this.tooltipTourElement) { | ||
throw new Error("There is no TooltipTourElement"); | ||
} | ||
this.guideMe.hideTooltip(); | ||
this.tooltipTourElement.hideTooltip(); | ||
if (!((_a = this.options) == null ? void 0 : _a.disableOverlay)) { | ||
this.guideMe.hideOverlay(); | ||
this.tooltipTourElement.hideOverlay(); | ||
} | ||
@@ -81,8 +81,8 @@ if (!((_b = this.options) == null ? void 0 : _b.disableFocusTrap)) { | ||
destroy() { | ||
if (!this.guideMe) { | ||
throw new Error("There is no GuideMeElement"); | ||
if (!this.tooltipTourElement) { | ||
throw new Error("There is no TooltipTourElement"); | ||
} | ||
this.hide(); | ||
this.guideMe.destroy(); | ||
this.guideMe = null; | ||
this.tooltipTourElement.destroy(); | ||
this.tooltipTourElement = null; | ||
this.currentElementIndex = -1; | ||
@@ -97,12 +97,12 @@ } | ||
initialize() { | ||
const guideMeElement = document.querySelector( | ||
"guide-me-element" | ||
const tooltipTourElement = document.querySelector( | ||
"tooltip-tour-element" | ||
); | ||
if (guideMeElement) { | ||
this.guideMe = guideMeElement; | ||
if (tooltipTourElement) { | ||
this.tooltipTourElement = tooltipTourElement; | ||
} else { | ||
this.guideMe = document.createElement( | ||
"guide-me-element" | ||
this.tooltipTourElement = document.createElement( | ||
"tooltip-tour-element" | ||
); | ||
document.body.appendChild(this.guideMe); | ||
document.body.appendChild(this.tooltipTourElement); | ||
} | ||
@@ -112,8 +112,8 @@ } | ||
var _a, _b, _c, _d, _e, _f; | ||
if (!this.guideMe) { | ||
throw new Error("There is no GuideMeElement"); | ||
if (!this.tooltipTourElement) { | ||
throw new Error("There is no TooltipTourElement"); | ||
} | ||
const item = this.elements[this.currentElementIndex]; | ||
if (!item) { | ||
this.guideMe.hideTooltip(); | ||
this.tooltipTourElement.hideTooltip(); | ||
if (!((_a = this.options) == null ? void 0 : _a.disableFocusTrap)) { | ||
@@ -123,10 +123,10 @@ this.destroyFocusTrap(); | ||
if (!((_b = this.options) == null ? void 0 : _b.disableOverlay)) { | ||
this.guideMe.hideOverlay(); | ||
this.tooltipTourElement.hideOverlay(); | ||
} | ||
return; | ||
} | ||
this.guideMe.setTooltipContent(item.tooltip); | ||
this.guideMe.showTooltip(item.element); | ||
this.tooltipTourElement.setTooltipContent(item.tooltip); | ||
this.tooltipTourElement.showTooltip(item.element); | ||
if (!((_c = this.options) == null ? void 0 : _c.disableOverlay)) { | ||
this.guideMe.showOverlay(); | ||
this.tooltipTourElement.showOverlay(); | ||
} | ||
@@ -139,3 +139,3 @@ if (!((_d = this.options) == null ? void 0 : _d.disableFocusTrap)) { | ||
this.trap = focusTrap.createFocusTrap( | ||
[this.guideMe.tooltip, item.element], | ||
[this.tooltipTourElement.tooltip, item.element], | ||
{ | ||
@@ -154,3 +154,3 @@ fallbackFocus: item.element | ||
} | ||
const shadowRoot = this.guideMe.shadowRoot; | ||
const shadowRoot = this.tooltipTourElement.shadowRoot; | ||
const prevButton = shadowRoot == null ? void 0 : shadowRoot.querySelector("[slot=prev]"); | ||
@@ -170,3 +170,3 @@ const nextButton = shadowRoot == null ? void 0 : shadowRoot.querySelector("[slot=next]"); | ||
setHighlight(element) { | ||
element.classList.add("gm-highlight"); | ||
element.classList.add("tt-highlight"); | ||
element.style.zIndex = "10000"; | ||
@@ -178,4 +178,4 @@ if (element.style.position !== "relative" && element.style.position !== "absolute" && element.style.position !== "fixed" && element.style.position !== "sticky") { | ||
unsetHighlights() { | ||
document.querySelectorAll(".gm-highlight").forEach((item) => { | ||
item.classList.remove("gm-highlight"); | ||
document.querySelectorAll(".tt-highlight").forEach((item) => { | ||
item.classList.remove("tt-highlight"); | ||
const element = item; | ||
@@ -188,5 +188,5 @@ element.style.position = ""; | ||
// src/GuideMeElement.ts | ||
// src/TooltipTourElement.ts | ||
var import_core = require("@popperjs/core"); | ||
var GuideMeElement = class extends HTMLElement { | ||
var TooltipTourElement = class extends HTMLElement { | ||
constructor() { | ||
@@ -371,9 +371,9 @@ var _a, _b, _c; | ||
// src/index.ts | ||
var createGuide = (elements, options) => { | ||
return new GuideMe(elements, options); | ||
var createTooltipTour = (elements, options) => { | ||
return new TooltipTour(elements, options); | ||
}; | ||
customElements.define("guide-me-element", GuideMeElement); | ||
customElements.define("tooltip-tour-element", TooltipTourElement); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
createGuide | ||
createTooltipTour | ||
}); |
{ | ||
"name": "tooltip-tour", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A JavaScript library that guides users through a web page with a flying tooltip. The tooltip provides step-by-step information about each section of the page, moving smoothly to the next section for a seamless and informative user experience.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24403