unpoly-rails 3.10.0 → 3.10.2

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.
@@ -5,7 +5,7 @@
5
5
  /***/ (() => {
6
6
 
7
7
  window.up = {
8
- version: '3.10.0'
8
+ version: '3.10.2'
9
9
  };
10
10
 
11
11
 
@@ -637,8 +637,8 @@ up.util = (function () {
637
637
  });
638
638
  }
639
639
  }
640
- function delegatePromise(object, promiseProp) {
641
- return defineDelegates(object, ['then', 'catch', 'finally'], function () { return this[promiseProp]; });
640
+ function delegatePromise(object, targetProvider) {
641
+ return defineDelegates(object, ['then', 'catch', 'finally'], targetProvider);
642
642
  }
643
643
  function stringifyArg(arg, placeholder = '%o') {
644
644
  let string;
@@ -2262,7 +2262,7 @@ up.RenderJob = (_a = class RenderJob {
2262
2262
  }
2263
2263
  },
2264
2264
  (() => {
2265
- u.delegatePromise(_a.prototype, '_rendered');
2265
+ u.delegatePromise(_a.prototype, function () { return this._rendered; });
2266
2266
  u.memoizeMethod(_a.prototype, {
2267
2267
  _awaitFinished: true,
2268
2268
  _getChange: true,
@@ -2853,9 +2853,8 @@ up.Change.CloseLayer = class CloseLayer extends up.Change {
2853
2853
  this._history = options.history ?? true;
2854
2854
  }
2855
2855
  execute() {
2856
- if (!this._layer.isOpen()) {
2857
- return Promise.resolve();
2858
- }
2856
+ if (!this._layer.isOpen())
2857
+ return;
2859
2858
  up.browser.assertConfirmed(this.options);
2860
2859
  if (this._emitCloseEvent().defaultPrevented && this._preventable) {
2861
2860
  throw new up.Aborted('Close event was prevented');
@@ -2904,10 +2903,13 @@ up.Change.CloseLayer = class CloseLayer extends up.Change {
2904
2903
  });
2905
2904
  }
2906
2905
  _handleFocus(formerParent) {
2906
+ let hadFocus = this._layer.hasFocus();
2907
2907
  this._layer.overlayFocus.teardown();
2908
2908
  formerParent.overlayFocus?.moveToFront();
2909
- let newFocusElement = this._layer.origin || formerParent.element;
2910
- up.focus(newFocusElement, { preventScroll: true });
2909
+ if (hadFocus) {
2910
+ let newFocusElement = this._layer.origin || formerParent.element;
2911
+ up.focus(newFocusElement, { preventScroll: true });
2912
+ }
2911
2913
  }
2912
2914
  };
2913
2915
 
@@ -4099,15 +4101,21 @@ up.FormValidator = class FormValidator {
4099
4101
  /***/ (() => {
4100
4102
 
4101
4103
  up.FocusCapsule = class FocusCapsule {
4102
- constructor(element, target, cursorProps) {
4104
+ constructor(element, target) {
4103
4105
  this._element = element;
4104
4106
  this._target = target;
4105
- this._cursorProps = cursorProps;
4107
+ this._cursorProps = up.viewport.copyCursorProps(this._element);
4106
4108
  }
4107
4109
  wasLost() {
4108
- return document.activeElement !== this._element;
4110
+ return document.activeElement !== this._element && !this._voided;
4111
+ }
4112
+ autoVoid() {
4113
+ up.on('focusin', { once: true }, () => this._voided = true);
4109
4114
  }
4110
4115
  restore(layer, focusOptions) {
4116
+ if (!this.wasLost()) {
4117
+ return false;
4118
+ }
4111
4119
  let rediscoveredElement = up.fragment.get(this._target, { layer });
4112
4120
  if (rediscoveredElement) {
4113
4121
  up.viewport.copyCursorProps(this._cursorProps, rediscoveredElement);
@@ -4122,8 +4130,7 @@ up.FocusCapsule = class FocusCapsule {
4122
4130
  let target = up.fragment.tryToTarget(focusedElement);
4123
4131
  if (!target)
4124
4132
  return;
4125
- const cursorProps = up.viewport.copyCursorProps(focusedElement);
4126
- return new this(focusedElement, target, cursorProps);
4133
+ return new this(focusedElement, target);
4127
4134
  }
4128
4135
  };
4129
4136
 
@@ -4296,9 +4303,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
4296
4303
  return this._focusElement(match);
4297
4304
  }
4298
4305
  _restoreLostFocus() {
4299
- if (this._wasFocusLost()) {
4300
- return this.focusCapsule?.restore(this.layer, PREVENT_SCROLL_OPTIONS);
4301
- }
4306
+ return this.focusCapsule?.restore(this.layer, PREVENT_SCROLL_OPTIONS);
4302
4307
  }
4303
4308
  _restorePreviousFocusForLocation() {
4304
4309
  return up.viewport.restoreFocus({ layer: this.layer });
@@ -6806,7 +6811,7 @@ up.Request = (_a = class Request extends up.Record {
6806
6811
  }
6807
6812
  },
6808
6813
  (() => {
6809
- u.delegatePromise(_a.prototype, '_deferred');
6814
+ u.delegatePromise(_a.prototype, function () { return this._deferred; });
6810
6815
  })(),
6811
6816
  _a);
6812
6817
 
@@ -6954,14 +6959,14 @@ up.Request.Cache = class Cache {
6954
6959
  _isUsable(request) {
6955
6960
  return request.age < up.network.config.cacheEvictAge;
6956
6961
  }
6957
- get _size() {
6962
+ get currentSize() {
6958
6963
  return this._requests.length;
6959
6964
  }
6960
6965
  get _capacity() {
6961
6966
  return up.network.config.cacheSize;
6962
6967
  }
6963
6968
  _limitSize() {
6964
- for (let i = 0; i < (this._size - this._capacity); i++) {
6969
+ for (let i = 0; i < (this.currentSize - this._capacity); i++) {
6965
6970
  this._delete(this._requests[0]);
6966
6971
  }
6967
6972
  }
@@ -10960,7 +10965,7 @@ up.status = (function () {
10960
10965
  let focusCapsule = up.FocusCapsule.preserve(bindLayer);
10961
10966
  let applyPreviews = () => doRunPreviews(request, renderOptions);
10962
10967
  let revertPreviews = bindLayer.asCurrent(applyPreviews);
10963
- up.on('focusin', { once: true }, () => focusCapsule = null);
10968
+ focusCapsule?.autoVoid();
10964
10969
  return () => {
10965
10970
  bindLayer.asCurrent(revertPreviews);
10966
10971
  focusCapsule?.restore(bindLayer, { preventScroll: true });