react-shepherd 3.3.7 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import React, { useMemo } from 'react';
2
2
 
3
- /*! shepherd.js 8.3.1 */
3
+ /*! shepherd.js 10.0.0 */
4
4
  var isMergeableObject = function isMergeableObject(value) {
5
5
  return isNonNullObject(value) && !isSpecial(value);
6
6
  };
@@ -171,7 +171,11 @@ function isUndefined(value) {
171
171
  }
172
172
 
173
173
  class Evented {
174
- on(event, handler, ctx, once = false) {
174
+ on(event, handler, ctx, once) {
175
+ if (once === void 0) {
176
+ once = false;
177
+ }
178
+
175
179
  if (isUndefined(this.bindings)) {
176
180
  this.bindings = {};
177
181
  }
@@ -210,7 +214,11 @@ class Evented {
210
214
  return this;
211
215
  }
212
216
 
213
- trigger(event, ...args) {
217
+ trigger(event) {
218
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
219
+ args[_key - 1] = arguments[_key];
220
+ }
221
+
214
222
  if (!isUndefined(this.bindings) && this.bindings[event]) {
215
223
  this.bindings[event].forEach((binding, index) => {
216
224
  const {
@@ -471,17 +479,42 @@ function getBasePlacement(placement) {
471
479
  return placement.split('-')[0];
472
480
  }
473
481
 
474
- function getBoundingClientRect(element) {
482
+ var max = Math.max;
483
+ var min = Math.min;
484
+ var round = Math.round;
485
+
486
+ function getBoundingClientRect(element, includeScale) {
487
+ if (includeScale === void 0) {
488
+ includeScale = false;
489
+ }
490
+
475
491
  var rect = element.getBoundingClientRect();
492
+ var scaleX = 1;
493
+ var scaleY = 1;
494
+
495
+ if (isHTMLElement(element) && includeScale) {
496
+ var offsetHeight = element.offsetHeight;
497
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
498
+ // Fallback to 1 in case both values are `0`
499
+
500
+ if (offsetWidth > 0) {
501
+ scaleX = round(rect.width) / offsetWidth || 1;
502
+ }
503
+
504
+ if (offsetHeight > 0) {
505
+ scaleY = round(rect.height) / offsetHeight || 1;
506
+ }
507
+ }
508
+
476
509
  return {
477
- width: rect.width,
478
- height: rect.height,
479
- top: rect.top,
480
- right: rect.right,
481
- bottom: rect.bottom,
482
- left: rect.left,
483
- x: rect.left,
484
- y: rect.top
510
+ width: rect.width / scaleX,
511
+ height: rect.height / scaleY,
512
+ top: rect.top / scaleY,
513
+ right: rect.right / scaleX,
514
+ bottom: rect.bottom / scaleY,
515
+ left: rect.left / scaleX,
516
+ x: rect.left / scaleX,
517
+ y: rect.top / scaleY
485
518
  };
486
519
  } // means it doesn't take into account transforms.
487
520
 
@@ -589,6 +622,10 @@ function getContainingBlock(element) {
589
622
 
590
623
  var currentNode = getParentNode(element);
591
624
 
625
+ if (isShadowRoot(currentNode)) {
626
+ currentNode = currentNode.host;
627
+ }
628
+
592
629
  while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
593
630
  var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
594
631
  // create a containing block.
@@ -625,14 +662,15 @@ function getMainAxisFromPlacement(placement) {
625
662
  return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
626
663
  }
627
664
 
628
- var max = Math.max;
629
- var min = Math.min;
630
- var round = Math.round;
631
-
632
665
  function within(min$1, value, max$1) {
633
666
  return max(min$1, min(value, max$1));
634
667
  }
635
668
 
669
+ function withinMaxClamp(min, value, max) {
670
+ var v = within(min, value, max);
671
+ return v > max ? max : v;
672
+ }
673
+
636
674
  function getFreshSideObject() {
637
675
  return {
638
676
  top: 0,
@@ -733,6 +771,11 @@ var arrow$1 = {
733
771
  requires: ['popperOffsets'],
734
772
  requiresIfExists: ['preventOverflow']
735
773
  };
774
+
775
+ function getVariation(placement) {
776
+ return placement.split('-')[1];
777
+ }
778
+
736
779
  var unsetSides = {
737
780
  top: 'auto',
738
781
  right: 'auto',
@@ -748,8 +791,8 @@ function roundOffsetsByDPR(_ref) {
748
791
  var win = window;
749
792
  var dpr = win.devicePixelRatio || 1;
750
793
  return {
751
- x: round(round(x * dpr) / dpr) || 0,
752
- y: round(round(y * dpr) / dpr) || 0
794
+ x: round(x * dpr) / dpr || 0,
795
+ y: round(y * dpr) / dpr || 0
753
796
  };
754
797
  }
755
798
 
@@ -759,18 +802,28 @@ function mapToStyles(_ref2) {
759
802
  var popper = _ref2.popper,
760
803
  popperRect = _ref2.popperRect,
761
804
  placement = _ref2.placement,
805
+ variation = _ref2.variation,
762
806
  offsets = _ref2.offsets,
763
807
  position = _ref2.position,
764
808
  gpuAcceleration = _ref2.gpuAcceleration,
765
809
  adaptive = _ref2.adaptive,
766
- roundOffsets = _ref2.roundOffsets;
767
-
768
- var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
769
- _ref3$x = _ref3.x,
770
- x = _ref3$x === void 0 ? 0 : _ref3$x,
771
- _ref3$y = _ref3.y,
772
- y = _ref3$y === void 0 ? 0 : _ref3$y;
810
+ roundOffsets = _ref2.roundOffsets,
811
+ isFixed = _ref2.isFixed;
812
+ var _offsets$x = offsets.x,
813
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
814
+ _offsets$y = offsets.y,
815
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
816
+
817
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
818
+ x: x,
819
+ y: y
820
+ }) : {
821
+ x: x,
822
+ y: y
823
+ };
773
824
 
825
+ x = _ref3.x;
826
+ y = _ref3.y;
774
827
  var hasX = offsets.hasOwnProperty('x');
775
828
  var hasY = offsets.hasOwnProperty('y');
776
829
  var sideX = left;
@@ -785,7 +838,7 @@ function mapToStyles(_ref2) {
785
838
  if (offsetParent === getWindow(popper)) {
786
839
  offsetParent = getDocumentElement(popper);
787
840
 
788
- if (getComputedStyle(offsetParent).position !== 'static') {
841
+ if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
789
842
  heightProp = 'scrollHeight';
790
843
  widthProp = 'scrollWidth';
791
844
  }
@@ -794,17 +847,19 @@ function mapToStyles(_ref2) {
794
847
 
795
848
  offsetParent = offsetParent;
796
849
 
797
- if (placement === top) {
798
- sideY = bottom; // $FlowFixMe[prop-missing]
799
-
800
- y -= offsetParent[heightProp] - popperRect.height;
850
+ if (placement === top || (placement === left || placement === right) && variation === end) {
851
+ sideY = bottom;
852
+ var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
853
+ offsetParent[heightProp];
854
+ y -= offsetY - popperRect.height;
801
855
  y *= gpuAcceleration ? 1 : -1;
802
856
  }
803
857
 
804
- if (placement === left) {
805
- sideX = right; // $FlowFixMe[prop-missing]
806
-
807
- x -= offsetParent[widthProp] - popperRect.width;
858
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
859
+ sideX = right;
860
+ var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
861
+ offsetParent[widthProp];
862
+ x -= offsetX - popperRect.width;
808
863
  x *= gpuAcceleration ? 1 : -1;
809
864
  }
810
865
  }
@@ -813,18 +868,29 @@ function mapToStyles(_ref2) {
813
868
  position: position
814
869
  }, adaptive && unsetSides);
815
870
 
871
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
872
+ x: x,
873
+ y: y
874
+ }) : {
875
+ x: x,
876
+ y: y
877
+ };
878
+
879
+ x = _ref4.x;
880
+ y = _ref4.y;
881
+
816
882
  if (gpuAcceleration) {
817
883
  var _Object$assign;
818
884
 
819
- return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
885
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
820
886
  }
821
887
 
822
888
  return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
823
889
  }
824
890
 
825
- function computeStyles(_ref4) {
826
- var state = _ref4.state,
827
- options = _ref4.options;
891
+ function computeStyles(_ref5) {
892
+ var state = _ref5.state,
893
+ options = _ref5.options;
828
894
  var _options$gpuAccelerat = options.gpuAcceleration,
829
895
  gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
830
896
  _options$adaptive = options.adaptive,
@@ -833,9 +899,11 @@ function computeStyles(_ref4) {
833
899
  roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
834
900
  var commonStyles = {
835
901
  placement: getBasePlacement(state.placement),
902
+ variation: getVariation(state.placement),
836
903
  popper: state.elements.popper,
837
904
  popperRect: state.rects.popper,
838
- gpuAcceleration: gpuAcceleration
905
+ gpuAcceleration: gpuAcceleration,
906
+ isFixed: state.options.strategy === 'fixed'
839
907
  };
840
908
 
841
909
  if (state.modifiersData.popperOffsets != null) {
@@ -1092,7 +1160,7 @@ function getInnerBoundingClientRect(element) {
1092
1160
  }
1093
1161
 
1094
1162
  function getClientRectFromMixedType(element, clippingParent) {
1095
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1163
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1096
1164
  } // A "clipping parent" is an overflowable container with the characteristic of
1097
1165
  // clipping (or hiding) overflowing elements with a position different from
1098
1166
  // `initial`
@@ -1134,10 +1202,6 @@ function getClippingRect(element, boundary, rootBoundary) {
1134
1202
  return clippingRect;
1135
1203
  }
1136
1204
 
1137
- function getVariation(placement) {
1138
- return placement.split('-')[1];
1139
- }
1140
-
1141
1205
  function computeOffsets(_ref) {
1142
1206
  var reference = _ref.reference,
1143
1207
  element = _ref.element,
@@ -1223,11 +1287,10 @@ function detectOverflow(state, options) {
1223
1287
  padding = _options$padding === void 0 ? 0 : _options$padding;
1224
1288
  var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1225
1289
  var altContext = elementContext === popper ? reference : popper;
1226
- var referenceElement = state.elements.reference;
1227
1290
  var popperRect = state.rects.popper;
1228
1291
  var element = state.elements[altBoundary ? altContext : elementContext];
1229
1292
  var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
1230
- var referenceClientRect = getBoundingClientRect(referenceElement);
1293
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
1231
1294
  var popperOffsets = computeOffsets({
1232
1295
  reference: referenceClientRect,
1233
1296
  element: popperRect,
@@ -1610,6 +1673,14 @@ function preventOverflow(_ref) {
1610
1673
  var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1611
1674
  placement: state.placement
1612
1675
  })) : tetherOffset;
1676
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
1677
+ mainAxis: tetherOffsetValue,
1678
+ altAxis: tetherOffsetValue
1679
+ } : Object.assign({
1680
+ mainAxis: 0,
1681
+ altAxis: 0
1682
+ }, tetherOffsetValue);
1683
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
1613
1684
  var data = {
1614
1685
  x: 0,
1615
1686
  y: 0
@@ -1619,13 +1690,15 @@ function preventOverflow(_ref) {
1619
1690
  return;
1620
1691
  }
1621
1692
 
1622
- if (checkMainAxis || checkAltAxis) {
1693
+ if (checkMainAxis) {
1694
+ var _offsetModifierState$;
1695
+
1623
1696
  var mainSide = mainAxis === 'y' ? top : left;
1624
1697
  var altSide = mainAxis === 'y' ? bottom : right;
1625
1698
  var len = mainAxis === 'y' ? 'height' : 'width';
1626
1699
  var offset = popperOffsets[mainAxis];
1627
- var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
1628
- var max$1 = popperOffsets[mainAxis] - overflow[altSide];
1700
+ var min$1 = offset + overflow[mainSide];
1701
+ var max$1 = offset - overflow[altSide];
1629
1702
  var additive = tether ? -popperRect[len] / 2 : 0;
1630
1703
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
1631
1704
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
@@ -1645,36 +1718,45 @@ function preventOverflow(_ref) {
1645
1718
  // width or height)
1646
1719
 
1647
1720
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1648
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
1649
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
1721
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
1722
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
1650
1723
  var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1651
1724
  var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1652
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
1653
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
1654
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
1725
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
1726
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
1727
+ var tetherMax = offset + maxOffset - offsetModifierValue;
1728
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1729
+ popperOffsets[mainAxis] = preventedOffset;
1730
+ data[mainAxis] = preventedOffset - offset;
1731
+ }
1655
1732
 
1656
- if (checkMainAxis) {
1657
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1658
- popperOffsets[mainAxis] = preventedOffset;
1659
- data[mainAxis] = preventedOffset - offset;
1660
- }
1733
+ if (checkAltAxis) {
1734
+ var _offsetModifierState$2;
1661
1735
 
1662
- if (checkAltAxis) {
1663
- var _mainSide = mainAxis === 'x' ? top : left;
1736
+ var _mainSide = mainAxis === 'x' ? top : left;
1664
1737
 
1665
- var _altSide = mainAxis === 'x' ? bottom : right;
1738
+ var _altSide = mainAxis === 'x' ? bottom : right;
1666
1739
 
1667
- var _offset = popperOffsets[altAxis];
1740
+ var _offset = popperOffsets[altAxis];
1668
1741
 
1669
- var _min = _offset + overflow[_mainSide];
1742
+ var _len = altAxis === 'y' ? 'height' : 'width';
1670
1743
 
1671
- var _max = _offset - overflow[_altSide];
1744
+ var _min = _offset + overflow[_mainSide];
1672
1745
 
1673
- var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
1746
+ var _max = _offset - overflow[_altSide];
1674
1747
 
1675
- popperOffsets[altAxis] = _preventedOffset;
1676
- data[altAxis] = _preventedOffset - _offset;
1677
- }
1748
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
1749
+
1750
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
1751
+
1752
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
1753
+
1754
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
1755
+
1756
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
1757
+
1758
+ popperOffsets[altAxis] = _preventedOffset;
1759
+ data[altAxis] = _preventedOffset - _offset;
1678
1760
  }
1679
1761
 
1680
1762
  state.modifiersData[name] = data;
@@ -1702,7 +1784,15 @@ function getNodeScroll(node) {
1702
1784
  } else {
1703
1785
  return getHTMLElementScroll(node);
1704
1786
  }
1705
- } // Composite means it takes into account transforms as well as layout.
1787
+ }
1788
+
1789
+ function isElementScaled(element) {
1790
+ var rect = element.getBoundingClientRect();
1791
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
1792
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
1793
+ return scaleX !== 1 || scaleY !== 1;
1794
+ } // Returns the composite rect of an element relative to its offsetParent.
1795
+ // Composite means it takes into account transforms as well as layout.
1706
1796
 
1707
1797
 
1708
1798
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
@@ -1710,9 +1800,10 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1710
1800
  isFixed = false;
1711
1801
  }
1712
1802
 
1713
- var documentElement = getDocumentElement(offsetParent);
1714
- var rect = getBoundingClientRect(elementOrVirtualElement);
1715
1803
  var isOffsetParentAnElement = isHTMLElement(offsetParent);
1804
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
1805
+ var documentElement = getDocumentElement(offsetParent);
1806
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
1716
1807
  var scroll = {
1717
1808
  scrollLeft: 0,
1718
1809
  scrollTop: 0
@@ -1729,7 +1820,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1729
1820
  }
1730
1821
 
1731
1822
  if (isHTMLElement(offsetParent)) {
1732
- offsets = getBoundingClientRect(offsetParent);
1823
+ offsets = getBoundingClientRect(offsetParent, true);
1733
1824
  offsets.x += offsetParent.clientLeft;
1734
1825
  offsets.y += offsetParent.clientTop;
1735
1826
  } else if (documentElement) {
@@ -1866,7 +1957,8 @@ function popperGenerator(generatorOptions) {
1866
1957
  var isDestroyed = false;
1867
1958
  var instance = {
1868
1959
  state: state,
1869
- setOptions: function setOptions(options) {
1960
+ setOptions: function setOptions(setOptionsAction) {
1961
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
1870
1962
  cleanupModifierEffects();
1871
1963
  state.options = Object.assign({}, defaultOptions, state.options, options);
1872
1964
  state.scrollParents = {
@@ -2013,7 +2105,7 @@ var createPopper = /*#__PURE__*/popperGenerator({
2013
2105
  }); // eslint-disable-next-line import/no-unused-modules
2014
2106
 
2015
2107
  function _extends() {
2016
- _extends = Object.assign || function (target) {
2108
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
2017
2109
  for (var i = 1; i < arguments.length; i++) {
2018
2110
  var source = arguments[i];
2019
2111
 
@@ -2026,7 +2118,6 @@ function _extends() {
2026
2118
 
2027
2119
  return target;
2028
2120
  };
2029
-
2030
2121
  return _extends.apply(this, arguments);
2031
2122
  }
2032
2123
 
@@ -2034,9 +2125,10 @@ function _getCenteredStylePopperModifier() {
2034
2125
  return [{
2035
2126
  name: 'applyStyles',
2036
2127
 
2037
- fn({
2038
- state
2039
- }) {
2128
+ fn(_ref) {
2129
+ let {
2130
+ state
2131
+ } = _ref;
2040
2132
  Object.keys(state.elements).forEach(name => {
2041
2133
  if (name !== 'popper') {
2042
2134
  return;
@@ -2121,9 +2213,9 @@ function normalizePrefix(prefix) {
2121
2213
  return prefix.charAt(prefix.length - 1) !== '-' ? `${prefix}-` : prefix;
2122
2214
  }
2123
2215
  /**
2124
- * Checks if options.attachTo.element is a string, and if so, tries to find the element
2216
+ * Resolves attachTo options, converting element option value to a qualified HTMLElement.
2125
2217
  * @param {Step} step The step instance
2126
- * @returns {{element, on}}
2218
+ * @returns {{}|{element, on}}
2127
2219
  * `element` is a qualified HTML Element
2128
2220
  * `on` is a string position value
2129
2221
  */
@@ -2133,11 +2225,16 @@ function parseAttachTo(step) {
2133
2225
  const options = step.options.attachTo || {};
2134
2226
  const returnOpts = Object.assign({}, options);
2135
2227
 
2136
- if (isString(options.element)) {
2228
+ if (isFunction(returnOpts.element)) {
2229
+ // Bind the callback to step so that it has access to the object, to enable running additional logic
2230
+ returnOpts.element = returnOpts.element.call(step);
2231
+ }
2232
+
2233
+ if (isString(returnOpts.element)) {
2137
2234
  // Can't override the element in user opts reference because we can't
2138
2235
  // guarantee that the element will exist in the future.
2139
2236
  try {
2140
- returnOpts.element = document.querySelector(options.element);
2237
+ returnOpts.element = document.querySelector(returnOpts.element);
2141
2238
  } catch (e) {// TODO
2142
2239
  }
2143
2240
 
@@ -2148,6 +2245,21 @@ function parseAttachTo(step) {
2148
2245
 
2149
2246
  return returnOpts;
2150
2247
  }
2248
+ /**
2249
+ * Checks if the step should be centered or not. Does not trigger attachTo.element evaluation, making it a pure
2250
+ * alternative for the deprecated step.isCentered() method.
2251
+ * @param resolvedAttachToOptions
2252
+ * @returns {boolean}
2253
+ */
2254
+
2255
+
2256
+ function shouldCenterStep(resolvedAttachToOptions) {
2257
+ if (resolvedAttachToOptions === undefined || resolvedAttachToOptions === null) {
2258
+ return true;
2259
+ }
2260
+
2261
+ return !resolvedAttachToOptions.element || !resolvedAttachToOptions.on;
2262
+ }
2151
2263
  /**
2152
2264
  * Determines options for the tooltip and initializes
2153
2265
  * `step.tooltip` as a Popper instance.
@@ -2160,11 +2272,12 @@ function setupTooltip(step) {
2160
2272
  step.tooltip.destroy();
2161
2273
  }
2162
2274
 
2163
- const attachToOptions = parseAttachTo(step);
2275
+ const attachToOptions = step._getResolvedAttachToOptions();
2276
+
2164
2277
  let target = attachToOptions.element;
2165
2278
  const popperOptions = getPopperOptions(attachToOptions, step);
2166
2279
 
2167
- if (step.isCentered()) {
2280
+ if (shouldCenterStep(attachToOptions)) {
2168
2281
  target = document.body;
2169
2282
  const content = step.shepherdElementComponent.getElement();
2170
2283
  content.classList.add('shepherd-centered');
@@ -2222,7 +2335,7 @@ function getPopperOptions(attachToOptions, step) {
2222
2335
  strategy: 'absolute'
2223
2336
  };
2224
2337
 
2225
- if (step.isCentered()) {
2338
+ if (shouldCenterStep(attachToOptions)) {
2226
2339
  popperOptions = makeCenteredPopper(step);
2227
2340
  } else {
2228
2341
  popperOptions.placement = attachToOptions.on;
@@ -2396,26 +2509,44 @@ function schedule_update() {
2396
2509
 
2397
2510
  function add_render_callback(fn) {
2398
2511
  render_callbacks.push(fn);
2399
- }
2512
+ } // 1. All beforeUpdate callbacks, in order: parents before children
2513
+ // 2. All bind:this callbacks, in reverse order: children before parents.
2514
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
2515
+ // for afterUpdates called during the initial onMount, which are called in
2516
+ // reverse order: children before parents.
2517
+ // Since callbacks might update component values, which could trigger another
2518
+ // call to flush(), the following steps guard against this:
2519
+ // 1. During beforeUpdate, any updated components will be added to the
2520
+ // dirty_components array and will cause a reentrant call to flush(). Because
2521
+ // the flush index is kept outside the function, the reentrant call will pick
2522
+ // up where the earlier call left off and go through all dirty components. The
2523
+ // current_component value is saved and restored so that the reentrant call will
2524
+ // not interfere with the "parent" flush() call.
2525
+ // 2. bind:this callbacks cannot trigger new flush() calls.
2526
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
2527
+ // callback called a second time; the seen_callbacks set, outside the flush()
2528
+ // function, guarantees this behavior.
2529
+
2400
2530
 
2401
- let flushing = false;
2402
2531
  const seen_callbacks = new Set();
2532
+ let flushidx = 0; // Do *not* move this inside the flush() function
2403
2533
 
2404
2534
  function flush() {
2405
- if (flushing) return;
2406
- flushing = true;
2535
+ const saved_component = current_component;
2407
2536
 
2408
2537
  do {
2409
2538
  // first, call beforeUpdate functions
2410
2539
  // and update components
2411
- for (let i = 0; i < dirty_components.length; i += 1) {
2412
- const component = dirty_components[i];
2540
+ while (flushidx < dirty_components.length) {
2541
+ const component = dirty_components[flushidx];
2542
+ flushidx++;
2413
2543
  set_current_component(component);
2414
2544
  update(component.$$);
2415
2545
  }
2416
2546
 
2417
2547
  set_current_component(null);
2418
2548
  dirty_components.length = 0;
2549
+ flushidx = 0;
2419
2550
 
2420
2551
  while (binding_callbacks.length) binding_callbacks.pop()(); // then, once components are updated, call
2421
2552
  // afterUpdate functions. This may cause
@@ -2440,8 +2571,8 @@ function flush() {
2440
2571
  }
2441
2572
 
2442
2573
  update_scheduled = false;
2443
- flushing = false;
2444
2574
  seen_callbacks.clear();
2575
+ set_current_component(saved_component);
2445
2576
  }
2446
2577
 
2447
2578
  function update($$) {
@@ -2593,7 +2724,11 @@ function make_dirty(component, i) {
2593
2724
  component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
2594
2725
  }
2595
2726
 
2596
- function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
2727
+ function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty) {
2728
+ if (dirty === void 0) {
2729
+ dirty = [-1];
2730
+ }
2731
+
2597
2732
  const parent_component = current_component;
2598
2733
  set_current_component(component);
2599
2734
  const $$ = component.$$ = {
@@ -2610,15 +2745,17 @@ function init(component, options, instance, create_fragment, not_equal, props, d
2610
2745
  on_disconnect: [],
2611
2746
  before_update: [],
2612
2747
  after_update: [],
2613
- context: new Map(parent_component ? parent_component.$$.context : options.context || []),
2748
+ context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
2614
2749
  // everything else
2615
2750
  callbacks: blank_object(),
2616
2751
  dirty,
2617
- skip_bound: false
2752
+ skip_bound: false,
2753
+ root: options.target || parent_component.$$.root
2618
2754
  };
2755
+ append_styles && append_styles($$.root);
2619
2756
  let ready = false;
2620
- $$.ctx = instance ? instance(component, options.props || {}, (i, ret, ...rest) => {
2621
- const value = rest.length ? rest[0] : ret;
2757
+ $$.ctx = instance ? instance(component, options.props || {}, function (i, ret) {
2758
+ const value = (arguments.length <= 2 ? 0 : arguments.length - 2) ? arguments.length <= 2 ? undefined : arguments[2] : ret;
2622
2759
 
2623
2760
  if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
2624
2761
  if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);
@@ -2680,7 +2817,7 @@ class SvelteComponent {
2680
2817
  }
2681
2818
 
2682
2819
  }
2683
- /* src/js/components/shepherd-button.svelte generated by Svelte v3.37.0 */
2820
+ /* src/js/components/shepherd-button.svelte generated by Svelte v3.48.0 */
2684
2821
 
2685
2822
 
2686
2823
  function create_fragment$8(ctx) {
@@ -2699,9 +2836,9 @@ function create_fragment$8(ctx) {
2699
2836
  ctx[3] : null);
2700
2837
  attr(button, "class", button_class_value = `${
2701
2838
  /*classes*/
2702
- ctx[1] || ""} shepherd-button ${
2839
+ ctx[1] || ''} shepherd-button ${
2703
2840
  /*secondary*/
2704
- ctx[4] ? "shepherd-button-secondary" : ""}`);
2841
+ ctx[4] ? 'shepherd-button-secondary' : ''}`);
2705
2842
  button.disabled =
2706
2843
  /*disabled*/
2707
2844
  ctx[2];
@@ -2726,7 +2863,8 @@ function create_fragment$8(ctx) {
2726
2863
  }
2727
2864
  },
2728
2865
 
2729
- p(new_ctx, [dirty]) {
2866
+ p(new_ctx, _ref) {
2867
+ let [dirty] = _ref;
2730
2868
  ctx = new_ctx;
2731
2869
  if (dirty &
2732
2870
  /*text*/
@@ -2748,9 +2886,9 @@ function create_fragment$8(ctx) {
2748
2886
  /*classes, secondary*/
2749
2887
  18 && button_class_value !== (button_class_value = `${
2750
2888
  /*classes*/
2751
- ctx[1] || ""} shepherd-button ${
2889
+ ctx[1] || ''} shepherd-button ${
2752
2890
  /*secondary*/
2753
- ctx[4] ? "shepherd-button-secondary" : ""}`)) {
2891
+ ctx[4] ? 'shepherd-button-secondary' : ''}`)) {
2754
2892
  attr(button, "class", button_class_value);
2755
2893
  }
2756
2894
 
@@ -2777,24 +2915,22 @@ function create_fragment$8(ctx) {
2777
2915
 
2778
2916
  function instance$8($$self, $$props, $$invalidate) {
2779
2917
  let {
2780
- config
2781
- } = $$props,
2782
- {
2918
+ config,
2783
2919
  step
2784
2920
  } = $$props;
2785
2921
  let action, classes, disabled, label, secondary, text;
2786
2922
 
2787
- function getDisabled(disabled) {
2788
- if (isFunction(disabled)) {
2789
- return disabled = disabled.call(step);
2923
+ function getConfigOption(option) {
2924
+ if (isFunction(option)) {
2925
+ return option = option.call(step);
2790
2926
  }
2791
2927
 
2792
- return disabled;
2928
+ return option;
2793
2929
  }
2794
2930
 
2795
2931
  $$self.$$set = $$props => {
2796
- if ("config" in $$props) $$invalidate(6, config = $$props.config);
2797
- if ("step" in $$props) $$invalidate(7, step = $$props.step);
2932
+ if ('config' in $$props) $$invalidate(6, config = $$props.config);
2933
+ if ('step' in $$props) $$invalidate(7, step = $$props.step);
2798
2934
  };
2799
2935
 
2800
2936
  $$self.$$.update = () => {
@@ -2804,10 +2940,10 @@ function instance$8($$self, $$props, $$invalidate) {
2804
2940
  {
2805
2941
  $$invalidate(0, action = config.action ? config.action.bind(step.tour) : null);
2806
2942
  $$invalidate(1, classes = config.classes);
2807
- $$invalidate(2, disabled = config.disabled ? getDisabled(config.disabled) : false);
2808
- $$invalidate(3, label = config.label);
2943
+ $$invalidate(2, disabled = config.disabled ? getConfigOption(config.disabled) : false);
2944
+ $$invalidate(3, label = config.label ? getConfigOption(config.label) : null);
2809
2945
  $$invalidate(4, secondary = config.secondary);
2810
- $$invalidate(5, text = config.text);
2946
+ $$invalidate(5, text = config.text ? getConfigOption(config.text) : null);
2811
2947
  }
2812
2948
  }
2813
2949
  };
@@ -2825,7 +2961,7 @@ class Shepherd_button extends SvelteComponent {
2825
2961
  }
2826
2962
 
2827
2963
  }
2828
- /* src/js/components/shepherd-footer.svelte generated by Svelte v3.37.0 */
2964
+ /* src/js/components/shepherd-footer.svelte generated by Svelte v3.48.0 */
2829
2965
 
2830
2966
 
2831
2967
  function get_each_context(ctx, list, i) {
@@ -3006,7 +3142,9 @@ function create_fragment$7(ctx) {
3006
3142
  current = true;
3007
3143
  },
3008
3144
 
3009
- p(ctx, [dirty]) {
3145
+ p(ctx, _ref) {
3146
+ let [dirty] = _ref;
3147
+
3010
3148
  if (
3011
3149
  /*buttons*/
3012
3150
  ctx[1]) {
@@ -3059,7 +3197,7 @@ function instance$7($$self, $$props, $$invalidate) {
3059
3197
  } = $$props;
3060
3198
 
3061
3199
  $$self.$$set = $$props => {
3062
- if ("step" in $$props) $$invalidate(0, step = $$props.step);
3200
+ if ('step' in $$props) $$invalidate(0, step = $$props.step);
3063
3201
  };
3064
3202
 
3065
3203
  $$self.$$.update = () => {
@@ -3082,7 +3220,7 @@ class Shepherd_footer extends SvelteComponent {
3082
3220
  }
3083
3221
 
3084
3222
  }
3085
- /* src/js/components/shepherd-cancel-icon.svelte generated by Svelte v3.37.0 */
3223
+ /* src/js/components/shepherd-cancel-icon.svelte generated by Svelte v3.48.0 */
3086
3224
 
3087
3225
 
3088
3226
  function create_fragment$6(ctx) {
@@ -3101,7 +3239,7 @@ function create_fragment$6(ctx) {
3101
3239
  /*cancelIcon*/
3102
3240
  ctx[0].label ?
3103
3241
  /*cancelIcon*/
3104
- ctx[0].label : "Close Tour");
3242
+ ctx[0].label : 'Close Tour');
3105
3243
  attr(button, "class", "shepherd-cancel-icon");
3106
3244
  attr(button, "type", "button");
3107
3245
  },
@@ -3118,14 +3256,16 @@ function create_fragment$6(ctx) {
3118
3256
  }
3119
3257
  },
3120
3258
 
3121
- p(ctx, [dirty]) {
3259
+ p(ctx, _ref) {
3260
+ let [dirty] = _ref;
3261
+
3122
3262
  if (dirty &
3123
3263
  /*cancelIcon*/
3124
3264
  1 && button_aria_label_value !== (button_aria_label_value =
3125
3265
  /*cancelIcon*/
3126
3266
  ctx[0].label ?
3127
3267
  /*cancelIcon*/
3128
- ctx[0].label : "Close Tour")) {
3268
+ ctx[0].label : 'Close Tour')) {
3129
3269
  attr(button, "aria-label", button_aria_label_value);
3130
3270
  }
3131
3271
  },
@@ -3144,9 +3284,7 @@ function create_fragment$6(ctx) {
3144
3284
 
3145
3285
  function instance$6($$self, $$props, $$invalidate) {
3146
3286
  let {
3147
- cancelIcon
3148
- } = $$props,
3149
- {
3287
+ cancelIcon,
3150
3288
  step
3151
3289
  } = $$props;
3152
3290
  /**
@@ -3159,8 +3297,8 @@ function instance$6($$self, $$props, $$invalidate) {
3159
3297
  };
3160
3298
 
3161
3299
  $$self.$$set = $$props => {
3162
- if ("cancelIcon" in $$props) $$invalidate(0, cancelIcon = $$props.cancelIcon);
3163
- if ("step" in $$props) $$invalidate(2, step = $$props.step);
3300
+ if ('cancelIcon' in $$props) $$invalidate(0, cancelIcon = $$props.cancelIcon);
3301
+ if ('step' in $$props) $$invalidate(2, step = $$props.step);
3164
3302
  };
3165
3303
 
3166
3304
  return [cancelIcon, handleCancelClick, step];
@@ -3176,7 +3314,7 @@ class Shepherd_cancel_icon extends SvelteComponent {
3176
3314
  }
3177
3315
 
3178
3316
  }
3179
- /* src/js/components/shepherd-title.svelte generated by Svelte v3.37.0 */
3317
+ /* src/js/components/shepherd-title.svelte generated by Svelte v3.48.0 */
3180
3318
 
3181
3319
 
3182
3320
  function create_fragment$5(ctx) {
@@ -3197,7 +3335,9 @@ function create_fragment$5(ctx) {
3197
3335
  ctx[3](h3);
3198
3336
  },
3199
3337
 
3200
- p(ctx, [dirty]) {
3338
+ p(ctx, _ref) {
3339
+ let [dirty] = _ref;
3340
+
3201
3341
  if (dirty &
3202
3342
  /*labelId*/
3203
3343
  2) {
@@ -3222,12 +3362,8 @@ function create_fragment$5(ctx) {
3222
3362
 
3223
3363
  function instance$5($$self, $$props, $$invalidate) {
3224
3364
  let {
3225
- labelId
3226
- } = $$props,
3227
- {
3228
- element
3229
- } = $$props,
3230
- {
3365
+ labelId,
3366
+ element,
3231
3367
  title
3232
3368
  } = $$props;
3233
3369
  afterUpdate(() => {
@@ -3239,16 +3375,16 @@ function instance$5($$self, $$props, $$invalidate) {
3239
3375
  });
3240
3376
 
3241
3377
  function h3_binding($$value) {
3242
- binding_callbacks[$$value ? "unshift" : "push"](() => {
3378
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
3243
3379
  element = $$value;
3244
3380
  $$invalidate(0, element);
3245
3381
  });
3246
3382
  }
3247
3383
 
3248
3384
  $$self.$$set = $$props => {
3249
- if ("labelId" in $$props) $$invalidate(1, labelId = $$props.labelId);
3250
- if ("element" in $$props) $$invalidate(0, element = $$props.element);
3251
- if ("title" in $$props) $$invalidate(2, title = $$props.title);
3385
+ if ('labelId' in $$props) $$invalidate(1, labelId = $$props.labelId);
3386
+ if ('element' in $$props) $$invalidate(0, element = $$props.element);
3387
+ if ('title' in $$props) $$invalidate(2, title = $$props.title);
3252
3388
  };
3253
3389
 
3254
3390
  return [element, labelId, title, h3_binding];
@@ -3265,7 +3401,7 @@ class Shepherd_title extends SvelteComponent {
3265
3401
  }
3266
3402
 
3267
3403
  }
3268
- /* src/js/components/shepherd-header.svelte generated by Svelte v3.37.0 */
3404
+ /* src/js/components/shepherd-header.svelte generated by Svelte v3.48.0 */
3269
3405
 
3270
3406
 
3271
3407
  function create_if_block_1$1(ctx) {
@@ -3410,7 +3546,9 @@ function create_fragment$4(ctx) {
3410
3546
  current = true;
3411
3547
  },
3412
3548
 
3413
- p(ctx, [dirty]) {
3549
+ p(ctx, _ref) {
3550
+ let [dirty] = _ref;
3551
+
3414
3552
  if (
3415
3553
  /*title*/
3416
3554
  ctx[2]) {
@@ -3488,16 +3626,14 @@ function create_fragment$4(ctx) {
3488
3626
 
3489
3627
  function instance$4($$self, $$props, $$invalidate) {
3490
3628
  let {
3491
- labelId
3492
- } = $$props,
3493
- {
3629
+ labelId,
3494
3630
  step
3495
3631
  } = $$props;
3496
3632
  let title, cancelIcon;
3497
3633
 
3498
3634
  $$self.$$set = $$props => {
3499
- if ("labelId" in $$props) $$invalidate(0, labelId = $$props.labelId);
3500
- if ("step" in $$props) $$invalidate(1, step = $$props.step);
3635
+ if ('labelId' in $$props) $$invalidate(0, labelId = $$props.labelId);
3636
+ if ('step' in $$props) $$invalidate(1, step = $$props.step);
3501
3637
  };
3502
3638
 
3503
3639
  $$self.$$.update = () => {
@@ -3524,7 +3660,7 @@ class Shepherd_header extends SvelteComponent {
3524
3660
  }
3525
3661
 
3526
3662
  }
3527
- /* src/js/components/shepherd-text.svelte generated by Svelte v3.37.0 */
3663
+ /* src/js/components/shepherd-text.svelte generated by Svelte v3.48.0 */
3528
3664
 
3529
3665
 
3530
3666
  function create_fragment$3(ctx) {
@@ -3545,7 +3681,9 @@ function create_fragment$3(ctx) {
3545
3681
  ctx[3](div);
3546
3682
  },
3547
3683
 
3548
- p(ctx, [dirty]) {
3684
+ p(ctx, _ref) {
3685
+ let [dirty] = _ref;
3686
+
3549
3687
  if (dirty &
3550
3688
  /*descriptionId*/
3551
3689
  2) {
@@ -3570,12 +3708,8 @@ function create_fragment$3(ctx) {
3570
3708
 
3571
3709
  function instance$3($$self, $$props, $$invalidate) {
3572
3710
  let {
3573
- descriptionId
3574
- } = $$props,
3575
- {
3576
- element
3577
- } = $$props,
3578
- {
3711
+ descriptionId,
3712
+ element,
3579
3713
  step
3580
3714
  } = $$props;
3581
3715
  afterUpdate(() => {
@@ -3595,16 +3729,16 @@ function instance$3($$self, $$props, $$invalidate) {
3595
3729
  });
3596
3730
 
3597
3731
  function div_binding($$value) {
3598
- binding_callbacks[$$value ? "unshift" : "push"](() => {
3732
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
3599
3733
  element = $$value;
3600
3734
  $$invalidate(0, element);
3601
3735
  });
3602
3736
  }
3603
3737
 
3604
3738
  $$self.$$set = $$props => {
3605
- if ("descriptionId" in $$props) $$invalidate(1, descriptionId = $$props.descriptionId);
3606
- if ("element" in $$props) $$invalidate(0, element = $$props.element);
3607
- if ("step" in $$props) $$invalidate(2, step = $$props.step);
3739
+ if ('descriptionId' in $$props) $$invalidate(1, descriptionId = $$props.descriptionId);
3740
+ if ('element' in $$props) $$invalidate(0, element = $$props.element);
3741
+ if ('step' in $$props) $$invalidate(2, step = $$props.step);
3608
3742
  };
3609
3743
 
3610
3744
  return [element, descriptionId, step, div_binding];
@@ -3621,7 +3755,7 @@ class Shepherd_text extends SvelteComponent {
3621
3755
  }
3622
3756
 
3623
3757
  }
3624
- /* src/js/components/shepherd-content.svelte generated by Svelte v3.37.0 */
3758
+ /* src/js/components/shepherd-content.svelte generated by Svelte v3.48.0 */
3625
3759
 
3626
3760
 
3627
3761
  function create_if_block_2(ctx) {
@@ -3830,7 +3964,8 @@ function create_fragment$2(ctx) {
3830
3964
  current = true;
3831
3965
  },
3832
3966
 
3833
- p(ctx, [dirty]) {
3967
+ p(ctx, _ref) {
3968
+ let [dirty] = _ref;
3834
3969
  if (dirty &
3835
3970
  /*step*/
3836
3971
  4) show_if_2 = !isUndefined(
@@ -3952,19 +4087,15 @@ function create_fragment$2(ctx) {
3952
4087
 
3953
4088
  function instance$2($$self, $$props, $$invalidate) {
3954
4089
  let {
3955
- descriptionId
3956
- } = $$props,
3957
- {
3958
- labelId
3959
- } = $$props,
3960
- {
4090
+ descriptionId,
4091
+ labelId,
3961
4092
  step
3962
4093
  } = $$props;
3963
4094
 
3964
4095
  $$self.$$set = $$props => {
3965
- if ("descriptionId" in $$props) $$invalidate(0, descriptionId = $$props.descriptionId);
3966
- if ("labelId" in $$props) $$invalidate(1, labelId = $$props.labelId);
3967
- if ("step" in $$props) $$invalidate(2, step = $$props.step);
4096
+ if ('descriptionId' in $$props) $$invalidate(0, descriptionId = $$props.descriptionId);
4097
+ if ('labelId' in $$props) $$invalidate(1, labelId = $$props.labelId);
4098
+ if ('step' in $$props) $$invalidate(2, step = $$props.step);
3968
4099
  };
3969
4100
 
3970
4101
  return [descriptionId, labelId, step];
@@ -3981,7 +4112,7 @@ class Shepherd_content extends SvelteComponent {
3981
4112
  }
3982
4113
 
3983
4114
  }
3984
- /* src/js/components/shepherd-element.svelte generated by Svelte v3.37.0 */
4115
+ /* src/js/components/shepherd-element.svelte generated by Svelte v3.48.0 */
3985
4116
 
3986
4117
 
3987
4118
  function create_if_block(ctx) {
@@ -4094,7 +4225,9 @@ function create_fragment$1(ctx) {
4094
4225
  }
4095
4226
  },
4096
4227
 
4097
- p(ctx, [dirty]) {
4228
+ p(ctx, _ref) {
4229
+ let [dirty] = _ref;
4230
+
4098
4231
  if (
4099
4232
  /*step*/
4100
4233
  ctx[4].options.arrow &&
@@ -4196,35 +4329,19 @@ const LEFT_ARROW = 37;
4196
4329
  const RIGHT_ARROW = 39;
4197
4330
 
4198
4331
  function getClassesArray(classes) {
4199
- return classes.split(" ").filter(className => !!className.length);
4332
+ return classes.split(' ').filter(className => !!className.length);
4200
4333
  }
4201
4334
 
4202
4335
  function instance$1($$self, $$props, $$invalidate) {
4203
4336
  let {
4204
- classPrefix
4205
- } = $$props,
4206
- {
4207
- element
4208
- } = $$props,
4209
- {
4210
- descriptionId
4211
- } = $$props,
4212
- {
4213
- firstFocusableElement
4214
- } = $$props,
4215
- {
4216
- focusableElements
4217
- } = $$props,
4218
- {
4219
- labelId
4220
- } = $$props,
4221
- {
4222
- lastFocusableElement
4223
- } = $$props,
4224
- {
4225
- step
4226
- } = $$props,
4227
- {
4337
+ classPrefix,
4338
+ element,
4339
+ descriptionId,
4340
+ firstFocusableElement,
4341
+ focusableElements,
4342
+ labelId,
4343
+ lastFocusableElement,
4344
+ step,
4228
4345
  dataStepId
4229
4346
  } = $$props;
4230
4347
  let hasCancelIcon, hasTitle, classes;
@@ -4236,7 +4353,7 @@ function instance$1($$self, $$props, $$invalidate) {
4236
4353
  $$invalidate(1, dataStepId = {
4237
4354
  [`data-${classPrefix}shepherd-step-id`]: step.id
4238
4355
  });
4239
- $$invalidate(9, focusableElements = element.querySelectorAll("a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex=\"0\"]"));
4356
+ $$invalidate(9, focusableElements = element.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'));
4240
4357
  $$invalidate(8, firstFocusableElement = focusableElements[0]);
4241
4358
  $$invalidate(10, lastFocusableElement = focusableElements[focusableElements.length - 1]);
4242
4359
  });
@@ -4294,7 +4411,7 @@ function instance$1($$self, $$props, $$invalidate) {
4294
4411
 
4295
4412
 
4296
4413
  if (e.shiftKey) {
4297
- if (document.activeElement === firstFocusableElement || document.activeElement.classList.contains("shepherd-element")) {
4414
+ if (document.activeElement === firstFocusableElement || document.activeElement.classList.contains('shepherd-element')) {
4298
4415
  e.preventDefault();
4299
4416
  lastFocusableElement.focus();
4300
4417
  }
@@ -4331,22 +4448,22 @@ function instance$1($$self, $$props, $$invalidate) {
4331
4448
  };
4332
4449
 
4333
4450
  function div_binding($$value) {
4334
- binding_callbacks[$$value ? "unshift" : "push"](() => {
4451
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
4335
4452
  element = $$value;
4336
4453
  $$invalidate(0, element);
4337
4454
  });
4338
4455
  }
4339
4456
 
4340
4457
  $$self.$$set = $$props => {
4341
- if ("classPrefix" in $$props) $$invalidate(11, classPrefix = $$props.classPrefix);
4342
- if ("element" in $$props) $$invalidate(0, element = $$props.element);
4343
- if ("descriptionId" in $$props) $$invalidate(2, descriptionId = $$props.descriptionId);
4344
- if ("firstFocusableElement" in $$props) $$invalidate(8, firstFocusableElement = $$props.firstFocusableElement);
4345
- if ("focusableElements" in $$props) $$invalidate(9, focusableElements = $$props.focusableElements);
4346
- if ("labelId" in $$props) $$invalidate(3, labelId = $$props.labelId);
4347
- if ("lastFocusableElement" in $$props) $$invalidate(10, lastFocusableElement = $$props.lastFocusableElement);
4348
- if ("step" in $$props) $$invalidate(4, step = $$props.step);
4349
- if ("dataStepId" in $$props) $$invalidate(1, dataStepId = $$props.dataStepId);
4458
+ if ('classPrefix' in $$props) $$invalidate(11, classPrefix = $$props.classPrefix);
4459
+ if ('element' in $$props) $$invalidate(0, element = $$props.element);
4460
+ if ('descriptionId' in $$props) $$invalidate(2, descriptionId = $$props.descriptionId);
4461
+ if ('firstFocusableElement' in $$props) $$invalidate(8, firstFocusableElement = $$props.firstFocusableElement);
4462
+ if ('focusableElements' in $$props) $$invalidate(9, focusableElements = $$props.focusableElements);
4463
+ if ('labelId' in $$props) $$invalidate(3, labelId = $$props.labelId);
4464
+ if ('lastFocusableElement' in $$props) $$invalidate(10, lastFocusableElement = $$props.lastFocusableElement);
4465
+ if ('step' in $$props) $$invalidate(4, step = $$props.step);
4466
+ if ('dataStepId' in $$props) $$invalidate(1, dataStepId = $$props.dataStepId);
4350
4467
  };
4351
4468
 
4352
4469
  $$self.$$.update = () => {
@@ -4756,10 +4873,11 @@ class Step extends Evented {
4756
4873
  * });
4757
4874
  * ```
4758
4875
  *
4759
- * If you don’t specify an attachTo the element will appear in the middle of the screen.
4876
+ * If you don’t specify an `attachTo` the element will appear in the middle of the screen. The same will happen if your `attachTo.element` callback returns `null`, `undefined`, or a selector that does not exist in the DOM.
4760
4877
  * If you omit the `on` portion of `attachTo`, the element will still be highlighted, but the tooltip will appear
4761
4878
  * in the middle of the screen, without an arrow pointing to the target.
4762
- * @param {HTMLElement|string} options.attachTo.element An element selector string or a DOM element.
4879
+ * If the element to highlight does not yet exist while instantiating tour steps, you may use lazy evaluation by supplying a function to `attachTo.element`. The function will be called in the `before-show` phase.
4880
+ * @param {string|HTMLElement|function} options.attachTo.element An element selector string, DOM element, or a function (returning a selector, a DOM element, `null` or `undefined`).
4763
4881
  * @param {string} options.attachTo.on The optional direction to place the Popper tooltip relative to the element.
4764
4882
  * - Possible string values: 'auto', 'auto-start', 'auto-end', 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'right', 'right-start', 'right-end', 'left', 'left-start', 'left-end'
4765
4883
  * @param {Object} options.advanceOn An action on the page which should advance shepherd to the next step.
@@ -4828,11 +4946,23 @@ class Step extends Evented {
4828
4946
  * ```
4829
4947
  * @return {Step} The newly created Step instance
4830
4948
  */
4831
- constructor(tour, options = {}) {
4949
+ constructor(tour, options) {
4950
+ if (options === void 0) {
4951
+ options = {};
4952
+ }
4953
+
4832
4954
  super(tour, options);
4833
4955
  this.tour = tour;
4834
4956
  this.classPrefix = this.tour.options ? normalizePrefix(this.tour.options.classPrefix) : '';
4835
4957
  this.styles = tour.styles;
4958
+ /**
4959
+ * Resolved attachTo options. Due to lazy evaluation, we only resolve the options during `before-show` phase.
4960
+ * Do not use this directly, use the _getResolvedAttachToOptions method instead.
4961
+ * @type {null|{}|{element, to}}
4962
+ * @private
4963
+ */
4964
+
4965
+ this._resolvedAttachTo = null;
4836
4966
  autoBind(this);
4837
4967
 
4838
4968
  this._setOptions(options);
@@ -4907,14 +5037,29 @@ class Step extends Evented {
4907
5037
  this.trigger('hide');
4908
5038
  }
4909
5039
  /**
4910
- * Checks if the step should be centered or not
4911
- * @return {boolean} True if the step is centered
5040
+ * Resolves attachTo options.
5041
+ * @returns {{}|{element, on}}
5042
+ * @private
4912
5043
  */
4913
5044
 
4914
5045
 
4915
- isCentered() {
4916
- const attachToOptions = parseAttachTo(this);
4917
- return !attachToOptions.element || !attachToOptions.on;
5046
+ _resolveAttachToOptions() {
5047
+ this._resolvedAttachTo = parseAttachTo(this);
5048
+ return this._resolvedAttachTo;
5049
+ }
5050
+ /**
5051
+ * A selector for resolved attachTo options.
5052
+ * @returns {{}|{element, on}}
5053
+ * @private
5054
+ */
5055
+
5056
+
5057
+ _getResolvedAttachToOptions() {
5058
+ if (this._resolvedAttachTo === null) {
5059
+ return this._resolveAttachToOptions();
5060
+ }
5061
+
5062
+ return this._resolvedAttachTo;
4918
5063
  }
4919
5064
  /**
4920
5065
  * Check if the step is open and visible
@@ -5012,7 +5157,7 @@ class Step extends Evented {
5012
5157
  _scrollTo(scrollToOptions) {
5013
5158
  const {
5014
5159
  element
5015
- } = parseAttachTo(this);
5160
+ } = this._getResolvedAttachToOptions();
5016
5161
 
5017
5162
  if (isFunction(this.options.scrollToHandler)) {
5018
5163
  this.options.scrollToHandler(element);
@@ -5043,7 +5188,11 @@ class Step extends Evented {
5043
5188
  */
5044
5189
 
5045
5190
 
5046
- _setOptions(options = {}) {
5191
+ _setOptions(options) {
5192
+ if (options === void 0) {
5193
+ options = {};
5194
+ }
5195
+
5047
5196
  let tourOptions = this.tour && this.tour.options && this.tour.options.defaultStepOptions;
5048
5197
  tourOptions = cjs({}, tourOptions || {});
5049
5198
  this.options = Object.assign({
@@ -5089,7 +5238,9 @@ class Step extends Evented {
5089
5238
 
5090
5239
 
5091
5240
  _show() {
5092
- this.trigger('before-show');
5241
+ this.trigger('before-show'); // Force resolve to make sure the options are updated on subsequent shows.
5242
+
5243
+ this._resolveAttachToOptions();
5093
5244
 
5094
5245
  this._setupElements();
5095
5246
 
@@ -5137,6 +5288,8 @@ class Step extends Evented {
5137
5288
  targetElement.classList.add(step.options.highlightClass);
5138
5289
  }
5139
5290
 
5291
+ targetElement.classList.remove('shepherd-target-click-disabled');
5292
+
5140
5293
  if (step.options.canClickTarget === false) {
5141
5294
  targetElement.classList.add('shepherd-target-click-disabled');
5142
5295
  }
@@ -5191,13 +5344,14 @@ function cleanupSteps(tour) {
5191
5344
  */
5192
5345
 
5193
5346
 
5194
- function makeOverlayPath({
5195
- width,
5196
- height,
5197
- x = 0,
5198
- y = 0,
5199
- r = 0
5200
- }) {
5347
+ function makeOverlayPath(_ref) {
5348
+ let {
5349
+ width,
5350
+ height,
5351
+ x = 0,
5352
+ y = 0,
5353
+ r = 0
5354
+ } = _ref;
5201
5355
  const {
5202
5356
  innerWidth: w,
5203
5357
  innerHeight: h
@@ -5218,7 +5372,7 @@ V${y + r}\
5218
5372
  a${r},${r},0,0,0-${r}-${r}\
5219
5373
  Z`;
5220
5374
  }
5221
- /* src/js/components/shepherd-modal.svelte generated by Svelte v3.37.0 */
5375
+ /* src/js/components/shepherd-modal.svelte generated by Svelte v3.48.0 */
5222
5376
 
5223
5377
 
5224
5378
  function create_fragment(ctx) {
@@ -5236,7 +5390,7 @@ function create_fragment(ctx) {
5236
5390
  ctx[2]);
5237
5391
  attr(svg, "class", svg_class_value = `${
5238
5392
  /*modalIsVisible*/
5239
- ctx[1] ? "shepherd-modal-is-visible" : ""} shepherd-modal-overlay-container`);
5393
+ ctx[1] ? 'shepherd-modal-is-visible' : ''} shepherd-modal-overlay-container`);
5240
5394
  },
5241
5395
 
5242
5396
  m(target, anchor) {
@@ -5254,7 +5408,9 @@ function create_fragment(ctx) {
5254
5408
  }
5255
5409
  },
5256
5410
 
5257
- p(ctx, [dirty]) {
5411
+ p(ctx, _ref) {
5412
+ let [dirty] = _ref;
5413
+
5258
5414
  if (dirty &
5259
5415
  /*pathDefinition*/
5260
5416
  4) {
@@ -5267,7 +5423,7 @@ function create_fragment(ctx) {
5267
5423
  /*modalIsVisible*/
5268
5424
  2 && svg_class_value !== (svg_class_value = `${
5269
5425
  /*modalIsVisible*/
5270
- ctx[1] ? "shepherd-modal-is-visible" : ""} shepherd-modal-overlay-container`)) {
5426
+ ctx[1] ? 'shepherd-modal-is-visible' : ''} shepherd-modal-overlay-container`)) {
5271
5427
  attr(svg, "class", svg_class_value);
5272
5428
  }
5273
5429
  },
@@ -5294,7 +5450,7 @@ function _getScrollParent(element) {
5294
5450
 
5295
5451
  const isHtmlElement = element instanceof HTMLElement;
5296
5452
  const overflowY = isHtmlElement && window.getComputedStyle(element).overflowY;
5297
- const isScrollable = overflowY !== "hidden" && overflowY !== "visible";
5453
+ const isScrollable = overflowY !== 'hidden' && overflowY !== 'visible';
5298
5454
 
5299
5455
  if (isScrollable && element.scrollHeight >= element.clientHeight) {
5300
5456
  return element;
@@ -5336,9 +5492,7 @@ function _getVisibleHeight(element, scrollParent) {
5336
5492
 
5337
5493
  function instance($$self, $$props, $$invalidate) {
5338
5494
  let {
5339
- element
5340
- } = $$props,
5341
- {
5495
+ element,
5342
5496
  openingProperties
5343
5497
  } = $$props;
5344
5498
  uuid();
@@ -5365,7 +5519,15 @@ function instance($$self, $$props, $$invalidate) {
5365
5519
  _cleanupStepEventListeners();
5366
5520
  }
5367
5521
 
5368
- function positionModal(modalOverlayOpeningPadding = 0, modalOverlayOpeningRadius = 0, scrollParent, targetElement) {
5522
+ function positionModal(modalOverlayOpeningPadding, modalOverlayOpeningRadius, scrollParent, targetElement) {
5523
+ if (modalOverlayOpeningPadding === void 0) {
5524
+ modalOverlayOpeningPadding = 0;
5525
+ }
5526
+
5527
+ if (modalOverlayOpeningRadius === void 0) {
5528
+ modalOverlayOpeningRadius = 0;
5529
+ }
5530
+
5369
5531
  if (targetElement) {
5370
5532
  const {
5371
5533
  y,
@@ -5422,7 +5584,7 @@ function instance($$self, $$props, $$invalidate) {
5422
5584
 
5423
5585
  function _addStepEventListeners() {
5424
5586
  // Prevents window from moving on touch.
5425
- window.addEventListener("touchmove", _preventModalBodyTouch, {
5587
+ window.addEventListener('touchmove', _preventModalBodyTouch, {
5426
5588
  passive: false
5427
5589
  });
5428
5590
  }
@@ -5438,7 +5600,7 @@ function instance($$self, $$props, $$invalidate) {
5438
5600
  rafId = undefined;
5439
5601
  }
5440
5602
 
5441
- window.removeEventListener("touchmove", _preventModalBodyTouch, {
5603
+ window.removeEventListener('touchmove', _preventModalBodyTouch, {
5442
5604
  passive: false
5443
5605
  });
5444
5606
  }
@@ -5470,15 +5632,15 @@ function instance($$self, $$props, $$invalidate) {
5470
5632
  }
5471
5633
 
5472
5634
  function svg_binding($$value) {
5473
- binding_callbacks[$$value ? "unshift" : "push"](() => {
5635
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
5474
5636
  element = $$value;
5475
5637
  $$invalidate(0, element);
5476
5638
  });
5477
5639
  }
5478
5640
 
5479
5641
  $$self.$$set = $$props => {
5480
- if ("element" in $$props) $$invalidate(0, element = $$props.element);
5481
- if ("openingProperties" in $$props) $$invalidate(4, openingProperties = $$props.openingProperties);
5642
+ if ('element' in $$props) $$invalidate(0, element = $$props.element);
5643
+ if ('openingProperties' in $$props) $$invalidate(4, openingProperties = $$props.openingProperties);
5482
5644
  };
5483
5645
 
5484
5646
  $$self.$$.update = () => {
@@ -5563,7 +5725,11 @@ class Tour extends Evented {
5563
5725
  * can remain interactive
5564
5726
  * @returns {Tour}
5565
5727
  */
5566
- constructor(options = {}) {
5728
+ constructor(options) {
5729
+ if (options === void 0) {
5730
+ options = {};
5731
+ }
5732
+
5567
5733
  super(options);
5568
5734
  autoBind(this);
5569
5735
  const defaultTourOptions = {
@@ -5757,7 +5923,15 @@ class Tour extends Evented {
5757
5923
  */
5758
5924
 
5759
5925
 
5760
- show(key = 0, forward = true) {
5926
+ show(key, forward) {
5927
+ if (key === void 0) {
5928
+ key = 0;
5929
+ }
5930
+
5931
+ if (forward === void 0) {
5932
+ forward = true;
5933
+ }
5934
+
5761
5935
  const step = isString(key) ? this.getById(key) : this.steps[key];
5762
5936
 
5763
5937
  if (step) {
@@ -5864,7 +6038,7 @@ class Tour extends Evented {
5864
6038
  });
5865
6039
  }
5866
6040
  /**
5867
- * Called when `showOn` evaluates to false, to skip the step
6041
+ * Called when `showOn` evaluates to false, to skip the step or complete the tour if it's the last step
5868
6042
  * @param {Step} step The step to skip
5869
6043
  * @param {Boolean} forward True if we are going forward, false if backward
5870
6044
  * @private
@@ -5873,8 +6047,13 @@ class Tour extends Evented {
5873
6047
 
5874
6048
  _skipStep(step, forward) {
5875
6049
  const index = this.steps.indexOf(step);
5876
- const nextIndex = forward ? index + 1 : index - 1;
5877
- this.show(nextIndex, forward);
6050
+
6051
+ if (index === this.steps.length - 1) {
6052
+ this.complete();
6053
+ } else {
6054
+ const nextIndex = forward ? index + 1 : index - 1;
6055
+ this.show(nextIndex, forward);
6056
+ }
5878
6057
  }
5879
6058
  /**
5880
6059
  * Before showing, hide the current step and if the tour is not
@@ -5929,9 +6108,7 @@ var addSteps = function (steps, tour) {
5929
6108
  step.buttons = buttons.map(function (button) {
5930
6109
  var action = button.action, classes = button.classes, disabled = button.disabled, label = button.label, secondary = button.secondary, text = button.text, type = button.type;
5931
6110
  return {
5932
- // TypeScript doesn't have great support for dynamic method calls with
5933
- // bracket notation, so we use the `any` escape hatch
5934
- action: tour[type] || action,
6111
+ action: type ? tour[type] : action,
5935
6112
  classes: classes,
5936
6113
  disabled: disabled,
5937
6114
  label: label,