unpoly-rails 2.4.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of unpoly-rails might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/assets/unpoly/unpoly.css +1 -1
- data/assets/unpoly/unpoly.es5.js +134 -43
- data/assets/unpoly/unpoly.es5.min.js +1 -1
- data/assets/unpoly/unpoly.js +134 -43
- data/assets/unpoly/unpoly.min.css +1 -1
- data/assets/unpoly/unpoly.min.js +1 -1
- data/lib/unpoly/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfc6a21b6b4c3fc7ca2773d5d89a7784011ea7a25b02d91b41242692d7c96642
|
4
|
+
data.tar.gz: aa8f9f2b03a820b3c9a77063f7c5af9e89933b82ebd9c80d9cce1fc5ef838511
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 551e3a230fbaef98632c4c531d86034953d2288ad2358d4e02ea625991e1504ef769a1e22f3d6b65e5f48ad8717ce6cc42873c55892e560fdb4d041ee39071e9
|
7
|
+
data.tar.gz: 41ab6a4f9c2953aa93d6a3843177e3503583b29579bc365cb9c5ce12e3d93f7a235828aaf80fb445b78f537915a441cf9658f8926e095a8b8643674d87d5b842
|
data/assets/unpoly/unpoly.css
CHANGED
data/assets/unpoly/unpoly.es5.js
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
@module up
|
9
9
|
*/
|
10
10
|
window.up = {
|
11
|
-
version: '2.
|
11
|
+
version: '2.5.0'
|
12
12
|
};
|
13
13
|
|
14
14
|
|
@@ -3064,8 +3064,12 @@ up.element = (function () {
|
|
3064
3064
|
// innerHTML on Chrome. See https://jsben.ch/QQngJ
|
3065
3065
|
var range = document.createRange();
|
3066
3066
|
range.setStart(document.body, 0);
|
3067
|
-
var fragment = range.createContextualFragment(html);
|
3068
|
-
|
3067
|
+
var fragment = range.createContextualFragment(html.trim());
|
3068
|
+
var elements = fragment.childNodes;
|
3069
|
+
if (elements.length !== 1) {
|
3070
|
+
throw new Error('HTML must have a single root element');
|
3071
|
+
}
|
3072
|
+
return elements[0];
|
3069
3073
|
}
|
3070
3074
|
/*-
|
3071
3075
|
@function up.element.root
|
@@ -4718,6 +4722,9 @@ up.Change.UpdateLayer = /** @class */ (function (_super) {
|
|
4718
4722
|
var lookupOpts = { layer: this.layer, origin: oldElement };
|
4719
4723
|
var partner = void 0;
|
4720
4724
|
if (options.descendantsOnly) {
|
4725
|
+
// Since newElement is from a freshly parsed HTML document, we could use
|
4726
|
+
// up.element functions to match the selector. However, since we also want
|
4727
|
+
// to use custom selectors like ":main" or "&" we use up.fragment.get().
|
4721
4728
|
partner = up.fragment.get(newElement, partnerSelector, lookupOpts);
|
4722
4729
|
}
|
4723
4730
|
else {
|
@@ -5282,11 +5289,11 @@ up.Change.FromURL = /** @class */ (function (_super) {
|
|
5282
5289
|
}
|
5283
5290
|
else {
|
5284
5291
|
var log = ['Loaded fragment from failed response to %s (HTTP %d)', this.request.description, this.response.status];
|
5292
|
+
// Although updateContentFromResponse() will fulfill with a successful replacement of options.failTarget,
|
5293
|
+
// we still want to reject the promise that's returned to our API client. Hence we throw.
|
5285
5294
|
throw this.updateContentFromResponse(log, this.failOptions);
|
5286
5295
|
}
|
5287
5296
|
};
|
5288
|
-
// Although processResponse() will fulfill with a successful replacement of options.failTarget,
|
5289
|
-
// we still want to reject the promise that's returned to our API client.
|
5290
5297
|
FromURL.prototype.isSuccessfulResponse = function () {
|
5291
5298
|
return (this.successOptions.fail === false) || this.response.ok;
|
5292
5299
|
};
|
@@ -11657,7 +11664,7 @@ var u = up.util;
|
|
11657
11664
|
up.store || (up.store = {});
|
11658
11665
|
up.store.Memory = /** @class */ (function () {
|
11659
11666
|
function Memory() {
|
11660
|
-
this.
|
11667
|
+
this.data = {};
|
11661
11668
|
}
|
11662
11669
|
Memory.prototype.clear = function () {
|
11663
11670
|
this.data = {};
|
@@ -11990,7 +11997,7 @@ up.URLPattern = /** @class */ (function () {
|
|
11990
11997
|
return '([^/?#]+)';
|
11991
11998
|
}
|
11992
11999
|
});
|
11993
|
-
return new RegExp('^' + reCode + '$');
|
12000
|
+
return new RegExp('^(?:' + reCode + ')$');
|
11994
12001
|
};
|
11995
12002
|
// This method is performance-sensitive. It's called for every link in an [up-nav]
|
11996
12003
|
// after every fragment update.
|
@@ -13669,11 +13676,14 @@ up.log = (function () {
|
|
13669
13676
|
Note that errors will always be printed, regardless of this setting.
|
13670
13677
|
@param {boolean} [config.banner=true]
|
13671
13678
|
Print the Unpoly banner to the developer console.
|
13679
|
+
@param {boolean} [config.format=!isIE11]
|
13680
|
+
Format output using CSS.
|
13672
13681
|
@stable
|
13673
13682
|
*/
|
13674
13683
|
var config = new up.Config(function () { return ({
|
13675
13684
|
enabled: sessionStore.get('enabled'),
|
13676
|
-
banner: true
|
13685
|
+
banner: true,
|
13686
|
+
format: up.browser.canFormatLog()
|
13677
13687
|
}); });
|
13678
13688
|
function reset() {
|
13679
13689
|
config.reset();
|
@@ -13734,7 +13744,7 @@ up.log = (function () {
|
|
13734
13744
|
args[_i - 3] = arguments[_i];
|
13735
13745
|
}
|
13736
13746
|
if (message) {
|
13737
|
-
if (
|
13747
|
+
if (config.format) {
|
13738
13748
|
args.unshift(''); // Reset
|
13739
13749
|
args.unshift('color: #666666; padding: 1px 3px; border: 1px solid #bbbbbb; border-radius: 2px; font-size: 90%; display: inline-block');
|
13740
13750
|
message = "%c" + trace + "%c " + message;
|
@@ -13765,7 +13775,7 @@ up.log = (function () {
|
|
13765
13775
|
text += "Call `up.log.enable()` to enable logging for this session.";
|
13766
13776
|
}
|
13767
13777
|
var color = 'color: #777777';
|
13768
|
-
if (
|
13778
|
+
if (config.format) {
|
13769
13779
|
console.log('%c' + logo + '%c' + text, 'font-family: monospace;' + color, color);
|
13770
13780
|
}
|
13771
13781
|
else {
|
@@ -14461,9 +14471,11 @@ up.history = (function () {
|
|
14461
14471
|
|
14462
14472
|
@property up.history.config
|
14463
14473
|
@param {Array} [config.restoreTargets=[]]
|
14464
|
-
A list of possible CSS selectors to [replace](/up.render) when the user goes back in history.
|
14474
|
+
A list of possible CSS selectors to [replace](/up.render) when the user goes back or forward in history.
|
14475
|
+
|
14476
|
+
If more than one target is configured, the first selector matching both the current page and server response will be updated.
|
14465
14477
|
|
14466
|
-
|
14478
|
+
If nothing is configured, the `<body>` element will be replaced.
|
14467
14479
|
@param {boolean} [config.enabled=true]
|
14468
14480
|
Defines whether [fragment updates](/up.render) will update the browser's current URL.
|
14469
14481
|
|
@@ -14686,7 +14698,6 @@ up.history = (function () {
|
|
14686
14698
|
layer: 'root',
|
14687
14699
|
target: config.restoreTargets,
|
14688
14700
|
cache: true,
|
14689
|
-
keep: false,
|
14690
14701
|
scroll: 'restore',
|
14691
14702
|
// Since the URL was already changed by the browser, don't save scroll state.
|
14692
14703
|
saveScroll: false
|
@@ -14853,7 +14864,8 @@ up.fragment = (function () {
|
|
14853
14864
|
@param {Array<string>} [config.mainTargets=['[up-main]', 'main', ':layer']]
|
14854
14865
|
An array of CSS selectors matching default render targets.
|
14855
14866
|
|
14856
|
-
When no other render target is given, Unpoly will
|
14867
|
+
When no other render target is given, Unpoly will update the first selector matching both
|
14868
|
+
the current page and the server response.
|
14857
14869
|
|
14858
14870
|
When [navigating](/navigation) to a main target, Unpoly will automatically
|
14859
14871
|
[reset scroll positions](/scroll-option) and
|
@@ -17712,7 +17724,6 @@ up.motion = (function () {
|
|
17712
17724
|
|
17713
17725
|
```js
|
17714
17726
|
up.animate('.warning', 'fade-in', {
|
17715
|
-
delay: 1000,
|
17716
17727
|
duration: 250,
|
17717
17728
|
easing: 'linear'
|
17718
17729
|
})
|
@@ -19799,7 +19810,7 @@ up.layer = (function () {
|
|
19799
19810
|
@stable
|
19800
19811
|
*/
|
19801
19812
|
/*-
|
19802
|
-
This event is emitted after a new overlay
|
19813
|
+
This event is emitted after a new overlay was placed into the DOM.
|
19803
19814
|
|
19804
19815
|
The event is emitted right before the opening animation starts. Because the overlay
|
19805
19816
|
has not been rendered by the browser, this makes it a good occasion to
|
@@ -19882,7 +19893,7 @@ up.layer = (function () {
|
|
19882
19893
|
}
|
19883
19894
|
}
|
19884
19895
|
/*-
|
19885
|
-
[Follows](/a-up-follow) this link and opens the result in a new overlay.
|
19896
|
+
[Follows](/a-up-follow) this link and [opens the result in a new overlay](/opening-overlays).
|
19886
19897
|
|
19887
19898
|
### Example
|
19888
19899
|
|
@@ -20261,6 +20272,34 @@ up.layer = (function () {
|
|
20261
20272
|
@stable
|
20262
20273
|
*/
|
20263
20274
|
/*-
|
20275
|
+
This event is emitted before a layer is [accepted](/closing-overlays).
|
20276
|
+
|
20277
|
+
The event is emitted on the [element of the layer](/up.layer.element) that is about to close.
|
20278
|
+
|
20279
|
+
@event up:layer:accept
|
20280
|
+
@param {up.Layer} event.layer
|
20281
|
+
The layer that is about to close.
|
20282
|
+
@param {Element} [event.origin]
|
20283
|
+
The element that is causing the layer to close.
|
20284
|
+
@param event.preventDefault()
|
20285
|
+
Event listeners may call this method to prevent the overlay from closing.
|
20286
|
+
@stable
|
20287
|
+
*/
|
20288
|
+
/*-
|
20289
|
+
This event is emitted after a layer was [accepted](/closing-overlays).
|
20290
|
+
|
20291
|
+
The event is emitted on the [layer's](/up.layer.element) when the close animation
|
20292
|
+
is starting. If the layer has no close animaton and was already removed from the DOM,
|
20293
|
+
the event is emitted a second time on the `document`.
|
20294
|
+
|
20295
|
+
@event up:layer:accepted
|
20296
|
+
@param {up.Layer} event.layer
|
20297
|
+
The layer that was closed.
|
20298
|
+
@param {Element} [event.origin]
|
20299
|
+
The element that has caused the layer to close.
|
20300
|
+
@stable
|
20301
|
+
*/
|
20302
|
+
/*-
|
20264
20303
|
[Dismisses](/closing-overlays) the [current layer](/up.layer.current).
|
20265
20304
|
|
20266
20305
|
This is a shortcut for `up.layer.current.dismiss()`.
|
@@ -20272,6 +20311,34 @@ up.layer = (function () {
|
|
20272
20311
|
@stable
|
20273
20312
|
*/
|
20274
20313
|
/*-
|
20314
|
+
This event is emitted before a layer is [dismissed](/closing-overlays).
|
20315
|
+
|
20316
|
+
The event is emitted on the [element of the layer](/up.layer.element) that is about to close.
|
20317
|
+
|
20318
|
+
@event up:layer:dismiss
|
20319
|
+
@param {up.Layer} event.layer
|
20320
|
+
The layer that is about to close.
|
20321
|
+
@param {Element} [event.origin]
|
20322
|
+
The element that is causing the layer to close.
|
20323
|
+
@param event.preventDefault()
|
20324
|
+
Event listeners may call this method to prevent the overlay from closing.
|
20325
|
+
@stable
|
20326
|
+
*/
|
20327
|
+
/*-
|
20328
|
+
This event is emitted after a layer was [dismissed](/closing-overlays).
|
20329
|
+
|
20330
|
+
The event is emitted on the [layer's](/up.layer.element) when the close animation
|
20331
|
+
is starting. If the layer has no close animaton and was already removed from the DOM,
|
20332
|
+
the event is emitted a second time on the `document`.
|
20333
|
+
|
20334
|
+
@event up:layer:dismissed
|
20335
|
+
@param {up.Layer} event.layer
|
20336
|
+
The layer that was closed.
|
20337
|
+
@param {Element} [event.origin]
|
20338
|
+
The element that has caused the layer to close.
|
20339
|
+
@stable
|
20340
|
+
*/
|
20341
|
+
/*-
|
20275
20342
|
Returns whether the [current layer](/up.layer.current) is the [root layer](/up.layer.root).
|
20276
20343
|
|
20277
20344
|
This is a shortcut for `up.layer.current.isRoot()`.
|
@@ -20846,6 +20913,7 @@ up.link = (function () {
|
|
20846
20913
|
var _a, _b;
|
20847
20914
|
// If passed a selector, up.fragment.get() will prefer a match on the current layer.
|
20848
20915
|
link = up.fragment.get(link);
|
20916
|
+
// Request options
|
20849
20917
|
options = parseRequestOptions(link, options);
|
20850
20918
|
var parser = new up.OptionsParser(options, link, { fail: true });
|
20851
20919
|
// Feedback options
|
@@ -21064,7 +21132,8 @@ up.link = (function () {
|
|
21064
21132
|
}
|
21065
21133
|
e.setMissingAttrs(link, {
|
21066
21134
|
tabindex: '0',
|
21067
|
-
role: 'link'
|
21135
|
+
role: 'link',
|
21136
|
+
'up-clickable': '' // Get pointer pointer from link.css
|
21068
21137
|
});
|
21069
21138
|
link.addEventListener('keydown', function (event) {
|
21070
21139
|
if ((event.key === 'Enter') || (event.key === 'Space')) {
|
@@ -21595,6 +21664,10 @@ up.link = (function () {
|
|
21595
21664
|
}
|
21596
21665
|
e.setMissingAttrs(area, areaAttrs);
|
21597
21666
|
makeFollowable(area);
|
21667
|
+
// We could also consider making the area clickable, via makeClickable().
|
21668
|
+
// However, since the original link is already present within the area,
|
21669
|
+
// we would not add accessibility benefits. We might also confuse screen readers
|
21670
|
+
// with a nested link.
|
21598
21671
|
}
|
21599
21672
|
});
|
21600
21673
|
/*-
|
@@ -21881,21 +21954,40 @@ up.form = (function () {
|
|
21881
21954
|
@stable
|
21882
21955
|
*/
|
21883
21956
|
function submitOptions(form, options) {
|
21957
|
+
form = getForm(form);
|
21958
|
+
options = parseBasicOptions(form, options);
|
21959
|
+
var parser = new up.OptionsParser(options, form);
|
21960
|
+
parser.string('failTarget', { default: up.fragment.toTarget(form) });
|
21961
|
+
// The guardEvent will also be assigned an { renderOptions } property in up.render()
|
21962
|
+
options.guardEvent || (options.guardEvent = up.event.build('up:form:submit', {
|
21963
|
+
submitButton: options.submitButton,
|
21964
|
+
params: options.params,
|
21965
|
+
log: 'Submitting form'
|
21966
|
+
}));
|
21967
|
+
// Now that we have extracted everything form-specific into options, we can call
|
21968
|
+
// up.link.followOptions(). This will also parse the myriads of other options
|
21969
|
+
// that are possible on both <form> and <a> elements.
|
21970
|
+
u.assign(options, up.link.followOptions(form, options));
|
21971
|
+
return options;
|
21972
|
+
}
|
21973
|
+
// This was extracted from submitOptions().
|
21974
|
+
// Validation needs to submit a form without options intended for the final submission,
|
21975
|
+
// like [up-scroll], [up-confirm], etc.
|
21976
|
+
function parseBasicOptions(form, options) {
|
21884
21977
|
options = u.options(options);
|
21885
|
-
form =
|
21886
|
-
form = e.closest(form, 'form');
|
21978
|
+
form = getForm(form);
|
21887
21979
|
var parser = new up.OptionsParser(options, form);
|
21888
21980
|
// Parse params from form fields.
|
21889
21981
|
var params = up.Params.fromForm(form);
|
21890
|
-
|
21891
|
-
if (submitButton) {
|
21982
|
+
options.submitButton || (options.submitButton = submittingButton(form));
|
21983
|
+
if (options.submitButton) {
|
21892
21984
|
// Submit buttons with a [name] attribute will add to the params.
|
21893
21985
|
// Note that addField() will only add an entry if the given button has a [name] attribute.
|
21894
|
-
params.addField(submitButton);
|
21986
|
+
params.addField(options.submitButton);
|
21895
21987
|
// Submit buttons may have [formmethod] and [formaction] attribute
|
21896
21988
|
// that override [method] and [action] attribute from the <form> element.
|
21897
|
-
options.method || (options.method = submitButton.getAttribute('formmethod'));
|
21898
|
-
options.url || (options.url = submitButton.getAttribute('formaction'));
|
21989
|
+
options.method || (options.method = options.submitButton.getAttribute('formmethod'));
|
21990
|
+
options.url || (options.url = options.submitButton.getAttribute('formaction'));
|
21899
21991
|
}
|
21900
21992
|
params.addAll(options.params);
|
21901
21993
|
options.params = params;
|
@@ -21912,13 +22004,6 @@ up.form = (function () {
|
|
21912
22004
|
// a demo of vanilla browser behavior.
|
21913
22005
|
options.url = up.Params.stripURL(options.url);
|
21914
22006
|
}
|
21915
|
-
parser.string('failTarget', { default: up.fragment.toTarget(form) });
|
21916
|
-
// The guardEvent will also be assigned an { renderOptions } property in up.render()
|
21917
|
-
options.guardEvent || (options.guardEvent = up.event.build('up:form:submit', { log: 'Submitting form' }));
|
21918
|
-
// Now that we have extracted everything form-specific into options, we can call
|
21919
|
-
// up.link.followOptions(). This will also parse the myriads of other options
|
21920
|
-
// that are possible on both <form> and <a> elements.
|
21921
|
-
u.assign(options, up.link.followOptions(form, options));
|
21922
22007
|
return options;
|
21923
22008
|
}
|
21924
22009
|
/*-
|
@@ -21945,8 +22030,12 @@ up.form = (function () {
|
|
21945
22030
|
@event up:form:submit
|
21946
22031
|
@param {Element} event.target
|
21947
22032
|
The `<form>` element that will be submitted.
|
22033
|
+
@param {up.Params} event.params
|
22034
|
+
The [form parameters](/up.Params) that will be send as the form's request payload.
|
22035
|
+
@param {Element} [event.submitButton]
|
22036
|
+
The button used to submit the form.
|
21948
22037
|
@param {Object} event.renderOptions
|
21949
|
-
An object with [render options](/up.render) for the fragment update
|
22038
|
+
An object with [render options](/up.render) for the fragment update.
|
21950
22039
|
|
21951
22040
|
Listeners may inspect and modify these options.
|
21952
22041
|
@param event.preventDefault()
|
@@ -21959,7 +22048,7 @@ up.form = (function () {
|
|
21959
22048
|
up.on('up:click', submitButtonSelector, function (event, button) {
|
21960
22049
|
// Don't mess with focus unless we know that we're going to handle the form.
|
21961
22050
|
// https://groups.google.com/g/unpoly/c/wsiATxepVZk
|
21962
|
-
var form =
|
22051
|
+
var form = getForm(button);
|
21963
22052
|
if (form && isSubmittable(form)) {
|
21964
22053
|
button.focus();
|
21965
22054
|
}
|
@@ -22028,7 +22117,7 @@ up.form = (function () {
|
|
22028
22117
|
A destructor function that removes the observe watch when called.
|
22029
22118
|
@stable
|
22030
22119
|
*/
|
22031
|
-
|
22120
|
+
function observe(elements) {
|
22032
22121
|
var _a, _b;
|
22033
22122
|
var args = [];
|
22034
22123
|
for (var _i = 1; _i < arguments.length; _i++) {
|
@@ -22051,7 +22140,7 @@ up.form = (function () {
|
|
22051
22140
|
var observer = new up.FieldObserver(fields, options, callback);
|
22052
22141
|
observer.start();
|
22053
22142
|
return function () { return observer.stop(); };
|
22054
|
-
}
|
22143
|
+
}
|
22055
22144
|
function observeCallbackFromElement(element) {
|
22056
22145
|
var rawCallback = element.getAttribute('up-observe');
|
22057
22146
|
if (rawCallback) {
|
@@ -22145,10 +22234,8 @@ up.form = (function () {
|
|
22145
22234
|
function validate(field, options) {
|
22146
22235
|
// If passed a selector, up.fragment.get() will prefer a match on the current layer.
|
22147
22236
|
field = up.fragment.get(field);
|
22148
|
-
options =
|
22149
|
-
options.navigate = false;
|
22237
|
+
options = parseBasicOptions(field, options);
|
22150
22238
|
options.origin = field;
|
22151
|
-
options.history = false;
|
22152
22239
|
options.target = findValidateTarget(field, options);
|
22153
22240
|
options.focus = 'keep';
|
22154
22241
|
// The protocol doesn't define whether the validation results in a status code.
|
@@ -22160,7 +22247,7 @@ up.form = (function () {
|
|
22160
22247
|
options.headers[up.protocol.headerize('validate')] = field.getAttribute('name') || ':unknown';
|
22161
22248
|
// The guardEvent will also be assigned a { renderOptions } attribute in up.render()
|
22162
22249
|
options.guardEvent = up.event.build('up:form:validate', { field: field, log: 'Validating form' });
|
22163
|
-
return
|
22250
|
+
return up.render(options);
|
22164
22251
|
}
|
22165
22252
|
/*-
|
22166
22253
|
This event is emitted before a field is being [validated](/input-up-validate).
|
@@ -22262,7 +22349,7 @@ up.form = (function () {
|
|
22262
22349
|
show = u.intersect(fieldValues, showValues).length > 0;
|
22263
22350
|
}
|
22264
22351
|
e.toggle(target, show);
|
22265
|
-
|
22352
|
+
target.classList.add('up-switched');
|
22266
22353
|
});
|
22267
22354
|
function findSwitcherForTarget(target) {
|
22268
22355
|
var form = getContainer(target);
|
@@ -22273,9 +22360,13 @@ up.form = (function () {
|
|
22273
22360
|
});
|
22274
22361
|
return switcher || up.fail('Could not find [up-switch] field for %o', target);
|
22275
22362
|
}
|
22276
|
-
function
|
22363
|
+
function getForm(elementOrTarget, fallbackSelector) {
|
22364
|
+
var element = up.fragment.get(elementOrTarget);
|
22277
22365
|
// Element#form will also work if the element is outside the form with an [form=form-id] attribute
|
22278
|
-
return element.form || e.closest(element,
|
22366
|
+
return element.form || e.closest(element, 'form') || (fallbackSelector && e.closest(element, fallbackSelector));
|
22367
|
+
}
|
22368
|
+
function getContainer(element) {
|
22369
|
+
return getForm(element, up.layer.anySelector());
|
22279
22370
|
}
|
22280
22371
|
function isField(element) {
|
22281
22372
|
return e.matches(element, fieldSelector());
|