unpoly-rails 3.0.0 → 3.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.
- checksums.yaml +4 -4
- data/assets/unpoly/unpoly-migrate.js +16 -9
- data/assets/unpoly/unpoly-migrate.min.js +1 -1
- data/assets/unpoly/unpoly.es6.js +67 -45
- data/assets/unpoly/unpoly.es6.min.js +1 -1
- data/assets/unpoly/unpoly.js +66 -44
- data/assets/unpoly/unpoly.min.js +1 -1
- data/lib/unpoly/rails/version.rb +1 -1
- metadata +2 -2
data/assets/unpoly/unpoly.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
/***/ (() => {
|
6
6
|
|
7
7
|
window.up = {
|
8
|
-
version: '3.
|
8
|
+
version: '3.1.0'
|
9
9
|
};
|
10
10
|
|
11
11
|
|
@@ -2319,7 +2319,12 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
|
|
2319
2319
|
let cursorProps = up.viewport.copyCursorProps(viewport);
|
2320
2320
|
return () => up.viewport.copyCursorProps(cursorProps, viewport);
|
2321
2321
|
});
|
2322
|
-
document.body
|
2322
|
+
if (this.willChangeElement(document.body)) {
|
2323
|
+
keepPlan.newElement.replaceWith(keepable);
|
2324
|
+
}
|
2325
|
+
else {
|
2326
|
+
document.body.append(keepable);
|
2327
|
+
}
|
2323
2328
|
keepPlans.push(keepPlan);
|
2324
2329
|
}
|
2325
2330
|
}
|
@@ -2434,6 +2439,9 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
|
|
2434
2439
|
const oldFragments = u.map(this.steps, 'oldElement');
|
2435
2440
|
return u.some(oldFragments, up.fragment.hasAutoHistory);
|
2436
2441
|
}
|
2442
|
+
willChangeElement(element) {
|
2443
|
+
return u.some(this.steps, (step) => step.oldElement.contains(element));
|
2444
|
+
}
|
2437
2445
|
},
|
2438
2446
|
(() => {
|
2439
2447
|
u.memoizeMethod(_a.prototype, [
|
@@ -3517,16 +3525,19 @@ up.FormValidator = class FormValidator {
|
|
3517
3525
|
this.honorAbort();
|
3518
3526
|
}
|
3519
3527
|
honorAbort() {
|
3520
|
-
up.fragment.onAborted(this.form, ({ target }) =>
|
3521
|
-
|
3522
|
-
|
3528
|
+
up.fragment.onAborted(this.form, { around: true }, ({ target }) => this.unscheduleSolutionsWithin(target));
|
3529
|
+
}
|
3530
|
+
unscheduleSolutionsWithin(container) {
|
3531
|
+
this.dirtySolutions = u.reject(this.dirtySolutions, ({ element }) => container.contains(element));
|
3523
3532
|
}
|
3524
3533
|
resetNextRenderPromise() {
|
3525
3534
|
this.nextRenderPromise = u.newDeferred();
|
3526
3535
|
}
|
3527
3536
|
watchContainer(fieldOrForm) {
|
3528
3537
|
let { event } = this.originOptions(fieldOrForm);
|
3529
|
-
|
3538
|
+
let guard = () => up.fragment.isAlive(fieldOrForm);
|
3539
|
+
let callback = () => up.error.muteUncriticalRejection(this.validate({ origin: fieldOrForm }));
|
3540
|
+
up.on(fieldOrForm, event, { guard }, callback);
|
3530
3541
|
}
|
3531
3542
|
validate(options = {}) {
|
3532
3543
|
let solutions = this.getSolutions(options);
|
@@ -3562,13 +3573,19 @@ up.FormValidator = class FormValidator {
|
|
3562
3573
|
if (u.isString(target) && target) {
|
3563
3574
|
up.puts('up.validate()', 'Validating target "%s"', target);
|
3564
3575
|
let simpleSelectors = up.fragment.splitTarget(target);
|
3565
|
-
return simpleSelectors.map(function (simpleSelector) {
|
3566
|
-
|
3567
|
-
|
3568
|
-
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3576
|
+
return u.compact(simpleSelectors.map(function (simpleSelector) {
|
3577
|
+
let element = up.fragment.get(simpleSelector, { origin });
|
3578
|
+
if (element) {
|
3579
|
+
return {
|
3580
|
+
element,
|
3581
|
+
target: simpleSelector,
|
3582
|
+
origin
|
3583
|
+
};
|
3584
|
+
}
|
3585
|
+
else {
|
3586
|
+
up.fail('Validation target "%s" does not match an element', simpleSelector);
|
3587
|
+
}
|
3588
|
+
}));
|
3572
3589
|
}
|
3573
3590
|
}
|
3574
3591
|
getElementSolutions(element) {
|
@@ -3602,7 +3619,7 @@ up.FormValidator = class FormValidator {
|
|
3602
3619
|
up.error.muteUncriticalRejection(this.doRenderDirtySolutions());
|
3603
3620
|
}
|
3604
3621
|
async doRenderDirtySolutions() {
|
3605
|
-
this.dirtySolutions = u.filter(this.dirtySolutions, ({ element, origin }) => element
|
3622
|
+
this.dirtySolutions = u.filter(this.dirtySolutions, ({ element, origin }) => up.fragment.isAlive(element) && up.fragment.isAlive(origin));
|
3606
3623
|
if (!this.dirtySolutions.length || this.rendering) {
|
3607
3624
|
return;
|
3608
3625
|
}
|
@@ -4639,13 +4656,13 @@ up.Layer.OverlayWithViewport = (_a = class OverlayWithViewport extends up.Layer.
|
|
4639
4656
|
var _a;
|
4640
4657
|
const e = up.element;
|
4641
4658
|
up.Layer.Root = (_a = class Root extends up.Layer {
|
4659
|
+
get element() {
|
4660
|
+
return e.root;
|
4661
|
+
}
|
4642
4662
|
constructor(options) {
|
4643
4663
|
super(options);
|
4644
4664
|
this.setupHandlers();
|
4645
4665
|
}
|
4646
|
-
get element() {
|
4647
|
-
return e.root;
|
4648
|
-
}
|
4649
4666
|
getFirstSwappableElement() {
|
4650
4667
|
return document.body;
|
4651
4668
|
}
|
@@ -5652,7 +5669,6 @@ up.RenderOptions = (function () {
|
|
5652
5669
|
saveFocus: true,
|
5653
5670
|
focus: 'keep',
|
5654
5671
|
abort: 'target',
|
5655
|
-
revalidate: 'auto',
|
5656
5672
|
failOptions: true,
|
5657
5673
|
};
|
5658
5674
|
const PRELOAD_OVERRIDES = {
|
@@ -5797,26 +5813,6 @@ up.RenderResult = class RenderResult extends up.Record {
|
|
5797
5813
|
var _a;
|
5798
5814
|
const u = up.util;
|
5799
5815
|
up.Request = (_a = class Request extends up.Record {
|
5800
|
-
constructor(options) {
|
5801
|
-
super(options);
|
5802
|
-
this.params = new up.Params(this.params);
|
5803
|
-
if (this.wrapMethod == null) {
|
5804
|
-
this.wrapMethod = up.network.config.wrapMethod;
|
5805
|
-
}
|
5806
|
-
this.normalize();
|
5807
|
-
if ((this.target || this.layer || this.origin) && !options.basic) {
|
5808
|
-
const layerLookupOptions = { origin: this.origin };
|
5809
|
-
this.layer = up.layer.get(this.layer, layerLookupOptions);
|
5810
|
-
this.failLayer = up.layer.get(this.failLayer || this.layer, layerLookupOptions);
|
5811
|
-
this.context || (this.context = this.layer.context || {});
|
5812
|
-
this.failContext || (this.failContext = this.failLayer.context || {});
|
5813
|
-
this.mode || (this.mode = this.layer.mode);
|
5814
|
-
this.failMode || (this.failMode = this.failLayer.mode);
|
5815
|
-
}
|
5816
|
-
this.deferred = u.newDeferred();
|
5817
|
-
this.badResponseTime ?? (this.badResponseTime = u.evalOption(up.network.config.badResponseTime, this));
|
5818
|
-
this.addAutoHeaders();
|
5819
|
-
}
|
5820
5816
|
keys() {
|
5821
5817
|
return [
|
5822
5818
|
'method',
|
@@ -5859,6 +5855,26 @@ up.Request = (_a = class Request extends up.Record {
|
|
5859
5855
|
builtAt: new Date(),
|
5860
5856
|
};
|
5861
5857
|
}
|
5858
|
+
constructor(options) {
|
5859
|
+
super(options);
|
5860
|
+
this.params = new up.Params(this.params);
|
5861
|
+
if (this.wrapMethod == null) {
|
5862
|
+
this.wrapMethod = up.network.config.wrapMethod;
|
5863
|
+
}
|
5864
|
+
this.normalize();
|
5865
|
+
if ((this.target || this.layer || this.origin) && !options.basic) {
|
5866
|
+
const layerLookupOptions = { origin: this.origin };
|
5867
|
+
this.layer = up.layer.get(this.layer, layerLookupOptions);
|
5868
|
+
this.failLayer = up.layer.get(this.failLayer || this.layer, layerLookupOptions);
|
5869
|
+
this.context || (this.context = this.layer.context || {});
|
5870
|
+
this.failContext || (this.failContext = this.failLayer.context || {});
|
5871
|
+
this.mode || (this.mode = this.layer.mode);
|
5872
|
+
this.failMode || (this.failMode = this.failLayer.mode);
|
5873
|
+
}
|
5874
|
+
this.deferred = u.newDeferred();
|
5875
|
+
this.badResponseTime ?? (this.badResponseTime = u.evalOption(up.network.config.badResponseTime, this));
|
5876
|
+
this.addAutoHeaders();
|
5877
|
+
}
|
5862
5878
|
get xhr() {
|
5863
5879
|
return this._xhr ?? (this._xhr = new XMLHttpRequest());
|
5864
5880
|
}
|
@@ -7713,12 +7729,13 @@ up.fragment = (function () {
|
|
7713
7729
|
verifyDerivedTarget: true,
|
7714
7730
|
navigateOptions: {
|
7715
7731
|
cache: 'auto',
|
7732
|
+
revalidate: 'auto',
|
7716
7733
|
feedback: true,
|
7717
7734
|
fallback: true,
|
7718
7735
|
focus: 'auto',
|
7719
7736
|
scroll: 'auto',
|
7720
7737
|
history: 'auto',
|
7721
|
-
peel: true
|
7738
|
+
peel: true,
|
7722
7739
|
},
|
7723
7740
|
matchAroundOrigin: true,
|
7724
7741
|
runScripts: true,
|
@@ -7785,10 +7802,12 @@ up.fragment = (function () {
|
|
7785
7802
|
const parent = options.parent || document;
|
7786
7803
|
return up.emit(parent, 'up:fragment:destroyed', { fragment, parent, log });
|
7787
7804
|
}
|
7788
|
-
function
|
7789
|
-
return
|
7805
|
+
function isNotDestroying(element) {
|
7806
|
+
return !element.closest('.up-destroying');
|
7807
|
+
}
|
7808
|
+
function isAlive(fragment) {
|
7809
|
+
return fragment.isConnected && isNotDestroying(fragment);
|
7790
7810
|
}
|
7791
|
-
const isNotDestroying = u.negate(isDestroying);
|
7792
7811
|
function getSmart(...args) {
|
7793
7812
|
const options = u.extractOptions(args);
|
7794
7813
|
const selector = args.pop();
|
@@ -8138,8 +8157,10 @@ up.fragment = (function () {
|
|
8138
8157
|
up.emit(element, 'up:fragment:aborted', { log: false });
|
8139
8158
|
}
|
8140
8159
|
}
|
8141
|
-
function onAborted(fragment,
|
8142
|
-
let
|
8160
|
+
function onAborted(fragment, ...args) {
|
8161
|
+
let callback = u.extractCallback(args);
|
8162
|
+
let options = u.extractOptions(args);
|
8163
|
+
let guard = (event) => event.target.contains(fragment) || (options.around && fragment.contains(event.target));
|
8143
8164
|
let unsubscribe = up.on('up:fragment:aborted', { guard }, callback);
|
8144
8165
|
up.destructor(fragment, unsubscribe);
|
8145
8166
|
return unsubscribe;
|
@@ -8187,6 +8208,7 @@ up.fragment = (function () {
|
|
8187
8208
|
onAborted,
|
8188
8209
|
splitTarget,
|
8189
8210
|
parseTargetSteps,
|
8211
|
+
isAlive,
|
8190
8212
|
};
|
8191
8213
|
})();
|
8192
8214
|
up.reload = up.fragment.reload;
|