New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

shepherd.js

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shepherd.js - npm Package Compare versions

Comparing version 2.0.0-beta.26 to 2.0.0-beta.27

2

babel.config.js

@@ -6,3 +6,3 @@ module.exports = function(api) {

presets: [
['@babel/preset-env', { targets: { 'node': 6 } }]
['@babel/preset-env']
],

@@ -9,0 +9,0 @@ plugins: [

/*!
* /*! shepherd.js 2.0.0-beta.26 * /
* /*! shepherd.js 2.0.0-beta.27 * /
*
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("popper.js")):"function"==typeof define&&define.amd?define(["popper.js"],e):"object"==typeof exports?exports.Shepherd=e(require("popper.js")):t.Shepherd=e(t.Popper)}(this,function(t){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=13)}([function(t,e){t.exports=function(t){return void 0===t}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e){var n=Object.prototype.toString;t.exports=function(t){return n.call(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Evented=void 0;var o=r(n(0)),i=r(n(14));function r(t){return t&&t.__esModule?t:{default:t}}e.Evented=class{on(t,e,n){const i=!(arguments.length<=3||void 0===arguments[3])&&arguments[3];(0,o.default)(this.bindings)&&(this.bindings={}),(0,o.default)(this.bindings[t])&&(this.bindings[t]=[]),this.bindings[t].push({handler:e,ctx:n,once:i})}once(t,e,n){this.on(t,e,n,!0)}off(t,e){if((0,o.default)(this.bindings)||(0,o.default)(this.bindings[t]))return!1;(0,o.default)(e)?delete this.bindings[t]:this.bindings[t].forEach((n,o)=>{n.handler===e&&this.bindings[t].splice(o,1)})}trigger(t){if(!(0,o.default)(this.bindings)&&this.bindings[t]){const e=(0,i.default)(arguments);this.bindings[t].forEach((n,o)=>{const i=n.ctx,r=n.handler,s=n.once,c=i||this;r.apply(c,e),s&&this.bindings[t].splice(o,1)})}}}},function(t,e,n){var o=n(2),i=n(8),r=n(1),s="[object String]";t.exports=function(t){return"string"==typeof t||!i(t)&&r(t)&&o(t)==s}},function(t,e){t.exports=function(t,e){return function(n){return t(e(n))}}},function(t,e,n){var o=n(2),i=n(18),r="[object AsyncFunction]",s="[object Function]",c="[object GeneratorFunction]",u="[object Proxy]";t.exports=function(t){if(!i(t))return!1;var e=o(t);return e==s||e==c||e==r||e==u}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Step=void 0;var o=l(n(0)),i=l(n(4)),r=l(n(9)),s=l(n(6)),c=l(n(19)),u=l(n(28)),a=l(n(10)),p=n(3);n(34);var d=n(11),h=n(12);function l(t){return t&&t.__esModule?t:{default:t}}const f=function(){let t=0;return function(){return++t}}();e.Step=class extends p.Evented{constructor(t,e){return super(t,e),this.tour=t,d.bindMethods.call(this,["_show","cancel","complete","destroy","hide","isOpen","render","scrollTo","show"]),this.setOptions(e),this.bindAdvance=d.bindAdvance.bind(this),this.bindButtonEvents=d.bindButtonEvents.bind(this),this.bindCancelLink=d.bindCancelLink.bind(this),this.setupPopper=h.setupPopper.bind(this),this}_addButtons(t){if(this.options.buttons){const e=document.createElement("footer"),n=(0,h.createFromHTML)('<ul class="shepherd-buttons"></ul>');e.classList.add("shepherd-footer"),this.options.buttons.map(t=>{const e=(0,h.createFromHTML)(`<li><a class="shepherd-button ${t.classes||""}">${t.text}</a>`);n.appendChild(e),this.bindButtonEvents(t,e.querySelector("a"))}),e.appendChild(n),t.appendChild(e)}}_addCancelLink(t,e){if(this.options.showCancelLink){const n=(0,h.createFromHTML)('<a href class="shepherd-cancel-link"></a>');e.appendChild(n),t.classList.add("shepherd-has-cancel-link"),this.bindCancelLink(n)}}_addContent(t){const e=(0,h.createFromHTML)('<div class="shepherd-text"></div>');let n=this.options.text;(0,s.default)(n)&&(n=n.call(this,e)),n instanceof HTMLElement?e.appendChild(n):((0,i.default)(n)&&(n=[n]),n.map(t=>{e.innerHTML+=`<p>${t}</p>`})),t.appendChild(e)}_attach(t){const e=this.options.renderLocation;if(e){if(e instanceof HTMLElement)return e.appendChild(t);if((0,i.default)(e))return document.querySelector(e).appendChild(t)}return document.body.appendChild(t)}_createElement(){const t=document.createElement("div"),e=this.options.classes||"",n=(0,h.createFromHTML)(`<div class='${e}' data-id='${this.id}' id="${this.options.idAttribute}"}>`),i=document.createElement("header");if(this.options.title){const t=document.createElement("h3");t.classList.add("shepherd-title"),t.innerHTML=`${this.options.title}`,i.appendChild(t),n.classList.add("shepherd-has-title")}return t.classList.add("shepherd-content"),i.classList.add("shepherd-header"),n.appendChild(t),t.appendChild(i),this.options.attachTo&&n.appendChild((0,h.createFromHTML)('<div class="popper__arrow" x-arrow></div>')),(0,o.default)(this.options.text)||this._addContent(t),this._addButtons(t),this._addCancelLink(n,i),n}getTour(){return this.tour}getAttachTo(){const t=(0,h.parsePosition)(this.options.attachTo)||{},e=Object.assign({},t);if((0,i.default)(t.element)){try{e.element=document.querySelector(t.element)}catch(t){}e.element||console.error(`The element for this Shepherd step was not found ${t.element}`)}return e}cancel(){this.tour.cancel(),this.trigger("cancel")}complete(){this.tour.complete(),this.trigger("complete")}destroy(){(0,u.default)(this.el)&&this.el.parentNode&&(this.el.parentNode.removeChild(this.el),delete this.el),this.popper&&this.popper.destroy(),this.popper=null,this.trigger("destroy")}hide(){this.trigger("before-hide"),this.el&&(this.el.hidden=!0,this.el.style.display="none"),document.body.removeAttribute("data-shepherd-step"),this.target&&this.target.classList.remove("shepherd-enabled","shepherd-target"),this.popper&&this.popper.destroy(),this.popper=null,this.trigger("hide")}isOpen(){return this.el&&!this.el.hidden}render(){(0,o.default)(this.el)||this.destroy(),this.el=this._createElement(),this.options.advanceOn&&this.bindAdvance(),this._attach(this.el),this.setupPopper()}scrollTo(){const t=this.getAttachTo().element;(0,s.default)(this.options.scrollToHandler)?this.options.scrollToHandler(t):(0,u.default)(t)&&t.scrollIntoView()}setOptions(t={}){this.options=t;const e=this.options.when;this.destroy(),this.id=this.options.id||`step-${f()}`,(0,a.default)(e,(t,e)=>{this.on(e,t,this)}),this._setUpButtons()}show(){if((0,s.default)(this.options.beforeShowPromise)){const t=this.options.beforeShowPromise();if(!(0,o.default)(t))return t.then(()=>this._show())}this._show()}_setUpButtons(){const t=this.options.buttons;t&&((0,o.default)(t)||(0,c.default)(t)?this.options.buttons=[{text:"Next",action:this.tour.next,classes:"btn"}]:(0,r.default)(t)&&(this.options.buttons=[this.options.buttons]))}_show(){this.trigger("before-show"),this.el||this.render(),this.el.hidden=!1,this.el.style.display="block",document.body.setAttribute("data-shepherd-step",this.id),this.setupPopper(),this.options.scrollTo&&setTimeout(()=>{this.scrollTo()}),this.trigger("show")}}},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){var o=n(2),i=n(17),r=n(1),s="[object Object]",c=Function.prototype,u=Object.prototype,a=c.toString,p=u.hasOwnProperty,d=a.call(Object);t.exports=function(t){if(!r(t)||o(t)!=s)return!1;var e=i(t);if(null===e)return!0;var n=p.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&a.call(n)==d}},function(t,e,n){var o=n(29),i=n(33);t.exports=function(t,e){return t&&o(t,i(e))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=c(n(0)),i=c(n(4)),r=c(n(10));e.bindAdvance=function(){const t=(0,s.parseShorthand)(this.options.advanceOn,["selector","event"]),e=t.event,n=t.selector,i=function(t){return e=>{if(this.isOpen()){const n=this.el&&e.target===this.el,i=!(0,o.default)(t)&&e.target.matches(t);(i||n)&&this.tour.next()}}}.call(this,n),r=document.querySelector(n);!(0,o.default)(n)&&r?r.addEventListener(e,i):document.body.addEventListener(e,i,!0);this.on("destroy",()=>document.body.removeEventListener(e,i,!0))},e.bindButtonEvents=function(t,e){t.events=t.events||{},(0,o.default)(t.action)||(t.events.click=t.action);(0,r.default)(t.events,(t,n)=>{if((0,i.default)(t)){const e=t;t=(()=>this.tour.show(e))}e.dataset.buttonEvent=!0,e.addEventListener(n,t),this.on("destroy",()=>{e.removeAttribute("data-button-event"),e.removeEventListener(n,t)})})},e.bindCancelLink=function(t){t.addEventListener("click",t=>{t.preventDefault(),this.cancel()})},e.bindMethods=function(t){t.map(t=>{this[t]=this[t].bind(this)})};var s=n(12);function c(t){return t&&t.__esModule?t:{default:t}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=c(n(35)),i=c(n(0)),r=c(n(1));e.createFromHTML=function(t){const e=document.createElement("div");return e.innerHTML=t,e.children[0]},e.parsePosition=function(t){if((0,r.default)(t))return t.hasOwnProperty("element")&&t.hasOwnProperty("on")?t:null;const e=/^(.+) (top|left|right|bottom|center)$/.exec(t);if(!e)return null;return{element:e[1],on:e[2]}},e.parseShorthand=function(t,e){if(null===t||(0,i.default)(t))return t;if((0,r.default)(t))return t;const n=t.split(" ");return(0,o.default)(e,n)},e.setupPopper=function(){if((0,i.default)(s.default))throw new Error("Using the attachment feature of Shepherd requires the Popper.js library");const t=this.getAttachTo();t.modifiers=t.modifiers||{};let e=t.on||"right";t.positionFixed=!1,(0,i.default)(t.element)&&(e="top",function(t){t.element=document.body,t.modifiers=Object.assign({computeStyle:{enabled:!0,fn:t=>(t.styles=Object.assign({},t.styles,{left:"50%",top:"50%",transform:"translate(-50%, -50%)"}),t)}},t.modifiers),t.positionFixed=!0}(t));this.popper&&this.popper.destroy();this.el.classList.add("shepherd-element");const n=function(t,e){return Object.assign({},{placement:t,arrowElement:this.el.querySelector(".popper__arrow"),modifiers:e.modifiers,positionFixed:e.positionFixed},this.options.popperOptions)}.call(this,e,t);this.popper=new s.default(t.element,this.el,n),this.target=t.element,this.target.classList.add("shepherd-enabled","shepherd-target")};var s=c(n(42));function c(t){return t&&t.__esModule?t:{default:t}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),i=n(7),r=n(43);Object.assign(r.Shepherd,{Tour:r.Tour,Step:i.Step,Evented:o.Evented}),e.default=r.Shepherd,t.exports=e.default},function(t,e,n){var o=n(15),i=n(16);t.exports=function(t,e,n){var r=null==t?0:t.length;return r?(e=n||void 0===e?1:i(e),o(t,e<0?0:e,r)):[]}},function(t,e){t.exports=function(t,e,n){var o=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var r=Array(i);++o<i;)r[o]=t[o+e];return r}},function(t,e){t.exports=function(t){return t}},function(t,e,n){var o=n(5)(Object.getPrototypeOf,Object);t.exports=o},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e,n){var o=n(20),i=n(21),r=n(22),s=n(8),c=n(23),u=n(25),a=n(26),p=n(27),d="[object Map]",h="[object Set]",l=Object.prototype.hasOwnProperty;t.exports=function(t){if(null==t)return!0;if(c(t)&&(s(t)||"string"==typeof t||"function"==typeof t.splice||u(t)||p(t)||r(t)))return!t.length;var e=i(t);if(e==d||e==h)return!t.size;if(a(t))return!o(t).length;for(var n in t)if(l.call(t,n))return!1;return!0}},function(t,e,n){var o=n(5)(Object.keys,Object);t.exports=o},function(t,e){var n=Object.prototype.toString;t.exports=function(t){return n.call(t)}},function(t,e){t.exports=function(){return!1}},function(t,e,n){var o=n(6),i=n(24);t.exports=function(t){return null!=t&&i(t.length)&&!o(t)}},function(t,e){var n=9007199254740991;t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=n}},function(t,e){t.exports=function(){return!1}},function(t,e){t.exports=function(){return!1}},function(t,e){t.exports=function(){return!1}},function(t,e,n){var o=n(1),i=n(9);t.exports=function(t){return o(t)&&1===t.nodeType&&!i(t)}},function(t,e,n){var o=n(30),i=n(32);t.exports=function(t,e){return t&&o(t,e,i)}},function(t,e,n){var o=n(31)();t.exports=o},function(t,e){t.exports=function(t){return function(e,n,o){for(var i=-1,r=Object(e),s=o(e),c=s.length;c--;){var u=s[t?c:++i];if(!1===n(r[u],u,r))break}return e}}},function(t,e,n){var o=n(5)(Object.keys,Object);t.exports=o},function(t,e){t.exports=function(t){return t}},function(t,e){Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector)},function(t,e,n){var o=n(36),i=n(41);t.exports=function(t,e){return i(t||[],e||[],o)}},function(t,e,n){var o=n(37),i=n(40),r=Object.prototype.hasOwnProperty;t.exports=function(t,e,n){var s=t[e];r.call(t,e)&&i(s,n)&&(void 0!==n||e in t)||o(t,e,n)}},function(t,e,n){var o=n(38);t.exports=function(t,e,n){"__proto__"==e&&o?o(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}},function(t,e,n){var o=n(39),i=function(){try{var t=o(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=i},function(t,e){t.exports=function(t,e){return null==t?void 0:t[e]}},function(t,e){t.exports=function(t,e){return t===e||t!=t&&e!=e}},function(t,e){t.exports=function(t,e,n){for(var o=-1,i=t.length,r=e.length,s={};++o<i;){var c=o<r?e[o]:void 0;n(s,t[o],c)}return s}},function(e,n){e.exports=t},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Shepherd=e.Tour=void 0;var o=p(n(0)),i=p(n(4)),r=p(n(44)),s=p(n(6)),c=n(3),u=n(7),a=n(11);function p(t){return t&&t.__esModule?t:{default:t}}const d=new c.Evented;e.Tour=class extends c.Evented{constructor(t={}){return super(t),a.bindMethods.call(this,["back","cancel","complete","next"]),this.options=t,this.steps=this.options.steps||[],["active","cancel","complete","inactive","show","start"].map(t=>{(t=>{this.on(t,e=>{(e=e||{}).tour=this,d.trigger(t,e)})})(t)}),this}addStep(t,e){let n,i;return(0,o.default)(e)?i=t:(n=t,i=e),i instanceof u.Step?i.tour=this:i=this.setupStep(i,n),this.steps.push(i),i}back(){const t=this.steps.indexOf(this.currentStep);this.show(t-1,!1)}cancel(){if(this.options.confirmCancel){const t=this.options.confirmCancelMessage||"Are you sure you want to stop the tour?";window.confirm(t)&&this.done("cancel")}else this.done("cancel")}complete(){this.done("complete")}done(t){this.currentStep&&this.currentStep.hide(),this.trigger(t),d.activeTour&&d.activeTour.steps.forEach(t=>{t.destroy()}),d.activeTour=null,document.body.classList.remove("shepherd-active"),this.trigger("inactive",{tour:this})}getById(t){return this.steps.find(e=>e.id===t)}getCurrentStep(){return this.currentStep}next(){const t=this.steps.indexOf(this.currentStep);t===this.steps.length-1?this.complete():this.show(t+1,!0)}removeStep(t){const e=this.getCurrentStep();this.steps.some((e,n)=>{if(e.id===t)return e.isOpen()&&e.hide(),e.destroy(),this.steps.splice(n,1),!0}),e&&e.id===t&&(this.currentStep=void 0,this.steps.length?this.show(0):this.cancel())}setupStep(t,e){return((0,i.default)(e)||(0,r.default)(e))&&(t.id=e.toString()),t=Object.assign({},this.options.defaults,t),new u.Step(this,t)}show(t=0,e=!0){this._setupActiveTour();const n=(0,i.default)(t)?this.getById(t):this.steps[t];n&&((0,s.default)(n.options.showOn)&&!n.options.showOn()?this._skipStep(n,e):(this.trigger("show",{step:n,previous:this.currentStep}),this.currentStep=n,n.show()))}start(){this.trigger("start"),this.currentStep=null,this.next()}_setupActiveTour(){this.currentStep?this.currentStep.hide():(document.body.classList.add("shepherd-active"),this.trigger("active",{tour:this})),d.activeTour=this}_skipStep(t,e){const n=this.steps.indexOf(t),o=e?n+1:n-1;this.show(o,e)}},e.Shepherd=d},function(t,e,n){var o=n(2),i=n(1),r="[object Number]";t.exports=function(t){return"number"==typeof t||i(t)&&o(t)==r}}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("popper.js")):"function"==typeof define&&define.amd?define(["popper.js"],e):"object"==typeof exports?exports.Shepherd=e(require("popper.js")):t.Shepherd=e(t.Popper)}(this,function(t){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=13)}([function(t,e){t.exports=function(t){return void 0===t}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e){var n=Object.prototype.toString;t.exports=function(t){return n.call(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Evented=void 0;var o=i(n(0)),r=i(n(14));function i(t){return t&&t.__esModule?t:{default:t}}function s(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}e.Evented=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,n){e&&s(t.prototype,e),n&&s(t,n)}(t,[{key:"on",value:function(t,e,n){var r=!(arguments.length<=3||void 0===arguments[3])&&arguments[3];(0,o.default)(this.bindings)&&(this.bindings={}),(0,o.default)(this.bindings[t])&&(this.bindings[t]=[]),this.bindings[t].push({handler:e,ctx:n,once:r})}},{key:"once",value:function(t,e,n){this.on(t,e,n,!0)}},{key:"off",value:function(t,e){var n=this;if((0,o.default)(this.bindings)||(0,o.default)(this.bindings[t]))return!1;(0,o.default)(e)?delete this.bindings[t]:this.bindings[t].forEach(function(o,r){o.handler===e&&n.bindings[t].splice(r,1)})}},{key:"trigger",value:function(t){var e=this;if(!(0,o.default)(this.bindings)&&this.bindings[t]){var n=(0,r.default)(arguments);this.bindings[t].forEach(function(o,r){var i=o.ctx,s=o.handler,u=o.once,c=i||e;s.apply(c,n),u&&e.bindings[t].splice(r,1)})}}}]),t}()},function(t,e,n){var o=n(2),r=n(8),i=n(1),s="[object String]";t.exports=function(t){return"string"==typeof t||!r(t)&&i(t)&&o(t)==s}},function(t,e){t.exports=function(t,e){return function(n){return t(e(n))}}},function(t,e,n){var o=n(2),r=n(18),i="[object AsyncFunction]",s="[object Function]",u="[object GeneratorFunction]",c="[object Proxy]";t.exports=function(t){if(!r(t))return!1;var e=o(t);return e==s||e==u||e==i||e==c}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Step=void 0;var o=d(n(0)),r=d(n(4)),i=d(n(9)),s=d(n(6)),u=d(n(19)),c=d(n(28)),a=d(n(10)),l=n(3);n(34);var p=n(11),f=n(12);function d(t){return t&&t.__esModule?t:{default:t}}function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function v(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function y(t,e){return!e||"object"!==h(e)&&"function"!=typeof e?g(t):e}function b(t){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function m(t,e){return(m=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function g(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var O=function(){var t=0;return function(){return++t}}();e.Step=function(t){function e(t,n){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(o=y(this,b(e).call(this,t,n))).tour=t,p.bindMethods.call(g(g(o)),["_show","cancel","complete","destroy","hide","isOpen","render","scrollTo","show"]),o.setOptions(n),o.bindAdvance=p.bindAdvance.bind(g(g(o))),o.bindButtonEvents=p.bindButtonEvents.bind(g(g(o))),o.bindCancelLink=p.bindCancelLink.bind(g(g(o))),o.setupPopper=f.setupPopper.bind(g(g(o))),y(o,g(g(o)))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&m(t,e)}(e,l.Evented),function(t,e,n){e&&v(t.prototype,e),n&&v(t,n)}(e,[{key:"_addButtons",value:function(t){var e=this;if(this.options.buttons){var n=document.createElement("footer"),o=(0,f.createFromHTML)('<ul class="shepherd-buttons"></ul>');n.classList.add("shepherd-footer"),this.options.buttons.map(function(t){var n=(0,f.createFromHTML)('<li><a class="shepherd-button '.concat(t.classes||"",'">').concat(t.text,"</a>"));o.appendChild(n),e.bindButtonEvents(t,n.querySelector("a"))}),n.appendChild(o),t.appendChild(n)}}},{key:"_addCancelLink",value:function(t,e){if(this.options.showCancelLink){var n=(0,f.createFromHTML)('<a href class="shepherd-cancel-link"></a>');e.appendChild(n),t.classList.add("shepherd-has-cancel-link"),this.bindCancelLink(n)}}},{key:"_addContent",value:function(t){var e=(0,f.createFromHTML)('<div class="shepherd-text"></div>'),n=this.options.text;(0,s.default)(n)&&(n=n.call(this,e)),n instanceof HTMLElement?e.appendChild(n):((0,r.default)(n)&&(n=[n]),n.map(function(t){e.innerHTML+="<p>".concat(t,"</p>")})),t.appendChild(e)}},{key:"_attach",value:function(t){var e=this.options.renderLocation;if(e){if(e instanceof HTMLElement)return e.appendChild(t);if((0,r.default)(e))return document.querySelector(e).appendChild(t)}return document.body.appendChild(t)}},{key:"_createElement",value:function(){var t=document.createElement("div"),e=this.options.classes||"",n=(0,f.createFromHTML)("<div class='".concat(e,"' data-id='").concat(this.id,"' id=\"").concat(this.options.idAttribute,'"}>')),r=document.createElement("header");if(this.options.title){var i=document.createElement("h3");i.classList.add("shepherd-title"),i.innerHTML="".concat(this.options.title),r.appendChild(i),n.classList.add("shepherd-has-title")}return t.classList.add("shepherd-content"),r.classList.add("shepherd-header"),n.appendChild(t),t.appendChild(r),this.options.attachTo&&n.appendChild((0,f.createFromHTML)('<div class="popper__arrow" x-arrow></div>')),(0,o.default)(this.options.text)||this._addContent(t),this._addButtons(t),this._addCancelLink(n,r),n}},{key:"getTour",value:function(){return this.tour}},{key:"getAttachTo",value:function(){var t=(0,f.parsePosition)(this.options.attachTo)||{},e=Object.assign({},t);if((0,r.default)(t.element)){try{e.element=document.querySelector(t.element)}catch(t){}e.element||console.error("The element for this Shepherd step was not found ".concat(t.element))}return e}},{key:"cancel",value:function(){this.tour.cancel(),this.trigger("cancel")}},{key:"complete",value:function(){this.tour.complete(),this.trigger("complete")}},{key:"destroy",value:function(){(0,c.default)(this.el)&&this.el.parentNode&&(this.el.parentNode.removeChild(this.el),delete this.el),this.popper&&this.popper.destroy(),this.popper=null,this.trigger("destroy")}},{key:"hide",value:function(){this.trigger("before-hide"),this.el&&(this.el.hidden=!0,this.el.style.display="none"),document.body.removeAttribute("data-shepherd-step"),this.target&&this.target.classList.remove("shepherd-enabled","shepherd-target"),this.popper&&this.popper.destroy(),this.popper=null,this.trigger("hide")}},{key:"isOpen",value:function(){return this.el&&!this.el.hidden}},{key:"render",value:function(){(0,o.default)(this.el)||this.destroy(),this.el=this._createElement(),this.options.advanceOn&&this.bindAdvance(),this._attach(this.el),this.setupPopper()}},{key:"scrollTo",value:function(){var t=this.getAttachTo().element;(0,s.default)(this.options.scrollToHandler)?this.options.scrollToHandler(t):(0,c.default)(t)&&t.scrollIntoView()}},{key:"setOptions",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=e;var n=this.options.when;this.destroy(),this.id=this.options.id||"step-".concat(O()),(0,a.default)(n,function(e,n){t.on(n,e,t)}),this._setUpButtons()}},{key:"show",value:function(){var t=this;if((0,s.default)(this.options.beforeShowPromise)){var e=this.options.beforeShowPromise();if(!(0,o.default)(e))return e.then(function(){return t._show()})}this._show()}},{key:"_setUpButtons",value:function(){var t=this.options.buttons;t&&((0,o.default)(t)||(0,u.default)(t)?this.options.buttons=[{text:"Next",action:this.tour.next,classes:"btn"}]:(0,i.default)(t)&&(this.options.buttons=[this.options.buttons]))}},{key:"_show",value:function(){var t=this;this.trigger("before-show"),this.el||this.render(),this.el.hidden=!1,this.el.style.display="block",document.body.setAttribute("data-shepherd-step",this.id),this.setupPopper(),this.options.scrollTo&&setTimeout(function(){t.scrollTo()}),this.trigger("show")}}]),e}()},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){var o=n(2),r=n(17),i=n(1),s="[object Object]",u=Function.prototype,c=Object.prototype,a=u.toString,l=c.hasOwnProperty,p=a.call(Object);t.exports=function(t){if(!i(t)||o(t)!=s)return!1;var e=r(t);if(null===e)return!0;var n=l.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&a.call(n)==p}},function(t,e,n){var o=n(29),r=n(33);t.exports=function(t,e){return t&&o(t,r(e))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=u(n(0)),r=u(n(4)),i=u(n(10));e.bindAdvance=function(){var t=(0,s.parseShorthand)(this.options.advanceOn,["selector","event"]),e=t.event,n=t.selector,r=function(t){var e=this;return function(n){if(e.isOpen()){var r=e.el&&n.target===e.el,i=!(0,o.default)(t)&&n.target.matches(t);(i||r)&&e.tour.next()}}}.call(this,n),i=document.querySelector(n);!(0,o.default)(n)&&i?i.addEventListener(e,r):document.body.addEventListener(e,r,!0);this.on("destroy",function(){return document.body.removeEventListener(e,r,!0)})},e.bindButtonEvents=function(t,e){var n=this;t.events=t.events||{},(0,o.default)(t.action)||(t.events.click=t.action);(0,i.default)(t.events,function(t,o){if((0,r.default)(t)){var i=t;t=function(){return n.tour.show(i)}}e.dataset.buttonEvent=!0,e.addEventListener(o,t),n.on("destroy",function(){e.removeAttribute("data-button-event"),e.removeEventListener(o,t)})})},e.bindCancelLink=function(t){var e=this;t.addEventListener("click",function(t){t.preventDefault(),e.cancel()})},e.bindMethods=function(t){var e=this;t.map(function(t){e[t]=e[t].bind(e)})};var s=n(12);function u(t){return t&&t.__esModule?t:{default:t}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=u(n(35)),r=u(n(0)),i=u(n(1));e.createFromHTML=function(t){var e=document.createElement("div");return e.innerHTML=t,e.children[0]},e.parsePosition=function(t){if((0,i.default)(t))return t.hasOwnProperty("element")&&t.hasOwnProperty("on")?t:null;var e=/^(.+) (top|left|right|bottom|center)$/.exec(t);if(!e)return null;return{element:e[1],on:e[2]}},e.parseShorthand=function(t,e){if(null===t||(0,r.default)(t))return t;if((0,i.default)(t))return t;var n=t.split(" ");return(0,o.default)(e,n)},e.setupPopper=function(){if((0,r.default)(s.default))throw new Error("Using the attachment feature of Shepherd requires the Popper.js library");var t=this.getAttachTo();t.modifiers=t.modifiers||{};var e=t.on||"right";t.positionFixed=!1,(0,r.default)(t.element)&&(e="top",function(t){t.element=document.body,t.modifiers=Object.assign({computeStyle:{enabled:!0,fn:function(t){return t.styles=Object.assign({},t.styles,{left:"50%",top:"50%",transform:"translate(-50%, -50%)"}),t}}},t.modifiers),t.positionFixed=!0}(t));this.popper&&this.popper.destroy();this.el.classList.add("shepherd-element");var n=function(t,e){return Object.assign({},{placement:t,arrowElement:this.el.querySelector(".popper__arrow"),modifiers:e.modifiers,positionFixed:e.positionFixed},this.options.popperOptions)}.call(this,e,t);this.popper=new s.default(t.element,this.el,n),this.target=t.element,this.target.classList.add("shepherd-enabled","shepherd-target")};var s=u(n(42));function u(t){return t&&t.__esModule?t:{default:t}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(3),r=n(7),i=n(43);Object.assign(i.Shepherd,{Tour:i.Tour,Step:r.Step,Evented:o.Evented}),e.default=i.Shepherd,t.exports=e.default},function(t,e,n){var o=n(15),r=n(16);t.exports=function(t,e,n){var i=null==t?0:t.length;return i?(e=n||void 0===e?1:r(e),o(t,e<0?0:e,i)):[]}},function(t,e){t.exports=function(t,e,n){var o=-1,r=t.length;e<0&&(e=-e>r?0:r+e),(n=n>r?r:n)<0&&(n+=r),r=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(r);++o<r;)i[o]=t[o+e];return i}},function(t,e){t.exports=function(t){return t}},function(t,e,n){var o=n(5)(Object.getPrototypeOf,Object);t.exports=o},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e,n){var o=n(20),r=n(21),i=n(22),s=n(8),u=n(23),c=n(25),a=n(26),l=n(27),p="[object Map]",f="[object Set]",d=Object.prototype.hasOwnProperty;t.exports=function(t){if(null==t)return!0;if(u(t)&&(s(t)||"string"==typeof t||"function"==typeof t.splice||c(t)||l(t)||i(t)))return!t.length;var e=r(t);if(e==p||e==f)return!t.size;if(a(t))return!o(t).length;for(var n in t)if(d.call(t,n))return!1;return!0}},function(t,e,n){var o=n(5)(Object.keys,Object);t.exports=o},function(t,e){var n=Object.prototype.toString;t.exports=function(t){return n.call(t)}},function(t,e){t.exports=function(){return!1}},function(t,e,n){var o=n(6),r=n(24);t.exports=function(t){return null!=t&&r(t.length)&&!o(t)}},function(t,e){var n=9007199254740991;t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=n}},function(t,e){t.exports=function(){return!1}},function(t,e){t.exports=function(){return!1}},function(t,e){t.exports=function(){return!1}},function(t,e,n){var o=n(1),r=n(9);t.exports=function(t){return o(t)&&1===t.nodeType&&!r(t)}},function(t,e,n){var o=n(30),r=n(32);t.exports=function(t,e){return t&&o(t,e,r)}},function(t,e,n){var o=n(31)();t.exports=o},function(t,e){t.exports=function(t){return function(e,n,o){for(var r=-1,i=Object(e),s=o(e),u=s.length;u--;){var c=s[t?u:++r];if(!1===n(i[c],c,i))break}return e}}},function(t,e,n){var o=n(5)(Object.keys,Object);t.exports=o},function(t,e){t.exports=function(t){return t}},function(t,e){Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector)},function(t,e,n){var o=n(36),r=n(41);t.exports=function(t,e){return r(t||[],e||[],o)}},function(t,e,n){var o=n(37),r=n(40),i=Object.prototype.hasOwnProperty;t.exports=function(t,e,n){var s=t[e];i.call(t,e)&&r(s,n)&&(void 0!==n||e in t)||o(t,e,n)}},function(t,e,n){var o=n(38);t.exports=function(t,e,n){"__proto__"==e&&o?o(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}},function(t,e,n){var o=n(39),r=function(){try{var t=o(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=r},function(t,e){t.exports=function(t,e){return null==t?void 0:t[e]}},function(t,e){t.exports=function(t,e){return t===e||t!=t&&e!=e}},function(t,e){t.exports=function(t,e,n){for(var o=-1,r=t.length,i=e.length,s={};++o<r;){var u=o<i?e[o]:void 0;n(s,t[o],u)}return s}},function(e,n){e.exports=t},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Shepherd=e.Tour=void 0;var o=l(n(0)),r=l(n(4)),i=l(n(44)),s=l(n(6)),u=n(3),c=n(7),a=n(11);function l(t){return t&&t.__esModule?t:{default:t}}function p(t){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function f(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function d(t,e){return!e||"object"!==p(e)&&"function"!=typeof e?y(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function v(t,e){return(v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function y(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var b=new u.Evented;e.Tour=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=d(this,h(e).call(this,n)),a.bindMethods.call(y(y(t)),["back","cancel","complete","next"]),t.options=n,t.steps=t.options.steps||[];return["active","cancel","complete","inactive","show","start"].map(function(e){!function(e){t.on(e,function(n){(n=n||{}).tour=y(y(t)),b.trigger(e,n)})}(e)}),d(t,y(y(t)))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&v(t,e)}(e,u.Evented),function(t,e,n){e&&f(t.prototype,e),n&&f(t,n)}(e,[{key:"addStep",value:function(t,e){var n,r;return(0,o.default)(e)?r=t:(n=t,r=e),r instanceof c.Step?r.tour=this:r=this.setupStep(r,n),this.steps.push(r),r}},{key:"back",value:function(){var t=this.steps.indexOf(this.currentStep);this.show(t-1,!1)}},{key:"cancel",value:function(){if(this.options.confirmCancel){var t=this.options.confirmCancelMessage||"Are you sure you want to stop the tour?";window.confirm(t)&&this.done("cancel")}else this.done("cancel")}},{key:"complete",value:function(){this.done("complete")}},{key:"done",value:function(t){this.currentStep&&this.currentStep.hide(),this.trigger(t),b.activeTour&&b.activeTour.steps.forEach(function(t){t.destroy()}),b.activeTour=null,document.body.classList.remove("shepherd-active"),this.trigger("inactive",{tour:this})}},{key:"getById",value:function(t){return this.steps.find(function(e){return e.id===t})}},{key:"getCurrentStep",value:function(){return this.currentStep}},{key:"next",value:function(){var t=this.steps.indexOf(this.currentStep);t===this.steps.length-1?this.complete():this.show(t+1,!0)}},{key:"removeStep",value:function(t){var e=this,n=this.getCurrentStep();this.steps.some(function(n,o){if(n.id===t)return n.isOpen()&&n.hide(),n.destroy(),e.steps.splice(o,1),!0}),n&&n.id===t&&(this.currentStep=void 0,this.steps.length?this.show(0):this.cancel())}},{key:"setupStep",value:function(t,e){return((0,r.default)(e)||(0,i.default)(e))&&(t.id=e.toString()),t=Object.assign({},this.options.defaultStepOptions,t),new c.Step(this,t)}},{key:"show",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this._setupActiveTour();var n=(0,r.default)(t)?this.getById(t):this.steps[t];n&&((0,s.default)(n.options.showOn)&&!n.options.showOn()?this._skipStep(n,e):(this.trigger("show",{step:n,previous:this.currentStep}),this.currentStep=n,n.show()))}},{key:"start",value:function(){this.trigger("start"),this.currentStep=null,this.next()}},{key:"_setupActiveTour",value:function(){this.currentStep?this.currentStep.hide():(document.body.classList.add("shepherd-active"),this.trigger("active",{tour:this})),b.activeTour=this}},{key:"_skipStep",value:function(t,e){var n=this.steps.indexOf(t),o=e?n+1:n-1;this.show(o,e)}}]),e}();e.Shepherd=b},function(t,e,n){var o=n(2),r=n(1),i="[object Number]";t.exports=function(t){return"number"==typeof t||r(t)&&o(t)==i}}])});
//# sourceMappingURL=shepherd.min.js.map

@@ -38,3 +38,3 @@ ## Shepherd

const tour = new Shepherd.Tour({
defaults: {
defaultStepOptions: {
classes: 'shepherd-theme-arrows',

@@ -46,3 +46,3 @@ scrollTo: true

The `defaults` option allows you to specify any options which should be applied
The `defaultStepOptions` option allows you to specify any options which should be applied
to all this tour's steps by default.

@@ -121,3 +121,3 @@

- `steps`: An array of Step instances to initialize the tour with
- `defaults`: Default options for Steps created through `addStep`
- `defaultStepOptions`: Default options for Steps created through `addStep`
- `confirmCancel`: If true, will issue a window.confirm before cancelling

@@ -179,6 +179,6 @@ - `confirmCancelMessage`: The message to display in the confirm dialog

```javascript
events: {
click: function() {
return Shepherd.activeTour.show('some_step_name');
}
events: {
click: function() {
return Shepherd.activeTour.show('some_step_name');
}
}

@@ -283,3 +283,3 @@ ```

let tour = new Shepherd.Tour({
defaults: {
defaultStepOptions: {
classes: 'shepherd-theme-custom'

@@ -286,0 +286,0 @@ }

{
"name": "shepherd.js",
"version": "2.0.0-beta.26",
"version": "2.0.0-beta.27",
"repository": {

@@ -37,2 +37,3 @@ "type": "git",

"start-test-server": "http-server",
"test": "yarn test:ci",
"test:build": "cross-env NODE_ENV=test yarn build",

@@ -62,3 +63,3 @@ "test:ci": "yarn test:unit:ci && yarn test:cy:ci",

"babel-loader": "^8.0.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-add-module-exports": "^1.0.0",
"babel-plugin-istanbul": "^5.0.1",

@@ -65,0 +66,0 @@ "babel-plugin-lodash": "^3.3.4",

@@ -11,6 +11,6 @@ ## Shepherd

[![Test Coverage](https://api.codeclimate.com/v1/badges/b295b0cc0d828ccc1b76/test_coverage)](https://codeclimate.com/github/shipshapecode/shepherd/test_coverage)
[![Greenkeeper badge](https://badges.greenkeeper.io/shipshapecode/shepherd.svg)](https://greenkeeper.io/)
[![Guide your users through a tour of your app](http://i.imgur.com/LDhfBvd.png)](https://shipshapecode.github.io/shepherd/docs/welcome/) [![Greenkeeper badge](https://badges.greenkeeper.io/shipshapecode/shepherd.svg)](https://greenkeeper.io/)
[![Guide your users through a tour of your app](http://i.imgur.com/LDhfBvd.png)](https://shipshapecode.github.io/shepherd/docs/welcome/)
## Install

@@ -38,3 +38,3 @@

let tour = new Shepherd.Tour({
defaults: {
defaultStepOptions: {
classes: 'shepherd-theme-arrows'

@@ -41,0 +41,0 @@ }

@@ -16,3 +16,3 @@ import { isFunction, isNumber, isString, isUndefined } from 'lodash';

* @param {Object} options The options for the tour
* @param {Object} options.defaults Default options for Steps created through `addStep`
* @param {Object} options.defaultStepOptions Default options for Steps created through `addStep`
* @param {Step[]} options.steps An array of Step instances to initialize the tour with

@@ -202,3 +202,3 @@ * @returns {Tour}

stepOptions = Object.assign({}, this.options.defaults, stepOptions);
stepOptions = Object.assign({}, this.options.defaultStepOptions, stepOptions);

@@ -276,2 +276,2 @@ return new Step(this, stepOptions);

export { Shepherd };
export { Shepherd };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc