Comparing version 1.1.5-next.0 to 1.1.6-next.0
// Generated by dts-bundle-generator v8.0.1 | ||
export type Side = "top" | "right" | "bottom" | "left" | "over"; | ||
export type Alignment = "start" | "center" | "end"; | ||
export type AllowedButtons = "next" | "previous" | "close"; | ||
export type Popover = { | ||
title?: string; | ||
description?: string; | ||
side?: Side; | ||
align?: Alignment; | ||
showButtons?: AllowedButtons[]; | ||
showProgress?: boolean; | ||
disableButtons?: AllowedButtons[]; | ||
popoverClass?: string; | ||
progressText?: string; | ||
doneBtnText?: string; | ||
nextBtnText?: string; | ||
prevBtnText?: string; | ||
onPopoverRendered?: (popover: PopoverDOM) => void; | ||
onNextClick?: (element: Element | undefined, step: DriveStep) => void; | ||
onPrevClick?: (element: Element | undefined, step: DriveStep) => void; | ||
onCloseClick?: (element: Element | undefined, step: DriveStep) => void; | ||
}; | ||
export type PopoverDOM = { | ||
wrapper: HTMLElement; | ||
arrow: HTMLElement; | ||
title: HTMLElement; | ||
description: HTMLElement; | ||
footer: HTMLElement; | ||
progress: HTMLElement; | ||
previousButton: HTMLElement; | ||
nextButton: HTMLElement; | ||
closeButton: HTMLElement; | ||
footerButtons: HTMLElement; | ||
}; | ||
declare function requireRefresh(): void; | ||
export type StageDefinition = { | ||
@@ -54,4 +20,6 @@ x: number; | ||
__activeStagePosition?: StageDefinition; | ||
__stageSvg?: SVGSVGElement; | ||
__overlaySvg?: SVGSVGElement; | ||
}; | ||
declare function getState(): State; | ||
declare function getState<K extends keyof State>(key: K): State[K]; | ||
export type DriverHook = (element: Element | undefined, step: DriveStep, opts: { | ||
@@ -90,5 +58,44 @@ config: Config; | ||
}; | ||
declare function configure(config?: Config): void; | ||
declare function getConfig(): Config; | ||
declare function getConfig<K extends keyof Config>(key: K): Config[K]; | ||
export type Side = "top" | "right" | "bottom" | "left" | "over"; | ||
export type Alignment = "start" | "center" | "end"; | ||
export type AllowedButtons = "next" | "previous" | "close"; | ||
export type Popover = { | ||
title?: string; | ||
description?: string; | ||
side?: Side; | ||
align?: Alignment; | ||
showButtons?: AllowedButtons[]; | ||
showProgress?: boolean; | ||
disableButtons?: AllowedButtons[]; | ||
popoverClass?: string; | ||
progressText?: string; | ||
doneBtnText?: string; | ||
nextBtnText?: string; | ||
prevBtnText?: string; | ||
onPopoverRendered?: (popover: PopoverDOM) => void; | ||
onNextClick?: DriverHook; | ||
onPrevClick?: DriverHook; | ||
onCloseClick?: DriverHook; | ||
}; | ||
export type PopoverDOM = { | ||
wrapper: HTMLElement; | ||
arrow: HTMLElement; | ||
title: HTMLElement; | ||
description: HTMLElement; | ||
footer: HTMLElement; | ||
progress: HTMLElement; | ||
previousButton: HTMLElement; | ||
nextButton: HTMLElement; | ||
closeButton: HTMLElement; | ||
footerButtons: HTMLElement; | ||
}; | ||
declare function requireRefresh(): void; | ||
export type DriveStep = { | ||
element?: string | Element; | ||
onDeselected?: (element: Element | undefined, step: DriveStep) => void; | ||
onHighlightStarted?: DriverHook; | ||
onHighlighted?: DriverHook; | ||
onDeselected?: DriverHook; | ||
popover?: Popover; | ||
@@ -100,2 +107,5 @@ }; | ||
drive: (stepIndex?: number) => void; | ||
setConfig: typeof configure; | ||
getConfig: typeof getConfig; | ||
getState: typeof getState; | ||
moveNext: () => void; | ||
@@ -102,0 +112,0 @@ movePrevious: () => void; |
@@ -1,2 +0,2 @@ | ||
this.driver=this.driver||{};this.driver.js=function(M){"use strict";let R={};function G(e={}){R={animate:!0,allowClose:!0,opacity:.7,smoothScroll:!1,showProgress:!1,stagePadding:10,stageRadius:5,popoverOffset:10,showButtons:["next","previous","close"],disableButtons:[],backdropColor:"#000",...e}}function d(e){return e?R[e]:R}function H(e,o,t,n){return(e/=n/2)<1?t/2*e*e+o:-t/2*(--e*(e-2)-1)+o}function A(e){if(!e||U(e))return;const o=d("smoothScroll");e.scrollIntoView({behavior:!o||J(e)?"auto":"smooth",inline:"center",block:"center"})}function J(e){if(!e||!e.parentElement)return;const o=e.parentElement;return o.scrollHeight>o.clientHeight}function U(e){const o=e.getBoundingClientRect();return o.top>=0&&o.left>=0&&o.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&o.right<=(window.innerWidth||document.documentElement.clientWidth)}let E={};function b(e,o){E[e]=o}function p(e){return e?E[e]:E}function ee(){E={}}let T={};function B(e,o){T[e]=o}function $(e){var o;(o=T[e])==null||o.call(T)}function te(){T={}}function oe(e,o,t,n){let l=p("__activeStagePosition");const r=l||t.getBoundingClientRect(),h=n.getBoundingClientRect(),v=H(e,r.x,h.x-r.x,o),i=H(e,r.y,h.y-r.y,o),s=H(e,r.width,h.width-r.width,o),a=H(e,r.height,h.height-r.height,o);l={x:v,y:i,width:s,height:a},_(l),b("__activeStagePosition",l)}function W(e){if(!e)return;const o=e.getBoundingClientRect(),t={x:o.x,y:o.y,width:o.width,height:o.height};b("__activeStagePosition",t),_(t)}function ne(){const e=p("__activeStagePosition"),o=p("__stageSvg");if(!e)return;if(!o){console.warn("No stage svg found.");return}const t=window.innerWidth,n=window.innerHeight;o.setAttribute("viewBox",`0 0 ${t} ${n}`)}function ie(e){const o=re(e);document.body.appendChild(o),z(o,t=>{t.target.tagName==="path"&&$("overlayClick")}),b("__stageSvg",o)}function _(e){const o=p("__stageSvg");if(!o){ie(e);return}const t=o.firstElementChild;if((t==null?void 0:t.tagName)!=="path")throw new Error("no path element found in stage svg");t.setAttribute("d",N(e))}function re(e){const o=window.innerWidth,t=window.innerHeight,n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("driver-stage","driver-stage-animated"),n.setAttribute("viewBox",`0 0 ${o} ${t}`),n.setAttribute("xmlSpace","preserve"),n.setAttribute("xmlnsXlink","http://www.w3.org/1999/xlink"),n.setAttribute("version","1.1"),n.setAttribute("preserveAspectRatio","xMinYMin slice"),n.style.fillRule="evenodd",n.style.clipRule="evenodd",n.style.strokeLinejoin="round",n.style.strokeMiterlimit="2",n.style.zIndex="10000",n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%";const l=document.createElementNS("http://www.w3.org/2000/svg","path");return l.setAttribute("d",N(e)),l.style.fill=d("backdropColor")||"rgb(0,0,0)",l.style.opacity=`${d("opacity")}`,l.style.pointerEvents="auto",l.style.cursor="auto",n.appendChild(l),n}function N(e){const o=window.innerWidth,t=window.innerHeight,n=d("stagePadding")||0,l=d("stageRadius")||0,r=e.width+n*2,h=e.height+n*2,v=Math.min(l,r/2,h/2),i=Math.floor(Math.max(v,0)),s=e.x-n+i,a=e.y-n,c=r-i*2,g=h-i*2;return`M${o},0L0,0L0,${t}L${o},${t}L${o},0Z | ||
M${s},${a} h${c} a${i},${i} 0 0 1 ${i},${i} v${g} a${i},${i} 0 0 1 -${i},${i} h-${c} a${i},${i} 0 0 1 -${i},-${i} v-${g} a${i},${i} 0 0 1 ${i},-${i} z`}function se(){const e=p("__stageSvg");e&&e.remove()}function ae(){const e=document.getElementById("driver-dummy-element");if(e)return e;let o=document.createElement("div");return o.id="driver-dummy-element",o.style.width="0",o.style.height="0",o.style.pointerEvents="none",o.style.opacity="0",o.style.position="fixed",o.style.top="50%",o.style.left="50%",document.body.appendChild(o),o}function I(e){const{element:o}=e;let t=typeof o=="string"?document.querySelector(o):o;t||(t=ae()),de(t,e)}function ce(){const e=p("activeElement"),o=p("activeStep");e&&(W(e),ne(),V(e,o))}function de(e,o){const n=Date.now(),l=p("activeStep"),r=p("activeElement")||e,h=!r||r===e,v=e.id==="driver-dummy-element",i=r.id==="driver-dummy-element",s=d("animate"),a=d("onHighlightStarted"),c=d("onHighlighted"),g=(l==null?void 0:l.onDeselected)||d("onDeselected"),m=d(),w=p();!h&&g&&g(i?void 0:r,l,{config:m,state:w}),a&&a(v?void 0:e,o,{config:m,state:w});const u=!h&&s;let f=!1;ve();const L=()=>{if(p("__transitionCallback")!==L)return;const S=Date.now()-n,y=400-S<=400/2;o.popover&&y&&!f&&u&&(O(e,o),f=!0),d("animate")&&S<400?oe(S,400,r,e):(W(e),c&&c(v?void 0:e,o,{config:d(),state:p()}),b("__transitionCallback",void 0),b("previousStep",l),b("previousElement",r),b("activeStep",o),b("activeElement",e)),window.requestAnimationFrame(L)};b("__transitionCallback",L),window.requestAnimationFrame(L),A(e),!u&&o.popover&&O(e,o),r.classList.remove("driver-active-element"),e.classList.add("driver-active-element")}function le(){var e;(e=document.getElementById("driver-dummy-element"))==null||e.remove(),document.querySelectorAll(".driver-active-element").forEach(o=>{o.classList.remove("driver-active-element")})}function k(){const e=p("__resizeTimeout");e&&window.cancelAnimationFrame(e),b("__resizeTimeout",window.requestAnimationFrame(ce))}function pe(e){d("allowKeyboardControl");e.key==="Escape"?$("escapePress"):e.key==="ArrowRight"?$("arrowRightPress"):e.key==="ArrowLeft"&&$("arrowLeftPress")}function z(e,o,t){const n=(r,h)=>{const v=r.target;e.contains(v)&&((!t||t(v))&&r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),h==null||h(r))};document.addEventListener("pointerdown",n,!0),document.addEventListener("mousedown",n,!0),document.addEventListener("pointerup",n,!0),document.addEventListener("mouseup",n,!0),document.addEventListener("click",r=>{n(r,o)},!0)}function ue(){window.addEventListener("keyup",pe,!1),window.addEventListener("resize",k),window.addEventListener("scroll",k)}function he(){window.removeEventListener("resize",k),window.removeEventListener("scroll",k)}function ve(){const e=p("popover");e&&(e.wrapper.style.display="none")}function O(e,o){var S,P;let t=p("popover");t&&document.body.removeChild(t.wrapper),t=ge(),document.body.appendChild(t.wrapper);const{title:n,description:l,showButtons:r,disableButtons:h,showProgress:v,nextBtnText:i=d("nextBtnText")||"Next →",prevBtnText:s=d("prevBtnText")||"← Previous",progressText:a=d("progressText")||"{current} of {total}"}=o.popover||{};t.nextButton.innerHTML=i,t.previousButton.innerHTML=s,t.progress.innerHTML=a,n?(t.title.innerText=n,t.title.style.display="block"):t.title.style.display="none",l?(t.description.innerHTML=l,t.description.style.display="block"):t.description.style.display="none";const c=r||d("showButtons"),g=v||d("showProgress")||!1,m=(c==null?void 0:c.includes("next"))||(c==null?void 0:c.includes("previous"))||g;t.closeButton.style.display=c.includes("close")?"block":"none",m?(t.footer.style.display="flex",t.progress.style.display=g?"block":"none",t.nextButton.style.display=c.includes("next")?"block":"none",t.previousButton.style.display=c.includes("previous")?"block":"none"):t.footer.style.display="none";const w=h||d("disableButtons")||[];w!=null&&w.includes("next")&&t.nextButton.classList.add("driver-popover-btn-disabled"),w!=null&&w.includes("previous")&&t.previousButton.classList.add("driver-popover-btn-disabled"),w!=null&&w.includes("close")&&t.closeButton.classList.add("driver-popover-btn-disabled");const u=t.wrapper;u.style.display="block",u.style.left="",u.style.top="",u.style.bottom="",u.style.right="";const f=t.arrow;f.className="driver-popover-arrow";const L=((S=o.popover)==null?void 0:S.popoverClass)||d("popoverClass")||"";u.className=`driver-popover ${L}`.trim(),z(t.wrapper,y=>{var K,Q,Z;const x=y.target,X=((K=o.popover)==null?void 0:K.onNextClick)||d("onNextClick"),Y=((Q=o.popover)==null?void 0:Q.onPrevClick)||d("onPrevClick"),j=((Z=o.popover)==null?void 0:Z.onCloseClick)||d("onCloseClick");if(x.classList.contains("driver-popover-next-btn"))return X?X(e,o,{config:d(),state:p()}):$("nextClick");if(x.classList.contains("driver-popover-prev-btn"))return Y?Y(e,o,{config:d(),state:p()}):$("prevClick");if(x.classList.contains("driver-popover-close-btn"))return j?j(e,o,{config:d(),state:p()}):$("closeClick")},y=>!(t!=null&&t.description.contains(y))&&!(t!=null&&t.title.contains(y))),b("popover",t),V(e,o),A(u);const C=((P=o.popover)==null?void 0:P.onPopoverRendered)||d("onPopoverRendered");C&&C(t)}function D(){const e=p("popover");if(!(e!=null&&e.wrapper))return;const o=e.wrapper.getBoundingClientRect(),t=d("stagePadding")||0,n=d("popoverOffset")||0;return{width:o.width+t+n,height:o.height+t+n,realWidth:o.width,realHeight:o.height}}function F(e,o){const{elementDimensions:t,popoverDimensions:n,popoverPadding:l,popoverArrowDimensions:r}=o;return e==="start"?Math.max(Math.min(t.top-l,window.innerHeight-n.realHeight-r.width),r.width):e==="end"?Math.max(Math.min(t.top-(n==null?void 0:n.realHeight)+t.height+l,window.innerHeight-(n==null?void 0:n.realHeight)-r.width),r.width):e==="center"?Math.max(Math.min(t.top+t.height/2-(n==null?void 0:n.realHeight)/2,window.innerHeight-(n==null?void 0:n.realHeight)-r.width),r.width):0}function q(e,o){const{elementDimensions:t,popoverDimensions:n,popoverPadding:l,popoverArrowDimensions:r}=o;return e==="start"?Math.max(Math.min(t.left-l,window.innerWidth-n.realWidth-r.width),r.width):e==="end"?Math.max(Math.min(t.left-(n==null?void 0:n.realWidth)+t.width+l,window.innerWidth-(n==null?void 0:n.realWidth)-r.width),r.width):e==="center"?Math.max(Math.min(t.left+t.width/2-(n==null?void 0:n.realWidth)/2,window.innerWidth-(n==null?void 0:n.realWidth)-r.width),r.width):0}function V(e,o){const t=p("popover");if(!t)return;const{align:n="start",side:l="left"}=(o==null?void 0:o.popover)||{},r=n,h=e.id==="driver-dummy-element"?"over":l,v=d("stagePadding")||0,i=D(),s=t.arrow.getBoundingClientRect(),a=e.getBoundingClientRect(),c=a.top-i.height;let g=c>=0;const m=window.innerHeight-(a.bottom+i.height);let w=m>=0;const u=a.left-i.width;let f=u>=0;const L=window.innerWidth-(a.right+i.width);let C=L>=0;const S=!g&&!w&&!f&&!C;let P=h;if(h==="top"&&g?C=f=w=!1:h==="bottom"&&w?C=f=g=!1:h==="left"&&f?C=g=w=!1:h==="right"&&C&&(f=g=w=!1),h==="over"){const y=window.innerWidth/2-i.realWidth/2,x=window.innerHeight/2-i.realHeight/2;t.wrapper.style.left=`${y}px`,t.wrapper.style.right="auto",t.wrapper.style.top=`${x}px`,t.wrapper.style.bottom="auto"}else if(S){const y=window.innerWidth/2-(i==null?void 0:i.realWidth)/2,x=10;t.wrapper.style.left=`${y}px`,t.wrapper.style.right="auto",t.wrapper.style.bottom=`${x}px`,t.wrapper.style.top="auto"}else if(f){const y=Math.min(u,window.innerWidth-(i==null?void 0:i.realWidth)-s.width),x=F(r,{elementDimensions:a,popoverDimensions:i,popoverPadding:v,popoverArrowDimensions:s});t.wrapper.style.left=`${y}px`,t.wrapper.style.top=`${x}px`,t.wrapper.style.bottom="auto",t.wrapper.style.right="auto",P="left"}else if(C){const y=Math.min(L,window.innerWidth-(i==null?void 0:i.realWidth)-s.width),x=F(r,{elementDimensions:a,popoverDimensions:i,popoverPadding:v,popoverArrowDimensions:s});t.wrapper.style.right=`${y}px`,t.wrapper.style.top=`${x}px`,t.wrapper.style.bottom="auto",t.wrapper.style.left="auto",P="right"}else if(g){const y=Math.min(c,window.innerHeight-i.realHeight-s.width);let x=q(r,{elementDimensions:a,popoverDimensions:i,popoverPadding:v,popoverArrowDimensions:s});t.wrapper.style.top=`${y}px`,t.wrapper.style.left=`${x}px`,t.wrapper.style.bottom="auto",t.wrapper.style.right="auto",P="top"}else if(w){const y=Math.min(m,window.innerHeight-(i==null?void 0:i.realHeight)-s.width);let x=q(r,{elementDimensions:a,popoverDimensions:i,popoverPadding:v,popoverArrowDimensions:s});t.wrapper.style.left=`${x}px`,t.wrapper.style.bottom=`${y}px`,t.wrapper.style.top="auto",t.wrapper.style.right="auto",P="bottom"}S?t.arrow.classList.add("driver-popover-arrow-none"):fe(r,P,e)}function fe(e,o,t){const n=p("popover");if(!n)return;const l=t.getBoundingClientRect(),r=D(),h=n.arrow,v=r.width,i=window.innerWidth,s=l.width,a=l.left,c=r.height,g=window.innerHeight,m=l.top,w=l.height;h.className="driver-popover-arrow";let u=o,f=e;o==="top"?(a+s<=0?(u="right",f="end"):a+s-v<=0&&(u="top",f="start"),a>=i?(u="left",f="end"):a+v>=i&&(u="top",f="end")):o==="bottom"?(a+s<=0?(u="right",f="start"):a+s-v<=0&&(u="bottom",f="start"),a>=i?(u="left",f="start"):a+v>=i&&(u="bottom",f="end")):o==="left"?(m+w<=0?(u="bottom",f="end"):m+w-c<=0&&(u="left",f="start"),m>=g?(u="top",f="end"):m+c>=g&&(u="left",f="end")):o==="right"&&(m+w<=0?(u="bottom",f="start"):m+w-c<=0&&(u="right",f="start"),m>=g?(u="top",f="start"):m+c>=g&&(u="right",f="end")),u?(h.classList.add(`driver-popover-arrow-side-${u}`),h.classList.add(`driver-popover-arrow-align-${f}`)):h.classList.add("driver-popover-arrow-none")}function ge(){const e=document.createElement("div");e.classList.add("driver-popover");const o=document.createElement("div");o.classList.add("driver-popover-arrow");const t=document.createElement("div");t.classList.add("driver-popover-title"),t.style.display="none",t.innerText="Popover Title";const n=document.createElement("div");n.classList.add("driver-popover-description"),n.style.display="none",n.innerText="Popover description is here";const l=document.createElement("button");l.classList.add("driver-popover-close-btn"),l.innerHTML="×";const r=document.createElement("div");r.classList.add("driver-popover-footer");const h=document.createElement("span");h.classList.add("driver-popover-progress-text"),h.innerText="";const v=document.createElement("span");v.classList.add("driver-popover-navigation-btns");const i=document.createElement("button");i.classList.add("driver-popover-prev-btn"),i.innerHTML="← Previous";const s=document.createElement("button");return s.classList.add("driver-popover-next-btn"),s.innerHTML="Next →",v.appendChild(i),v.appendChild(s),r.appendChild(h),r.appendChild(v),e.appendChild(l),e.appendChild(o),e.appendChild(t),e.appendChild(n),e.appendChild(r),{wrapper:e,arrow:o,title:t,description:n,footer:r,previousButton:i,nextButton:s,closeButton:l,footerButtons:v,progress:h}}function we(){var o;const e=p("popover");e&&((o=e.wrapper.parentElement)==null||o.removeChild(e.wrapper))}const ye="";function me(e={}){G(e);function o(){d("allowClose")&&i()}function t(){const s=p("activeIndex"),a=d("steps")||[];if(typeof s>"u")return;const c=s+1;a[c]?v(c):i()}function n(){const s=p("activeIndex"),a=d("steps")||[];if(typeof s>"u")return;const c=s-1;a[c]?v(c):i()}function l(){const s=d("steps")||[],a=p("activeIndex");if(typeof a>"u")return;const c=a-1;s[c]&&v(c)}function r(){var m;const s=p("activeIndex"),a=p("activeStep"),c=p("activeElement");if(typeof s>"u"||typeof a>"u")return;const g=((m=a.popover)==null?void 0:m.onNextClick)||d("onNextClick");if(g)return g(c,a,{config:d(),state:p()});t()}function h(){p("isInitialized")||(b("isInitialized",!0),document.body.classList.add("driver-active",d("animate")?"driver-fade":"driver-simple"),ue(),B("overlayClick",o),B("escapePress",o),B("arrowLeftPress",l),B("arrowRightPress",r))}function v(s=0){var S,P,y,x;const a=d("steps");if(!a){console.error("No steps to drive through"),i();return}a[s]||(console.warn(`Step not found at index: ${s}`),i()),b("activeIndex",s);const c=a[s],g=a[s+1],m=a[s-1],w=((S=c.popover)==null?void 0:S.doneBtnText)||d("doneBtnText")||"Done",u=d("allowClose"),f=typeof((P=c.popover)==null?void 0:P.showProgress)<"u"?(y=c.popover)==null?void 0:y.showProgress:d("showProgress"),C=(((x=c.popover)==null?void 0:x.progressText)||d("progressText")||"{{current}} of {{total}}").replace("{{current}}",`${s+1}`).replace("{{total}}",`${a.length}`);console.log(f),I({...c,popover:{showButtons:["next","previous",...u?["close"]:[]],nextBtnText:g?void 0:w,disableButtons:[...m?[]:["previous"]],showProgress:f,progressText:C,onNextClick:()=>{g?v(s+1):i()},onPrevClick:()=>{v(s-1)},onCloseClick:()=>{i()},...(c==null?void 0:c.popover)||{}}})}function i(s=!0){const a=p("activeElement"),c=p("activeStep"),g=d("onDestroyStarted");if(s&&g){g(a,c,{config:d(),state:p()});return}const m=(c==null?void 0:c.onDeselected)||d("onDeselected"),w=d("onDestroyed");if(document.body.classList.remove("driver-active","driver-fade","driver-simple"),he(),we(),le(),se(),te(),ee(),a&&c){const u=a.id==="driver-dummy-element";m&&m(u?void 0:a,c,{config:d(),state:p()}),w&&w(u?void 0:a,c,{config:d(),state:p()})}}return{isActive:()=>p("isInitialized")||!1,refresh:k,drive:(s=0)=>{h(),v(s)},moveNext:t,movePrevious:n,hasNextStep:()=>{const s=d("steps")||[],a=p("activeIndex");return a!==void 0&&s[a+1]},hasPreviousStep:()=>{const s=d("steps")||[],a=p("activeIndex");return a!==void 0&&s[a-1]},highlight:s=>{h(),I({...s,popover:s.popover?{showButtons:[],showProgress:!1,progressText:"",...s.popover}:void 0})},destroy:()=>{i(!1)}}}return M.driver=me,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"}),M}({}); | ||
this.driver=this.driver||{};this.driver.js=function(_){"use strict";let I={};function N(e={}){I={animate:!0,allowClose:!0,opacity:.7,smoothScroll:!1,showProgress:!1,stagePadding:10,stageRadius:5,popoverOffset:10,showButtons:["next","previous","close"],disableButtons:[],backdropColor:"#000",...e}}function c(e){return e?I[e]:I}function A(e,t,o,n){return(e/=n/2)<1?o/2*e*e+t:-o/2*(--e*(e-2)-1)+t}function O(e){if(!e||U(e))return;const t=c("smoothScroll");e.scrollIntoView({behavior:!t||J(e)?"auto":"smooth",inline:"center",block:"center"})}function J(e){if(!e||!e.parentElement)return;const t=e.parentElement;return t.scrollHeight>t.clientHeight}function U(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}let M={};function C(e,t){M[e]=t}function d(e){return e?M[e]:M}function ee(){M={}}let k={};function R(e,t){k[e]=t}function T(e){var t;(t=k[e])==null||t.call(k)}function te(){k={}}function oe(e,t,o,n){let p=d("__activeStagePosition");const r=p||o.getBoundingClientRect(),v=n.getBoundingClientRect(),f=A(e,r.x,v.x-r.x,t),i=A(e,r.y,v.y-r.y,t),a=A(e,r.width,v.width-r.width,t),s=A(e,r.height,v.height-r.height,t);p={x:f,y:i,width:a,height:s},D(p),C("__activeStagePosition",p)}function z(e){if(!e)return;const t=e.getBoundingClientRect(),o={x:t.x,y:t.y,width:t.width,height:t.height};C("__activeStagePosition",o),D(o)}function ne(){const e=d("__activeStagePosition"),t=d("__overlaySvg");if(!e)return;if(!t){console.warn("No stage svg found.");return}const o=window.innerWidth,n=window.innerHeight;t.setAttribute("viewBox",`0 0 ${o} ${n}`)}function ie(e){const t=re(e);document.body.appendChild(t),V(t,o=>{o.target.tagName==="path"&&T("overlayClick")}),C("__overlaySvg",t)}function D(e){const t=d("__overlaySvg");if(!t){ie(e);return}const o=t.firstElementChild;if((o==null?void 0:o.tagName)!=="path")throw new Error("no path element found in stage svg");o.setAttribute("d",F(e))}function re(e){const t=window.innerWidth,o=window.innerHeight,n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.classList.add("driver-overlay","driver-overlay-animated"),n.setAttribute("viewBox",`0 0 ${t} ${o}`),n.setAttribute("xmlSpace","preserve"),n.setAttribute("xmlnsXlink","http://www.w3.org/1999/xlink"),n.setAttribute("version","1.1"),n.setAttribute("preserveAspectRatio","xMinYMin slice"),n.style.fillRule="evenodd",n.style.clipRule="evenodd",n.style.strokeLinejoin="round",n.style.strokeMiterlimit="2",n.style.zIndex="10000",n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%";const p=document.createElementNS("http://www.w3.org/2000/svg","path");return p.setAttribute("d",F(e)),p.style.fill=c("backdropColor")||"rgb(0,0,0)",p.style.opacity=`${c("opacity")}`,p.style.pointerEvents="auto",p.style.cursor="auto",n.appendChild(p),n}function F(e){const t=window.innerWidth,o=window.innerHeight,n=c("stagePadding")||0,p=c("stageRadius")||0,r=e.width+n*2,v=e.height+n*2,f=Math.min(p,r/2,v/2),i=Math.floor(Math.max(f,0)),a=e.x-n+i,s=e.y-n,l=r-i*2,w=v-i*2;return`M${t},0L0,0L0,${o}L${t},${o}L${t},0Z | ||
M${a},${s} h${l} a${i},${i} 0 0 1 ${i},${i} v${w} a${i},${i} 0 0 1 -${i},${i} h-${l} a${i},${i} 0 0 1 -${i},-${i} v-${w} a${i},${i} 0 0 1 ${i},-${i} z`}function se(){const e=d("__overlaySvg");e&&e.remove()}function ae(){const e=document.getElementById("driver-dummy-element");if(e)return e;let t=document.createElement("div");return t.id="driver-dummy-element",t.style.width="0",t.style.height="0",t.style.pointerEvents="none",t.style.opacity="0",t.style.position="fixed",t.style.top="50%",t.style.left="50%",document.body.appendChild(t),t}function q(e){const{element:t}=e;let o=typeof t=="string"?document.querySelector(t):t;o||(o=ae()),ce(o,e)}function le(){const e=d("activeElement"),t=d("activeStep");e&&(z(e),ne(),Q(e,t))}function ce(e,t){const n=Date.now(),p=d("activeStep"),r=d("activeElement")||e,v=!r||r===e,f=e.id==="driver-dummy-element",i=r.id==="driver-dummy-element",a=c("animate"),s=t.onHighlightStarted||c("onHighlightStarted"),l=(t==null?void 0:t.onHighlighted)||c("onHighlighted"),w=(p==null?void 0:p.onDeselected)||c("onDeselected"),m=c(),h=d();!v&&w&&w(i?void 0:r,p,{config:m,state:h}),s&&s(f?void 0:e,t,{config:m,state:h});const u=!v&&a;let g=!1;he();const L=()=>{if(d("__transitionCallback")!==L)return;const b=Date.now()-n,y=400-b<=400/2;t.popover&&y&&!g&&u&&(X(e,t),g=!0),c("animate")&&b<400?oe(b,400,r,e):(z(e),l&&l(f?void 0:e,t,{config:c(),state:d()}),C("__transitionCallback",void 0),C("previousStep",p),C("previousElement",r),C("activeStep",t),C("activeElement",e)),window.requestAnimationFrame(L)};C("__transitionCallback",L),window.requestAnimationFrame(L),O(e),!u&&t.popover&&X(e,t),r.classList.remove("driver-active-element"),e.classList.add("driver-active-element")}function de(){var e;(e=document.getElementById("driver-dummy-element"))==null||e.remove(),document.querySelectorAll(".driver-active-element").forEach(t=>{t.classList.remove("driver-active-element")})}function $(){const e=d("__resizeTimeout");e&&window.cancelAnimationFrame(e),C("__resizeTimeout",window.requestAnimationFrame(le))}function pe(e){c("allowKeyboardControl");e.key==="Escape"?T("escapePress"):e.key==="ArrowRight"?T("arrowRightPress"):e.key==="ArrowLeft"&&T("arrowLeftPress")}function V(e,t,o){const n=(r,v)=>{const f=r.target;e.contains(f)&&((!o||o(f))&&r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),v==null||v(r))};document.addEventListener("pointerdown",n,!0),document.addEventListener("mousedown",n,!0),document.addEventListener("pointerup",n,!0),document.addEventListener("mouseup",n,!0),document.addEventListener("click",r=>{n(r,t)},!0)}function ue(){window.addEventListener("keyup",pe,!1),window.addEventListener("resize",$),window.addEventListener("scroll",$)}function ve(){window.removeEventListener("resize",$),window.removeEventListener("scroll",$)}function he(){const e=d("popover");e&&(e.wrapper.style.display="none")}function X(e,t){var b,S;let o=d("popover");o&&document.body.removeChild(o.wrapper),o=ge(),document.body.appendChild(o.wrapper);const{title:n,description:p,showButtons:r,disableButtons:v,showProgress:f,nextBtnText:i=c("nextBtnText")||"Next →",prevBtnText:a=c("prevBtnText")||"← Previous",progressText:s=c("progressText")||"{current} of {total}"}=t.popover||{};o.nextButton.innerHTML=i,o.previousButton.innerHTML=a,o.progress.innerHTML=s,n?(o.title.innerText=n,o.title.style.display="block"):o.title.style.display="none",p?(o.description.innerHTML=p,o.description.style.display="block"):o.description.style.display="none";const l=r||c("showButtons"),w=f||c("showProgress")||!1,m=(l==null?void 0:l.includes("next"))||(l==null?void 0:l.includes("previous"))||w;o.closeButton.style.display=l.includes("close")?"block":"none",m?(o.footer.style.display="flex",o.progress.style.display=w?"block":"none",o.nextButton.style.display=l.includes("next")?"block":"none",o.previousButton.style.display=l.includes("previous")?"block":"none"):o.footer.style.display="none";const h=v||c("disableButtons")||[];h!=null&&h.includes("next")&&o.nextButton.classList.add("driver-popover-btn-disabled"),h!=null&&h.includes("previous")&&o.previousButton.classList.add("driver-popover-btn-disabled"),h!=null&&h.includes("close")&&o.closeButton.classList.add("driver-popover-btn-disabled");const u=o.wrapper;u.style.display="block",u.style.left="",u.style.top="",u.style.bottom="",u.style.right="";const g=o.arrow;g.className="driver-popover-arrow";const L=((b=t.popover)==null?void 0:b.popoverClass)||c("popoverClass")||"";u.className=`driver-popover ${L}`.trim(),V(o.wrapper,y=>{var W,Z,G;const x=y.target,H=((W=t.popover)==null?void 0:W.onNextClick)||c("onNextClick"),E=((Z=t.popover)==null?void 0:Z.onPrevClick)||c("onPrevClick"),B=((G=t.popover)==null?void 0:G.onCloseClick)||c("onCloseClick");if(x.classList.contains("driver-popover-next-btn"))return H?H(e,t,{config:c(),state:d()}):T("nextClick");if(x.classList.contains("driver-popover-prev-btn"))return E?E(e,t,{config:c(),state:d()}):T("prevClick");if(x.classList.contains("driver-popover-close-btn"))return B?B(e,t,{config:c(),state:d()}):T("closeClick")},y=>!(o!=null&&o.description.contains(y))&&!(o!=null&&o.title.contains(y))),C("popover",o),Q(e,t),O(u);const P=((S=t.popover)==null?void 0:S.onPopoverRendered)||c("onPopoverRendered");P&&P(o)}function Y(){const e=d("popover");if(!(e!=null&&e.wrapper))return;const t=e.wrapper.getBoundingClientRect(),o=c("stagePadding")||0,n=c("popoverOffset")||0;return{width:t.width+o+n,height:t.height+o+n,realWidth:t.width,realHeight:t.height}}function j(e,t){const{elementDimensions:o,popoverDimensions:n,popoverPadding:p,popoverArrowDimensions:r}=t;return e==="start"?Math.max(Math.min(o.top-p,window.innerHeight-n.realHeight-r.width),r.width):e==="end"?Math.max(Math.min(o.top-(n==null?void 0:n.realHeight)+o.height+p,window.innerHeight-(n==null?void 0:n.realHeight)-r.width),r.width):e==="center"?Math.max(Math.min(o.top+o.height/2-(n==null?void 0:n.realHeight)/2,window.innerHeight-(n==null?void 0:n.realHeight)-r.width),r.width):0}function K(e,t){const{elementDimensions:o,popoverDimensions:n,popoverPadding:p,popoverArrowDimensions:r}=t;return e==="start"?Math.max(Math.min(o.left-p,window.innerWidth-n.realWidth-r.width),r.width):e==="end"?Math.max(Math.min(o.left-(n==null?void 0:n.realWidth)+o.width+p,window.innerWidth-(n==null?void 0:n.realWidth)-r.width),r.width):e==="center"?Math.max(Math.min(o.left+o.width/2-(n==null?void 0:n.realWidth)/2,window.innerWidth-(n==null?void 0:n.realWidth)-r.width),r.width):0}function Q(e,t){const o=d("popover");if(!o)return;const{align:n="start",side:p="left"}=(t==null?void 0:t.popover)||{},r=n,v=e.id==="driver-dummy-element"?"over":p,f=c("stagePadding")||0,i=Y(),a=o.arrow.getBoundingClientRect(),s=e.getBoundingClientRect(),l=s.top-i.height;let w=l>=0;const m=window.innerHeight-(s.bottom+i.height);let h=m>=0;const u=s.left-i.width;let g=u>=0;const L=window.innerWidth-(s.right+i.width);let P=L>=0;const b=!w&&!h&&!g&&!P;let S=v;if(v==="top"&&w?P=g=h=!1:v==="bottom"&&h?P=g=w=!1:v==="left"&&g?P=w=h=!1:v==="right"&&P&&(g=w=h=!1),v==="over"){const y=window.innerWidth/2-i.realWidth/2,x=window.innerHeight/2-i.realHeight/2;o.wrapper.style.left=`${y}px`,o.wrapper.style.right="auto",o.wrapper.style.top=`${x}px`,o.wrapper.style.bottom="auto"}else if(b){const y=window.innerWidth/2-(i==null?void 0:i.realWidth)/2,x=10;o.wrapper.style.left=`${y}px`,o.wrapper.style.right="auto",o.wrapper.style.bottom=`${x}px`,o.wrapper.style.top="auto"}else if(g){const y=Math.min(u,window.innerWidth-(i==null?void 0:i.realWidth)-a.width),x=j(r,{elementDimensions:s,popoverDimensions:i,popoverPadding:f,popoverArrowDimensions:a});o.wrapper.style.left=`${y}px`,o.wrapper.style.top=`${x}px`,o.wrapper.style.bottom="auto",o.wrapper.style.right="auto",S="left"}else if(P){const y=Math.min(L,window.innerWidth-(i==null?void 0:i.realWidth)-a.width),x=j(r,{elementDimensions:s,popoverDimensions:i,popoverPadding:f,popoverArrowDimensions:a});o.wrapper.style.right=`${y}px`,o.wrapper.style.top=`${x}px`,o.wrapper.style.bottom="auto",o.wrapper.style.left="auto",S="right"}else if(w){const y=Math.min(l,window.innerHeight-i.realHeight-a.width);let x=K(r,{elementDimensions:s,popoverDimensions:i,popoverPadding:f,popoverArrowDimensions:a});o.wrapper.style.top=`${y}px`,o.wrapper.style.left=`${x}px`,o.wrapper.style.bottom="auto",o.wrapper.style.right="auto",S="top"}else if(h){const y=Math.min(m,window.innerHeight-(i==null?void 0:i.realHeight)-a.width);let x=K(r,{elementDimensions:s,popoverDimensions:i,popoverPadding:f,popoverArrowDimensions:a});o.wrapper.style.left=`${x}px`,o.wrapper.style.bottom=`${y}px`,o.wrapper.style.top="auto",o.wrapper.style.right="auto",S="bottom"}b?o.arrow.classList.add("driver-popover-arrow-none"):fe(r,S,e)}function fe(e,t,o){const n=d("popover");if(!n)return;const p=o.getBoundingClientRect(),r=Y(),v=n.arrow,f=r.width,i=window.innerWidth,a=p.width,s=p.left,l=r.height,w=window.innerHeight,m=p.top,h=p.height;v.className="driver-popover-arrow";let u=t,g=e;t==="top"?(s+a<=0?(u="right",g="end"):s+a-f<=0&&(u="top",g="start"),s>=i?(u="left",g="end"):s+f>=i&&(u="top",g="end")):t==="bottom"?(s+a<=0?(u="right",g="start"):s+a-f<=0&&(u="bottom",g="start"),s>=i?(u="left",g="start"):s+f>=i&&(u="bottom",g="end")):t==="left"?(m+h<=0?(u="bottom",g="end"):m+h-l<=0&&(u="left",g="start"),m>=w?(u="top",g="end"):m+l>=w&&(u="left",g="end")):t==="right"&&(m+h<=0?(u="bottom",g="start"):m+h-l<=0&&(u="right",g="start"),m>=w?(u="top",g="start"):m+l>=w&&(u="right",g="end")),u?(v.classList.add(`driver-popover-arrow-side-${u}`),v.classList.add(`driver-popover-arrow-align-${g}`)):v.classList.add("driver-popover-arrow-none")}function ge(){const e=document.createElement("div");e.classList.add("driver-popover");const t=document.createElement("div");t.classList.add("driver-popover-arrow");const o=document.createElement("div");o.classList.add("driver-popover-title"),o.style.display="none",o.innerText="Popover Title";const n=document.createElement("div");n.classList.add("driver-popover-description"),n.style.display="none",n.innerText="Popover description is here";const p=document.createElement("button");p.classList.add("driver-popover-close-btn"),p.innerHTML="×";const r=document.createElement("div");r.classList.add("driver-popover-footer");const v=document.createElement("span");v.classList.add("driver-popover-progress-text"),v.innerText="";const f=document.createElement("span");f.classList.add("driver-popover-navigation-btns");const i=document.createElement("button");i.classList.add("driver-popover-prev-btn"),i.innerHTML="← Previous";const a=document.createElement("button");return a.classList.add("driver-popover-next-btn"),a.innerHTML="Next →",f.appendChild(i),f.appendChild(a),r.appendChild(v),r.appendChild(f),e.appendChild(p),e.appendChild(t),e.appendChild(o),e.appendChild(n),e.appendChild(r),{wrapper:e,arrow:t,title:o,description:n,footer:r,previousButton:i,nextButton:a,closeButton:p,footerButtons:f,progress:v}}function we(){var t;const e=d("popover");e&&((t=e.wrapper.parentElement)==null||t.removeChild(e.wrapper))}const ye="";function me(e={}){N(e);function t(){c("allowClose")&&i()}function o(){const a=d("activeIndex"),s=c("steps")||[];if(typeof a>"u")return;const l=a+1;s[l]?f(l):i()}function n(){const a=d("activeIndex"),s=c("steps")||[];if(typeof a>"u")return;const l=a-1;s[l]?f(l):i()}function p(){var u;if(d("__transitionCallback"))return;const s=d("activeIndex"),l=d("activeStep"),w=d("activeElement");if(typeof s>"u"||typeof l>"u"||typeof d("activeIndex")>"u")return;const h=((u=l.popover)==null?void 0:u.onPrevClick)||c("onPrevClick");if(h)return h(w,l,{config:c(),state:d()});n()}function r(){var h;if(d("__transitionCallback"))return;const s=d("activeIndex"),l=d("activeStep"),w=d("activeElement");if(typeof s>"u"||typeof l>"u")return;const m=((h=l.popover)==null?void 0:h.onNextClick)||c("onNextClick");if(m)return m(w,l,{config:c(),state:d()});o()}function v(){d("isInitialized")||(C("isInitialized",!0),document.body.classList.add("driver-active",c("animate")?"driver-fade":"driver-simple"),ue(),R("overlayClick",t),R("escapePress",t),R("arrowLeftPress",p),R("arrowRightPress",r))}function f(a=0){var y,x,H,E,B;const s=c("steps");if(!s){console.error("No steps to drive through"),i();return}if(!s[a]){i();return}C("activeIndex",a);const l=s[a],w=s[a+1],m=s[a-1],h=((y=l.popover)==null?void 0:y.doneBtnText)||c("doneBtnText")||"Done",u=c("allowClose"),g=typeof((x=l.popover)==null?void 0:x.showProgress)<"u"?(H=l.popover)==null?void 0:H.showProgress:c("showProgress"),P=(((E=l.popover)==null?void 0:E.progressText)||c("progressText")||"{{current}} of {{total}}").replace("{{current}}",`${a+1}`).replace("{{total}}",`${s.length}`),b=((B=l.popover)==null?void 0:B.showButtons)||c("showButtons"),S=["next","previous",...u?["close"]:[]].filter(W=>!(b!=null&&b.length)||b.includes(W));q({...l,popover:{showButtons:S,nextBtnText:w?void 0:h,disableButtons:[...m?[]:["previous"]],showProgress:g,progressText:P,onNextClick:()=>{w?f(a+1):i()},onPrevClick:()=>{f(a-1)},onCloseClick:()=>{i()},...(l==null?void 0:l.popover)||{}}})}function i(a=!0){const s=d("activeElement"),l=d("activeStep"),w=c("onDestroyStarted");if(a&&w){const u=!s||(s==null?void 0:s.id)==="driver-dummy-element";w(u?void 0:s,l,{config:c(),state:d()});return}const m=(l==null?void 0:l.onDeselected)||c("onDeselected"),h=c("onDestroyed");if(document.body.classList.remove("driver-active","driver-fade","driver-simple"),ve(),we(),de(),se(),te(),ee(),s&&l){const u=s.id==="driver-dummy-element";m&&m(u?void 0:s,l,{config:c(),state:d()}),h&&h(u?void 0:s,l,{config:c(),state:d()})}}return{isActive:()=>d("isInitialized")||!1,refresh:$,drive:(a=0)=>{v(),f(a)},setConfig:N,getConfig:c,getState:d,moveNext:o,movePrevious:n,hasNextStep:()=>{const a=c("steps")||[],s=d("activeIndex");return s!==void 0&&a[s+1]},hasPreviousStep:()=>{const a=c("steps")||[],s=d("activeIndex");return s!==void 0&&a[s-1]},highlight:a=>{v(),q({...a,popover:a.popover?{showButtons:[],showProgress:!1,progressText:"",...a.popover}:void 0})},destroy:()=>{i(!1)}}}return _.driver=me,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),_}({}); |
{ | ||
"name": "driver.js", | ||
"private": false, | ||
"version": "1.1.5-next.0", | ||
"version": "1.1.6-next.0", | ||
"main": "./dist/driver.js.cjs", | ||
@@ -6,0 +6,0 @@ "module": "./dist/driver.js.mjs", |
Sorry, the diff of this file is not supported yet
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
79899
848