unpoly-rails 3.10.0.rc1 → 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.
- checksums.yaml +4 -4
- data/assets/unpoly/unpoly.es6.js +72 -69
- data/assets/unpoly/unpoly.es6.min.js +1 -1
- data/assets/unpoly/unpoly.js +69 -68
- data/assets/unpoly/unpoly.min.js +1 -1
- data/lib/unpoly/rails/change/field_definition.rb +12 -4
- data/lib/unpoly/rails/change.rb +26 -11
- data/lib/unpoly/rails/util.rb +8 -0
- data/lib/unpoly/rails/version.rb +1 -1
- metadata +5 -5
data/assets/unpoly/unpoly.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
/***/ (() => {
|
6
6
|
|
7
7
|
window.up = {
|
8
|
-
version: '3.10.
|
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,
|
641
|
-
return defineDelegates(object, ['then', 'catch', 'finally'],
|
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;
|
@@ -2212,18 +2212,16 @@ up.RenderJob = (_a = class RenderJob {
|
|
2212
2212
|
}
|
2213
2213
|
}
|
2214
2214
|
_getChange() {
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2215
|
+
let handleAbort = u.memoize((request) => this._handleAbortOption(request));
|
2216
|
+
let renderOptions = { ...this.options, handleAbort };
|
2217
|
+
if (renderOptions.url) {
|
2218
|
+
return new up.Change.FromURL(renderOptions);
|
2219
|
+
}
|
2220
|
+
else if (renderOptions.response) {
|
2221
|
+
return new up.Change.FromResponse(renderOptions);
|
2218
2222
|
}
|
2219
2223
|
else {
|
2220
|
-
|
2221
|
-
if (this.options.response) {
|
2222
|
-
return new up.Change.FromResponse({ ...this.options, onRender });
|
2223
|
-
}
|
2224
|
-
else {
|
2225
|
-
return new up.Change.FromContent({ ...this.options, onRender });
|
2226
|
-
}
|
2224
|
+
return new up.Change.FromContent(renderOptions);
|
2227
2225
|
}
|
2228
2226
|
}
|
2229
2227
|
_emitGuardEvent() {
|
@@ -2264,7 +2262,7 @@ up.RenderJob = (_a = class RenderJob {
|
|
2264
2262
|
}
|
2265
2263
|
},
|
2266
2264
|
(() => {
|
2267
|
-
u.delegatePromise(_a.prototype,
|
2265
|
+
u.delegatePromise(_a.prototype, function () { return this._rendered; });
|
2268
2266
|
u.memoizeMethod(_a.prototype, {
|
2269
2267
|
_awaitFinished: true,
|
2270
2268
|
_getChange: true,
|
@@ -2855,9 +2853,8 @@ up.Change.CloseLayer = class CloseLayer extends up.Change {
|
|
2855
2853
|
this._history = options.history ?? true;
|
2856
2854
|
}
|
2857
2855
|
execute() {
|
2858
|
-
if (!this._layer.isOpen())
|
2859
|
-
return
|
2860
|
-
}
|
2856
|
+
if (!this._layer.isOpen())
|
2857
|
+
return;
|
2861
2858
|
up.browser.assertConfirmed(this.options);
|
2862
2859
|
if (this._emitCloseEvent().defaultPrevented && this._preventable) {
|
2863
2860
|
throw new up.Aborted('Close event was prevented');
|
@@ -2906,10 +2903,13 @@ up.Change.CloseLayer = class CloseLayer extends up.Change {
|
|
2906
2903
|
});
|
2907
2904
|
}
|
2908
2905
|
_handleFocus(formerParent) {
|
2906
|
+
let hadFocus = this._layer.hasFocus();
|
2909
2907
|
this._layer.overlayFocus.teardown();
|
2910
2908
|
formerParent.overlayFocus?.moveToFront();
|
2911
|
-
|
2912
|
-
|
2909
|
+
if (hadFocus) {
|
2910
|
+
let newFocusElement = this._layer.origin || formerParent.element;
|
2911
|
+
up.focus(newFocusElement, { preventScroll: true });
|
2912
|
+
}
|
2913
2913
|
}
|
2914
2914
|
};
|
2915
2915
|
|
@@ -2928,16 +2928,13 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2928
2928
|
up.network.loadPage(this.options);
|
2929
2929
|
return u.unresolvablePromise();
|
2930
2930
|
}
|
2931
|
-
this.request = up.request(this._getRequestAttrs());
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
this.
|
2936
|
-
|
2937
|
-
|
2938
|
-
_onRequestProcessed() {
|
2939
|
-
this.options.onRequestProcessed?.(this.request);
|
2940
|
-
this.request.runPreviews(this.options);
|
2931
|
+
let request = this.request = up.request(this._getRequestAttrs());
|
2932
|
+
this.options.onRequestKnown?.(request);
|
2933
|
+
if (this.options.preload)
|
2934
|
+
return request;
|
2935
|
+
this.options.handleAbort?.(request);
|
2936
|
+
request.runPreviews(this.options);
|
2937
|
+
return await u.always(request, responseOrError => this._onRequestSettled(responseOrError));
|
2941
2938
|
}
|
2942
2939
|
_newPageReason() {
|
2943
2940
|
if (u.isCrossOrigin(this.options.url)) {
|
@@ -2954,7 +2951,6 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2954
2951
|
...this.options,
|
2955
2952
|
...successAttrs,
|
2956
2953
|
...u.withRenamedKeys(failAttrs, up.fragment.failKey),
|
2957
|
-
onProcessed: this._onRequestProcessed.bind(this),
|
2958
2954
|
};
|
2959
2955
|
}
|
2960
2956
|
getPreflightProps() {
|
@@ -3203,7 +3199,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3203
3199
|
if (assets) {
|
3204
3200
|
up.script.assertAssetsOK(assets, plan.options);
|
3205
3201
|
}
|
3206
|
-
this.options.
|
3202
|
+
this.options.handleAbort?.(null);
|
3207
3203
|
}
|
3208
3204
|
_getResponseDoc() {
|
3209
3205
|
if (this._preflight)
|
@@ -4105,15 +4101,21 @@ up.FormValidator = class FormValidator {
|
|
4105
4101
|
/***/ (() => {
|
4106
4102
|
|
4107
4103
|
up.FocusCapsule = class FocusCapsule {
|
4108
|
-
constructor(element, target
|
4104
|
+
constructor(element, target) {
|
4109
4105
|
this._element = element;
|
4110
4106
|
this._target = target;
|
4111
|
-
this._cursorProps =
|
4107
|
+
this._cursorProps = up.viewport.copyCursorProps(this._element);
|
4112
4108
|
}
|
4113
4109
|
wasLost() {
|
4114
|
-
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);
|
4115
4114
|
}
|
4116
4115
|
restore(layer, focusOptions) {
|
4116
|
+
if (!this.wasLost()) {
|
4117
|
+
return false;
|
4118
|
+
}
|
4117
4119
|
let rediscoveredElement = up.fragment.get(this._target, { layer });
|
4118
4120
|
if (rediscoveredElement) {
|
4119
4121
|
up.viewport.copyCursorProps(this._cursorProps, rediscoveredElement);
|
@@ -4128,8 +4130,7 @@ up.FocusCapsule = class FocusCapsule {
|
|
4128
4130
|
let target = up.fragment.tryToTarget(focusedElement);
|
4129
4131
|
if (!target)
|
4130
4132
|
return;
|
4131
|
-
|
4132
|
-
return new this(focusedElement, target, cursorProps);
|
4133
|
+
return new this(focusedElement, target);
|
4133
4134
|
}
|
4134
4135
|
};
|
4135
4136
|
|
@@ -4302,9 +4303,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
|
|
4302
4303
|
return this._focusElement(match);
|
4303
4304
|
}
|
4304
4305
|
_restoreLostFocus() {
|
4305
|
-
|
4306
|
-
return this.focusCapsule?.restore(this.layer, PREVENT_SCROLL_OPTIONS);
|
4307
|
-
}
|
4306
|
+
return this.focusCapsule?.restore(this.layer, PREVENT_SCROLL_OPTIONS);
|
4308
4307
|
}
|
4309
4308
|
_restorePreviousFocusForLocation() {
|
4310
4309
|
return up.viewport.restoreFocus({ layer: this.layer });
|
@@ -5534,12 +5533,13 @@ up.LinkFollowIntent = class LinkFollowIntent {
|
|
5534
5533
|
constructor(link, callback) {
|
5535
5534
|
this._link = link;
|
5536
5535
|
this._callback = callback;
|
5536
|
+
this._lastRequest = null;
|
5537
5537
|
this._on('mouseenter mousedown touchstart', (event) => this._scheduleCallback(event));
|
5538
5538
|
this._on('mouseleave', () => this._unscheduleCallback());
|
5539
5539
|
up.fragment.onAborted(this._link, () => this._unscheduleCallback());
|
5540
5540
|
}
|
5541
|
-
_on(eventType,
|
5542
|
-
up.on(this._link, eventType, { passive: true },
|
5541
|
+
_on(eventType, fn) {
|
5542
|
+
up.on(this._link, eventType, { passive: true }, fn);
|
5543
5543
|
}
|
5544
5544
|
_scheduleCallback(event) {
|
5545
5545
|
if (!up.link.shouldFollowEvent(event, this._link))
|
@@ -5556,14 +5556,16 @@ up.LinkFollowIntent = class LinkFollowIntent {
|
|
5556
5556
|
}
|
5557
5557
|
_unscheduleCallback() {
|
5558
5558
|
clearTimeout(this._timer);
|
5559
|
-
|
5559
|
+
if (this._lastRequest?.background)
|
5560
|
+
this._lastRequest.abort();
|
5561
|
+
this._lastRequest = null;
|
5560
5562
|
}
|
5561
5563
|
_parseDelay() {
|
5562
5564
|
return e.numberAttr(this._link, 'up-preload-delay') ?? up.link.config.preloadDelay;
|
5563
5565
|
}
|
5564
5566
|
_runCallback(event) {
|
5565
5567
|
up.log.putsEvent(event);
|
5566
|
-
|
5568
|
+
this._callback({ onRequestKnown: (request) => this._lastRequest = request });
|
5567
5569
|
}
|
5568
5570
|
};
|
5569
5571
|
|
@@ -5680,17 +5682,15 @@ up.NonceableCallback = class NonceableCallback {
|
|
5680
5682
|
return new this(match[3], match[2]);
|
5681
5683
|
}
|
5682
5684
|
toFunction(...argNames) {
|
5683
|
-
let
|
5684
|
-
if (!/\b(;|return|throw)\b/.test(scriptExpression))
|
5685
|
-
scriptExpression = `return ${scriptExpression}`;
|
5685
|
+
let script = this.script;
|
5686
5686
|
if (this.nonce) {
|
5687
5687
|
let callbackThis = this;
|
5688
5688
|
return function (...args) {
|
5689
|
-
return callbackThis._runAsNoncedFunction(
|
5689
|
+
return callbackThis._runAsNoncedFunction(script, this, argNames, args);
|
5690
5690
|
};
|
5691
5691
|
}
|
5692
5692
|
else {
|
5693
|
-
return new Function(...argNames,
|
5693
|
+
return new Function(...argNames, script);
|
5694
5694
|
}
|
5695
5695
|
}
|
5696
5696
|
toString() {
|
@@ -6811,7 +6811,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6811
6811
|
}
|
6812
6812
|
},
|
6813
6813
|
(() => {
|
6814
|
-
u.delegatePromise(_a.prototype,
|
6814
|
+
u.delegatePromise(_a.prototype, function () { return this._deferred; });
|
6815
6815
|
})(),
|
6816
6816
|
_a);
|
6817
6817
|
|
@@ -6959,14 +6959,14 @@ up.Request.Cache = class Cache {
|
|
6959
6959
|
_isUsable(request) {
|
6960
6960
|
return request.age < up.network.config.cacheEvictAge;
|
6961
6961
|
}
|
6962
|
-
get
|
6962
|
+
get currentSize() {
|
6963
6963
|
return this._requests.length;
|
6964
6964
|
}
|
6965
6965
|
get _capacity() {
|
6966
6966
|
return up.network.config.cacheSize;
|
6967
6967
|
}
|
6968
6968
|
_limitSize() {
|
6969
|
-
for (let i = 0; i < (this.
|
6969
|
+
for (let i = 0; i < (this.currentSize - this._capacity); i++) {
|
6970
6970
|
this._delete(this._requests[0]);
|
6971
6971
|
}
|
6972
6972
|
}
|
@@ -8059,7 +8059,10 @@ up.protocol = (function () {
|
|
8059
8059
|
return u.normalizeMethod(up.browser.popCookie('_up_method'));
|
8060
8060
|
});
|
8061
8061
|
function locationFromXHR(xhr) {
|
8062
|
-
|
8062
|
+
let location = extractHeader(xhr, 'location') || xhr.responseURL;
|
8063
|
+
if (location) {
|
8064
|
+
return u.normalizeURL(location);
|
8065
|
+
}
|
8063
8066
|
}
|
8064
8067
|
const config = new up.Config(() => ({
|
8065
8068
|
methodParam: '_method',
|
@@ -8234,7 +8237,6 @@ up.script = (function () {
|
|
8234
8237
|
'up-on-finished',
|
8235
8238
|
'up-on-error',
|
8236
8239
|
'up-on-offline',
|
8237
|
-
'up-placeholder',
|
8238
8240
|
],
|
8239
8241
|
scriptSelectors: [
|
8240
8242
|
'script:not([type])',
|
@@ -9004,7 +9006,7 @@ up.fragment = (function () {
|
|
9004
9006
|
continue;
|
9005
9007
|
let placement = defaultPlacement;
|
9006
9008
|
let maybe = defaultMaybe;
|
9007
|
-
selector = selector.replace(/\b::?(before|after)\b/, (_match, customPlacement) => {
|
9009
|
+
selector = selector.replace(/\b::?(before|after|content)\b/, (_match, customPlacement) => {
|
9008
9010
|
placement = customPlacement;
|
9009
9011
|
return '';
|
9010
9012
|
});
|
@@ -9468,7 +9470,7 @@ up.viewport = (function () {
|
|
9468
9470
|
function firstHashTarget(hash, options = {}) {
|
9469
9471
|
if (hash = pureHash(hash)) {
|
9470
9472
|
const selector = [
|
9471
|
-
e.
|
9473
|
+
e.idSelector(hash),
|
9472
9474
|
'a' + e.attrSelector('name', hash)
|
9473
9475
|
].join();
|
9474
9476
|
return f.get(selector, options);
|
@@ -10488,7 +10490,7 @@ up.link = (function () {
|
|
10488
10490
|
return follow(link, forcedOptions, { defaults });
|
10489
10491
|
}
|
10490
10492
|
up.attribute('up-defer', { defaultValue: 'insert' }, function (link, condition) {
|
10491
|
-
let doLoad = () => up.error.muteUncriticalRejection(loadDeferred(link));
|
10493
|
+
let doLoad = (options) => up.error.muteUncriticalRejection(loadDeferred(link, options));
|
10492
10494
|
onLoadCondition(condition, link, doLoad);
|
10493
10495
|
});
|
10494
10496
|
up.on('up:click', config.selectorFn('followSelectors'), function (event, link) {
|
@@ -10511,7 +10513,7 @@ up.link = (function () {
|
|
10511
10513
|
});
|
10512
10514
|
up.compiler(config.selectorFn('preloadSelectors'), function (link) {
|
10513
10515
|
if (!isPreloadDisabled(link)) {
|
10514
|
-
let doPreload = () => up.error.muteUncriticalRejection(preload(link));
|
10516
|
+
let doPreload = (options) => up.error.muteUncriticalRejection(preload(link, options));
|
10515
10517
|
let condition = e.booleanOrStringAttr(link, 'up-preload');
|
10516
10518
|
if (condition === true || u.isUndefined(condition))
|
10517
10519
|
condition = 'hover';
|
@@ -10650,16 +10652,10 @@ up.form = (function () {
|
|
10650
10652
|
else {
|
10651
10653
|
control.disabled = true;
|
10652
10654
|
}
|
10653
|
-
return () => {
|
10654
|
-
control.disabled = false;
|
10655
|
-
if (focusFallback && document.activeElement === focusFallback && control.isConnected) {
|
10656
|
-
up.focus(control, { preventScroll: true });
|
10657
|
-
}
|
10658
|
-
};
|
10655
|
+
return () => { control.disabled = false; };
|
10659
10656
|
}
|
10660
10657
|
function getDisableContainers(disable, origin) {
|
10661
|
-
let
|
10662
|
-
let originScope = () => getScope(givenOrigin());
|
10658
|
+
let originScope = () => getScope(origin);
|
10663
10659
|
if (disable === true) {
|
10664
10660
|
return [originScope()];
|
10665
10661
|
}
|
@@ -10848,8 +10844,13 @@ up.form = (function () {
|
|
10848
10844
|
const element = up.fragment.get(elementOrSelector, options);
|
10849
10845
|
return element.form || element.closest('form');
|
10850
10846
|
}
|
10851
|
-
function getScope(
|
10852
|
-
|
10847
|
+
function getScope(origin, options) {
|
10848
|
+
if (origin) {
|
10849
|
+
return getForm(origin, options) || up.layer.get(origin).element;
|
10850
|
+
}
|
10851
|
+
else {
|
10852
|
+
return up.layer.current.element;
|
10853
|
+
}
|
10853
10854
|
}
|
10854
10855
|
function focusedField() {
|
10855
10856
|
return u.presence(document.activeElement, isField);
|
@@ -10964,7 +10965,7 @@ up.status = (function () {
|
|
10964
10965
|
let focusCapsule = up.FocusCapsule.preserve(bindLayer);
|
10965
10966
|
let applyPreviews = () => doRunPreviews(request, renderOptions);
|
10966
10967
|
let revertPreviews = bindLayer.asCurrent(applyPreviews);
|
10967
|
-
|
10968
|
+
focusCapsule?.autoVoid();
|
10968
10969
|
return () => {
|
10969
10970
|
bindLayer.asCurrent(revertPreviews);
|
10970
10971
|
focusCapsule?.restore(bindLayer, { preventScroll: true });
|