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.
package/dist/Shepherd.js CHANGED
@@ -8,7 +8,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
10
 
11
- /*! shepherd.js 8.3.1 */
11
+ /*! shepherd.js 10.0.0 */
12
12
  var isMergeableObject = function isMergeableObject(value) {
13
13
  return isNonNullObject(value) && !isSpecial(value);
14
14
  };
@@ -179,7 +179,11 @@ function isUndefined(value) {
179
179
  }
180
180
 
181
181
  class Evented {
182
- on(event, handler, ctx, once = false) {
182
+ on(event, handler, ctx, once) {
183
+ if (once === void 0) {
184
+ once = false;
185
+ }
186
+
183
187
  if (isUndefined(this.bindings)) {
184
188
  this.bindings = {};
185
189
  }
@@ -218,7 +222,11 @@ class Evented {
218
222
  return this;
219
223
  }
220
224
 
221
- trigger(event, ...args) {
225
+ trigger(event) {
226
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
227
+ args[_key - 1] = arguments[_key];
228
+ }
229
+
222
230
  if (!isUndefined(this.bindings) && this.bindings[event]) {
223
231
  this.bindings[event].forEach((binding, index) => {
224
232
  const {
@@ -479,17 +487,42 @@ function getBasePlacement(placement) {
479
487
  return placement.split('-')[0];
480
488
  }
481
489
 
482
- function getBoundingClientRect(element) {
490
+ var max = Math.max;
491
+ var min = Math.min;
492
+ var round = Math.round;
493
+
494
+ function getBoundingClientRect(element, includeScale) {
495
+ if (includeScale === void 0) {
496
+ includeScale = false;
497
+ }
498
+
483
499
  var rect = element.getBoundingClientRect();
500
+ var scaleX = 1;
501
+ var scaleY = 1;
502
+
503
+ if (isHTMLElement(element) && includeScale) {
504
+ var offsetHeight = element.offsetHeight;
505
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
506
+ // Fallback to 1 in case both values are `0`
507
+
508
+ if (offsetWidth > 0) {
509
+ scaleX = round(rect.width) / offsetWidth || 1;
510
+ }
511
+
512
+ if (offsetHeight > 0) {
513
+ scaleY = round(rect.height) / offsetHeight || 1;
514
+ }
515
+ }
516
+
484
517
  return {
485
- width: rect.width,
486
- height: rect.height,
487
- top: rect.top,
488
- right: rect.right,
489
- bottom: rect.bottom,
490
- left: rect.left,
491
- x: rect.left,
492
- y: rect.top
518
+ width: rect.width / scaleX,
519
+ height: rect.height / scaleY,
520
+ top: rect.top / scaleY,
521
+ right: rect.right / scaleX,
522
+ bottom: rect.bottom / scaleY,
523
+ left: rect.left / scaleX,
524
+ x: rect.left / scaleX,
525
+ y: rect.top / scaleY
493
526
  };
494
527
  } // means it doesn't take into account transforms.
495
528
 
@@ -597,6 +630,10 @@ function getContainingBlock(element) {
597
630
 
598
631
  var currentNode = getParentNode(element);
599
632
 
633
+ if (isShadowRoot(currentNode)) {
634
+ currentNode = currentNode.host;
635
+ }
636
+
600
637
  while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
601
638
  var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
602
639
  // create a containing block.
@@ -633,14 +670,15 @@ function getMainAxisFromPlacement(placement) {
633
670
  return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
634
671
  }
635
672
 
636
- var max = Math.max;
637
- var min = Math.min;
638
- var round = Math.round;
639
-
640
673
  function within(min$1, value, max$1) {
641
674
  return max(min$1, min(value, max$1));
642
675
  }
643
676
 
677
+ function withinMaxClamp(min, value, max) {
678
+ var v = within(min, value, max);
679
+ return v > max ? max : v;
680
+ }
681
+
644
682
  function getFreshSideObject() {
645
683
  return {
646
684
  top: 0,
@@ -741,6 +779,11 @@ var arrow$1 = {
741
779
  requires: ['popperOffsets'],
742
780
  requiresIfExists: ['preventOverflow']
743
781
  };
782
+
783
+ function getVariation(placement) {
784
+ return placement.split('-')[1];
785
+ }
786
+
744
787
  var unsetSides = {
745
788
  top: 'auto',
746
789
  right: 'auto',
@@ -756,8 +799,8 @@ function roundOffsetsByDPR(_ref) {
756
799
  var win = window;
757
800
  var dpr = win.devicePixelRatio || 1;
758
801
  return {
759
- x: round(round(x * dpr) / dpr) || 0,
760
- y: round(round(y * dpr) / dpr) || 0
802
+ x: round(x * dpr) / dpr || 0,
803
+ y: round(y * dpr) / dpr || 0
761
804
  };
762
805
  }
763
806
 
@@ -767,18 +810,28 @@ function mapToStyles(_ref2) {
767
810
  var popper = _ref2.popper,
768
811
  popperRect = _ref2.popperRect,
769
812
  placement = _ref2.placement,
813
+ variation = _ref2.variation,
770
814
  offsets = _ref2.offsets,
771
815
  position = _ref2.position,
772
816
  gpuAcceleration = _ref2.gpuAcceleration,
773
817
  adaptive = _ref2.adaptive,
774
- roundOffsets = _ref2.roundOffsets;
775
-
776
- var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
777
- _ref3$x = _ref3.x,
778
- x = _ref3$x === void 0 ? 0 : _ref3$x,
779
- _ref3$y = _ref3.y,
780
- y = _ref3$y === void 0 ? 0 : _ref3$y;
818
+ roundOffsets = _ref2.roundOffsets,
819
+ isFixed = _ref2.isFixed;
820
+ var _offsets$x = offsets.x,
821
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
822
+ _offsets$y = offsets.y,
823
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
824
+
825
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
826
+ x: x,
827
+ y: y
828
+ }) : {
829
+ x: x,
830
+ y: y
831
+ };
781
832
 
833
+ x = _ref3.x;
834
+ y = _ref3.y;
782
835
  var hasX = offsets.hasOwnProperty('x');
783
836
  var hasY = offsets.hasOwnProperty('y');
784
837
  var sideX = left;
@@ -793,7 +846,7 @@ function mapToStyles(_ref2) {
793
846
  if (offsetParent === getWindow(popper)) {
794
847
  offsetParent = getDocumentElement(popper);
795
848
 
796
- if (getComputedStyle(offsetParent).position !== 'static') {
849
+ if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
797
850
  heightProp = 'scrollHeight';
798
851
  widthProp = 'scrollWidth';
799
852
  }
@@ -802,17 +855,19 @@ function mapToStyles(_ref2) {
802
855
 
803
856
  offsetParent = offsetParent;
804
857
 
805
- if (placement === top) {
806
- sideY = bottom; // $FlowFixMe[prop-missing]
807
-
808
- y -= offsetParent[heightProp] - popperRect.height;
858
+ if (placement === top || (placement === left || placement === right) && variation === end) {
859
+ sideY = bottom;
860
+ var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
861
+ offsetParent[heightProp];
862
+ y -= offsetY - popperRect.height;
809
863
  y *= gpuAcceleration ? 1 : -1;
810
864
  }
811
865
 
812
- if (placement === left) {
813
- sideX = right; // $FlowFixMe[prop-missing]
814
-
815
- x -= offsetParent[widthProp] - popperRect.width;
866
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
867
+ sideX = right;
868
+ var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
869
+ offsetParent[widthProp];
870
+ x -= offsetX - popperRect.width;
816
871
  x *= gpuAcceleration ? 1 : -1;
817
872
  }
818
873
  }
@@ -821,18 +876,29 @@ function mapToStyles(_ref2) {
821
876
  position: position
822
877
  }, adaptive && unsetSides);
823
878
 
879
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
880
+ x: x,
881
+ y: y
882
+ }) : {
883
+ x: x,
884
+ y: y
885
+ };
886
+
887
+ x = _ref4.x;
888
+ y = _ref4.y;
889
+
824
890
  if (gpuAcceleration) {
825
891
  var _Object$assign;
826
892
 
827
- 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));
893
+ 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));
828
894
  }
829
895
 
830
896
  return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
831
897
  }
832
898
 
833
- function computeStyles(_ref4) {
834
- var state = _ref4.state,
835
- options = _ref4.options;
899
+ function computeStyles(_ref5) {
900
+ var state = _ref5.state,
901
+ options = _ref5.options;
836
902
  var _options$gpuAccelerat = options.gpuAcceleration,
837
903
  gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
838
904
  _options$adaptive = options.adaptive,
@@ -841,9 +907,11 @@ function computeStyles(_ref4) {
841
907
  roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
842
908
  var commonStyles = {
843
909
  placement: getBasePlacement(state.placement),
910
+ variation: getVariation(state.placement),
844
911
  popper: state.elements.popper,
845
912
  popperRect: state.rects.popper,
846
- gpuAcceleration: gpuAcceleration
913
+ gpuAcceleration: gpuAcceleration,
914
+ isFixed: state.options.strategy === 'fixed'
847
915
  };
848
916
 
849
917
  if (state.modifiersData.popperOffsets != null) {
@@ -1100,7 +1168,7 @@ function getInnerBoundingClientRect(element) {
1100
1168
  }
1101
1169
 
1102
1170
  function getClientRectFromMixedType(element, clippingParent) {
1103
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1171
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1104
1172
  } // A "clipping parent" is an overflowable container with the characteristic of
1105
1173
  // clipping (or hiding) overflowing elements with a position different from
1106
1174
  // `initial`
@@ -1142,10 +1210,6 @@ function getClippingRect(element, boundary, rootBoundary) {
1142
1210
  return clippingRect;
1143
1211
  }
1144
1212
 
1145
- function getVariation(placement) {
1146
- return placement.split('-')[1];
1147
- }
1148
-
1149
1213
  function computeOffsets(_ref) {
1150
1214
  var reference = _ref.reference,
1151
1215
  element = _ref.element,
@@ -1231,11 +1295,10 @@ function detectOverflow(state, options) {
1231
1295
  padding = _options$padding === void 0 ? 0 : _options$padding;
1232
1296
  var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1233
1297
  var altContext = elementContext === popper ? reference : popper;
1234
- var referenceElement = state.elements.reference;
1235
1298
  var popperRect = state.rects.popper;
1236
1299
  var element = state.elements[altBoundary ? altContext : elementContext];
1237
1300
  var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
1238
- var referenceClientRect = getBoundingClientRect(referenceElement);
1301
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
1239
1302
  var popperOffsets = computeOffsets({
1240
1303
  reference: referenceClientRect,
1241
1304
  element: popperRect,
@@ -1618,6 +1681,14 @@ function preventOverflow(_ref) {
1618
1681
  var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1619
1682
  placement: state.placement
1620
1683
  })) : tetherOffset;
1684
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
1685
+ mainAxis: tetherOffsetValue,
1686
+ altAxis: tetherOffsetValue
1687
+ } : Object.assign({
1688
+ mainAxis: 0,
1689
+ altAxis: 0
1690
+ }, tetherOffsetValue);
1691
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
1621
1692
  var data = {
1622
1693
  x: 0,
1623
1694
  y: 0
@@ -1627,13 +1698,15 @@ function preventOverflow(_ref) {
1627
1698
  return;
1628
1699
  }
1629
1700
 
1630
- if (checkMainAxis || checkAltAxis) {
1701
+ if (checkMainAxis) {
1702
+ var _offsetModifierState$;
1703
+
1631
1704
  var mainSide = mainAxis === 'y' ? top : left;
1632
1705
  var altSide = mainAxis === 'y' ? bottom : right;
1633
1706
  var len = mainAxis === 'y' ? 'height' : 'width';
1634
1707
  var offset = popperOffsets[mainAxis];
1635
- var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
1636
- var max$1 = popperOffsets[mainAxis] - overflow[altSide];
1708
+ var min$1 = offset + overflow[mainSide];
1709
+ var max$1 = offset - overflow[altSide];
1637
1710
  var additive = tether ? -popperRect[len] / 2 : 0;
1638
1711
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
1639
1712
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
@@ -1653,36 +1726,45 @@ function preventOverflow(_ref) {
1653
1726
  // width or height)
1654
1727
 
1655
1728
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1656
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
1657
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
1729
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
1730
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
1658
1731
  var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1659
1732
  var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1660
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
1661
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
1662
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
1733
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
1734
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
1735
+ var tetherMax = offset + maxOffset - offsetModifierValue;
1736
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1737
+ popperOffsets[mainAxis] = preventedOffset;
1738
+ data[mainAxis] = preventedOffset - offset;
1739
+ }
1663
1740
 
1664
- if (checkMainAxis) {
1665
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1666
- popperOffsets[mainAxis] = preventedOffset;
1667
- data[mainAxis] = preventedOffset - offset;
1668
- }
1741
+ if (checkAltAxis) {
1742
+ var _offsetModifierState$2;
1669
1743
 
1670
- if (checkAltAxis) {
1671
- var _mainSide = mainAxis === 'x' ? top : left;
1744
+ var _mainSide = mainAxis === 'x' ? top : left;
1672
1745
 
1673
- var _altSide = mainAxis === 'x' ? bottom : right;
1746
+ var _altSide = mainAxis === 'x' ? bottom : right;
1674
1747
 
1675
- var _offset = popperOffsets[altAxis];
1748
+ var _offset = popperOffsets[altAxis];
1676
1749
 
1677
- var _min = _offset + overflow[_mainSide];
1750
+ var _len = altAxis === 'y' ? 'height' : 'width';
1678
1751
 
1679
- var _max = _offset - overflow[_altSide];
1752
+ var _min = _offset + overflow[_mainSide];
1680
1753
 
1681
- var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
1754
+ var _max = _offset - overflow[_altSide];
1682
1755
 
1683
- popperOffsets[altAxis] = _preventedOffset;
1684
- data[altAxis] = _preventedOffset - _offset;
1685
- }
1756
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
1757
+
1758
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
1759
+
1760
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
1761
+
1762
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
1763
+
1764
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
1765
+
1766
+ popperOffsets[altAxis] = _preventedOffset;
1767
+ data[altAxis] = _preventedOffset - _offset;
1686
1768
  }
1687
1769
 
1688
1770
  state.modifiersData[name] = data;
@@ -1710,7 +1792,15 @@ function getNodeScroll(node) {
1710
1792
  } else {
1711
1793
  return getHTMLElementScroll(node);
1712
1794
  }
1713
- } // Composite means it takes into account transforms as well as layout.
1795
+ }
1796
+
1797
+ function isElementScaled(element) {
1798
+ var rect = element.getBoundingClientRect();
1799
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
1800
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
1801
+ return scaleX !== 1 || scaleY !== 1;
1802
+ } // Returns the composite rect of an element relative to its offsetParent.
1803
+ // Composite means it takes into account transforms as well as layout.
1714
1804
 
1715
1805
 
1716
1806
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
@@ -1718,9 +1808,10 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1718
1808
  isFixed = false;
1719
1809
  }
1720
1810
 
1721
- var documentElement = getDocumentElement(offsetParent);
1722
- var rect = getBoundingClientRect(elementOrVirtualElement);
1723
1811
  var isOffsetParentAnElement = isHTMLElement(offsetParent);
1812
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
1813
+ var documentElement = getDocumentElement(offsetParent);
1814
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
1724
1815
  var scroll = {
1725
1816
  scrollLeft: 0,
1726
1817
  scrollTop: 0
@@ -1737,7 +1828,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1737
1828
  }
1738
1829
 
1739
1830
  if (isHTMLElement(offsetParent)) {
1740
- offsets = getBoundingClientRect(offsetParent);
1831
+ offsets = getBoundingClientRect(offsetParent, true);
1741
1832
  offsets.x += offsetParent.clientLeft;
1742
1833
  offsets.y += offsetParent.clientTop;
1743
1834
  } else if (documentElement) {
@@ -1874,7 +1965,8 @@ function popperGenerator(generatorOptions) {
1874
1965
  var isDestroyed = false;
1875
1966
  var instance = {
1876
1967
  state: state,
1877
- setOptions: function setOptions(options) {
1968
+ setOptions: function setOptions(setOptionsAction) {
1969
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
1878
1970
  cleanupModifierEffects();
1879
1971
  state.options = Object.assign({}, defaultOptions, state.options, options);
1880
1972
  state.scrollParents = {
@@ -2021,7 +2113,7 @@ var createPopper = /*#__PURE__*/popperGenerator({
2021
2113
  }); // eslint-disable-next-line import/no-unused-modules
2022
2114
 
2023
2115
  function _extends() {
2024
- _extends = Object.assign || function (target) {
2116
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
2025
2117
  for (var i = 1; i < arguments.length; i++) {
2026
2118
  var source = arguments[i];
2027
2119
 
@@ -2034,7 +2126,6 @@ function _extends() {
2034
2126
 
2035
2127
  return target;
2036
2128
  };
2037
-
2038
2129
  return _extends.apply(this, arguments);
2039
2130
  }
2040
2131
 
@@ -2042,9 +2133,10 @@ function _getCenteredStylePopperModifier() {
2042
2133
  return [{
2043
2134
  name: 'applyStyles',
2044
2135
 
2045
- fn({
2046
- state
2047
- }) {
2136
+ fn(_ref) {
2137
+ let {
2138
+ state
2139
+ } = _ref;
2048
2140
  Object.keys(state.elements).forEach(name => {
2049
2141
  if (name !== 'popper') {
2050
2142
  return;
@@ -2129,9 +2221,9 @@ function normalizePrefix(prefix) {
2129
2221
  return prefix.charAt(prefix.length - 1) !== '-' ? `${prefix}-` : prefix;
2130
2222
  }
2131
2223
  /**
2132
- * Checks if options.attachTo.element is a string, and if so, tries to find the element
2224
+ * Resolves attachTo options, converting element option value to a qualified HTMLElement.
2133
2225
  * @param {Step} step The step instance
2134
- * @returns {{element, on}}
2226
+ * @returns {{}|{element, on}}
2135
2227
  * `element` is a qualified HTML Element
2136
2228
  * `on` is a string position value
2137
2229
  */
@@ -2141,11 +2233,16 @@ function parseAttachTo(step) {
2141
2233
  const options = step.options.attachTo || {};
2142
2234
  const returnOpts = Object.assign({}, options);
2143
2235
 
2144
- if (isString(options.element)) {
2236
+ if (isFunction(returnOpts.element)) {
2237
+ // Bind the callback to step so that it has access to the object, to enable running additional logic
2238
+ returnOpts.element = returnOpts.element.call(step);
2239
+ }
2240
+
2241
+ if (isString(returnOpts.element)) {
2145
2242
  // Can't override the element in user opts reference because we can't
2146
2243
  // guarantee that the element will exist in the future.
2147
2244
  try {
2148
- returnOpts.element = document.querySelector(options.element);
2245
+ returnOpts.element = document.querySelector(returnOpts.element);
2149
2246
  } catch (e) {// TODO
2150
2247
  }
2151
2248
 
@@ -2156,6 +2253,21 @@ function parseAttachTo(step) {
2156
2253
 
2157
2254
  return returnOpts;
2158
2255
  }
2256
+ /**
2257
+ * Checks if the step should be centered or not. Does not trigger attachTo.element evaluation, making it a pure
2258
+ * alternative for the deprecated step.isCentered() method.
2259
+ * @param resolvedAttachToOptions
2260
+ * @returns {boolean}
2261
+ */
2262
+
2263
+
2264
+ function shouldCenterStep(resolvedAttachToOptions) {
2265
+ if (resolvedAttachToOptions === undefined || resolvedAttachToOptions === null) {
2266
+ return true;
2267
+ }
2268
+
2269
+ return !resolvedAttachToOptions.element || !resolvedAttachToOptions.on;
2270
+ }
2159
2271
  /**
2160
2272
  * Determines options for the tooltip and initializes
2161
2273
  * `step.tooltip` as a Popper instance.
@@ -2168,11 +2280,12 @@ function setupTooltip(step) {
2168
2280
  step.tooltip.destroy();
2169
2281
  }
2170
2282
 
2171
- const attachToOptions = parseAttachTo(step);
2283
+ const attachToOptions = step._getResolvedAttachToOptions();
2284
+
2172
2285
  let target = attachToOptions.element;
2173
2286
  const popperOptions = getPopperOptions(attachToOptions, step);
2174
2287
 
2175
- if (step.isCentered()) {
2288
+ if (shouldCenterStep(attachToOptions)) {
2176
2289
  target = document.body;
2177
2290
  const content = step.shepherdElementComponent.getElement();
2178
2291
  content.classList.add('shepherd-centered');
@@ -2230,7 +2343,7 @@ function getPopperOptions(attachToOptions, step) {
2230
2343
  strategy: 'absolute'
2231
2344
  };
2232
2345
 
2233
- if (step.isCentered()) {
2346
+ if (shouldCenterStep(attachToOptions)) {
2234
2347
  popperOptions = makeCenteredPopper(step);
2235
2348
  } else {
2236
2349
  popperOptions.placement = attachToOptions.on;
@@ -2404,26 +2517,44 @@ function schedule_update() {
2404
2517
 
2405
2518
  function add_render_callback(fn) {
2406
2519
  render_callbacks.push(fn);
2407
- }
2520
+ } // 1. All beforeUpdate callbacks, in order: parents before children
2521
+ // 2. All bind:this callbacks, in reverse order: children before parents.
2522
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
2523
+ // for afterUpdates called during the initial onMount, which are called in
2524
+ // reverse order: children before parents.
2525
+ // Since callbacks might update component values, which could trigger another
2526
+ // call to flush(), the following steps guard against this:
2527
+ // 1. During beforeUpdate, any updated components will be added to the
2528
+ // dirty_components array and will cause a reentrant call to flush(). Because
2529
+ // the flush index is kept outside the function, the reentrant call will pick
2530
+ // up where the earlier call left off and go through all dirty components. The
2531
+ // current_component value is saved and restored so that the reentrant call will
2532
+ // not interfere with the "parent" flush() call.
2533
+ // 2. bind:this callbacks cannot trigger new flush() calls.
2534
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
2535
+ // callback called a second time; the seen_callbacks set, outside the flush()
2536
+ // function, guarantees this behavior.
2537
+
2408
2538
 
2409
- let flushing = false;
2410
2539
  const seen_callbacks = new Set();
2540
+ let flushidx = 0; // Do *not* move this inside the flush() function
2411
2541
 
2412
2542
  function flush() {
2413
- if (flushing) return;
2414
- flushing = true;
2543
+ const saved_component = current_component;
2415
2544
 
2416
2545
  do {
2417
2546
  // first, call beforeUpdate functions
2418
2547
  // and update components
2419
- for (let i = 0; i < dirty_components.length; i += 1) {
2420
- const component = dirty_components[i];
2548
+ while (flushidx < dirty_components.length) {
2549
+ const component = dirty_components[flushidx];
2550
+ flushidx++;
2421
2551
  set_current_component(component);
2422
2552
  update(component.$$);
2423
2553
  }
2424
2554
 
2425
2555
  set_current_component(null);
2426
2556
  dirty_components.length = 0;
2557
+ flushidx = 0;
2427
2558
 
2428
2559
  while (binding_callbacks.length) binding_callbacks.pop()(); // then, once components are updated, call
2429
2560
  // afterUpdate functions. This may cause
@@ -2448,8 +2579,8 @@ function flush() {
2448
2579
  }
2449
2580
 
2450
2581
  update_scheduled = false;
2451
- flushing = false;
2452
2582
  seen_callbacks.clear();
2583
+ set_current_component(saved_component);
2453
2584
  }
2454
2585
 
2455
2586
  function update($$) {
@@ -2601,7 +2732,11 @@ function make_dirty(component, i) {
2601
2732
  component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
2602
2733
  }
2603
2734
 
2604
- function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
2735
+ function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty) {
2736
+ if (dirty === void 0) {
2737
+ dirty = [-1];
2738
+ }
2739
+
2605
2740
  const parent_component = current_component;
2606
2741
  set_current_component(component);
2607
2742
  const $$ = component.$$ = {
@@ -2618,15 +2753,17 @@ function init(component, options, instance, create_fragment, not_equal, props, d
2618
2753
  on_disconnect: [],
2619
2754
  before_update: [],
2620
2755
  after_update: [],
2621
- context: new Map(parent_component ? parent_component.$$.context : options.context || []),
2756
+ context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
2622
2757
  // everything else
2623
2758
  callbacks: blank_object(),
2624
2759
  dirty,
2625
- skip_bound: false
2760
+ skip_bound: false,
2761
+ root: options.target || parent_component.$$.root
2626
2762
  };
2763
+ append_styles && append_styles($$.root);
2627
2764
  let ready = false;
2628
- $$.ctx = instance ? instance(component, options.props || {}, (i, ret, ...rest) => {
2629
- const value = rest.length ? rest[0] : ret;
2765
+ $$.ctx = instance ? instance(component, options.props || {}, function (i, ret) {
2766
+ const value = (arguments.length <= 2 ? 0 : arguments.length - 2) ? arguments.length <= 2 ? undefined : arguments[2] : ret;
2630
2767
 
2631
2768
  if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
2632
2769
  if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);
@@ -2688,7 +2825,7 @@ class SvelteComponent {
2688
2825
  }
2689
2826
 
2690
2827
  }
2691
- /* src/js/components/shepherd-button.svelte generated by Svelte v3.37.0 */
2828
+ /* src/js/components/shepherd-button.svelte generated by Svelte v3.48.0 */
2692
2829
 
2693
2830
 
2694
2831
  function create_fragment$8(ctx) {
@@ -2707,9 +2844,9 @@ function create_fragment$8(ctx) {
2707
2844
  ctx[3] : null);
2708
2845
  attr(button, "class", button_class_value = `${
2709
2846
  /*classes*/
2710
- ctx[1] || ""} shepherd-button ${
2847
+ ctx[1] || ''} shepherd-button ${
2711
2848
  /*secondary*/
2712
- ctx[4] ? "shepherd-button-secondary" : ""}`);
2849
+ ctx[4] ? 'shepherd-button-secondary' : ''}`);
2713
2850
  button.disabled =
2714
2851
  /*disabled*/
2715
2852
  ctx[2];
@@ -2734,7 +2871,8 @@ function create_fragment$8(ctx) {
2734
2871
  }
2735
2872
  },
2736
2873
 
2737
- p(new_ctx, [dirty]) {
2874
+ p(new_ctx, _ref) {
2875
+ let [dirty] = _ref;
2738
2876
  ctx = new_ctx;
2739
2877
  if (dirty &
2740
2878
  /*text*/
@@ -2756,9 +2894,9 @@ function create_fragment$8(ctx) {
2756
2894
  /*classes, secondary*/
2757
2895
  18 && button_class_value !== (button_class_value = `${
2758
2896
  /*classes*/
2759
- ctx[1] || ""} shepherd-button ${
2897
+ ctx[1] || ''} shepherd-button ${
2760
2898
  /*secondary*/
2761
- ctx[4] ? "shepherd-button-secondary" : ""}`)) {
2899
+ ctx[4] ? 'shepherd-button-secondary' : ''}`)) {
2762
2900
  attr(button, "class", button_class_value);
2763
2901
  }
2764
2902
 
@@ -2785,24 +2923,22 @@ function create_fragment$8(ctx) {
2785
2923
 
2786
2924
  function instance$8($$self, $$props, $$invalidate) {
2787
2925
  let {
2788
- config
2789
- } = $$props,
2790
- {
2926
+ config,
2791
2927
  step
2792
2928
  } = $$props;
2793
2929
  let action, classes, disabled, label, secondary, text;
2794
2930
 
2795
- function getDisabled(disabled) {
2796
- if (isFunction(disabled)) {
2797
- return disabled = disabled.call(step);
2931
+ function getConfigOption(option) {
2932
+ if (isFunction(option)) {
2933
+ return option = option.call(step);
2798
2934
  }
2799
2935
 
2800
- return disabled;
2936
+ return option;
2801
2937
  }
2802
2938
 
2803
2939
  $$self.$$set = $$props => {
2804
- if ("config" in $$props) $$invalidate(6, config = $$props.config);
2805
- if ("step" in $$props) $$invalidate(7, step = $$props.step);
2940
+ if ('config' in $$props) $$invalidate(6, config = $$props.config);
2941
+ if ('step' in $$props) $$invalidate(7, step = $$props.step);
2806
2942
  };
2807
2943
 
2808
2944
  $$self.$$.update = () => {
@@ -2812,10 +2948,10 @@ function instance$8($$self, $$props, $$invalidate) {
2812
2948
  {
2813
2949
  $$invalidate(0, action = config.action ? config.action.bind(step.tour) : null);
2814
2950
  $$invalidate(1, classes = config.classes);
2815
- $$invalidate(2, disabled = config.disabled ? getDisabled(config.disabled) : false);
2816
- $$invalidate(3, label = config.label);
2951
+ $$invalidate(2, disabled = config.disabled ? getConfigOption(config.disabled) : false);
2952
+ $$invalidate(3, label = config.label ? getConfigOption(config.label) : null);
2817
2953
  $$invalidate(4, secondary = config.secondary);
2818
- $$invalidate(5, text = config.text);
2954
+ $$invalidate(5, text = config.text ? getConfigOption(config.text) : null);
2819
2955
  }
2820
2956
  }
2821
2957
  };
@@ -2833,7 +2969,7 @@ class Shepherd_button extends SvelteComponent {
2833
2969
  }
2834
2970
 
2835
2971
  }
2836
- /* src/js/components/shepherd-footer.svelte generated by Svelte v3.37.0 */
2972
+ /* src/js/components/shepherd-footer.svelte generated by Svelte v3.48.0 */
2837
2973
 
2838
2974
 
2839
2975
  function get_each_context(ctx, list, i) {
@@ -3014,7 +3150,9 @@ function create_fragment$7(ctx) {
3014
3150
  current = true;
3015
3151
  },
3016
3152
 
3017
- p(ctx, [dirty]) {
3153
+ p(ctx, _ref) {
3154
+ let [dirty] = _ref;
3155
+
3018
3156
  if (
3019
3157
  /*buttons*/
3020
3158
  ctx[1]) {
@@ -3067,7 +3205,7 @@ function instance$7($$self, $$props, $$invalidate) {
3067
3205
  } = $$props;
3068
3206
 
3069
3207
  $$self.$$set = $$props => {
3070
- if ("step" in $$props) $$invalidate(0, step = $$props.step);
3208
+ if ('step' in $$props) $$invalidate(0, step = $$props.step);
3071
3209
  };
3072
3210
 
3073
3211
  $$self.$$.update = () => {
@@ -3090,7 +3228,7 @@ class Shepherd_footer extends SvelteComponent {
3090
3228
  }
3091
3229
 
3092
3230
  }
3093
- /* src/js/components/shepherd-cancel-icon.svelte generated by Svelte v3.37.0 */
3231
+ /* src/js/components/shepherd-cancel-icon.svelte generated by Svelte v3.48.0 */
3094
3232
 
3095
3233
 
3096
3234
  function create_fragment$6(ctx) {
@@ -3109,7 +3247,7 @@ function create_fragment$6(ctx) {
3109
3247
  /*cancelIcon*/
3110
3248
  ctx[0].label ?
3111
3249
  /*cancelIcon*/
3112
- ctx[0].label : "Close Tour");
3250
+ ctx[0].label : 'Close Tour');
3113
3251
  attr(button, "class", "shepherd-cancel-icon");
3114
3252
  attr(button, "type", "button");
3115
3253
  },
@@ -3126,14 +3264,16 @@ function create_fragment$6(ctx) {
3126
3264
  }
3127
3265
  },
3128
3266
 
3129
- p(ctx, [dirty]) {
3267
+ p(ctx, _ref) {
3268
+ let [dirty] = _ref;
3269
+
3130
3270
  if (dirty &
3131
3271
  /*cancelIcon*/
3132
3272
  1 && button_aria_label_value !== (button_aria_label_value =
3133
3273
  /*cancelIcon*/
3134
3274
  ctx[0].label ?
3135
3275
  /*cancelIcon*/
3136
- ctx[0].label : "Close Tour")) {
3276
+ ctx[0].label : 'Close Tour')) {
3137
3277
  attr(button, "aria-label", button_aria_label_value);
3138
3278
  }
3139
3279
  },
@@ -3152,9 +3292,7 @@ function create_fragment$6(ctx) {
3152
3292
 
3153
3293
  function instance$6($$self, $$props, $$invalidate) {
3154
3294
  let {
3155
- cancelIcon
3156
- } = $$props,
3157
- {
3295
+ cancelIcon,
3158
3296
  step
3159
3297
  } = $$props;
3160
3298
  /**
@@ -3167,8 +3305,8 @@ function instance$6($$self, $$props, $$invalidate) {
3167
3305
  };
3168
3306
 
3169
3307
  $$self.$$set = $$props => {
3170
- if ("cancelIcon" in $$props) $$invalidate(0, cancelIcon = $$props.cancelIcon);
3171
- if ("step" in $$props) $$invalidate(2, step = $$props.step);
3308
+ if ('cancelIcon' in $$props) $$invalidate(0, cancelIcon = $$props.cancelIcon);
3309
+ if ('step' in $$props) $$invalidate(2, step = $$props.step);
3172
3310
  };
3173
3311
 
3174
3312
  return [cancelIcon, handleCancelClick, step];
@@ -3184,7 +3322,7 @@ class Shepherd_cancel_icon extends SvelteComponent {
3184
3322
  }
3185
3323
 
3186
3324
  }
3187
- /* src/js/components/shepherd-title.svelte generated by Svelte v3.37.0 */
3325
+ /* src/js/components/shepherd-title.svelte generated by Svelte v3.48.0 */
3188
3326
 
3189
3327
 
3190
3328
  function create_fragment$5(ctx) {
@@ -3205,7 +3343,9 @@ function create_fragment$5(ctx) {
3205
3343
  ctx[3](h3);
3206
3344
  },
3207
3345
 
3208
- p(ctx, [dirty]) {
3346
+ p(ctx, _ref) {
3347
+ let [dirty] = _ref;
3348
+
3209
3349
  if (dirty &
3210
3350
  /*labelId*/
3211
3351
  2) {
@@ -3230,12 +3370,8 @@ function create_fragment$5(ctx) {
3230
3370
 
3231
3371
  function instance$5($$self, $$props, $$invalidate) {
3232
3372
  let {
3233
- labelId
3234
- } = $$props,
3235
- {
3236
- element
3237
- } = $$props,
3238
- {
3373
+ labelId,
3374
+ element,
3239
3375
  title
3240
3376
  } = $$props;
3241
3377
  afterUpdate(() => {
@@ -3247,16 +3383,16 @@ function instance$5($$self, $$props, $$invalidate) {
3247
3383
  });
3248
3384
 
3249
3385
  function h3_binding($$value) {
3250
- binding_callbacks[$$value ? "unshift" : "push"](() => {
3386
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
3251
3387
  element = $$value;
3252
3388
  $$invalidate(0, element);
3253
3389
  });
3254
3390
  }
3255
3391
 
3256
3392
  $$self.$$set = $$props => {
3257
- if ("labelId" in $$props) $$invalidate(1, labelId = $$props.labelId);
3258
- if ("element" in $$props) $$invalidate(0, element = $$props.element);
3259
- if ("title" in $$props) $$invalidate(2, title = $$props.title);
3393
+ if ('labelId' in $$props) $$invalidate(1, labelId = $$props.labelId);
3394
+ if ('element' in $$props) $$invalidate(0, element = $$props.element);
3395
+ if ('title' in $$props) $$invalidate(2, title = $$props.title);
3260
3396
  };
3261
3397
 
3262
3398
  return [element, labelId, title, h3_binding];
@@ -3273,7 +3409,7 @@ class Shepherd_title extends SvelteComponent {
3273
3409
  }
3274
3410
 
3275
3411
  }
3276
- /* src/js/components/shepherd-header.svelte generated by Svelte v3.37.0 */
3412
+ /* src/js/components/shepherd-header.svelte generated by Svelte v3.48.0 */
3277
3413
 
3278
3414
 
3279
3415
  function create_if_block_1$1(ctx) {
@@ -3418,7 +3554,9 @@ function create_fragment$4(ctx) {
3418
3554
  current = true;
3419
3555
  },
3420
3556
 
3421
- p(ctx, [dirty]) {
3557
+ p(ctx, _ref) {
3558
+ let [dirty] = _ref;
3559
+
3422
3560
  if (
3423
3561
  /*title*/
3424
3562
  ctx[2]) {
@@ -3496,16 +3634,14 @@ function create_fragment$4(ctx) {
3496
3634
 
3497
3635
  function instance$4($$self, $$props, $$invalidate) {
3498
3636
  let {
3499
- labelId
3500
- } = $$props,
3501
- {
3637
+ labelId,
3502
3638
  step
3503
3639
  } = $$props;
3504
3640
  let title, cancelIcon;
3505
3641
 
3506
3642
  $$self.$$set = $$props => {
3507
- if ("labelId" in $$props) $$invalidate(0, labelId = $$props.labelId);
3508
- if ("step" in $$props) $$invalidate(1, step = $$props.step);
3643
+ if ('labelId' in $$props) $$invalidate(0, labelId = $$props.labelId);
3644
+ if ('step' in $$props) $$invalidate(1, step = $$props.step);
3509
3645
  };
3510
3646
 
3511
3647
  $$self.$$.update = () => {
@@ -3532,7 +3668,7 @@ class Shepherd_header extends SvelteComponent {
3532
3668
  }
3533
3669
 
3534
3670
  }
3535
- /* src/js/components/shepherd-text.svelte generated by Svelte v3.37.0 */
3671
+ /* src/js/components/shepherd-text.svelte generated by Svelte v3.48.0 */
3536
3672
 
3537
3673
 
3538
3674
  function create_fragment$3(ctx) {
@@ -3553,7 +3689,9 @@ function create_fragment$3(ctx) {
3553
3689
  ctx[3](div);
3554
3690
  },
3555
3691
 
3556
- p(ctx, [dirty]) {
3692
+ p(ctx, _ref) {
3693
+ let [dirty] = _ref;
3694
+
3557
3695
  if (dirty &
3558
3696
  /*descriptionId*/
3559
3697
  2) {
@@ -3578,12 +3716,8 @@ function create_fragment$3(ctx) {
3578
3716
 
3579
3717
  function instance$3($$self, $$props, $$invalidate) {
3580
3718
  let {
3581
- descriptionId
3582
- } = $$props,
3583
- {
3584
- element
3585
- } = $$props,
3586
- {
3719
+ descriptionId,
3720
+ element,
3587
3721
  step
3588
3722
  } = $$props;
3589
3723
  afterUpdate(() => {
@@ -3603,16 +3737,16 @@ function instance$3($$self, $$props, $$invalidate) {
3603
3737
  });
3604
3738
 
3605
3739
  function div_binding($$value) {
3606
- binding_callbacks[$$value ? "unshift" : "push"](() => {
3740
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
3607
3741
  element = $$value;
3608
3742
  $$invalidate(0, element);
3609
3743
  });
3610
3744
  }
3611
3745
 
3612
3746
  $$self.$$set = $$props => {
3613
- if ("descriptionId" in $$props) $$invalidate(1, descriptionId = $$props.descriptionId);
3614
- if ("element" in $$props) $$invalidate(0, element = $$props.element);
3615
- if ("step" in $$props) $$invalidate(2, step = $$props.step);
3747
+ if ('descriptionId' in $$props) $$invalidate(1, descriptionId = $$props.descriptionId);
3748
+ if ('element' in $$props) $$invalidate(0, element = $$props.element);
3749
+ if ('step' in $$props) $$invalidate(2, step = $$props.step);
3616
3750
  };
3617
3751
 
3618
3752
  return [element, descriptionId, step, div_binding];
@@ -3629,7 +3763,7 @@ class Shepherd_text extends SvelteComponent {
3629
3763
  }
3630
3764
 
3631
3765
  }
3632
- /* src/js/components/shepherd-content.svelte generated by Svelte v3.37.0 */
3766
+ /* src/js/components/shepherd-content.svelte generated by Svelte v3.48.0 */
3633
3767
 
3634
3768
 
3635
3769
  function create_if_block_2(ctx) {
@@ -3838,7 +3972,8 @@ function create_fragment$2(ctx) {
3838
3972
  current = true;
3839
3973
  },
3840
3974
 
3841
- p(ctx, [dirty]) {
3975
+ p(ctx, _ref) {
3976
+ let [dirty] = _ref;
3842
3977
  if (dirty &
3843
3978
  /*step*/
3844
3979
  4) show_if_2 = !isUndefined(
@@ -3960,19 +4095,15 @@ function create_fragment$2(ctx) {
3960
4095
 
3961
4096
  function instance$2($$self, $$props, $$invalidate) {
3962
4097
  let {
3963
- descriptionId
3964
- } = $$props,
3965
- {
3966
- labelId
3967
- } = $$props,
3968
- {
4098
+ descriptionId,
4099
+ labelId,
3969
4100
  step
3970
4101
  } = $$props;
3971
4102
 
3972
4103
  $$self.$$set = $$props => {
3973
- if ("descriptionId" in $$props) $$invalidate(0, descriptionId = $$props.descriptionId);
3974
- if ("labelId" in $$props) $$invalidate(1, labelId = $$props.labelId);
3975
- if ("step" in $$props) $$invalidate(2, step = $$props.step);
4104
+ if ('descriptionId' in $$props) $$invalidate(0, descriptionId = $$props.descriptionId);
4105
+ if ('labelId' in $$props) $$invalidate(1, labelId = $$props.labelId);
4106
+ if ('step' in $$props) $$invalidate(2, step = $$props.step);
3976
4107
  };
3977
4108
 
3978
4109
  return [descriptionId, labelId, step];
@@ -3989,7 +4120,7 @@ class Shepherd_content extends SvelteComponent {
3989
4120
  }
3990
4121
 
3991
4122
  }
3992
- /* src/js/components/shepherd-element.svelte generated by Svelte v3.37.0 */
4123
+ /* src/js/components/shepherd-element.svelte generated by Svelte v3.48.0 */
3993
4124
 
3994
4125
 
3995
4126
  function create_if_block(ctx) {
@@ -4102,7 +4233,9 @@ function create_fragment$1(ctx) {
4102
4233
  }
4103
4234
  },
4104
4235
 
4105
- p(ctx, [dirty]) {
4236
+ p(ctx, _ref) {
4237
+ let [dirty] = _ref;
4238
+
4106
4239
  if (
4107
4240
  /*step*/
4108
4241
  ctx[4].options.arrow &&
@@ -4204,35 +4337,19 @@ const LEFT_ARROW = 37;
4204
4337
  const RIGHT_ARROW = 39;
4205
4338
 
4206
4339
  function getClassesArray(classes) {
4207
- return classes.split(" ").filter(className => !!className.length);
4340
+ return classes.split(' ').filter(className => !!className.length);
4208
4341
  }
4209
4342
 
4210
4343
  function instance$1($$self, $$props, $$invalidate) {
4211
4344
  let {
4212
- classPrefix
4213
- } = $$props,
4214
- {
4215
- element
4216
- } = $$props,
4217
- {
4218
- descriptionId
4219
- } = $$props,
4220
- {
4221
- firstFocusableElement
4222
- } = $$props,
4223
- {
4224
- focusableElements
4225
- } = $$props,
4226
- {
4227
- labelId
4228
- } = $$props,
4229
- {
4230
- lastFocusableElement
4231
- } = $$props,
4232
- {
4233
- step
4234
- } = $$props,
4235
- {
4345
+ classPrefix,
4346
+ element,
4347
+ descriptionId,
4348
+ firstFocusableElement,
4349
+ focusableElements,
4350
+ labelId,
4351
+ lastFocusableElement,
4352
+ step,
4236
4353
  dataStepId
4237
4354
  } = $$props;
4238
4355
  let hasCancelIcon, hasTitle, classes;
@@ -4244,7 +4361,7 @@ function instance$1($$self, $$props, $$invalidate) {
4244
4361
  $$invalidate(1, dataStepId = {
4245
4362
  [`data-${classPrefix}shepherd-step-id`]: step.id
4246
4363
  });
4247
- $$invalidate(9, focusableElements = element.querySelectorAll("a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex=\"0\"]"));
4364
+ $$invalidate(9, focusableElements = element.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'));
4248
4365
  $$invalidate(8, firstFocusableElement = focusableElements[0]);
4249
4366
  $$invalidate(10, lastFocusableElement = focusableElements[focusableElements.length - 1]);
4250
4367
  });
@@ -4302,7 +4419,7 @@ function instance$1($$self, $$props, $$invalidate) {
4302
4419
 
4303
4420
 
4304
4421
  if (e.shiftKey) {
4305
- if (document.activeElement === firstFocusableElement || document.activeElement.classList.contains("shepherd-element")) {
4422
+ if (document.activeElement === firstFocusableElement || document.activeElement.classList.contains('shepherd-element')) {
4306
4423
  e.preventDefault();
4307
4424
  lastFocusableElement.focus();
4308
4425
  }
@@ -4339,22 +4456,22 @@ function instance$1($$self, $$props, $$invalidate) {
4339
4456
  };
4340
4457
 
4341
4458
  function div_binding($$value) {
4342
- binding_callbacks[$$value ? "unshift" : "push"](() => {
4459
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
4343
4460
  element = $$value;
4344
4461
  $$invalidate(0, element);
4345
4462
  });
4346
4463
  }
4347
4464
 
4348
4465
  $$self.$$set = $$props => {
4349
- if ("classPrefix" in $$props) $$invalidate(11, classPrefix = $$props.classPrefix);
4350
- if ("element" in $$props) $$invalidate(0, element = $$props.element);
4351
- if ("descriptionId" in $$props) $$invalidate(2, descriptionId = $$props.descriptionId);
4352
- if ("firstFocusableElement" in $$props) $$invalidate(8, firstFocusableElement = $$props.firstFocusableElement);
4353
- if ("focusableElements" in $$props) $$invalidate(9, focusableElements = $$props.focusableElements);
4354
- if ("labelId" in $$props) $$invalidate(3, labelId = $$props.labelId);
4355
- if ("lastFocusableElement" in $$props) $$invalidate(10, lastFocusableElement = $$props.lastFocusableElement);
4356
- if ("step" in $$props) $$invalidate(4, step = $$props.step);
4357
- if ("dataStepId" in $$props) $$invalidate(1, dataStepId = $$props.dataStepId);
4466
+ if ('classPrefix' in $$props) $$invalidate(11, classPrefix = $$props.classPrefix);
4467
+ if ('element' in $$props) $$invalidate(0, element = $$props.element);
4468
+ if ('descriptionId' in $$props) $$invalidate(2, descriptionId = $$props.descriptionId);
4469
+ if ('firstFocusableElement' in $$props) $$invalidate(8, firstFocusableElement = $$props.firstFocusableElement);
4470
+ if ('focusableElements' in $$props) $$invalidate(9, focusableElements = $$props.focusableElements);
4471
+ if ('labelId' in $$props) $$invalidate(3, labelId = $$props.labelId);
4472
+ if ('lastFocusableElement' in $$props) $$invalidate(10, lastFocusableElement = $$props.lastFocusableElement);
4473
+ if ('step' in $$props) $$invalidate(4, step = $$props.step);
4474
+ if ('dataStepId' in $$props) $$invalidate(1, dataStepId = $$props.dataStepId);
4358
4475
  };
4359
4476
 
4360
4477
  $$self.$$.update = () => {
@@ -4764,10 +4881,11 @@ class Step extends Evented {
4764
4881
  * });
4765
4882
  * ```
4766
4883
  *
4767
- * If you don’t specify an attachTo the element will appear in the middle of the screen.
4884
+ * 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.
4768
4885
  * If you omit the `on` portion of `attachTo`, the element will still be highlighted, but the tooltip will appear
4769
4886
  * in the middle of the screen, without an arrow pointing to the target.
4770
- * @param {HTMLElement|string} options.attachTo.element An element selector string or a DOM element.
4887
+ * 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.
4888
+ * @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`).
4771
4889
  * @param {string} options.attachTo.on The optional direction to place the Popper tooltip relative to the element.
4772
4890
  * - 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'
4773
4891
  * @param {Object} options.advanceOn An action on the page which should advance shepherd to the next step.
@@ -4836,11 +4954,23 @@ class Step extends Evented {
4836
4954
  * ```
4837
4955
  * @return {Step} The newly created Step instance
4838
4956
  */
4839
- constructor(tour, options = {}) {
4957
+ constructor(tour, options) {
4958
+ if (options === void 0) {
4959
+ options = {};
4960
+ }
4961
+
4840
4962
  super(tour, options);
4841
4963
  this.tour = tour;
4842
4964
  this.classPrefix = this.tour.options ? normalizePrefix(this.tour.options.classPrefix) : '';
4843
4965
  this.styles = tour.styles;
4966
+ /**
4967
+ * Resolved attachTo options. Due to lazy evaluation, we only resolve the options during `before-show` phase.
4968
+ * Do not use this directly, use the _getResolvedAttachToOptions method instead.
4969
+ * @type {null|{}|{element, to}}
4970
+ * @private
4971
+ */
4972
+
4973
+ this._resolvedAttachTo = null;
4844
4974
  autoBind(this);
4845
4975
 
4846
4976
  this._setOptions(options);
@@ -4915,14 +5045,29 @@ class Step extends Evented {
4915
5045
  this.trigger('hide');
4916
5046
  }
4917
5047
  /**
4918
- * Checks if the step should be centered or not
4919
- * @return {boolean} True if the step is centered
5048
+ * Resolves attachTo options.
5049
+ * @returns {{}|{element, on}}
5050
+ * @private
4920
5051
  */
4921
5052
 
4922
5053
 
4923
- isCentered() {
4924
- const attachToOptions = parseAttachTo(this);
4925
- return !attachToOptions.element || !attachToOptions.on;
5054
+ _resolveAttachToOptions() {
5055
+ this._resolvedAttachTo = parseAttachTo(this);
5056
+ return this._resolvedAttachTo;
5057
+ }
5058
+ /**
5059
+ * A selector for resolved attachTo options.
5060
+ * @returns {{}|{element, on}}
5061
+ * @private
5062
+ */
5063
+
5064
+
5065
+ _getResolvedAttachToOptions() {
5066
+ if (this._resolvedAttachTo === null) {
5067
+ return this._resolveAttachToOptions();
5068
+ }
5069
+
5070
+ return this._resolvedAttachTo;
4926
5071
  }
4927
5072
  /**
4928
5073
  * Check if the step is open and visible
@@ -5020,7 +5165,7 @@ class Step extends Evented {
5020
5165
  _scrollTo(scrollToOptions) {
5021
5166
  const {
5022
5167
  element
5023
- } = parseAttachTo(this);
5168
+ } = this._getResolvedAttachToOptions();
5024
5169
 
5025
5170
  if (isFunction(this.options.scrollToHandler)) {
5026
5171
  this.options.scrollToHandler(element);
@@ -5051,7 +5196,11 @@ class Step extends Evented {
5051
5196
  */
5052
5197
 
5053
5198
 
5054
- _setOptions(options = {}) {
5199
+ _setOptions(options) {
5200
+ if (options === void 0) {
5201
+ options = {};
5202
+ }
5203
+
5055
5204
  let tourOptions = this.tour && this.tour.options && this.tour.options.defaultStepOptions;
5056
5205
  tourOptions = cjs({}, tourOptions || {});
5057
5206
  this.options = Object.assign({
@@ -5097,7 +5246,9 @@ class Step extends Evented {
5097
5246
 
5098
5247
 
5099
5248
  _show() {
5100
- this.trigger('before-show');
5249
+ this.trigger('before-show'); // Force resolve to make sure the options are updated on subsequent shows.
5250
+
5251
+ this._resolveAttachToOptions();
5101
5252
 
5102
5253
  this._setupElements();
5103
5254
 
@@ -5145,6 +5296,8 @@ class Step extends Evented {
5145
5296
  targetElement.classList.add(step.options.highlightClass);
5146
5297
  }
5147
5298
 
5299
+ targetElement.classList.remove('shepherd-target-click-disabled');
5300
+
5148
5301
  if (step.options.canClickTarget === false) {
5149
5302
  targetElement.classList.add('shepherd-target-click-disabled');
5150
5303
  }
@@ -5199,13 +5352,14 @@ function cleanupSteps(tour) {
5199
5352
  */
5200
5353
 
5201
5354
 
5202
- function makeOverlayPath({
5203
- width,
5204
- height,
5205
- x = 0,
5206
- y = 0,
5207
- r = 0
5208
- }) {
5355
+ function makeOverlayPath(_ref) {
5356
+ let {
5357
+ width,
5358
+ height,
5359
+ x = 0,
5360
+ y = 0,
5361
+ r = 0
5362
+ } = _ref;
5209
5363
  const {
5210
5364
  innerWidth: w,
5211
5365
  innerHeight: h
@@ -5226,7 +5380,7 @@ V${y + r}\
5226
5380
  a${r},${r},0,0,0-${r}-${r}\
5227
5381
  Z`;
5228
5382
  }
5229
- /* src/js/components/shepherd-modal.svelte generated by Svelte v3.37.0 */
5383
+ /* src/js/components/shepherd-modal.svelte generated by Svelte v3.48.0 */
5230
5384
 
5231
5385
 
5232
5386
  function create_fragment(ctx) {
@@ -5244,7 +5398,7 @@ function create_fragment(ctx) {
5244
5398
  ctx[2]);
5245
5399
  attr(svg, "class", svg_class_value = `${
5246
5400
  /*modalIsVisible*/
5247
- ctx[1] ? "shepherd-modal-is-visible" : ""} shepherd-modal-overlay-container`);
5401
+ ctx[1] ? 'shepherd-modal-is-visible' : ''} shepherd-modal-overlay-container`);
5248
5402
  },
5249
5403
 
5250
5404
  m(target, anchor) {
@@ -5262,7 +5416,9 @@ function create_fragment(ctx) {
5262
5416
  }
5263
5417
  },
5264
5418
 
5265
- p(ctx, [dirty]) {
5419
+ p(ctx, _ref) {
5420
+ let [dirty] = _ref;
5421
+
5266
5422
  if (dirty &
5267
5423
  /*pathDefinition*/
5268
5424
  4) {
@@ -5275,7 +5431,7 @@ function create_fragment(ctx) {
5275
5431
  /*modalIsVisible*/
5276
5432
  2 && svg_class_value !== (svg_class_value = `${
5277
5433
  /*modalIsVisible*/
5278
- ctx[1] ? "shepherd-modal-is-visible" : ""} shepherd-modal-overlay-container`)) {
5434
+ ctx[1] ? 'shepherd-modal-is-visible' : ''} shepherd-modal-overlay-container`)) {
5279
5435
  attr(svg, "class", svg_class_value);
5280
5436
  }
5281
5437
  },
@@ -5302,7 +5458,7 @@ function _getScrollParent(element) {
5302
5458
 
5303
5459
  const isHtmlElement = element instanceof HTMLElement;
5304
5460
  const overflowY = isHtmlElement && window.getComputedStyle(element).overflowY;
5305
- const isScrollable = overflowY !== "hidden" && overflowY !== "visible";
5461
+ const isScrollable = overflowY !== 'hidden' && overflowY !== 'visible';
5306
5462
 
5307
5463
  if (isScrollable && element.scrollHeight >= element.clientHeight) {
5308
5464
  return element;
@@ -5344,9 +5500,7 @@ function _getVisibleHeight(element, scrollParent) {
5344
5500
 
5345
5501
  function instance($$self, $$props, $$invalidate) {
5346
5502
  let {
5347
- element
5348
- } = $$props,
5349
- {
5503
+ element,
5350
5504
  openingProperties
5351
5505
  } = $$props;
5352
5506
  uuid();
@@ -5373,7 +5527,15 @@ function instance($$self, $$props, $$invalidate) {
5373
5527
  _cleanupStepEventListeners();
5374
5528
  }
5375
5529
 
5376
- function positionModal(modalOverlayOpeningPadding = 0, modalOverlayOpeningRadius = 0, scrollParent, targetElement) {
5530
+ function positionModal(modalOverlayOpeningPadding, modalOverlayOpeningRadius, scrollParent, targetElement) {
5531
+ if (modalOverlayOpeningPadding === void 0) {
5532
+ modalOverlayOpeningPadding = 0;
5533
+ }
5534
+
5535
+ if (modalOverlayOpeningRadius === void 0) {
5536
+ modalOverlayOpeningRadius = 0;
5537
+ }
5538
+
5377
5539
  if (targetElement) {
5378
5540
  const {
5379
5541
  y,
@@ -5430,7 +5592,7 @@ function instance($$self, $$props, $$invalidate) {
5430
5592
 
5431
5593
  function _addStepEventListeners() {
5432
5594
  // Prevents window from moving on touch.
5433
- window.addEventListener("touchmove", _preventModalBodyTouch, {
5595
+ window.addEventListener('touchmove', _preventModalBodyTouch, {
5434
5596
  passive: false
5435
5597
  });
5436
5598
  }
@@ -5446,7 +5608,7 @@ function instance($$self, $$props, $$invalidate) {
5446
5608
  rafId = undefined;
5447
5609
  }
5448
5610
 
5449
- window.removeEventListener("touchmove", _preventModalBodyTouch, {
5611
+ window.removeEventListener('touchmove', _preventModalBodyTouch, {
5450
5612
  passive: false
5451
5613
  });
5452
5614
  }
@@ -5478,15 +5640,15 @@ function instance($$self, $$props, $$invalidate) {
5478
5640
  }
5479
5641
 
5480
5642
  function svg_binding($$value) {
5481
- binding_callbacks[$$value ? "unshift" : "push"](() => {
5643
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
5482
5644
  element = $$value;
5483
5645
  $$invalidate(0, element);
5484
5646
  });
5485
5647
  }
5486
5648
 
5487
5649
  $$self.$$set = $$props => {
5488
- if ("element" in $$props) $$invalidate(0, element = $$props.element);
5489
- if ("openingProperties" in $$props) $$invalidate(4, openingProperties = $$props.openingProperties);
5650
+ if ('element' in $$props) $$invalidate(0, element = $$props.element);
5651
+ if ('openingProperties' in $$props) $$invalidate(4, openingProperties = $$props.openingProperties);
5490
5652
  };
5491
5653
 
5492
5654
  $$self.$$.update = () => {
@@ -5571,7 +5733,11 @@ class Tour extends Evented {
5571
5733
  * can remain interactive
5572
5734
  * @returns {Tour}
5573
5735
  */
5574
- constructor(options = {}) {
5736
+ constructor(options) {
5737
+ if (options === void 0) {
5738
+ options = {};
5739
+ }
5740
+
5575
5741
  super(options);
5576
5742
  autoBind(this);
5577
5743
  const defaultTourOptions = {
@@ -5765,7 +5931,15 @@ class Tour extends Evented {
5765
5931
  */
5766
5932
 
5767
5933
 
5768
- show(key = 0, forward = true) {
5934
+ show(key, forward) {
5935
+ if (key === void 0) {
5936
+ key = 0;
5937
+ }
5938
+
5939
+ if (forward === void 0) {
5940
+ forward = true;
5941
+ }
5942
+
5769
5943
  const step = isString(key) ? this.getById(key) : this.steps[key];
5770
5944
 
5771
5945
  if (step) {
@@ -5872,7 +6046,7 @@ class Tour extends Evented {
5872
6046
  });
5873
6047
  }
5874
6048
  /**
5875
- * Called when `showOn` evaluates to false, to skip the step
6049
+ * Called when `showOn` evaluates to false, to skip the step or complete the tour if it's the last step
5876
6050
  * @param {Step} step The step to skip
5877
6051
  * @param {Boolean} forward True if we are going forward, false if backward
5878
6052
  * @private
@@ -5881,8 +6055,13 @@ class Tour extends Evented {
5881
6055
 
5882
6056
  _skipStep(step, forward) {
5883
6057
  const index = this.steps.indexOf(step);
5884
- const nextIndex = forward ? index + 1 : index - 1;
5885
- this.show(nextIndex, forward);
6058
+
6059
+ if (index === this.steps.length - 1) {
6060
+ this.complete();
6061
+ } else {
6062
+ const nextIndex = forward ? index + 1 : index - 1;
6063
+ this.show(nextIndex, forward);
6064
+ }
5886
6065
  }
5887
6066
  /**
5888
6067
  * Before showing, hide the current step and if the tour is not
@@ -5937,9 +6116,7 @@ var addSteps = function (steps, tour) {
5937
6116
  step.buttons = buttons.map(function (button) {
5938
6117
  var action = button.action, classes = button.classes, disabled = button.disabled, label = button.label, secondary = button.secondary, text = button.text, type = button.type;
5939
6118
  return {
5940
- // TypeScript doesn't have great support for dynamic method calls with
5941
- // bracket notation, so we use the `any` escape hatch
5942
- action: tour[type] || action,
6119
+ action: type ? tour[type] : action,
5943
6120
  classes: classes,
5944
6121
  disabled: disabled,
5945
6122
  label: label,