@stackoverflow/stacks 0.72.0 → 0.73.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/js/stacks.js CHANGED
@@ -2296,7 +2296,7 @@ Copyright © 2020 Basecamp, LLC
2296
2296
  ;
2297
2297
 
2298
2298
  /**
2299
- * @popperjs/core v2.10.2 - MIT License
2299
+ * @popperjs/core v2.11.0 - MIT License
2300
2300
  */
2301
2301
 
2302
2302
  (function (global, factory) {
@@ -2305,42 +2305,6 @@ Copyright © 2020 Basecamp, LLC
2305
2305
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Popper = {}));
2306
2306
  }(this, (function (exports) { 'use strict';
2307
2307
 
2308
- // import { isHTMLElement } from './instanceOf';
2309
- function getBoundingClientRect(element, // eslint-disable-next-line unused-imports/no-unused-vars
2310
- includeScale) {
2311
-
2312
- var rect = element.getBoundingClientRect();
2313
- var scaleX = 1;
2314
- var scaleY = 1; // FIXME:
2315
- // `offsetWidth` returns an integer while `getBoundingClientRect`
2316
- // returns a float. This results in `scaleX` or `scaleY` being
2317
- // non-1 when it should be for elements that aren't a full pixel in
2318
- // width or height.
2319
- // if (isHTMLElement(element) && includeScale) {
2320
- // const offsetHeight = element.offsetHeight;
2321
- // const offsetWidth = element.offsetWidth;
2322
- // // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
2323
- // // Fallback to 1 in case both values are `0`
2324
- // if (offsetWidth > 0) {
2325
- // scaleX = rect.width / offsetWidth || 1;
2326
- // }
2327
- // if (offsetHeight > 0) {
2328
- // scaleY = rect.height / offsetHeight || 1;
2329
- // }
2330
- // }
2331
-
2332
- return {
2333
- width: rect.width / scaleX,
2334
- height: rect.height / scaleY,
2335
- top: rect.top / scaleY,
2336
- right: rect.right / scaleX,
2337
- bottom: rect.bottom / scaleY,
2338
- left: rect.left / scaleX,
2339
- x: rect.left / scaleX,
2340
- y: rect.top / scaleY
2341
- };
2342
- }
2343
-
2344
2308
  function getWindow(node) {
2345
2309
  if (node == null) {
2346
2310
  return window;
@@ -2354,16 +2318,6 @@ Copyright © 2020 Basecamp, LLC
2354
2318
  return node;
2355
2319
  }
2356
2320
 
2357
- function getWindowScroll(node) {
2358
- var win = getWindow(node);
2359
- var scrollLeft = win.pageXOffset;
2360
- var scrollTop = win.pageYOffset;
2361
- return {
2362
- scrollLeft: scrollLeft,
2363
- scrollTop: scrollTop
2364
- };
2365
- }
2366
-
2367
2321
  function isElement(node) {
2368
2322
  var OwnElement = getWindow(node).Element;
2369
2323
  return node instanceof OwnElement || node instanceof Element;
@@ -2384,6 +2338,55 @@ Copyright © 2020 Basecamp, LLC
2384
2338
  return node instanceof OwnElement || node instanceof ShadowRoot;
2385
2339
  }
2386
2340
 
2341
+ var max = Math.max;
2342
+ var min = Math.min;
2343
+ var round = Math.round;
2344
+
2345
+ function getBoundingClientRect(element, includeScale) {
2346
+ if (includeScale === void 0) {
2347
+ includeScale = false;
2348
+ }
2349
+
2350
+ var rect = element.getBoundingClientRect();
2351
+ var scaleX = 1;
2352
+ var scaleY = 1;
2353
+
2354
+ if (isHTMLElement(element) && includeScale) {
2355
+ var offsetHeight = element.offsetHeight;
2356
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
2357
+ // Fallback to 1 in case both values are `0`
2358
+
2359
+ if (offsetWidth > 0) {
2360
+ scaleX = round(rect.width) / offsetWidth || 1;
2361
+ }
2362
+
2363
+ if (offsetHeight > 0) {
2364
+ scaleY = round(rect.height) / offsetHeight || 1;
2365
+ }
2366
+ }
2367
+
2368
+ return {
2369
+ width: rect.width / scaleX,
2370
+ height: rect.height / scaleY,
2371
+ top: rect.top / scaleY,
2372
+ right: rect.right / scaleX,
2373
+ bottom: rect.bottom / scaleY,
2374
+ left: rect.left / scaleX,
2375
+ x: rect.left / scaleX,
2376
+ y: rect.top / scaleY
2377
+ };
2378
+ }
2379
+
2380
+ function getWindowScroll(node) {
2381
+ var win = getWindow(node);
2382
+ var scrollLeft = win.pageXOffset;
2383
+ var scrollTop = win.pageYOffset;
2384
+ return {
2385
+ scrollLeft: scrollLeft,
2386
+ scrollTop: scrollTop
2387
+ };
2388
+ }
2389
+
2387
2390
  function getHTMLElementScroll(element) {
2388
2391
  return {
2389
2392
  scrollLeft: element.scrollLeft,
@@ -2436,8 +2439,8 @@ Copyright © 2020 Basecamp, LLC
2436
2439
 
2437
2440
  function isElementScaled(element) {
2438
2441
  var rect = element.getBoundingClientRect();
2439
- var scaleX = rect.width / element.offsetWidth || 1;
2440
- var scaleY = rect.height / element.offsetHeight || 1;
2442
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
2443
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
2441
2444
  return scaleX !== 1 || scaleY !== 1;
2442
2445
  } // Returns the composite rect of an element relative to its offsetParent.
2443
2446
  // Composite means it takes into account transforms as well as layout.
@@ -2449,9 +2452,9 @@ Copyright © 2020 Basecamp, LLC
2449
2452
  }
2450
2453
 
2451
2454
  var isOffsetParentAnElement = isHTMLElement(offsetParent);
2452
- isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2455
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2453
2456
  var documentElement = getDocumentElement(offsetParent);
2454
- var rect = getBoundingClientRect(elementOrVirtualElement);
2457
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
2455
2458
  var scroll = {
2456
2459
  scrollLeft: 0,
2457
2460
  scrollTop: 0
@@ -2468,7 +2471,7 @@ Copyright © 2020 Basecamp, LLC
2468
2471
  }
2469
2472
 
2470
2473
  if (isHTMLElement(offsetParent)) {
2471
- offsets = getBoundingClientRect(offsetParent);
2474
+ offsets = getBoundingClientRect(offsetParent, true);
2472
2475
  offsets.x += offsetParent.clientLeft;
2473
2476
  offsets.y += offsetParent.clientTop;
2474
2477
  } else if (documentElement) {
@@ -2874,10 +2877,6 @@ Copyright © 2020 Basecamp, LLC
2874
2877
  };
2875
2878
  }
2876
2879
 
2877
- var max = Math.max;
2878
- var min = Math.min;
2879
- var round = Math.round;
2880
-
2881
2880
  // of the `<html>` and `<body>` rect bounds if horizontally scrollable
2882
2881
 
2883
2882
  function getDocumentRect(element) {
@@ -2949,7 +2948,7 @@ Copyright © 2020 Basecamp, LLC
2949
2948
  }
2950
2949
 
2951
2950
  function getClientRectFromMixedType(element, clippingParent) {
2952
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2951
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2953
2952
  } // A "clipping parent" is an overflowable container with the characteristic of
2954
2953
  // clipping (or hiding) overflowing elements with a position different from
2955
2954
  // `initial`
@@ -2966,7 +2965,7 @@ Copyright © 2020 Basecamp, LLC
2966
2965
 
2967
2966
 
2968
2967
  return clippingParents.filter(function (clippingParent) {
2969
- return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
2968
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body' && (canEscapeClipping ? getComputedStyle(clippingParent).position !== 'static' : true);
2970
2969
  });
2971
2970
  } // Gets the maximum area that the element is visible in due to any number of
2972
2971
  // clipping parents
@@ -3468,8 +3467,8 @@ Copyright © 2020 Basecamp, LLC
3468
3467
  var win = window;
3469
3468
  var dpr = win.devicePixelRatio || 1;
3470
3469
  return {
3471
- x: round(round(x * dpr) / dpr) || 0,
3472
- y: round(round(y * dpr) / dpr) || 0
3470
+ x: round(x * dpr) / dpr || 0,
3471
+ y: round(y * dpr) / dpr || 0
3473
3472
  };
3474
3473
  }
3475
3474
 
@@ -3484,7 +3483,8 @@ Copyright © 2020 Basecamp, LLC
3484
3483
  position = _ref2.position,
3485
3484
  gpuAcceleration = _ref2.gpuAcceleration,
3486
3485
  adaptive = _ref2.adaptive,
3487
- roundOffsets = _ref2.roundOffsets;
3486
+ roundOffsets = _ref2.roundOffsets,
3487
+ isFixed = _ref2.isFixed;
3488
3488
 
3489
3489
  var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
3490
3490
  _ref3$x = _ref3.x,
@@ -3516,16 +3516,18 @@ Copyright © 2020 Basecamp, LLC
3516
3516
  offsetParent = offsetParent;
3517
3517
 
3518
3518
  if (placement === top || (placement === left || placement === right) && variation === end) {
3519
- sideY = bottom; // $FlowFixMe[prop-missing]
3520
-
3521
- y -= offsetParent[heightProp] - popperRect.height;
3519
+ sideY = bottom;
3520
+ var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
3521
+ offsetParent[heightProp];
3522
+ y -= offsetY - popperRect.height;
3522
3523
  y *= gpuAcceleration ? 1 : -1;
3523
3524
  }
3524
3525
 
3525
3526
  if (placement === left || (placement === top || placement === bottom) && variation === end) {
3526
- sideX = right; // $FlowFixMe[prop-missing]
3527
-
3528
- x -= offsetParent[widthProp] - popperRect.width;
3527
+ sideX = right;
3528
+ var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
3529
+ offsetParent[widthProp];
3530
+ x -= offsetX - popperRect.width;
3529
3531
  x *= gpuAcceleration ? 1 : -1;
3530
3532
  }
3531
3533
  }
@@ -3568,7 +3570,8 @@ Copyright © 2020 Basecamp, LLC
3568
3570
  variation: getVariation(state.placement),
3569
3571
  popper: state.elements.popper,
3570
3572
  popperRect: state.rects.popper,
3571
- gpuAcceleration: gpuAcceleration
3573
+ gpuAcceleration: gpuAcceleration,
3574
+ isFixed: state.options.strategy === 'fixed'
3572
3575
  };
3573
3576
 
3574
3577
  if (state.modifiersData.popperOffsets != null) {
@@ -3951,6 +3954,10 @@ Copyright © 2020 Basecamp, LLC
3951
3954
  function within(min$1, value, max$1) {
3952
3955
  return max(min$1, min(value, max$1));
3953
3956
  }
3957
+ function withinMaxClamp(min, value, max) {
3958
+ var v = within(min, value, max);
3959
+ return v > max ? max : v;
3960
+ }
3954
3961
 
3955
3962
  function preventOverflow(_ref) {
3956
3963
  var state = _ref.state,
@@ -3985,6 +3992,14 @@ Copyright © 2020 Basecamp, LLC
3985
3992
  var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
3986
3993
  placement: state.placement
3987
3994
  })) : tetherOffset;
3995
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
3996
+ mainAxis: tetherOffsetValue,
3997
+ altAxis: tetherOffsetValue
3998
+ } : Object.assign({
3999
+ mainAxis: 0,
4000
+ altAxis: 0
4001
+ }, tetherOffsetValue);
4002
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
3988
4003
  var data = {
3989
4004
  x: 0,
3990
4005
  y: 0
@@ -3994,13 +4009,15 @@ Copyright © 2020 Basecamp, LLC
3994
4009
  return;
3995
4010
  }
3996
4011
 
3997
- if (checkMainAxis || checkAltAxis) {
4012
+ if (checkMainAxis) {
4013
+ var _offsetModifierState$;
4014
+
3998
4015
  var mainSide = mainAxis === 'y' ? top : left;
3999
4016
  var altSide = mainAxis === 'y' ? bottom : right;
4000
4017
  var len = mainAxis === 'y' ? 'height' : 'width';
4001
4018
  var offset = popperOffsets[mainAxis];
4002
- var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
4003
- var max$1 = popperOffsets[mainAxis] - overflow[altSide];
4019
+ var min$1 = offset + overflow[mainSide];
4020
+ var max$1 = offset - overflow[altSide];
4004
4021
  var additive = tether ? -popperRect[len] / 2 : 0;
4005
4022
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
4006
4023
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
@@ -4020,36 +4037,45 @@ Copyright © 2020 Basecamp, LLC
4020
4037
  // width or height)
4021
4038
 
4022
4039
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
4023
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
4024
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
4040
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
4041
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
4025
4042
  var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
4026
4043
  var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
4027
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
4028
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
4029
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
4044
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
4045
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
4046
+ var tetherMax = offset + maxOffset - offsetModifierValue;
4047
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
4048
+ popperOffsets[mainAxis] = preventedOffset;
4049
+ data[mainAxis] = preventedOffset - offset;
4050
+ }
4030
4051
 
4031
- if (checkMainAxis) {
4032
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
4033
- popperOffsets[mainAxis] = preventedOffset;
4034
- data[mainAxis] = preventedOffset - offset;
4035
- }
4052
+ if (checkAltAxis) {
4053
+ var _offsetModifierState$2;
4036
4054
 
4037
- if (checkAltAxis) {
4038
- var _mainSide = mainAxis === 'x' ? top : left;
4055
+ var _mainSide = mainAxis === 'x' ? top : left;
4039
4056
 
4040
- var _altSide = mainAxis === 'x' ? bottom : right;
4057
+ var _altSide = mainAxis === 'x' ? bottom : right;
4041
4058
 
4042
- var _offset = popperOffsets[altAxis];
4059
+ var _offset = popperOffsets[altAxis];
4043
4060
 
4044
- var _min = _offset + overflow[_mainSide];
4061
+ var _len = altAxis === 'y' ? 'height' : 'width';
4045
4062
 
4046
- var _max = _offset - overflow[_altSide];
4063
+ var _min = _offset + overflow[_mainSide];
4047
4064
 
4048
- var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
4065
+ var _max = _offset - overflow[_altSide];
4049
4066
 
4050
- popperOffsets[altAxis] = _preventedOffset;
4051
- data[altAxis] = _preventedOffset - _offset;
4052
- }
4067
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
4068
+
4069
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
4070
+
4071
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
4072
+
4073
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
4074
+
4075
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
4076
+
4077
+ popperOffsets[altAxis] = _preventedOffset;
4078
+ data[altAxis] = _preventedOffset - _offset;
4053
4079
  }
4054
4080
 
4055
4081
  state.modifiersData[name] = data;
@@ -5134,7 +5160,7 @@ var Stacks;
5134
5160
  if (popoverId) {
5135
5161
  popoverElement = document.getElementById(popoverId);
5136
5162
  if (!popoverElement) {
5137
- throw "[" + this.popoverSelectorAttribute + "=\"{POPOVER_ID}\"] required";
5163
+ throw "[".concat(this.popoverSelectorAttribute, "=\"{POPOVER_ID}\"] required");
5138
5164
  }
5139
5165
  }
5140
5166
  else {
@@ -5254,7 +5280,7 @@ var Stacks;
5254
5280
  function attachPopover(element, popover, options) {
5255
5281
  var _a = getPopover(element), referenceElement = _a.referenceElement, existingPopover = _a.popover;
5256
5282
  if (existingPopover) {
5257
- throw "element already has popover with id=\"" + existingPopover.id + "\"";
5283
+ throw "element already has popover with id=\"".concat(existingPopover.id, "\"");
5258
5284
  }
5259
5285
  if (!referenceElement) {
5260
5286
  throw "element has invalid data-s-popover-reference-selector attribute";
@@ -5269,10 +5295,10 @@ var Stacks;
5269
5295
  var existingId = referenceElement.getAttribute("aria-controls");
5270
5296
  var popoverId = popover.id;
5271
5297
  if (!popover.classList.contains('s-popover')) {
5272
- throw "popover should have the \"s-popover\" class but had class=\"" + popover.className + "\"";
5298
+ throw "popover should have the \"s-popover\" class but had class=\"".concat(popover.className, "\"");
5273
5299
  }
5274
5300
  if (existingId && existingId !== popoverId) {
5275
- throw "element has aria-controls=\"" + existingId + "\" but popover has id=\"" + popoverId + "\"";
5301
+ throw "element has aria-controls=\"".concat(existingId, "\" but popover has id=\"").concat(popoverId, "\"");
5276
5302
  }
5277
5303
  if (!popoverId) {
5278
5304
  popoverId = "--stacks-s-popover-" + Math.random().toString(36).substring(2, 10);
@@ -5745,7 +5771,7 @@ var Stacks;
5745
5771
  var headingElement = document.createElement("div");
5746
5772
  headingElement.classList.add("s-uploader--previews-heading");
5747
5773
  headingElement.innerText = res.length < count ?
5748
- "Showing " + res.length + " of " + count + " files" : count + " items";
5774
+ "Showing ".concat(res.length, " of ").concat(count, " files") : "".concat(count, " items");
5749
5775
  _this.previewsTarget.appendChild(headingElement);
5750
5776
  _this.previewsTarget.classList.add("has-multiple");
5751
5777
  }