unpoly-rails 3.10.0 → 3.11.0.rc1
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/README.md +84 -71
- data/assets/unpoly/unpoly-bootstrap3.min.js +1 -1
- data/assets/unpoly/unpoly-bootstrap4.min.js +1 -1
- data/assets/unpoly/unpoly-bootstrap5.min.js +1 -1
- data/assets/unpoly/unpoly-migrate.js +46 -15
- data/assets/unpoly/unpoly-migrate.min.js +1 -1
- data/assets/unpoly/unpoly.css +1 -0
- data/assets/unpoly/unpoly.es6.js +1029 -672
- data/assets/unpoly/unpoly.es6.min.js +1 -1
- data/assets/unpoly/unpoly.js +1025 -667
- data/assets/unpoly/unpoly.min.css +1 -1
- data/assets/unpoly/unpoly.min.js +1 -1
- data/lib/unpoly/rails/change/cache.rb +11 -4
- data/lib/unpoly/rails/change/layer.rb +9 -2
- data/lib/unpoly/rails/change.rb +11 -0
- data/lib/unpoly/rails/version.rb +1 -1
- metadata +5 -5
data/assets/unpoly/unpoly.es6.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
/***/ (() => {
|
6
6
|
|
7
7
|
window.up = {
|
8
|
-
version: '3.
|
8
|
+
version: '3.11.0-rc1'
|
9
9
|
};
|
10
10
|
|
11
11
|
|
@@ -116,7 +116,7 @@ up.util = (function () {
|
|
116
116
|
}
|
117
117
|
function iteratee(block) {
|
118
118
|
if (isString(block)) {
|
119
|
-
return item => item[block];
|
119
|
+
return (item) => item[block];
|
120
120
|
}
|
121
121
|
else {
|
122
122
|
return block;
|
@@ -135,11 +135,7 @@ up.util = (function () {
|
|
135
135
|
return mapped;
|
136
136
|
}
|
137
137
|
function mapObject(array, pairer) {
|
138
|
-
|
139
|
-
object[pair[0]] = pair[1];
|
140
|
-
return object;
|
141
|
-
};
|
142
|
-
return map(array, pairer).reduce(merger, {});
|
138
|
+
return Object.fromEntries(array.map(pairer));
|
143
139
|
}
|
144
140
|
function each(array, block) {
|
145
141
|
let i = 0;
|
@@ -147,15 +143,15 @@ up.util = (function () {
|
|
147
143
|
block(item, i++);
|
148
144
|
}
|
149
145
|
}
|
150
|
-
function isNull(
|
151
|
-
return
|
146
|
+
function isNull(value) {
|
147
|
+
return value === null;
|
152
148
|
}
|
153
|
-
function isUndefined(
|
154
|
-
return
|
149
|
+
function isUndefined(value) {
|
150
|
+
return value === undefined;
|
155
151
|
}
|
156
152
|
const isDefined = negate(isUndefined);
|
157
|
-
function isMissing(
|
158
|
-
return isUndefined(
|
153
|
+
function isMissing(value) {
|
154
|
+
return isUndefined(value) || isNull(value);
|
159
155
|
}
|
160
156
|
const isGiven = negate(isMissing);
|
161
157
|
function isBlank(value) {
|
@@ -180,50 +176,50 @@ up.util = (function () {
|
|
180
176
|
}
|
181
177
|
}
|
182
178
|
const isPresent = negate(isBlank);
|
183
|
-
function isFunction(
|
184
|
-
return typeof (
|
179
|
+
function isFunction(value) {
|
180
|
+
return typeof (value) === 'function';
|
185
181
|
}
|
186
|
-
function isString(
|
187
|
-
return (typeof (
|
182
|
+
function isString(value) {
|
183
|
+
return (typeof (value) === 'string') || value instanceof String;
|
188
184
|
}
|
189
|
-
function isBoolean(
|
190
|
-
return (typeof (
|
185
|
+
function isBoolean(value) {
|
186
|
+
return (typeof (value) === 'boolean') || value instanceof Boolean;
|
191
187
|
}
|
192
|
-
function isNumber(
|
193
|
-
return (typeof (
|
188
|
+
function isNumber(value) {
|
189
|
+
return (typeof (value) === 'number') || value instanceof Number;
|
194
190
|
}
|
195
|
-
function isOptions(
|
196
|
-
return (typeof (
|
191
|
+
function isOptions(value) {
|
192
|
+
return (typeof (value) === 'object') && !isNull(value) && (isUndefined(value.constructor) || (value.constructor === Object));
|
197
193
|
}
|
198
|
-
function isObject(
|
199
|
-
const typeOfResult = typeof (
|
200
|
-
return ((typeOfResult === 'object') && !isNull(
|
194
|
+
function isObject(value) {
|
195
|
+
const typeOfResult = typeof (value);
|
196
|
+
return ((typeOfResult === 'object') && !isNull(value)) || (typeOfResult === 'function');
|
201
197
|
}
|
202
|
-
function isElement(
|
203
|
-
return
|
198
|
+
function isElement(value) {
|
199
|
+
return value instanceof Element;
|
204
200
|
}
|
205
|
-
function isTextNode(
|
206
|
-
return
|
201
|
+
function isTextNode(value) {
|
202
|
+
return value instanceof Text;
|
207
203
|
}
|
208
|
-
function isRegExp(
|
209
|
-
return
|
204
|
+
function isRegExp(value) {
|
205
|
+
return value instanceof RegExp;
|
210
206
|
}
|
211
|
-
function isError(
|
212
|
-
return
|
207
|
+
function isError(value) {
|
208
|
+
return value instanceof Error;
|
213
209
|
}
|
214
|
-
function isJQuery(
|
215
|
-
return up.browser.canJQuery() &&
|
210
|
+
function isJQuery(value) {
|
211
|
+
return up.browser.canJQuery() && value instanceof jQuery;
|
216
212
|
}
|
217
|
-
function isElementLike(
|
213
|
+
function isElementLike(value) {
|
218
214
|
var _a;
|
219
|
-
return !!(
|
215
|
+
return !!(value && (value.addEventListener || (isJQuery(value) && ((_a = value[0]) === null || _a === void 0 ? void 0 : _a.addEventListener))));
|
220
216
|
}
|
221
|
-
function isPromise(
|
222
|
-
return isObject(
|
217
|
+
function isPromise(value) {
|
218
|
+
return isObject(value) && isFunction(value.then);
|
223
219
|
}
|
224
220
|
const { isArray } = Array;
|
225
|
-
function isFormData(
|
226
|
-
return
|
221
|
+
function isFormData(value) {
|
222
|
+
return value instanceof FormData;
|
227
223
|
}
|
228
224
|
function toArray(value) {
|
229
225
|
return isArray(value) ? value : copyArrayLike(value);
|
@@ -390,13 +386,15 @@ up.util = (function () {
|
|
390
386
|
return filterList(list, tester);
|
391
387
|
}
|
392
388
|
function intersect(array1, array2) {
|
393
|
-
return filterList(array1, element => contains(array2, element));
|
389
|
+
return filterList(array1, (element) => contains(array2, element));
|
394
390
|
}
|
395
391
|
function scheduleTimer(millis, callback) {
|
396
392
|
return setTimeout(callback, millis);
|
397
393
|
}
|
398
394
|
function queueTask(task) {
|
399
|
-
|
395
|
+
const channel = new MessageChannel();
|
396
|
+
channel.port1.onmessage = () => task();
|
397
|
+
channel.port2.postMessage(0);
|
400
398
|
}
|
401
399
|
function last(value) {
|
402
400
|
return value[value.length - 1];
|
@@ -463,7 +461,7 @@ up.util = (function () {
|
|
463
461
|
"'": '''
|
464
462
|
};
|
465
463
|
function escapeHTML(string) {
|
466
|
-
return string.replace(/[&<>"']/g, char => ESCAPE_HTML_ENTITY_MAP[char]);
|
464
|
+
return string.replace(/[&<>"']/g, (char) => ESCAPE_HTML_ENTITY_MAP[char]);
|
467
465
|
}
|
468
466
|
function escapeRegExp(string) {
|
469
467
|
return string.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
@@ -492,9 +490,9 @@ up.util = (function () {
|
|
492
490
|
function identity(arg) {
|
493
491
|
return arg;
|
494
492
|
}
|
495
|
-
function sequence(
|
496
|
-
functions =
|
497
|
-
return (...args) => map(functions, fn => fn(...args));
|
493
|
+
function sequence(...args) {
|
494
|
+
let functions = scanFunctions(...args);
|
495
|
+
return (...args) => map(functions, (fn) => fn(...args));
|
498
496
|
}
|
499
497
|
function flatten(array) {
|
500
498
|
const flattened = [];
|
@@ -548,7 +546,7 @@ up.util = (function () {
|
|
548
546
|
const aKeys = Object.keys(a);
|
549
547
|
const bKeys = Object.keys(b);
|
550
548
|
if (isEqualList(aKeys, bKeys)) {
|
551
|
-
return every(aKeys, aKey => isEqual(a[aKey], b[aKey]));
|
549
|
+
return every(aKeys, (aKey) => isEqual(a[aKey], b[aKey]));
|
552
550
|
}
|
553
551
|
else {
|
554
552
|
return false;
|
@@ -613,7 +611,7 @@ up.util = (function () {
|
|
613
611
|
return renamed;
|
614
612
|
}
|
615
613
|
function camelToKebabCase(str) {
|
616
|
-
return str.replace(/[A-Z]/g, char => '-' + char.toLowerCase());
|
614
|
+
return str.replace(/[A-Z]/g, (char) => '-' + char.toLowerCase());
|
617
615
|
}
|
618
616
|
function lowerCaseFirst(str) {
|
619
617
|
return str[0].toLowerCase() + str.slice(1);
|
@@ -639,8 +637,8 @@ up.util = (function () {
|
|
639
637
|
});
|
640
638
|
}
|
641
639
|
}
|
642
|
-
function delegatePromise(object,
|
643
|
-
return defineDelegates(object, ['then', 'catch', 'finally'],
|
640
|
+
function delegatePromise(object, targetProvider) {
|
641
|
+
return defineDelegates(object, ['then', 'catch', 'finally'], targetProvider);
|
644
642
|
}
|
645
643
|
function stringifyArg(arg, placeholder = '%o') {
|
646
644
|
let string;
|
@@ -868,6 +866,9 @@ up.util = (function () {
|
|
868
866
|
];
|
869
867
|
});
|
870
868
|
}
|
869
|
+
function spanObject(keys, value) {
|
870
|
+
return mapObject(keys, (key) => [key, value]);
|
871
|
+
}
|
871
872
|
return {
|
872
873
|
parseURL,
|
873
874
|
normalizeURL,
|
@@ -885,6 +886,7 @@ up.util = (function () {
|
|
885
886
|
map,
|
886
887
|
flatMap,
|
887
888
|
mapObject,
|
889
|
+
spanObject,
|
888
890
|
findResult,
|
889
891
|
some,
|
890
892
|
every,
|
@@ -1089,12 +1091,13 @@ up.element = (function () {
|
|
1089
1091
|
return root.querySelector(selector);
|
1090
1092
|
}
|
1091
1093
|
function subtree(root, selector) {
|
1092
|
-
const
|
1094
|
+
const descendantMatches = root.querySelectorAll(selector);
|
1093
1095
|
if (elementLikeMatches(root, selector)) {
|
1094
|
-
|
1096
|
+
return [root, ...descendantMatches];
|
1097
|
+
}
|
1098
|
+
else {
|
1099
|
+
return descendantMatches;
|
1095
1100
|
}
|
1096
|
-
results.push(...root.querySelectorAll(selector));
|
1097
|
-
return results;
|
1098
1101
|
}
|
1099
1102
|
function subtreeFirst(root, selector) {
|
1100
1103
|
return elementLikeMatches(root, selector) ? root : root.querySelector(selector);
|
@@ -1202,7 +1205,7 @@ up.element = (function () {
|
|
1202
1205
|
function metaContent(name) {
|
1203
1206
|
var _a;
|
1204
1207
|
const selector = "meta" + attrSelector('name', name);
|
1205
|
-
return (_a =
|
1208
|
+
return (_a = document.head.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.getAttribute('content');
|
1206
1209
|
}
|
1207
1210
|
function insertBefore(existingNode, newNode) {
|
1208
1211
|
existingNode.parentNode.insertBefore(newNode, existingNode);
|
@@ -1312,7 +1315,7 @@ up.element = (function () {
|
|
1312
1315
|
return element;
|
1313
1316
|
}
|
1314
1317
|
const SINGLETON_TAG_NAMES = ['HTML', 'BODY', 'HEAD', 'TITLE'];
|
1315
|
-
const isSingleton = up.mockable(element => element.matches(SINGLETON_TAG_NAMES.join()));
|
1318
|
+
const isSingleton = up.mockable((element) => element.matches(SINGLETON_TAG_NAMES.join()));
|
1316
1319
|
function elementTagName(element) {
|
1317
1320
|
return element.tagName.toLowerCase();
|
1318
1321
|
}
|
@@ -1340,9 +1343,11 @@ up.element = (function () {
|
|
1340
1343
|
function createBrokenDocumentFromHTML(html) {
|
1341
1344
|
return new DOMParser().parseFromString(html, 'text/html');
|
1342
1345
|
}
|
1343
|
-
function
|
1344
|
-
let clone = createFromHTML(
|
1345
|
-
|
1346
|
+
function revivedClone(element) {
|
1347
|
+
let clone = createFromHTML(element.outerHTML);
|
1348
|
+
if ('nonce' in element)
|
1349
|
+
clone.nonce = element.nonce;
|
1350
|
+
return clone;
|
1346
1351
|
}
|
1347
1352
|
function createFromHTML(html) {
|
1348
1353
|
return extractSingular(createNodesFromHTML(html));
|
@@ -1625,6 +1630,18 @@ up.element = (function () {
|
|
1625
1630
|
return [element.parentElement, 'beforeend'];
|
1626
1631
|
}
|
1627
1632
|
}
|
1633
|
+
function moveBefore(parent, movedElement, referenceElement) {
|
1634
|
+
let fn = parent.moveBefore || parent.insertBefore;
|
1635
|
+
fn.call(parent, movedElement, referenceElement);
|
1636
|
+
}
|
1637
|
+
function preservingAppend(parent, newNode) {
|
1638
|
+
moveBefore(parent, newNode, null);
|
1639
|
+
}
|
1640
|
+
function preservingReplace(oldElement, newElement) {
|
1641
|
+
let parent = oldElement.parentElement;
|
1642
|
+
moveBefore(parent, newElement, oldElement);
|
1643
|
+
oldElement.remove();
|
1644
|
+
}
|
1628
1645
|
return {
|
1629
1646
|
subtree,
|
1630
1647
|
subtreeFirst,
|
@@ -1651,7 +1668,7 @@ up.element = (function () {
|
|
1651
1668
|
attrSelector,
|
1652
1669
|
tagName: elementTagName,
|
1653
1670
|
createBrokenDocumentFromHTML,
|
1654
|
-
|
1671
|
+
revivedClone,
|
1655
1672
|
createNodesFromHTML,
|
1656
1673
|
createFromHTML,
|
1657
1674
|
extractSingular,
|
@@ -1693,6 +1710,8 @@ up.element = (function () {
|
|
1693
1710
|
matchSelectorMap,
|
1694
1711
|
elementLikeMatches,
|
1695
1712
|
documentPosition,
|
1713
|
+
preservingAppend,
|
1714
|
+
preservingReplace,
|
1696
1715
|
};
|
1697
1716
|
})();
|
1698
1717
|
|
@@ -1783,7 +1802,7 @@ up.Record = class Record {
|
|
1783
1802
|
return {};
|
1784
1803
|
}
|
1785
1804
|
constructor(options) {
|
1786
|
-
Object.assign(this, this.defaults(options), this.attributes(options));
|
1805
|
+
Object.assign(this, u.mergeDefined(this.defaults(options), this.attributes(options)));
|
1787
1806
|
}
|
1788
1807
|
attributes(source = this) {
|
1789
1808
|
return u.pick(source, this.keys());
|
@@ -1862,13 +1881,39 @@ up.LogConfig = class LogConfig extends up.Config {
|
|
1862
1881
|
/* 19 */
|
1863
1882
|
/***/ (() => {
|
1864
1883
|
|
1884
|
+
const u = up.util;
|
1885
|
+
up.Registry = class Registry {
|
1886
|
+
constructor(valueDescription, normalize = u.identity) {
|
1887
|
+
this._data = {};
|
1888
|
+
this._normalize = normalize;
|
1889
|
+
this._valueDescription = valueDescription;
|
1890
|
+
this.put = this.put.bind(this);
|
1891
|
+
document.addEventListener('up:framework:reset', () => this.reset());
|
1892
|
+
}
|
1893
|
+
put(key, object) {
|
1894
|
+
object = this._normalize(object);
|
1895
|
+
object.isDefault = up.framework.evaling;
|
1896
|
+
this._data[key] = object;
|
1897
|
+
}
|
1898
|
+
get(name) {
|
1899
|
+
return this._data[name] || up.fail("Unknown %s %o", this._valueDescription, name);
|
1900
|
+
}
|
1901
|
+
reset() {
|
1902
|
+
this._data = u.pickBy(this._data, 'isDefault');
|
1903
|
+
}
|
1904
|
+
};
|
1905
|
+
|
1906
|
+
|
1907
|
+
/***/ }),
|
1908
|
+
/* 20 */
|
1909
|
+
/***/ (() => {
|
1910
|
+
|
1865
1911
|
const u = up.util;
|
1866
1912
|
const e = up.element;
|
1867
1913
|
up.OptionsParser = class OptionsParser {
|
1868
1914
|
constructor(element, options, parserOptions = {}) {
|
1869
1915
|
this._options = options;
|
1870
1916
|
this._element = element;
|
1871
|
-
this._parserOptions = parserOptions;
|
1872
1917
|
this._fail = parserOptions.fail;
|
1873
1918
|
this._closest = parserOptions.closest;
|
1874
1919
|
this._attrPrefix = parserOptions.attrPrefix || 'up-';
|
@@ -1904,11 +1949,11 @@ up.OptionsParser = class OptionsParser {
|
|
1904
1949
|
value !== null && value !== void 0 ? value : (value = this._parseFromAttr(attrValueFn, this._element, attrName));
|
1905
1950
|
}
|
1906
1951
|
value !== null && value !== void 0 ? value : (value = (_b = keyOptions.default) !== null && _b !== void 0 ? _b : this._defaults[key]);
|
1907
|
-
let normalizeFn = keyOptions.normalize;
|
1908
|
-
if (normalizeFn) {
|
1909
|
-
value = normalizeFn(value);
|
1910
|
-
}
|
1911
1952
|
if (u.isDefined(value)) {
|
1953
|
+
let normalizeFn = keyOptions.normalize;
|
1954
|
+
if (normalizeFn) {
|
1955
|
+
value = normalizeFn(value);
|
1956
|
+
}
|
1912
1957
|
this._options[key] = value;
|
1913
1958
|
}
|
1914
1959
|
let failKey;
|
@@ -1917,8 +1962,8 @@ up.OptionsParser = class OptionsParser {
|
|
1917
1962
|
this.parse(attrValueFn, failKey, Object.assign(Object.assign({}, keyOptions), { attr: failAttrNames }));
|
1918
1963
|
}
|
1919
1964
|
}
|
1920
|
-
include(optionsFn) {
|
1921
|
-
let fnResult = optionsFn(this._element, this._options, this.
|
1965
|
+
include(optionsFn, parserOptions) {
|
1966
|
+
let fnResult = optionsFn(this._element, this._options, Object.assign({ defaults: this._defaults }, parserOptions));
|
1922
1967
|
Object.assign(this._options, fnResult);
|
1923
1968
|
}
|
1924
1969
|
_parseFromAttr(attrValueFn, element, attrName) {
|
@@ -1945,7 +1990,7 @@ up.OptionsParser = class OptionsParser {
|
|
1945
1990
|
|
1946
1991
|
|
1947
1992
|
/***/ }),
|
1948
|
-
/*
|
1993
|
+
/* 21 */
|
1949
1994
|
/***/ (() => {
|
1950
1995
|
|
1951
1996
|
const u = up.util;
|
@@ -1974,7 +2019,7 @@ up.FIFOCache = class FIFOCache {
|
|
1974
2019
|
|
1975
2020
|
|
1976
2021
|
/***/ }),
|
1977
|
-
/*
|
2022
|
+
/* 22 */
|
1978
2023
|
/***/ (() => {
|
1979
2024
|
|
1980
2025
|
up.Rect = class Rect extends up.Record {
|
@@ -2005,7 +2050,7 @@ up.Rect = class Rect extends up.Record {
|
|
2005
2050
|
|
2006
2051
|
|
2007
2052
|
/***/ }),
|
2008
|
-
/*
|
2053
|
+
/* 23 */
|
2009
2054
|
/***/ (() => {
|
2010
2055
|
|
2011
2056
|
const e = up.element;
|
@@ -2053,7 +2098,7 @@ up.BodyShifter = class BodyShifter {
|
|
2053
2098
|
|
2054
2099
|
|
2055
2100
|
/***/ }),
|
2056
|
-
/*
|
2101
|
+
/* 24 */
|
2057
2102
|
/***/ (() => {
|
2058
2103
|
|
2059
2104
|
const u = up.util;
|
@@ -2079,7 +2124,7 @@ up.Change = class Change {
|
|
2079
2124
|
|
2080
2125
|
|
2081
2126
|
/***/ }),
|
2082
|
-
/*
|
2127
|
+
/* 25 */
|
2083
2128
|
/***/ (() => {
|
2084
2129
|
|
2085
2130
|
const u = up.util;
|
@@ -2154,7 +2199,7 @@ up.Change.Addition = class Addition extends up.Change {
|
|
2154
2199
|
|
2155
2200
|
|
2156
2201
|
/***/ }),
|
2157
|
-
/*
|
2202
|
+
/* 26 */
|
2158
2203
|
/***/ (function() {
|
2159
2204
|
|
2160
2205
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -2280,7 +2325,7 @@ up.RenderJob = (_a = class RenderJob {
|
|
2280
2325
|
}
|
2281
2326
|
},
|
2282
2327
|
(() => {
|
2283
|
-
u.delegatePromise(_a.prototype,
|
2328
|
+
u.delegatePromise(_a.prototype, function () { return this._rendered; });
|
2284
2329
|
u.memoizeMethod(_a.prototype, {
|
2285
2330
|
_awaitFinished: true,
|
2286
2331
|
_getChange: true,
|
@@ -2290,7 +2335,7 @@ up.RenderJob = (_a = class RenderJob {
|
|
2290
2335
|
|
2291
2336
|
|
2292
2337
|
/***/ }),
|
2293
|
-
/*
|
2338
|
+
/* 27 */
|
2294
2339
|
/***/ (function() {
|
2295
2340
|
|
2296
2341
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -2326,20 +2371,20 @@ up.Change.DestroyFragment = class DestroyFragment extends up.Change {
|
|
2326
2371
|
return __awaiter(this, void 0, void 0, function* () {
|
2327
2372
|
this._emitDestroyed();
|
2328
2373
|
yield this._animate();
|
2329
|
-
this.
|
2374
|
+
this._erase();
|
2330
2375
|
(_a = this._onFinished) === null || _a === void 0 ? void 0 : _a.call(this);
|
2331
2376
|
});
|
2332
2377
|
}
|
2333
2378
|
_destroyNow() {
|
2334
2379
|
var _a;
|
2335
|
-
this.
|
2380
|
+
this._erase();
|
2336
2381
|
this._emitDestroyed();
|
2337
2382
|
(_a = this._onFinished) === null || _a === void 0 ? void 0 : _a.call(this);
|
2338
2383
|
}
|
2339
2384
|
_animate() {
|
2340
2385
|
return up.motion.animate(this._element, this._animation, this.options);
|
2341
2386
|
}
|
2342
|
-
|
2387
|
+
_erase() {
|
2343
2388
|
this._layer.asCurrent(() => {
|
2344
2389
|
up.fragment.abort(this._element);
|
2345
2390
|
up.script.clean(this._element, { layer: this._layer });
|
@@ -2354,7 +2399,7 @@ up.Change.DestroyFragment = class DestroyFragment extends up.Change {
|
|
2354
2399
|
|
2355
2400
|
|
2356
2401
|
/***/ }),
|
2357
|
-
/*
|
2402
|
+
/* 28 */
|
2358
2403
|
/***/ (function() {
|
2359
2404
|
|
2360
2405
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -2456,7 +2501,7 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
|
|
2456
2501
|
}
|
2457
2502
|
_buildLayer() {
|
2458
2503
|
const buildOptions = Object.assign(Object.assign({}, this.options), { opening: true });
|
2459
|
-
const beforeNew = optionsWithLayerDefaults => {
|
2504
|
+
const beforeNew = (optionsWithLayerDefaults) => {
|
2460
2505
|
return this.options = up.RenderOptions.finalize(optionsWithLayerDefaults);
|
2461
2506
|
};
|
2462
2507
|
return up.layer.build(buildOptions, beforeNew);
|
@@ -2513,7 +2558,7 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
|
|
2513
2558
|
|
2514
2559
|
|
2515
2560
|
/***/ }),
|
2516
|
-
/*
|
2561
|
+
/* 29 */
|
2517
2562
|
/***/ (() => {
|
2518
2563
|
|
2519
2564
|
var _a;
|
@@ -2660,7 +2705,7 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
|
|
2660
2705
|
|
2661
2706
|
|
2662
2707
|
/***/ }),
|
2663
|
-
/*
|
2708
|
+
/* 30 */
|
2664
2709
|
/***/ (function() {
|
2665
2710
|
|
2666
2711
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -2693,7 +2738,7 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2693
2738
|
target: up.fragment.targetForSteps(this._steps),
|
2694
2739
|
});
|
2695
2740
|
this._steps.reverse();
|
2696
|
-
const motionEndPromises = this._steps.map(step => this._executeStep(step));
|
2741
|
+
const motionEndPromises = this._steps.map((step) => this._executeStep(step));
|
2697
2742
|
this.renderResult.finished = this._finish(motionEndPromises);
|
2698
2743
|
return this.renderResult;
|
2699
2744
|
}
|
@@ -2726,14 +2771,14 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2726
2771
|
return Promise.resolve();
|
2727
2772
|
}
|
2728
2773
|
else {
|
2729
|
-
this.
|
2774
|
+
this._preserveDescendantKeepables(step);
|
2730
2775
|
const parent = step.oldElement.parentNode;
|
2731
2776
|
const morphOptions = Object.assign(Object.assign({}, step), { beforeStart() {
|
2732
2777
|
up.fragment.markAsDestroying(step.oldElement);
|
2733
2778
|
}, afterInsert: () => {
|
2734
|
-
this.
|
2779
|
+
this._restoreDescendantKeepables(step);
|
2735
2780
|
this.responseDoc.finalizeElement(step.newElement);
|
2736
|
-
this.
|
2781
|
+
this._finalizeDescendantKeepables(step);
|
2737
2782
|
up.hello(step.newElement, step);
|
2738
2783
|
this._addToResult(step.newElement);
|
2739
2784
|
}, beforeDetach: () => {
|
@@ -2804,8 +2849,8 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2804
2849
|
}
|
2805
2850
|
}
|
2806
2851
|
}
|
2807
|
-
|
2808
|
-
const
|
2852
|
+
_preserveDescendantKeepables(step) {
|
2853
|
+
const descendantKeepPlans = [];
|
2809
2854
|
if (step.keep) {
|
2810
2855
|
for (let keepable of step.oldElement.querySelectorAll('[up-keep]')) {
|
2811
2856
|
let keepPlan = this._findKeepPlan(Object.assign(Object.assign({}, step), { oldElement: keepable, descendantsOnly: true }));
|
@@ -2815,37 +2860,42 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2815
2860
|
keepable.classList.add('up-keeping');
|
2816
2861
|
up.script.disableSubtree(keepPlan.newElement);
|
2817
2862
|
let viewports = up.viewport.subtree(keepPlan.oldElement);
|
2818
|
-
keepPlan.revivers =
|
2863
|
+
keepPlan.revivers = u.map(viewports, function (viewport) {
|
2819
2864
|
let cursorProps = up.viewport.copyCursorProps(viewport);
|
2820
2865
|
return () => up.viewport.copyCursorProps(cursorProps, viewport);
|
2821
2866
|
});
|
2822
|
-
if (this.
|
2867
|
+
if (this._willChangeBody()) {
|
2823
2868
|
keepPlan.newElement.replaceWith(keepable);
|
2824
2869
|
}
|
2825
2870
|
else {
|
2826
|
-
document.body
|
2871
|
+
e.preservingAppend(document.body, keepable);
|
2827
2872
|
}
|
2828
|
-
|
2873
|
+
descendantKeepPlans.push(keepPlan);
|
2829
2874
|
}
|
2830
2875
|
}
|
2831
2876
|
}
|
2832
|
-
step.
|
2877
|
+
step.descendantKeepPlans = descendantKeepPlans;
|
2833
2878
|
}
|
2834
|
-
|
2835
|
-
for (let keepPlan of step.
|
2836
|
-
|
2879
|
+
_restoreDescendantKeepables(step) {
|
2880
|
+
for (let keepPlan of step.descendantKeepPlans) {
|
2881
|
+
if (this._willChangeBody()) {
|
2882
|
+
keepPlan.newElement.replaceWith(keepPlan.oldElement);
|
2883
|
+
}
|
2884
|
+
else {
|
2885
|
+
e.preservingReplace(keepPlan.newElement, keepPlan.oldElement);
|
2886
|
+
}
|
2837
2887
|
for (let reviver of keepPlan.revivers) {
|
2838
2888
|
reviver();
|
2839
2889
|
}
|
2840
2890
|
}
|
2841
2891
|
}
|
2842
|
-
|
2843
|
-
for (let keepPlan of step.
|
2892
|
+
_finalizeDescendantKeepables(step) {
|
2893
|
+
for (let keepPlan of step.descendantKeepPlans) {
|
2844
2894
|
keepPlan.oldElement.classList.remove('up-keeping');
|
2845
2895
|
}
|
2846
2896
|
}
|
2847
|
-
|
2848
|
-
return u.some(this._steps, (step) => step.oldElement.
|
2897
|
+
_willChangeBody() {
|
2898
|
+
return u.some(this._steps, (step) => step.oldElement.matches('body'));
|
2849
2899
|
}
|
2850
2900
|
_handleFocus(fragment, options) {
|
2851
2901
|
const fragmentFocus = new up.FragmentFocus(Object.assign(Object.assign({}, options), { fragment, autoMeans: up.fragment.config.autoFocus }));
|
@@ -2859,7 +2909,7 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2859
2909
|
|
2860
2910
|
|
2861
2911
|
/***/ }),
|
2862
|
-
/*
|
2912
|
+
/* 31 */
|
2863
2913
|
/***/ (() => {
|
2864
2914
|
|
2865
2915
|
const u = up.util;
|
@@ -2876,9 +2926,8 @@ up.Change.CloseLayer = class CloseLayer extends up.Change {
|
|
2876
2926
|
this._history = (_b = options.history) !== null && _b !== void 0 ? _b : true;
|
2877
2927
|
}
|
2878
2928
|
execute() {
|
2879
|
-
if (!this._layer.isOpen())
|
2880
|
-
return
|
2881
|
-
}
|
2929
|
+
if (!this._layer.isOpen())
|
2930
|
+
return;
|
2882
2931
|
up.browser.assertConfirmed(this.options);
|
2883
2932
|
if (this._emitCloseEvent().defaultPrevented && this._preventable) {
|
2884
2933
|
throw new up.Aborted('Close event was prevented');
|
@@ -2928,16 +2977,19 @@ up.Change.CloseLayer = class CloseLayer extends up.Change {
|
|
2928
2977
|
}
|
2929
2978
|
_handleFocus(formerParent) {
|
2930
2979
|
var _a;
|
2980
|
+
let hadFocus = this._layer.hasFocus();
|
2931
2981
|
this._layer.overlayFocus.teardown();
|
2932
2982
|
(_a = formerParent.overlayFocus) === null || _a === void 0 ? void 0 : _a.moveToFront();
|
2933
|
-
|
2934
|
-
|
2983
|
+
if (hadFocus) {
|
2984
|
+
let newFocusElement = this._layer.origin || formerParent.element;
|
2985
|
+
up.focus(newFocusElement, { preventScroll: true });
|
2986
|
+
}
|
2935
2987
|
}
|
2936
2988
|
};
|
2937
2989
|
|
2938
2990
|
|
2939
2991
|
/***/ }),
|
2940
|
-
/*
|
2992
|
+
/* 32 */
|
2941
2993
|
/***/ (function() {
|
2942
2994
|
|
2943
2995
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -2967,7 +3019,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2967
3019
|
return request;
|
2968
3020
|
(_e = (_d = this.options).handleAbort) === null || _e === void 0 ? void 0 : _e.call(_d, request);
|
2969
3021
|
request.runPreviews(this.options);
|
2970
|
-
return yield u.always(request, responseOrError => this._onRequestSettled(responseOrError));
|
3022
|
+
return yield u.always(request, (responseOrError) => this._onRequestSettled(responseOrError));
|
2971
3023
|
});
|
2972
3024
|
}
|
2973
3025
|
_newPageReason() {
|
@@ -3022,7 +3074,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
3022
3074
|
|
3023
3075
|
|
3024
3076
|
/***/ }),
|
3025
|
-
/*
|
3077
|
+
/* 33 */
|
3026
3078
|
/***/ (function() {
|
3027
3079
|
|
3028
3080
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -3138,6 +3190,11 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
|
|
3138
3190
|
renderOptions.source = this.improveHistoryValue(renderOptions.source, 'keep');
|
3139
3191
|
renderOptions.history = !!renderOptions.location;
|
3140
3192
|
}
|
3193
|
+
let openLayerOptions = this._response.openLayer;
|
3194
|
+
if (openLayerOptions) {
|
3195
|
+
Object.assign(renderOptions, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, up.Layer.Overlay.UNSET_VISUALS), { target: undefined }), up.fragment.config.navigateOptions), openLayerOptions), { layer: 'new' }));
|
3196
|
+
Object.assign(renderOptions, openLayerOptions);
|
3197
|
+
}
|
3141
3198
|
renderOptions.location = this.improveHistoryValue(renderOptions.location, serverLocation);
|
3142
3199
|
renderOptions.title = this.improveHistoryValue(renderOptions.title, this._response.title);
|
3143
3200
|
renderOptions.eventPlans = this._response.eventPlans;
|
@@ -3152,7 +3209,7 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
|
|
3152
3209
|
renderOptions.target = ':none';
|
3153
3210
|
}
|
3154
3211
|
renderOptions.context = u.merge(renderOptions.context, this._response.context);
|
3155
|
-
renderOptions.
|
3212
|
+
renderOptions.cspInfo = this._response.cspInfo;
|
3156
3213
|
(_b = renderOptions.time) !== null && _b !== void 0 ? _b : (renderOptions.time = this._response.lastModified);
|
3157
3214
|
(_c = renderOptions.etag) !== null && _c !== void 0 ? _c : (renderOptions.etag = this._response.etag);
|
3158
3215
|
}
|
@@ -3166,7 +3223,7 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
|
|
3166
3223
|
|
3167
3224
|
|
3168
3225
|
/***/ }),
|
3169
|
-
/*
|
3226
|
+
/* 34 */
|
3170
3227
|
/***/ (() => {
|
3171
3228
|
|
3172
3229
|
var _a;
|
@@ -3240,7 +3297,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3240
3297
|
'fragment',
|
3241
3298
|
'document',
|
3242
3299
|
'html',
|
3243
|
-
'
|
3300
|
+
'cspInfo',
|
3244
3301
|
'origin',
|
3245
3302
|
'data',
|
3246
3303
|
]);
|
@@ -3272,7 +3329,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3272
3329
|
return this._expandTargets(target || ':main', layer)[0];
|
3273
3330
|
}
|
3274
3331
|
getPreflightProps(opts = {}) {
|
3275
|
-
const getPlanProps = plan => plan.getPreflightProps();
|
3332
|
+
const getPlanProps = (plan) => plan.getPreflightProps();
|
3276
3333
|
return this._seekPlan(getPlanProps) || opts.optional || this._cannotMatchPreflightTarget();
|
3277
3334
|
}
|
3278
3335
|
_cannotMatchPreflightTarget() {
|
@@ -3324,7 +3381,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3324
3381
|
|
3325
3382
|
|
3326
3383
|
/***/ }),
|
3327
|
-
/*
|
3384
|
+
/* 35 */
|
3328
3385
|
/***/ (() => {
|
3329
3386
|
|
3330
3387
|
const u = up.util;
|
@@ -3420,7 +3477,7 @@ up.CompilerPass = class CompilerPass {
|
|
3420
3477
|
|
3421
3478
|
|
3422
3479
|
/***/ }),
|
3423
|
-
/*
|
3480
|
+
/* 36 */
|
3424
3481
|
/***/ (() => {
|
3425
3482
|
|
3426
3483
|
const u = up.util;
|
@@ -3527,7 +3584,7 @@ up.CSSTransition = class CSSTransition {
|
|
3527
3584
|
|
3528
3585
|
|
3529
3586
|
/***/ }),
|
3530
|
-
/*
|
3587
|
+
/* 37 */
|
3531
3588
|
/***/ (() => {
|
3532
3589
|
|
3533
3590
|
const u = up.util;
|
@@ -3550,7 +3607,7 @@ up.DestructorPass = class DestructorPass {
|
|
3550
3607
|
|
3551
3608
|
|
3552
3609
|
/***/ }),
|
3553
|
-
/*
|
3610
|
+
/* 38 */
|
3554
3611
|
/***/ (() => {
|
3555
3612
|
|
3556
3613
|
const u = up.util;
|
@@ -3650,7 +3707,7 @@ up.EventEmitter = class EventEmitter extends up.Record {
|
|
3650
3707
|
|
3651
3708
|
|
3652
3709
|
/***/ }),
|
3653
|
-
/*
|
3710
|
+
/* 39 */
|
3654
3711
|
/***/ (() => {
|
3655
3712
|
|
3656
3713
|
const u = up.util;
|
@@ -3703,7 +3760,8 @@ up.EventListener = class EventListener extends up.Record {
|
|
3703
3760
|
}
|
3704
3761
|
let element = event.target;
|
3705
3762
|
if (this.selector) {
|
3706
|
-
|
3763
|
+
let selector = u.evalOption(this.selector);
|
3764
|
+
element = element.closest(selector);
|
3707
3765
|
}
|
3708
3766
|
if (this.guard && !this.guard(event)) {
|
3709
3767
|
return;
|
@@ -3757,7 +3815,7 @@ up.EventListener = class EventListener extends up.Record {
|
|
3757
3815
|
|
3758
3816
|
|
3759
3817
|
/***/ }),
|
3760
|
-
/*
|
3818
|
+
/* 40 */
|
3761
3819
|
/***/ (() => {
|
3762
3820
|
|
3763
3821
|
const u = up.util;
|
@@ -3803,7 +3861,7 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
|
|
3803
3861
|
}
|
3804
3862
|
});
|
3805
3863
|
}
|
3806
|
-
static fromBindArgs(args,
|
3864
|
+
static fromBindArgs(args, overrides) {
|
3807
3865
|
args = u.copy(args);
|
3808
3866
|
const callback = args.pop();
|
3809
3867
|
let elements;
|
@@ -3823,14 +3881,64 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
|
|
3823
3881
|
}
|
3824
3882
|
const options = u.extractOptions(args);
|
3825
3883
|
const selector = args[0];
|
3826
|
-
const attributes = Object.assign(Object.assign({ elements, eventTypes, selector, callback }, options),
|
3884
|
+
const attributes = Object.assign(Object.assign({ elements, eventTypes, selector, callback }, options), overrides);
|
3827
3885
|
return new (this)(attributes);
|
3828
3886
|
}
|
3829
3887
|
};
|
3830
3888
|
|
3831
3889
|
|
3832
3890
|
/***/ }),
|
3833
|
-
/*
|
3891
|
+
/* 41 */
|
3892
|
+
/***/ (() => {
|
3893
|
+
|
3894
|
+
const u = up.util;
|
3895
|
+
up.SelectorTracker = class SelectorTracker {
|
3896
|
+
constructor(selector, options, addCallback) {
|
3897
|
+
var _a;
|
3898
|
+
this._selector = selector;
|
3899
|
+
this._addCallback = addCallback;
|
3900
|
+
this._layer = options.layer || 'any';
|
3901
|
+
this._filter = options.filter || u.identity;
|
3902
|
+
this._live = (_a = options.live) !== null && _a !== void 0 ? _a : true;
|
3903
|
+
this._knownMatches = new Map();
|
3904
|
+
}
|
3905
|
+
start() {
|
3906
|
+
this._sync();
|
3907
|
+
return u.sequence(this._trackFragments(), () => this._removeAllMatches());
|
3908
|
+
}
|
3909
|
+
_trackFragments() {
|
3910
|
+
if (this._live) {
|
3911
|
+
return up.on('up:fragment:inserted up:fragment:destroyed', () => this._sync());
|
3912
|
+
}
|
3913
|
+
}
|
3914
|
+
_sync() {
|
3915
|
+
let removeMap = new Map(this._knownMatches);
|
3916
|
+
this._knownMatches.clear();
|
3917
|
+
for (let newMatch of this._currentMatches) {
|
3918
|
+
let knownRemoveCallback = removeMap.get(newMatch);
|
3919
|
+
removeMap.delete(newMatch);
|
3920
|
+
let removeCallback = knownRemoveCallback || this._addCallback(newMatch) || u.noop;
|
3921
|
+
this._knownMatches.set(newMatch, removeCallback);
|
3922
|
+
}
|
3923
|
+
this._runRemoveCallbacks(removeMap);
|
3924
|
+
}
|
3925
|
+
get _currentMatches() {
|
3926
|
+
let allMatches = up.fragment.all(this._selector, { layer: this._layer });
|
3927
|
+
return this._filter(allMatches);
|
3928
|
+
}
|
3929
|
+
_removeAllMatches() {
|
3930
|
+
this._runRemoveCallbacks(this._knownMatches);
|
3931
|
+
}
|
3932
|
+
_runRemoveCallbacks(map) {
|
3933
|
+
for (let [element, removeCallback] of map) {
|
3934
|
+
removeCallback(element);
|
3935
|
+
}
|
3936
|
+
}
|
3937
|
+
};
|
3938
|
+
|
3939
|
+
|
3940
|
+
/***/ }),
|
3941
|
+
/* 42 */
|
3834
3942
|
/***/ (function() {
|
3835
3943
|
|
3836
3944
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -3845,42 +3953,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
3845
3953
|
const u = up.util;
|
3846
3954
|
up.FieldWatcher = class FieldWatcher {
|
3847
3955
|
constructor(root, options, callback) {
|
3956
|
+
var _a;
|
3848
3957
|
this._options = options;
|
3849
3958
|
this._root = root;
|
3850
|
-
this._scope = up.form.getScope(root);
|
3851
3959
|
this._callback = callback;
|
3852
3960
|
this._batch = options.batch;
|
3961
|
+
this._logPrefix = (_a = options.logPrefix) !== null && _a !== void 0 ? _a : 'up.watch()';
|
3962
|
+
this._ensureWatchable();
|
3853
3963
|
}
|
3854
3964
|
start() {
|
3855
3965
|
this._scheduledValues = null;
|
3856
3966
|
this._processedValues = this._readFieldValues();
|
3857
3967
|
this._currentTimer = null;
|
3858
3968
|
this._callbackRunning = false;
|
3859
|
-
this.
|
3860
|
-
this._watchFieldsWithin(this._root);
|
3861
|
-
this._root.addEventListener('up:fragment:inserted', ({ target }) => {
|
3862
|
-
if (target !== this._root)
|
3863
|
-
this._watchFieldsWithin(target);
|
3864
|
-
});
|
3865
|
-
this._cleaner(up.fragment.onAborted(this._scope, () => this._abort()));
|
3866
|
-
this._cleaner(up.on(this._scope, 'reset', () => this._onFormReset()));
|
3969
|
+
return u.sequence(up.form.trackFields(this._root, (field) => this._watchField(field)), this._trackAbort(), this._trackReset(), () => this._abort());
|
3867
3970
|
}
|
3868
|
-
|
3869
|
-
this.
|
3870
|
-
this.
|
3971
|
+
_ensureWatchable() {
|
3972
|
+
const fail = (message) => up.fail(message, this._logPrefix, this._root);
|
3973
|
+
if (!this._callback) {
|
3974
|
+
fail('No callback provided for %s (%o)');
|
3975
|
+
}
|
3976
|
+
if (this._root.matches('input[type=radio]')) {
|
3977
|
+
fail('Use %s with the container of a radio group, not with an individual radio button (%o)');
|
3978
|
+
}
|
3979
|
+
}
|
3980
|
+
_trackAbort() {
|
3981
|
+
let guard = ({ target }) => target.contains(this._region);
|
3982
|
+
return up.on('up:fragment:aborted', { guard }, () => this._abort());
|
3983
|
+
}
|
3984
|
+
_trackReset() {
|
3985
|
+
let guard = ({ target }) => target === this._region;
|
3986
|
+
return up.on('reset', { guard }, (event) => this._onFormReset(event));
|
3987
|
+
}
|
3988
|
+
get _region() {
|
3989
|
+
return up.form.getRegion(this._root);
|
3871
3990
|
}
|
3872
3991
|
_fieldOptions(field) {
|
3873
3992
|
let rootOptions = u.copy(this._options);
|
3874
3993
|
return up.form.watchOptions(field, rootOptions, { defaults: { event: 'input' } });
|
3875
3994
|
}
|
3876
|
-
_watchFieldsWithin(container) {
|
3877
|
-
for (let field of up.form.fields(container)) {
|
3878
|
-
this._watchField(field);
|
3879
|
-
}
|
3880
|
-
}
|
3881
3995
|
_watchField(field) {
|
3882
3996
|
let fieldOptions = this._fieldOptions(field);
|
3883
|
-
|
3997
|
+
let eventType = fieldOptions.event;
|
3998
|
+
return up.on(field, eventType, (event) => this._check(event, fieldOptions));
|
3884
3999
|
}
|
3885
4000
|
_abort() {
|
3886
4001
|
this._scheduledValues = null;
|
@@ -3906,7 +4021,7 @@ up.FieldWatcher = class FieldWatcher {
|
|
3906
4021
|
return;
|
3907
4022
|
if (this._currentTimer)
|
3908
4023
|
return;
|
3909
|
-
if (!this.
|
4024
|
+
if (!up.fragment.isAlive(this._region))
|
3910
4025
|
return;
|
3911
4026
|
let callbackOptions = u.omit(this._scheduledFieldOptions, ['event', 'delay']);
|
3912
4027
|
const diff = this._changedValues(this._processedValues, this._scheduledValues);
|
@@ -3952,20 +4067,143 @@ up.FieldWatcher = class FieldWatcher {
|
|
3952
4067
|
_readFieldValues() {
|
3953
4068
|
return up.Params.fromContainer(this._root).toObject();
|
3954
4069
|
}
|
3955
|
-
_check(fieldOptions = {}) {
|
4070
|
+
_check(event, fieldOptions = {}) {
|
4071
|
+
up.log.putsEvent(event);
|
3956
4072
|
const values = this._readFieldValues();
|
3957
4073
|
if (this._isNewValues(values)) {
|
3958
4074
|
this._scheduleValues(values, fieldOptions);
|
3959
4075
|
}
|
3960
4076
|
}
|
3961
|
-
_onFormReset() {
|
3962
|
-
u.task(() => this._check());
|
4077
|
+
_onFormReset(event) {
|
4078
|
+
u.task(() => this._check(event));
|
3963
4079
|
}
|
3964
4080
|
};
|
3965
4081
|
|
3966
4082
|
|
3967
4083
|
/***/ }),
|
3968
|
-
/*
|
4084
|
+
/* 43 */
|
4085
|
+
/***/ (() => {
|
4086
|
+
|
4087
|
+
const u = up.util;
|
4088
|
+
const e = up.element;
|
4089
|
+
const BUILTIN_SWITCH_EFFECTS = [
|
4090
|
+
{ attr: 'up-hide-for', toggle(target, active) { e.toggle(target, !active); } },
|
4091
|
+
{ attr: 'up-show-for', toggle(target, active) { e.toggle(target, active); } },
|
4092
|
+
{ attr: 'up-disable-for', toggle(target, active) { up.form.setDisabled(target, active); } },
|
4093
|
+
{ attr: 'up-enable-for', toggle(target, active) { up.form.setDisabled(target, !active); } },
|
4094
|
+
];
|
4095
|
+
up.Switcher = class Switcher {
|
4096
|
+
constructor(root) {
|
4097
|
+
this._root = root;
|
4098
|
+
this._switcheeSelector = root.getAttribute('up-switch') || up.fail("No switch target given for %o", root);
|
4099
|
+
this._regionSelector = root.getAttribute('up-switch-region');
|
4100
|
+
}
|
4101
|
+
start() {
|
4102
|
+
this._switchRegion();
|
4103
|
+
return u.sequence(this._trackFieldChanges(), this._trackNewSwitchees());
|
4104
|
+
}
|
4105
|
+
_trackFieldChanges() {
|
4106
|
+
var _a, _b;
|
4107
|
+
let callback = () => this._onFieldChanged();
|
4108
|
+
return ((_b = (_a = up.migrate).watchForSwitch) === null || _b === void 0 ? void 0 : _b.call(_a, this._root, callback))
|
4109
|
+
|| up.watch(this._root, { logPrefix: '[up-switch]' }, callback);
|
4110
|
+
}
|
4111
|
+
_trackNewSwitchees() {
|
4112
|
+
let filter = (matches) => {
|
4113
|
+
let scope = this._scope;
|
4114
|
+
return u.filter(matches, (match) => scope.contains(match));
|
4115
|
+
};
|
4116
|
+
let onSwitcheeAdded = (switchee) => this._switchSwitchee(switchee);
|
4117
|
+
return up.fragment.trackSelector(this._switcheeSelector, { filter }, onSwitcheeAdded);
|
4118
|
+
}
|
4119
|
+
_onFieldChanged() {
|
4120
|
+
this._switchRegion();
|
4121
|
+
}
|
4122
|
+
_switchRegion() {
|
4123
|
+
const fieldTokens = this._buildFieldTokens();
|
4124
|
+
for (let switchee of this._findSwitchees()) {
|
4125
|
+
this._switchSwitchee(switchee, fieldTokens);
|
4126
|
+
}
|
4127
|
+
}
|
4128
|
+
_switchSwitchee(switchee, fieldTokens = this._buildFieldTokens()) {
|
4129
|
+
let previousValues = switchee.upSwitchValues;
|
4130
|
+
if (!u.isEqual(previousValues, fieldTokens)) {
|
4131
|
+
switchee.upSwitchValues = fieldTokens;
|
4132
|
+
this._switchSwitcheeNow(switchee, fieldTokens);
|
4133
|
+
}
|
4134
|
+
}
|
4135
|
+
_switchSwitcheeNow(switchee, fieldTokens) {
|
4136
|
+
for (let { attr, toggle } of BUILTIN_SWITCH_EFFECTS) {
|
4137
|
+
let attrValue = switchee.getAttribute(attr);
|
4138
|
+
if (attrValue) {
|
4139
|
+
let activeTokens = this._parseSwitcheeTokens(attrValue);
|
4140
|
+
let isActive = u.intersect(fieldTokens, activeTokens).length > 0;
|
4141
|
+
toggle(switchee, isActive);
|
4142
|
+
}
|
4143
|
+
}
|
4144
|
+
let log = ['Switching %o', switchee];
|
4145
|
+
up.emit(switchee, 'up:form:switch', { field: this._root, tokens: fieldTokens, log });
|
4146
|
+
}
|
4147
|
+
_findSwitchees() {
|
4148
|
+
return up.fragment.subtree(this._scope, this._switcheeSelector);
|
4149
|
+
}
|
4150
|
+
get _scope() {
|
4151
|
+
if (this._regionSelector) {
|
4152
|
+
return up.fragment.get(this._regionSelector, { origin: this._root });
|
4153
|
+
}
|
4154
|
+
else {
|
4155
|
+
return up.form.getRegion(this._root);
|
4156
|
+
}
|
4157
|
+
}
|
4158
|
+
_parseSwitcheeTokens(str) {
|
4159
|
+
return u.getSimpleTokens(str, { json: true });
|
4160
|
+
}
|
4161
|
+
_buildFieldTokens() {
|
4162
|
+
var _a, _b;
|
4163
|
+
let fields = up.form.fields(this._root);
|
4164
|
+
let field = fields[0];
|
4165
|
+
let value;
|
4166
|
+
let meta;
|
4167
|
+
if (field.matches('input[type=checkbox]')) {
|
4168
|
+
if (field.checked) {
|
4169
|
+
value = field.value;
|
4170
|
+
meta = ':checked';
|
4171
|
+
}
|
4172
|
+
else {
|
4173
|
+
meta = ':unchecked';
|
4174
|
+
}
|
4175
|
+
}
|
4176
|
+
else if (field.matches('input[type=radio]')) {
|
4177
|
+
let checkedButton = ((_b = (_a = up.migrate).checkedRadioButtonForSwitch) === null || _b === void 0 ? void 0 : _b.call(_a, field)) || u.find(fields, 'checked');
|
4178
|
+
if (checkedButton) {
|
4179
|
+
meta = ':checked';
|
4180
|
+
value = checkedButton.value;
|
4181
|
+
}
|
4182
|
+
else {
|
4183
|
+
meta = ':unchecked';
|
4184
|
+
}
|
4185
|
+
}
|
4186
|
+
else {
|
4187
|
+
value = field.value;
|
4188
|
+
}
|
4189
|
+
const values = [];
|
4190
|
+
if (u.isPresent(value)) {
|
4191
|
+
values.push(value);
|
4192
|
+
values.push(':present');
|
4193
|
+
}
|
4194
|
+
else {
|
4195
|
+
values.push(':blank');
|
4196
|
+
}
|
4197
|
+
if (u.isPresent(meta)) {
|
4198
|
+
values.push(meta);
|
4199
|
+
}
|
4200
|
+
return values;
|
4201
|
+
}
|
4202
|
+
};
|
4203
|
+
|
4204
|
+
|
4205
|
+
/***/ }),
|
4206
|
+
/* 44 */
|
3969
4207
|
/***/ (function() {
|
3970
4208
|
|
3971
4209
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -3996,41 +4234,52 @@ up.FormValidator = class FormValidator {
|
|
3996
4234
|
this._dirtySolutions = [];
|
3997
4235
|
this._nextRenderTimer = null;
|
3998
4236
|
this._rendering = false;
|
3999
|
-
this._resetNextRenderPromise();
|
4000
4237
|
this._honorAbort();
|
4001
4238
|
}
|
4239
|
+
start() {
|
4240
|
+
let guard = (field) => this._isValidatingField(field);
|
4241
|
+
let callback = (field) => this._onFieldAdded(field);
|
4242
|
+
return up.form.trackFields(this._form, { guard }, callback);
|
4243
|
+
}
|
4244
|
+
_isValidatingField(field) {
|
4245
|
+
return field.closest('[up-validate]:not([up-validate=false])');
|
4246
|
+
}
|
4247
|
+
_onFieldAdded(field) {
|
4248
|
+
let eventType = up.form.validateOptions(field).event;
|
4249
|
+
return up.on(field, eventType, (event) => {
|
4250
|
+
up.log.putsEvent(event);
|
4251
|
+
up.error.muteUncriticalRejection(this.validate({ origin: field }));
|
4252
|
+
});
|
4253
|
+
}
|
4002
4254
|
_honorAbort() {
|
4003
4255
|
up.fragment.onAborted(this._form, (event) => this._onAborted(event));
|
4004
4256
|
}
|
4005
4257
|
_onAborted(event) {
|
4006
|
-
|
4007
|
-
|
4008
|
-
|
4009
|
-
|
4258
|
+
let abortedError = new up.Aborted(event.reason);
|
4259
|
+
let solution;
|
4260
|
+
while (solution = this._dirtySolutions.shift()) {
|
4261
|
+
solution.deferred.reject(abortedError);
|
4010
4262
|
}
|
4011
4263
|
}
|
4012
|
-
_resetNextRenderPromise() {
|
4013
|
-
this._nextRenderPromise = u.newDeferred();
|
4014
|
-
}
|
4015
|
-
watchContainer(fieldOrForm) {
|
4016
|
-
let { event } = this._originOptions(fieldOrForm);
|
4017
|
-
let guard = () => up.fragment.isAlive(fieldOrForm);
|
4018
|
-
let callback = () => up.error.muteUncriticalRejection(this.validate({ origin: fieldOrForm }));
|
4019
|
-
up.on(fieldOrForm, event, { guard }, callback);
|
4020
|
-
}
|
4021
4264
|
validate(options = {}) {
|
4022
|
-
|
4023
|
-
this.
|
4265
|
+
var _a;
|
4266
|
+
let newSolutions = this._getSolutions(options);
|
4267
|
+
this._dirtySolutions.push(...newSolutions);
|
4024
4268
|
this._scheduleNextRender();
|
4025
|
-
return
|
4269
|
+
return (_a = newSolutions[0]) === null || _a === void 0 ? void 0 : _a.deferred;
|
4026
4270
|
}
|
4027
4271
|
_getSolutions(options) {
|
4028
4272
|
let solutions = this._getTargetSelectorSolutions(options)
|
4029
4273
|
|| this._getFieldSolutions(options)
|
4030
4274
|
|| this._getElementSolutions(options.origin);
|
4275
|
+
let deferred = u.newDeferred();
|
4031
4276
|
for (let solution of solutions) {
|
4032
|
-
|
4277
|
+
let renderOptions = up.form.validateOptions(solution.origin, options);
|
4278
|
+
solution.batch = u.pluckKey(renderOptions, 'batch');
|
4279
|
+
solution.renderOptions = renderOptions;
|
4280
|
+
solution.destination = `${renderOptions.method} ${renderOptions.url}`;
|
4033
4281
|
solution.target = up.fragment.resolveOrigin(solution.target, solution);
|
4282
|
+
solution.deferred = deferred;
|
4034
4283
|
}
|
4035
4284
|
return solutions;
|
4036
4285
|
}
|
@@ -4083,9 +4332,6 @@ up.FormValidator = class FormValidator {
|
|
4083
4332
|
return this._getTargetSelectorSolutions({ target, origin: field });
|
4084
4333
|
}
|
4085
4334
|
}
|
4086
|
-
_originOptions(element, overrideOptions) {
|
4087
|
-
return up.form.watchOptions(element, overrideOptions, { defaults: { event: 'change' } });
|
4088
|
-
}
|
4089
4335
|
_scheduleNextRender() {
|
4090
4336
|
let solutionDelays = this._dirtySolutions.map((solution) => solution.renderOptions.delay);
|
4091
4337
|
let shortestDelay = Math.min(...solutionDelays) || 0;
|
@@ -4106,14 +4352,15 @@ up.FormValidator = class FormValidator {
|
|
4106
4352
|
return;
|
4107
4353
|
if (this._nextRenderTimer)
|
4108
4354
|
return;
|
4109
|
-
let
|
4110
|
-
|
4355
|
+
let solutionsBatch = this._selectDirtySolutionsBatch();
|
4356
|
+
let renderOptions = this._mergeRenderOptions(solutionsBatch);
|
4111
4357
|
this._rendering = true;
|
4112
|
-
let renderingPromise = this._nextRenderPromise;
|
4113
|
-
this._resetNextRenderPromise();
|
4114
4358
|
try {
|
4115
|
-
|
4116
|
-
|
4359
|
+
let renderPromise = up.render(renderOptions);
|
4360
|
+
for (let solution of solutionsBatch) {
|
4361
|
+
solution.deferred.resolve(renderPromise);
|
4362
|
+
}
|
4363
|
+
yield renderPromise;
|
4117
4364
|
}
|
4118
4365
|
finally {
|
4119
4366
|
this._rendering = false;
|
@@ -4121,20 +4368,39 @@ up.FormValidator = class FormValidator {
|
|
4121
4368
|
}
|
4122
4369
|
});
|
4123
4370
|
}
|
4371
|
+
_selectDirtySolutionsBatch() {
|
4372
|
+
let batch = [];
|
4373
|
+
let i = 0;
|
4374
|
+
while (i < this._dirtySolutions.length) {
|
4375
|
+
let solution = this._dirtySolutions[i];
|
4376
|
+
if (batch.length === 0 || this._canBatchSolutions(batch[0], solution)) {
|
4377
|
+
batch.push(solution);
|
4378
|
+
this._dirtySolutions.splice(i, 1);
|
4379
|
+
}
|
4380
|
+
else {
|
4381
|
+
i++;
|
4382
|
+
}
|
4383
|
+
}
|
4384
|
+
return batch;
|
4385
|
+
}
|
4386
|
+
_canBatchSolutions(s1, s2) {
|
4387
|
+
return s1.destination === s2.destination && s1.batch && s2.batch;
|
4388
|
+
}
|
4124
4389
|
_mergeRenderOptions(dirtySolutions) {
|
4125
4390
|
var _a;
|
4126
4391
|
let dirtyOrigins = u.map(dirtySolutions, 'origin');
|
4127
4392
|
let dirtyFields = u.flatMap(dirtyOrigins, up.form.fields);
|
4128
4393
|
let dirtyNames = u.uniq(u.map(dirtyFields, 'name'));
|
4129
4394
|
let dirtyRenderOptionsList = u.map(dirtySolutions, 'renderOptions');
|
4130
|
-
let
|
4395
|
+
let formDestinationOptions = up.form.destinationOptions(this._form);
|
4396
|
+
let options = u.mergeDefined(formDestinationOptions, ...dirtyRenderOptionsList);
|
4131
4397
|
options.target = u.map(dirtySolutions, 'target').join(', ');
|
4132
4398
|
options.origin = this._form;
|
4133
4399
|
(_a = options.focus) !== null && _a !== void 0 ? _a : (options.focus = 'keep');
|
4134
4400
|
options.failOptions = false;
|
4135
4401
|
options.defaultMaybe = true;
|
4136
|
-
options.params = up.Params.merge(
|
4137
|
-
options.headers = u.merge(
|
4402
|
+
options.params = up.Params.merge(formDestinationOptions.params, ...u.map(dirtyRenderOptionsList, 'params'));
|
4403
|
+
options.headers = u.merge(formDestinationOptions.headers, ...u.map(dirtyRenderOptionsList, 'headers'));
|
4138
4404
|
this._addValidateHeader(options.headers, dirtyNames);
|
4139
4405
|
options.feedback = u.some(dirtyRenderOptionsList, 'feedback');
|
4140
4406
|
options.data = undefined;
|
@@ -4162,27 +4428,29 @@ up.FormValidator = class FormValidator {
|
|
4162
4428
|
value = ':unknown';
|
4163
4429
|
headers[key] = value;
|
4164
4430
|
}
|
4165
|
-
static forElement(element) {
|
4166
|
-
let form = up.form.get(element);
|
4167
|
-
return form.upFormValidator || (form.upFormValidator = new this(form));
|
4168
|
-
}
|
4169
4431
|
};
|
4170
4432
|
|
4171
4433
|
|
4172
4434
|
/***/ }),
|
4173
|
-
/*
|
4435
|
+
/* 45 */
|
4174
4436
|
/***/ (() => {
|
4175
4437
|
|
4176
4438
|
up.FocusCapsule = class FocusCapsule {
|
4177
|
-
constructor(element, target
|
4439
|
+
constructor(element, target) {
|
4178
4440
|
this._element = element;
|
4179
4441
|
this._target = target;
|
4180
|
-
this._cursorProps =
|
4442
|
+
this._cursorProps = up.viewport.copyCursorProps(this._element);
|
4181
4443
|
}
|
4182
4444
|
wasLost() {
|
4183
|
-
return document.activeElement !== this._element;
|
4445
|
+
return document.activeElement !== this._element && !this._voided;
|
4446
|
+
}
|
4447
|
+
autoVoid() {
|
4448
|
+
up.on('focusin', { once: true }, () => this._voided = true);
|
4184
4449
|
}
|
4185
4450
|
restore(layer, focusOptions) {
|
4451
|
+
if (!this.wasLost()) {
|
4452
|
+
return false;
|
4453
|
+
}
|
4186
4454
|
let rediscoveredElement = up.fragment.get(this._target, { layer });
|
4187
4455
|
if (rediscoveredElement) {
|
4188
4456
|
up.viewport.copyCursorProps(this._cursorProps, rediscoveredElement);
|
@@ -4197,14 +4465,13 @@ up.FocusCapsule = class FocusCapsule {
|
|
4197
4465
|
let target = up.fragment.tryToTarget(focusedElement);
|
4198
4466
|
if (!target)
|
4199
4467
|
return;
|
4200
|
-
|
4201
|
-
return new this(focusedElement, target, cursorProps);
|
4468
|
+
return new this(focusedElement, target);
|
4202
4469
|
}
|
4203
4470
|
};
|
4204
4471
|
|
4205
4472
|
|
4206
4473
|
/***/ }),
|
4207
|
-
/*
|
4474
|
+
/* 46 */
|
4208
4475
|
/***/ (() => {
|
4209
4476
|
|
4210
4477
|
const u = up.util;
|
@@ -4247,7 +4514,7 @@ up.FragmentProcessor = class FragmentProcessor extends up.Record {
|
|
4247
4514
|
return this.processPrimitive(opt);
|
4248
4515
|
}
|
4249
4516
|
processArray(array) {
|
4250
|
-
return u.find(array, opt => this.tryProcess(opt));
|
4517
|
+
return u.find(array, (opt) => this.tryProcess(opt));
|
4251
4518
|
}
|
4252
4519
|
resolveCondition(condition) {
|
4253
4520
|
if (condition === 'main') {
|
@@ -4269,7 +4536,7 @@ up.FragmentProcessor = class FragmentProcessor extends up.Record {
|
|
4269
4536
|
|
4270
4537
|
|
4271
4538
|
/***/ }),
|
4272
|
-
/*
|
4539
|
+
/* 47 */
|
4273
4540
|
/***/ (() => {
|
4274
4541
|
|
4275
4542
|
const u = up.util;
|
@@ -4320,7 +4587,7 @@ up.FragmentFinder = class FragmentFinder {
|
|
4320
4587
|
|
4321
4588
|
|
4322
4589
|
/***/ }),
|
4323
|
-
/*
|
4590
|
+
/* 48 */
|
4324
4591
|
/***/ (() => {
|
4325
4592
|
|
4326
4593
|
const u = up.util;
|
@@ -4330,6 +4597,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
|
|
4330
4597
|
keys() {
|
4331
4598
|
return super.keys().concat([
|
4332
4599
|
'hash',
|
4600
|
+
'focusVisible',
|
4333
4601
|
'focusCapsule',
|
4334
4602
|
'inputDevice',
|
4335
4603
|
]);
|
@@ -4374,9 +4642,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
|
|
4374
4642
|
}
|
4375
4643
|
_restoreLostFocus() {
|
4376
4644
|
var _a;
|
4377
|
-
|
4378
|
-
return (_a = this.focusCapsule) === null || _a === void 0 ? void 0 : _a.restore(this.layer, PREVENT_SCROLL_OPTIONS);
|
4379
|
-
}
|
4645
|
+
return (_a = this.focusCapsule) === null || _a === void 0 ? void 0 : _a.restore(this.layer, PREVENT_SCROLL_OPTIONS);
|
4380
4646
|
}
|
4381
4647
|
_restorePreviousFocusForLocation() {
|
4382
4648
|
return up.viewport.restoreFocus({ layer: this.layer });
|
@@ -4389,7 +4655,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
|
|
4389
4655
|
}
|
4390
4656
|
_focusElement(element) {
|
4391
4657
|
if (element) {
|
4392
|
-
up.focus(element, Object.assign(Object.assign({ force: true }, PREVENT_SCROLL_OPTIONS), { inputDevice: this.inputDevice }));
|
4658
|
+
up.focus(element, Object.assign(Object.assign({ force: true }, PREVENT_SCROLL_OPTIONS), { inputDevice: this.inputDevice, focusVisible: this.focusVisible }));
|
4393
4659
|
return true;
|
4394
4660
|
}
|
4395
4661
|
}
|
@@ -4407,7 +4673,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
|
|
4407
4673
|
|
4408
4674
|
|
4409
4675
|
/***/ }),
|
4410
|
-
/*
|
4676
|
+
/* 49 */
|
4411
4677
|
/***/ (() => {
|
4412
4678
|
|
4413
4679
|
const e = up.element;
|
@@ -4494,6 +4760,11 @@ up.FragmentPolling = class FragmentPolling {
|
|
4494
4760
|
if (this._state !== 'started') {
|
4495
4761
|
return;
|
4496
4762
|
}
|
4763
|
+
if (!up.fragment.isAlive(this._fragment)) {
|
4764
|
+
this._stop();
|
4765
|
+
up.puts('[up-poll]', 'Stopped polling a detached fragment');
|
4766
|
+
return;
|
4767
|
+
}
|
4497
4768
|
if (!this._isFragmentVisible()) {
|
4498
4769
|
up.puts('[up-poll]', 'Will not poll hidden fragment');
|
4499
4770
|
return;
|
@@ -4565,7 +4836,7 @@ up.FragmentPolling = class FragmentPolling {
|
|
4565
4836
|
|
4566
4837
|
|
4567
4838
|
/***/ }),
|
4568
|
-
/*
|
4839
|
+
/* 50 */
|
4569
4840
|
/***/ (() => {
|
4570
4841
|
|
4571
4842
|
const u = up.util;
|
@@ -4582,8 +4853,10 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
|
|
4582
4853
|
}
|
4583
4854
|
processPrimitive(opt) {
|
4584
4855
|
switch (opt) {
|
4585
|
-
case '
|
4586
|
-
return this.
|
4856
|
+
case 'top':
|
4857
|
+
return this._scrollTo(0);
|
4858
|
+
case 'bottom':
|
4859
|
+
return this._scrollTo(99999999);
|
4587
4860
|
case 'layer':
|
4588
4861
|
return this._revealLayer();
|
4589
4862
|
case 'main':
|
@@ -4618,9 +4891,8 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
|
|
4618
4891
|
_revealLayer() {
|
4619
4892
|
return this._revealElement(this.layer.getBoxElement());
|
4620
4893
|
}
|
4621
|
-
|
4622
|
-
up.viewport.
|
4623
|
-
return true;
|
4894
|
+
_scrollTo(position) {
|
4895
|
+
return up.viewport.scrollTo(position, Object.assign(Object.assign({}, this.attributes()), { around: this.fragment }));
|
4624
4896
|
}
|
4625
4897
|
_restore() {
|
4626
4898
|
return up.viewport.restoreScroll(Object.assign(Object.assign({}, this.attributes()), { around: this.fragment }));
|
@@ -4629,7 +4901,7 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
|
|
4629
4901
|
|
4630
4902
|
|
4631
4903
|
/***/ }),
|
4632
|
-
/*
|
4904
|
+
/* 51 */
|
4633
4905
|
/***/ (() => {
|
4634
4906
|
|
4635
4907
|
const e = up.element;
|
@@ -4867,7 +5139,7 @@ up.Layer = class Layer extends up.Record {
|
|
4867
5139
|
up.history.push(location);
|
4868
5140
|
}
|
4869
5141
|
if (!this.opening) {
|
4870
|
-
this.emit('up:layer:location:changed', { location });
|
5142
|
+
this.emit('up:layer:location:changed', { location, log: false });
|
4871
5143
|
}
|
4872
5144
|
}
|
4873
5145
|
}
|
@@ -4897,7 +5169,7 @@ up.Layer = class Layer extends up.Record {
|
|
4897
5169
|
|
4898
5170
|
|
4899
5171
|
/***/ }),
|
4900
|
-
/*
|
5172
|
+
/* 52 */
|
4901
5173
|
/***/ (function() {
|
4902
5174
|
|
4903
5175
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -5007,7 +5279,7 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
|
|
5007
5279
|
}
|
5008
5280
|
if (this._supportsDismissMethod('outside')) {
|
5009
5281
|
if (this.viewportElement) {
|
5010
|
-
up.on(this.viewportElement, 'up:click', event => {
|
5282
|
+
up.on(this.viewportElement, 'up:click', (event) => {
|
5011
5283
|
if (event.target === this.viewportElement) {
|
5012
5284
|
this._onOutsideClicked(event, true);
|
5013
5285
|
}
|
@@ -5023,17 +5295,17 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
|
|
5023
5295
|
}
|
5024
5296
|
}
|
5025
5297
|
if (this._supportsDismissMethod('key')) {
|
5026
|
-
this.unbindEscapePressed = up.event.onEscape(event => this.onEscapePressed(event));
|
5298
|
+
this.unbindEscapePressed = up.event.onEscape((event) => this.onEscapePressed(event));
|
5027
5299
|
}
|
5028
|
-
this.
|
5300
|
+
this.registerAttrCloser('up-accept', (value, closeOptions) => {
|
5029
5301
|
this.accept(value, closeOptions);
|
5030
5302
|
});
|
5031
|
-
this.
|
5303
|
+
this.registerAttrCloser('up-dismiss', (value, closeOptions) => {
|
5032
5304
|
this.dismiss(value, closeOptions);
|
5033
5305
|
});
|
5034
5306
|
(_c = (_b = up.migrate).registerLayerCloser) === null || _c === void 0 ? void 0 : _c.call(_b, this);
|
5035
|
-
this.
|
5036
|
-
this.
|
5307
|
+
this._registerExternalEventCloser(this.acceptEvent, this.accept);
|
5308
|
+
this._registerExternalEventCloser(this.dismissEvent, this.dismiss);
|
5037
5309
|
this.on('up:click', 'label[for]', (event, label) => this._onLabelClicked(event, label));
|
5038
5310
|
}
|
5039
5311
|
_onLabelClicked(event, label) {
|
@@ -5068,26 +5340,38 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
|
|
5068
5340
|
}
|
5069
5341
|
}
|
5070
5342
|
}
|
5071
|
-
|
5072
|
-
|
5073
|
-
this.
|
5343
|
+
registerAttrCloser(attribute, closeFn) {
|
5344
|
+
this._registerClickCloser(attribute, closeFn);
|
5345
|
+
this._registerSubmitCloser(attribute, closeFn);
|
5346
|
+
}
|
5347
|
+
_registerClickCloser(attribute, closeFn) {
|
5348
|
+
this.on('up:click', `[${attribute}]:not(form)`, (event, link) => {
|
5349
|
+
up.event.halt(event, { log: true });
|
5350
|
+
const value = e.jsonAttr(link, attribute);
|
5351
|
+
this._onAttrCloserActivated(link, value, closeFn);
|
5352
|
+
});
|
5353
|
+
}
|
5354
|
+
_registerSubmitCloser(attribute, closeFn) {
|
5355
|
+
this.on('submit', `[${attribute}]`, (event, form) => {
|
5074
5356
|
up.event.halt(event, { log: true });
|
5075
|
-
const
|
5076
|
-
|
5077
|
-
const closeOptions = { origin };
|
5078
|
-
const parser = new up.OptionsParser(origin, closeOptions);
|
5079
|
-
parser.booleanOrString('animation');
|
5080
|
-
parser.string('easing');
|
5081
|
-
parser.number('duration');
|
5082
|
-
parser.string('confirm');
|
5083
|
-
up.error.muteUncriticalSync(() => closeFn(value, closeOptions));
|
5357
|
+
const value = up.Params.fromForm(form);
|
5358
|
+
this._onAttrCloserActivated(form, value, closeFn);
|
5084
5359
|
});
|
5085
5360
|
}
|
5086
|
-
|
5361
|
+
_onAttrCloserActivated(origin, value, closeFn) {
|
5362
|
+
const closeOptions = { origin };
|
5363
|
+
const parser = new up.OptionsParser(origin, closeOptions);
|
5364
|
+
parser.booleanOrString('animation');
|
5365
|
+
parser.string('easing');
|
5366
|
+
parser.number('duration');
|
5367
|
+
parser.string('confirm');
|
5368
|
+
up.error.muteUncriticalSync(() => closeFn(value, closeOptions));
|
5369
|
+
}
|
5370
|
+
_registerExternalEventCloser(eventTypes, closeFn) {
|
5087
5371
|
if (!eventTypes) {
|
5088
5372
|
return;
|
5089
5373
|
}
|
5090
|
-
return this.on(eventTypes, event => {
|
5374
|
+
return this.on(eventTypes, (event) => {
|
5091
5375
|
event.preventDefault();
|
5092
5376
|
up.error.muteUncriticalSync(() => closeFn.call(this, event, { response: event.response }));
|
5093
5377
|
});
|
@@ -5196,11 +5480,12 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
|
|
5196
5480
|
'closeEasing',
|
5197
5481
|
'trapFocus',
|
5198
5482
|
],
|
5483
|
+
_a.UNSET_VISUALS = u.spanObject(_a.VISUAL_KEYS, undefined),
|
5199
5484
|
_a);
|
5200
5485
|
|
5201
5486
|
|
5202
5487
|
/***/ }),
|
5203
|
-
/*
|
5488
|
+
/* 53 */
|
5204
5489
|
/***/ (() => {
|
5205
5490
|
|
5206
5491
|
up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
@@ -5239,7 +5524,7 @@ up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
|
5239
5524
|
|
5240
5525
|
|
5241
5526
|
/***/ }),
|
5242
|
-
/*
|
5527
|
+
/* 54 */
|
5243
5528
|
/***/ (() => {
|
5244
5529
|
|
5245
5530
|
up.Layer.OverlayWithViewport = class OverlayWithViewport extends up.Layer.Overlay {
|
@@ -5268,7 +5553,7 @@ up.Layer.OverlayWithViewport = class OverlayWithViewport extends up.Layer.Overla
|
|
5268
5553
|
|
5269
5554
|
|
5270
5555
|
/***/ }),
|
5271
|
-
/*
|
5556
|
+
/* 55 */
|
5272
5557
|
/***/ (() => {
|
5273
5558
|
|
5274
5559
|
var _a;
|
@@ -5314,7 +5599,7 @@ up.Layer.Root = (_a = class Root extends up.Layer {
|
|
5314
5599
|
|
5315
5600
|
|
5316
5601
|
/***/ }),
|
5317
|
-
/*
|
5602
|
+
/* 56 */
|
5318
5603
|
/***/ (() => {
|
5319
5604
|
|
5320
5605
|
var _a;
|
@@ -5325,7 +5610,7 @@ up.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {
|
|
5325
5610
|
|
5326
5611
|
|
5327
5612
|
/***/ }),
|
5328
|
-
/*
|
5613
|
+
/* 57 */
|
5329
5614
|
/***/ (() => {
|
5330
5615
|
|
5331
5616
|
var _a;
|
@@ -5336,7 +5621,7 @@ up.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {
|
|
5336
5621
|
|
5337
5622
|
|
5338
5623
|
/***/ }),
|
5339
|
-
/*
|
5624
|
+
/* 58 */
|
5340
5625
|
/***/ (() => {
|
5341
5626
|
|
5342
5627
|
var _a;
|
@@ -5347,7 +5632,7 @@ up.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {
|
|
5347
5632
|
|
5348
5633
|
|
5349
5634
|
/***/ }),
|
5350
|
-
/*
|
5635
|
+
/* 59 */
|
5351
5636
|
/***/ (() => {
|
5352
5637
|
|
5353
5638
|
var _a;
|
@@ -5358,7 +5643,7 @@ up.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {
|
|
5358
5643
|
|
5359
5644
|
|
5360
5645
|
/***/ }),
|
5361
|
-
/*
|
5646
|
+
/* 60 */
|
5362
5647
|
/***/ (() => {
|
5363
5648
|
|
5364
5649
|
var _a;
|
@@ -5374,7 +5659,7 @@ up.LayerLookup = (_a = class LayerLookup {
|
|
5374
5659
|
this._values = u.getSimpleTokens(options.layer);
|
5375
5660
|
}
|
5376
5661
|
all() {
|
5377
|
-
let results = u.flatMap(this._values, value => this._resolveValue(value));
|
5662
|
+
let results = u.flatMap(this._values, (value) => this._resolveValue(value));
|
5378
5663
|
results = u.compact(results);
|
5379
5664
|
results = u.uniq(results);
|
5380
5665
|
return results;
|
@@ -5389,7 +5674,7 @@ up.LayerLookup = (_a = class LayerLookup {
|
|
5389
5674
|
}
|
5390
5675
|
_forElement(element) {
|
5391
5676
|
element = e.get(element);
|
5392
|
-
return u.find(this._stack.reversed(), layer => layer.contains(element));
|
5677
|
+
return u.find(this._stack.reversed(), (layer) => layer.contains(element));
|
5393
5678
|
}
|
5394
5679
|
_forIndex(value) {
|
5395
5680
|
return this._stack.at(value);
|
@@ -5471,7 +5756,7 @@ up.LayerLookup = (_a = class LayerLookup {
|
|
5471
5756
|
|
5472
5757
|
|
5473
5758
|
/***/ }),
|
5474
|
-
/*
|
5759
|
+
/* 61 */
|
5475
5760
|
/***/ (() => {
|
5476
5761
|
|
5477
5762
|
const u = up.util;
|
@@ -5585,7 +5870,7 @@ up.LayerStack = class LayerStack {
|
|
5585
5870
|
|
5586
5871
|
|
5587
5872
|
/***/ }),
|
5588
|
-
/*
|
5873
|
+
/* 62 */
|
5589
5874
|
/***/ (() => {
|
5590
5875
|
|
5591
5876
|
const u = up.util;
|
@@ -5620,7 +5905,7 @@ up.LinkCurrentURLs = class LinkCurrentURLs {
|
|
5620
5905
|
|
5621
5906
|
|
5622
5907
|
/***/ }),
|
5623
|
-
/*
|
5908
|
+
/* 63 */
|
5624
5909
|
/***/ (() => {
|
5625
5910
|
|
5626
5911
|
const u = up.util;
|
@@ -5663,13 +5948,15 @@ up.LinkFollowIntent = class LinkFollowIntent {
|
|
5663
5948
|
}
|
5664
5949
|
_runCallback(event) {
|
5665
5950
|
up.log.putsEvent(event);
|
5951
|
+
if (!up.fragment.isAlive(this._link))
|
5952
|
+
return;
|
5666
5953
|
this._callback({ onRequestKnown: (request) => this._lastRequest = request });
|
5667
5954
|
}
|
5668
5955
|
};
|
5669
5956
|
|
5670
5957
|
|
5671
5958
|
/***/ }),
|
5672
|
-
/*
|
5959
|
+
/* 64 */
|
5673
5960
|
/***/ (function() {
|
5674
5961
|
|
5675
5962
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -5722,7 +6009,7 @@ up.MotionController = class MotionController {
|
|
5722
6009
|
}
|
5723
6010
|
_expandFinishRequest(elements) {
|
5724
6011
|
if (elements) {
|
5725
|
-
return u.flatMap(elements, el => e.list(el.closest(this._selector), el.querySelectorAll(this._selector)));
|
6012
|
+
return u.flatMap(elements, (el) => e.list(el.closest(this._selector), el.querySelectorAll(this._selector)));
|
5726
6013
|
}
|
5727
6014
|
else {
|
5728
6015
|
return document.querySelectorAll(this._selector);
|
@@ -5778,10 +6065,9 @@ up.MotionController = class MotionController {
|
|
5778
6065
|
|
5779
6066
|
|
5780
6067
|
/***/ }),
|
5781
|
-
/*
|
6068
|
+
/* 65 */
|
5782
6069
|
/***/ (() => {
|
5783
6070
|
|
5784
|
-
const u = up.util;
|
5785
6071
|
const e = up.element;
|
5786
6072
|
up.NonceableCallback = class NonceableCallback {
|
5787
6073
|
constructor(script, nonce) {
|
@@ -5835,37 +6121,11 @@ up.NonceableCallback = class NonceableCallback {
|
|
5835
6121
|
}
|
5836
6122
|
}
|
5837
6123
|
}
|
5838
|
-
_allowedBy(allowedNonces) {
|
5839
|
-
return this.nonce && u.contains(allowedNonces, this.nonce);
|
5840
|
-
}
|
5841
|
-
static adoptNonces(element, allowedNonces) {
|
5842
|
-
if (!(allowedNonces === null || allowedNonces === void 0 ? void 0 : allowedNonces.length)) {
|
5843
|
-
return;
|
5844
|
-
}
|
5845
|
-
const getPageNonce = u.memoize(up.protocol.cspNonce);
|
5846
|
-
u.each(up.script.config.nonceableAttributes, (attribute) => {
|
5847
|
-
let matches = e.subtree(element, `[${attribute}^="nonce-"]`);
|
5848
|
-
u.each(matches, (match) => {
|
5849
|
-
let attributeValue = match.getAttribute(attribute);
|
5850
|
-
let callback = this.fromString(attributeValue);
|
5851
|
-
let warn = (message, ...args) => up.log.warn('up.render()', `Cannot use callback [${attribute}="${attributeValue}"]: ${message}`, ...args);
|
5852
|
-
if (!callback._allowedBy(allowedNonces)) {
|
5853
|
-
return warn("Callback's CSP nonce (%o) does not match response header (%o)", callback.nonce, allowedNonces);
|
5854
|
-
}
|
5855
|
-
let pageNonce = getPageNonce();
|
5856
|
-
if (!pageNonce) {
|
5857
|
-
return warn("Current page's CSP nonce is unknown");
|
5858
|
-
}
|
5859
|
-
callback.nonce = pageNonce;
|
5860
|
-
match.setAttribute(attribute, callback.toString());
|
5861
|
-
});
|
5862
|
-
});
|
5863
|
-
}
|
5864
6124
|
};
|
5865
6125
|
|
5866
6126
|
|
5867
6127
|
/***/ }),
|
5868
|
-
/*
|
6128
|
+
/* 66 */
|
5869
6129
|
/***/ (() => {
|
5870
6130
|
|
5871
6131
|
const e = up.element;
|
@@ -5887,7 +6147,7 @@ up.OverlayFocus = class OverlayFocus {
|
|
5887
6147
|
'aria-modal': this._trapFocus.toString()
|
5888
6148
|
});
|
5889
6149
|
if (this._trapFocus) {
|
5890
|
-
this._untrapFocus = up.on('focusin', event => this._onFocus(event));
|
6150
|
+
this._untrapFocus = up.on('focusin', (event) => this._onFocus(event));
|
5891
6151
|
this._focusTrapBefore = e.affix(this._focusElement, 'beforebegin', 'up-focus-trap[tabindex=0]');
|
5892
6152
|
this._focusTrapAfter = e.affix(this._focusElement, 'afterend', 'up-focus-trap[tabindex=0]');
|
5893
6153
|
}
|
@@ -5938,7 +6198,7 @@ up.OverlayFocus = class OverlayFocus {
|
|
5938
6198
|
|
5939
6199
|
|
5940
6200
|
/***/ }),
|
5941
|
-
/*
|
6201
|
+
/* 67 */
|
5942
6202
|
/***/ (() => {
|
5943
6203
|
|
5944
6204
|
const u = up.util;
|
@@ -6075,7 +6335,7 @@ up.Params = class Params {
|
|
6075
6335
|
this.entries = u.reject(this.entries, this._matchEntryFn(name));
|
6076
6336
|
}
|
6077
6337
|
_matchEntryFn(name) {
|
6078
|
-
return entry => entry.name === name;
|
6338
|
+
return (entry) => entry.name === name;
|
6079
6339
|
}
|
6080
6340
|
get(name) {
|
6081
6341
|
if (this._isArrayKey(name)) {
|
@@ -6172,7 +6432,7 @@ up.Params = class Params {
|
|
6172
6432
|
|
6173
6433
|
|
6174
6434
|
/***/ }),
|
6175
|
-
/*
|
6435
|
+
/* 68 */
|
6176
6436
|
/***/ (() => {
|
6177
6437
|
|
6178
6438
|
const u = up.util;
|
@@ -6243,7 +6503,7 @@ up.Preview = class Preview {
|
|
6243
6503
|
}
|
6244
6504
|
disable(...args) {
|
6245
6505
|
let [element] = this._parseMutatorArgs(args, 'val');
|
6246
|
-
this.undo(up.form.
|
6506
|
+
this.undo(up.form.disableTemp(element));
|
6247
6507
|
}
|
6248
6508
|
insert(...args) {
|
6249
6509
|
let [reference, position = 'beforeend', tempValue] = this._parseMutatorArgs(args, 'val', u.isAdjacentPosition, 'val');
|
@@ -6300,7 +6560,7 @@ up.Preview = class Preview {
|
|
6300
6560
|
|
6301
6561
|
|
6302
6562
|
/***/ }),
|
6303
|
-
/*
|
6563
|
+
/* 69 */
|
6304
6564
|
/***/ (() => {
|
6305
6565
|
|
6306
6566
|
const e = up.element;
|
@@ -6350,7 +6610,7 @@ up.ProgressBar = class ProgressBar {
|
|
6350
6610
|
|
6351
6611
|
|
6352
6612
|
/***/ }),
|
6353
|
-
/*
|
6613
|
+
/* 70 */
|
6354
6614
|
/***/ (() => {
|
6355
6615
|
|
6356
6616
|
const u = up.util;
|
@@ -6447,7 +6707,7 @@ up.RenderOptions = (function () {
|
|
6447
6707
|
return u.merge(preprocessedOptions.defaults, lateDefaults, preprocessedOptions);
|
6448
6708
|
}
|
6449
6709
|
function assertContentGiven(options) {
|
6450
|
-
if (!u.some(CONTENT_KEYS, contentKey => u.isGiven(options[contentKey]))) {
|
6710
|
+
if (!u.some(CONTENT_KEYS, (contentKey) => u.isGiven(options[contentKey]))) {
|
6451
6711
|
if (options.defaultToEmptyContent) {
|
6452
6712
|
options.content = '';
|
6453
6713
|
}
|
@@ -6489,7 +6749,7 @@ up.RenderOptions = (function () {
|
|
6489
6749
|
|
6490
6750
|
|
6491
6751
|
/***/ }),
|
6492
|
-
/*
|
6752
|
+
/* 71 */
|
6493
6753
|
/***/ (function() {
|
6494
6754
|
|
6495
6755
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -6548,7 +6808,7 @@ up.RenderResult = class RenderResult extends up.Record {
|
|
6548
6808
|
|
6549
6809
|
|
6550
6810
|
/***/ }),
|
6551
|
-
/*
|
6811
|
+
/* 72 */
|
6552
6812
|
/***/ (() => {
|
6553
6813
|
|
6554
6814
|
var _a;
|
@@ -6575,6 +6835,8 @@ up.Request = (_a = class Request extends up.Record {
|
|
6575
6835
|
'failMode',
|
6576
6836
|
'failContext',
|
6577
6837
|
'origin',
|
6838
|
+
'originLayer',
|
6839
|
+
'originMode',
|
6578
6840
|
'builtAt',
|
6579
6841
|
'wrapMethod',
|
6580
6842
|
'contentType',
|
@@ -6587,31 +6849,32 @@ up.Request = (_a = class Request extends up.Record {
|
|
6587
6849
|
];
|
6588
6850
|
}
|
6589
6851
|
defaults() {
|
6852
|
+
let config = up.network.config;
|
6590
6853
|
return {
|
6591
6854
|
state: 'new',
|
6592
6855
|
abortable: true,
|
6593
6856
|
headers: {},
|
6594
|
-
timeout:
|
6857
|
+
timeout: config.timeout,
|
6595
6858
|
builtAt: new Date(),
|
6596
6859
|
previews: [],
|
6860
|
+
wrapMethod: config.wrapMethod,
|
6597
6861
|
};
|
6598
6862
|
}
|
6599
6863
|
constructor(options) {
|
6600
|
-
var _b, _c;
|
6864
|
+
var _b, _c, _d;
|
6601
6865
|
super(options);
|
6602
6866
|
this.params = new up.Params(this.params);
|
6603
|
-
if (this.wrapMethod == null) {
|
6604
|
-
this.wrapMethod = up.network.config.wrapMethod;
|
6605
|
-
}
|
6606
6867
|
this._normalize();
|
6607
6868
|
if ((this.target || this.layer || this.origin) && !options.basic) {
|
6608
6869
|
const layerLookupOptions = { origin: this.origin };
|
6609
6870
|
this.layer = up.layer.get(this.layer, layerLookupOptions);
|
6610
|
-
this.failLayer = up.layer.get(this.failLayer, layerLookupOptions);
|
6611
6871
|
this.context || (this.context = this.layer.context || {});
|
6612
|
-
this.failContext || (this.failContext = ((_b = this.failLayer) === null || _b === void 0 ? void 0 : _b.context) || {});
|
6613
6872
|
this.mode || (this.mode = this.layer.mode);
|
6873
|
+
this.failLayer = up.layer.get(this.failLayer, layerLookupOptions);
|
6874
|
+
this.failContext || (this.failContext = ((_b = this.failLayer) === null || _b === void 0 ? void 0 : _b.context) || {});
|
6614
6875
|
this.failMode || (this.failMode = (_c = this.failLayer) === null || _c === void 0 ? void 0 : _c.mode);
|
6876
|
+
this.originLayer || (this.originLayer = up.layer.get(this.origin) || up.layer.current);
|
6877
|
+
this.originMode || (this.originMode = (_d = this.originLayer) === null || _d === void 0 ? void 0 : _d.mode);
|
6615
6878
|
}
|
6616
6879
|
this.bindLayer = options.bindLayer || this.layer;
|
6617
6880
|
this._fragments = options.fragments;
|
@@ -6661,8 +6924,9 @@ up.Request = (_a = class Request extends up.Record {
|
|
6661
6924
|
u.task(() => {
|
6662
6925
|
this.layer = undefined;
|
6663
6926
|
this.failLayer = undefined;
|
6664
|
-
this.
|
6927
|
+
this.bindLayer = undefined;
|
6665
6928
|
this.origin = undefined;
|
6929
|
+
this.originLayer = undefined;
|
6666
6930
|
this._fragments = undefined;
|
6667
6931
|
this._bindFragments = undefined;
|
6668
6932
|
});
|
@@ -6819,6 +7083,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6819
7083
|
status: this.xhr.status,
|
6820
7084
|
title: up.protocol.titleFromXHR(this.xhr),
|
6821
7085
|
target: up.protocol.targetFromXHR(this.xhr),
|
7086
|
+
openLayer: up.protocol.openLayerFromXHR(this.xhr),
|
6822
7087
|
acceptLayer: up.protocol.acceptLayerFromXHR(this.xhr),
|
6823
7088
|
dismissLayer: up.protocol.dismissLayerFromXHR(this.xhr),
|
6824
7089
|
eventPlans: up.protocol.eventPlansFromXHR(this.xhr),
|
@@ -6872,7 +7137,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6872
7137
|
return this.headers[name];
|
6873
7138
|
}
|
6874
7139
|
_setAutoHeaders() {
|
6875
|
-
for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext']) {
|
7140
|
+
for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext', 'originMode']) {
|
6876
7141
|
this._setPropertyHeader(key);
|
6877
7142
|
}
|
6878
7143
|
let csrfHeader, csrfToken;
|
@@ -6927,13 +7192,13 @@ up.Request = (_a = class Request extends up.Record {
|
|
6927
7192
|
}
|
6928
7193
|
},
|
6929
7194
|
(() => {
|
6930
|
-
u.delegatePromise(_a.prototype,
|
7195
|
+
u.delegatePromise(_a.prototype, function () { return this._deferred; });
|
6931
7196
|
})(),
|
6932
7197
|
_a);
|
6933
7198
|
|
6934
7199
|
|
6935
7200
|
/***/ }),
|
6936
|
-
/*
|
7201
|
+
/* 73 */
|
6937
7202
|
/***/ (function() {
|
6938
7203
|
|
6939
7204
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -7091,14 +7356,14 @@ up.Request.Cache = class Cache {
|
|
7091
7356
|
_isUsable(request) {
|
7092
7357
|
return request.age < up.network.config.cacheEvictAge;
|
7093
7358
|
}
|
7094
|
-
get
|
7359
|
+
get currentSize() {
|
7095
7360
|
return this._requests.length;
|
7096
7361
|
}
|
7097
7362
|
get _capacity() {
|
7098
7363
|
return up.network.config.cacheSize;
|
7099
7364
|
}
|
7100
7365
|
_limitSize() {
|
7101
|
-
for (let i = 0; i < (this.
|
7366
|
+
for (let i = 0; i < (this.currentSize - this._capacity); i++) {
|
7102
7367
|
this._delete(this._requests[0]);
|
7103
7368
|
}
|
7104
7369
|
}
|
@@ -7114,7 +7379,7 @@ up.Request.Cache = class Cache {
|
|
7114
7379
|
|
7115
7380
|
|
7116
7381
|
/***/ }),
|
7117
|
-
/*
|
7382
|
+
/* 74 */
|
7118
7383
|
/***/ (() => {
|
7119
7384
|
|
7120
7385
|
const u = up.util;
|
@@ -7132,7 +7397,7 @@ up.Request.Queue = class Queue {
|
|
7132
7397
|
}
|
7133
7398
|
asap(request) {
|
7134
7399
|
request.runQueuedCallbacks();
|
7135
|
-
u.always(request, responseOrError => this._onRequestSettled(request, responseOrError));
|
7400
|
+
u.always(request, (responseOrError) => this._onRequestSettled(request, responseOrError));
|
7136
7401
|
this._scheduleSlowTimer(request);
|
7137
7402
|
this._queueRequest(request);
|
7138
7403
|
queueMicrotask(() => this._poke());
|
@@ -7163,7 +7428,7 @@ up.Request.Queue = class Queue {
|
|
7163
7428
|
this._queuedRequests.push(request);
|
7164
7429
|
}
|
7165
7430
|
_pluckNextRequest() {
|
7166
|
-
let request = u.find(this._queuedRequests, request => !request.background);
|
7431
|
+
let request = u.find(this._queuedRequests, (request) => !request.background);
|
7167
7432
|
request || (request = this._queuedRequests[0]);
|
7168
7433
|
return u.remove(this._queuedRequests, request);
|
7169
7434
|
}
|
@@ -7225,7 +7490,7 @@ up.Request.Queue = class Queue {
|
|
7225
7490
|
|
7226
7491
|
|
7227
7492
|
/***/ }),
|
7228
|
-
/*
|
7493
|
+
/* 75 */
|
7229
7494
|
/***/ (() => {
|
7230
7495
|
|
7231
7496
|
const u = up.util;
|
@@ -7264,7 +7529,7 @@ up.Request.FormRenderer = class FormRenderer {
|
|
7264
7529
|
|
7265
7530
|
|
7266
7531
|
/***/ }),
|
7267
|
-
/*
|
7532
|
+
/* 76 */
|
7268
7533
|
/***/ (() => {
|
7269
7534
|
|
7270
7535
|
var _a;
|
@@ -7335,7 +7600,7 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
|
|
7335
7600
|
|
7336
7601
|
|
7337
7602
|
/***/ }),
|
7338
|
-
/*
|
7603
|
+
/* 77 */
|
7339
7604
|
/***/ (() => {
|
7340
7605
|
|
7341
7606
|
const u = up.util;
|
@@ -7350,6 +7615,7 @@ up.Response = class Response extends up.Record {
|
|
7350
7615
|
'xhr',
|
7351
7616
|
'target',
|
7352
7617
|
'title',
|
7618
|
+
'openLayer',
|
7353
7619
|
'acceptLayer',
|
7354
7620
|
'dismissLayer',
|
7355
7621
|
'eventPlans',
|
@@ -7364,7 +7630,7 @@ up.Response = class Response extends up.Record {
|
|
7364
7630
|
defaults() {
|
7365
7631
|
return {
|
7366
7632
|
headers: {},
|
7367
|
-
loadedAt: new Date()
|
7633
|
+
loadedAt: new Date(),
|
7368
7634
|
};
|
7369
7635
|
}
|
7370
7636
|
get ok() {
|
@@ -7385,8 +7651,9 @@ up.Response = class Response extends up.Record {
|
|
7385
7651
|
get contentType() {
|
7386
7652
|
return this.header('Content-Type');
|
7387
7653
|
}
|
7388
|
-
get
|
7389
|
-
|
7654
|
+
get cspInfo() {
|
7655
|
+
let policy = this.header('Content-Security-Policy') || this.header('Content-Security-Policy-Report-Only');
|
7656
|
+
return up.protocol.cspInfoFromHeader(policy);
|
7390
7657
|
}
|
7391
7658
|
get lastModified() {
|
7392
7659
|
let header = this.header('Last-Modified');
|
@@ -7415,15 +7682,15 @@ up.Response = class Response extends up.Record {
|
|
7415
7682
|
|
7416
7683
|
|
7417
7684
|
/***/ }),
|
7418
|
-
/*
|
7685
|
+
/* 78 */
|
7419
7686
|
/***/ (() => {
|
7420
7687
|
|
7421
7688
|
var _a;
|
7422
7689
|
const u = up.util;
|
7423
7690
|
const e = up.element;
|
7424
|
-
const FULL_DOCUMENT_PATTERN = /^\s*<(html|!DOCTYPE)\b/i;
|
7691
|
+
const FULL_DOCUMENT_PATTERN = /^\s*(<!--[^-]*.*?-->\s*)*<(html|!DOCTYPE)\b/i;
|
7425
7692
|
up.ResponseDoc = (_a = class ResponseDoc {
|
7426
|
-
constructor({ document, fragment, content, target, origin, data,
|
7693
|
+
constructor({ document, fragment, content, target, origin, data, cspInfo, match }) {
|
7427
7694
|
if (document) {
|
7428
7695
|
this._parseDocument(document, origin, data);
|
7429
7696
|
}
|
@@ -7433,7 +7700,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
7433
7700
|
else {
|
7434
7701
|
this._parseContent(content || '', origin, target, data);
|
7435
7702
|
}
|
7436
|
-
this.
|
7703
|
+
this._cspInfo = cspInfo || {};
|
7437
7704
|
if (origin) {
|
7438
7705
|
let originSelector = up.fragment.tryToTarget(origin);
|
7439
7706
|
if (originSelector) {
|
@@ -7462,9 +7729,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
7462
7729
|
this._document = this._buildFauxDocument(value);
|
7463
7730
|
}
|
7464
7731
|
}
|
7465
|
-
_parseDocumentFromHTML(html) {
|
7466
|
-
return e.createBrokenDocumentFromHTML(html);
|
7467
|
-
}
|
7468
7732
|
_parseFragment(value, origin, data) {
|
7469
7733
|
let element = e.extractSingular(up.fragment.provideNodes(value, { origin, data }));
|
7470
7734
|
this._document = this._buildFauxDocument(element);
|
@@ -7502,7 +7766,14 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
7502
7766
|
return this._fromHead(up.history.findMetaTags);
|
7503
7767
|
}
|
7504
7768
|
get assets() {
|
7505
|
-
return this._fromHead(
|
7769
|
+
return this._fromHead((head) => {
|
7770
|
+
let assets = up.script.findAssets(head);
|
7771
|
+
return u.map(assets, (asset) => {
|
7772
|
+
this._adoptNoncesInSubtree(asset);
|
7773
|
+
let clone = this._reviveElementAsClone(asset);
|
7774
|
+
return clone;
|
7775
|
+
});
|
7776
|
+
});
|
7506
7777
|
}
|
7507
7778
|
get lang() {
|
7508
7779
|
if (this._isFullDocument) {
|
@@ -7555,21 +7826,44 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
7555
7826
|
throw new up.CannotMatch();
|
7556
7827
|
}
|
7557
7828
|
}
|
7829
|
+
_disableScriptsInSubtree(element) {
|
7830
|
+
let pageNonce = up.protocol.cspNonce();
|
7831
|
+
up.script.disableSubtree(element, (script) => !this._isScriptAllowed(script, pageNonce));
|
7832
|
+
}
|
7833
|
+
_isScriptAllowed(scriptElement, pageNonce) {
|
7834
|
+
var _b;
|
7835
|
+
let strategy = up.fragment.config.runScripts;
|
7836
|
+
if (strategy === true && ((_b = this._cspInfo.declaration) === null || _b === void 0 ? void 0 : _b.includes("'strict-dynamic'"))) {
|
7837
|
+
return pageNonce && (pageNonce === scriptElement.nonce);
|
7838
|
+
}
|
7839
|
+
else {
|
7840
|
+
return u.evalOption(strategy, scriptElement);
|
7841
|
+
}
|
7842
|
+
}
|
7843
|
+
_reviveElementAsClone(element) {
|
7844
|
+
return e.revivedClone(element);
|
7845
|
+
}
|
7846
|
+
_reviveSubtreeInPlace(element) {
|
7847
|
+
if (this._document instanceof Document) {
|
7848
|
+
for (let brokenElement of e.subtree(element, ':is(noscript, script, audio, video):not(.up-keeping, .up-keeping *)')) {
|
7849
|
+
let clone = this._reviveElementAsClone(brokenElement);
|
7850
|
+
brokenElement.replaceWith(clone);
|
7851
|
+
}
|
7852
|
+
}
|
7853
|
+
}
|
7854
|
+
_adoptNoncesInSubtree(element) {
|
7855
|
+
up.script.adoptNoncesInSubtree(element, this._cspInfo.nonces);
|
7856
|
+
}
|
7558
7857
|
commitElement(element) {
|
7559
7858
|
if (this._document.contains(element)) {
|
7560
|
-
|
7561
|
-
|
7562
|
-
}
|
7859
|
+
this._adoptNoncesInSubtree(element);
|
7860
|
+
this._disableScriptsInSubtree(element);
|
7563
7861
|
element.remove();
|
7564
7862
|
return true;
|
7565
7863
|
}
|
7566
7864
|
}
|
7567
7865
|
finalizeElement(element) {
|
7568
|
-
|
7569
|
-
if (this._document instanceof Document) {
|
7570
|
-
let brokenElements = e.subtree(element, ':is(noscript,script,audio,video):not(.up-keeping, .up-keeping *)');
|
7571
|
-
u.each(brokenElements, e.fixParserDamage);
|
7572
|
-
}
|
7866
|
+
this._reviveSubtreeInPlace(element);
|
7573
7867
|
}
|
7574
7868
|
},
|
7575
7869
|
(() => {
|
@@ -7581,7 +7875,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
7581
7875
|
|
7582
7876
|
|
7583
7877
|
/***/ }),
|
7584
|
-
/*
|
7878
|
+
/* 79 */
|
7585
7879
|
/***/ (() => {
|
7586
7880
|
|
7587
7881
|
const e = up.element;
|
@@ -7672,7 +7966,7 @@ up.RevealMotion = class RevealMotion {
|
|
7672
7966
|
|
7673
7967
|
|
7674
7968
|
/***/ }),
|
7675
|
-
/*
|
7969
|
+
/* 80 */
|
7676
7970
|
/***/ (() => {
|
7677
7971
|
|
7678
7972
|
const u = up.util;
|
@@ -7695,7 +7989,7 @@ up.Selector = class Selector {
|
|
7695
7989
|
this._layers = up.layer.getAll(options);
|
7696
7990
|
if (!this._layers.length)
|
7697
7991
|
throw new up.CannotMatch(["Unknown layer: %o", options.layer]);
|
7698
|
-
this._filters.push(match => u.some(this._layers, layer => layer.contains(match)));
|
7992
|
+
this._filters.push((match) => u.some(this._layers, (layer) => layer.contains(match)));
|
7699
7993
|
expandTargetLayer = this._layers[0];
|
7700
7994
|
}
|
7701
7995
|
this._selectors = up.fragment.expandTargets(selector, Object.assign(Object.assign({}, options), { layer: expandTargetLayer }));
|
@@ -7730,7 +8024,7 @@ up.Selector = class Selector {
|
|
7730
8024
|
});
|
7731
8025
|
}
|
7732
8026
|
_passesFilter(element) {
|
7733
|
-
return element && u.every(this._filters, filter => filter(element));
|
8027
|
+
return element && u.every(this._filters, (filter) => filter(element));
|
7734
8028
|
}
|
7735
8029
|
_filterOne(element) {
|
7736
8030
|
return u.presence(element, this._passesFilter.bind(this));
|
@@ -7742,7 +8036,7 @@ up.Selector = class Selector {
|
|
7742
8036
|
|
7743
8037
|
|
7744
8038
|
/***/ }),
|
7745
|
-
/*
|
8039
|
+
/* 81 */
|
7746
8040
|
/***/ (() => {
|
7747
8041
|
|
7748
8042
|
const u = up.util;
|
@@ -7863,7 +8157,7 @@ up.Tether = class Tether {
|
|
7863
8157
|
|
7864
8158
|
|
7865
8159
|
/***/ }),
|
7866
|
-
/*
|
8160
|
+
/* 82 */
|
7867
8161
|
/***/ (() => {
|
7868
8162
|
|
7869
8163
|
const u = up.util;
|
@@ -7937,7 +8231,7 @@ up.URLPattern = class URLPattern {
|
|
7937
8231
|
|
7938
8232
|
|
7939
8233
|
/***/ }),
|
7940
|
-
/*
|
8234
|
+
/* 83 */
|
7941
8235
|
/***/ (() => {
|
7942
8236
|
|
7943
8237
|
up.framework = (function () {
|
@@ -8026,7 +8320,7 @@ up.boot = up.framework.boot;
|
|
8026
8320
|
|
8027
8321
|
|
8028
8322
|
/***/ }),
|
8029
|
-
/*
|
8323
|
+
/* 84 */
|
8030
8324
|
/***/ (() => {
|
8031
8325
|
|
8032
8326
|
up.event = (function () {
|
@@ -8078,9 +8372,8 @@ up.event = (function () {
|
|
8078
8372
|
event.preventDefault();
|
8079
8373
|
}
|
8080
8374
|
const keyModifiers = ['metaKey', 'shiftKey', 'ctrlKey', 'altKey'];
|
8081
|
-
function
|
8082
|
-
return (
|
8083
|
-
!u.some(keyModifiers, modifier => event[modifier]);
|
8375
|
+
function isModified(event) {
|
8376
|
+
return (event.button > 0) || u.some(keyModifiers, (modifier) => event[modifier]);
|
8084
8377
|
}
|
8085
8378
|
function isSyntheticClick(event) {
|
8086
8379
|
return u.isMissing(event.clientX);
|
@@ -8101,7 +8394,7 @@ up.event = (function () {
|
|
8101
8394
|
return newEvent;
|
8102
8395
|
}
|
8103
8396
|
function executeEmitAttr(event, element) {
|
8104
|
-
if (
|
8397
|
+
if (isModified(event)) {
|
8105
8398
|
return;
|
8106
8399
|
}
|
8107
8400
|
const eventType = e.attr(element, 'up-emit');
|
@@ -8130,7 +8423,7 @@ up.event = (function () {
|
|
8130
8423
|
assertEmitted,
|
8131
8424
|
onEscape,
|
8132
8425
|
halt,
|
8133
|
-
|
8426
|
+
isModified,
|
8134
8427
|
isSyntheticClick,
|
8135
8428
|
fork,
|
8136
8429
|
keyModifiers,
|
@@ -8143,14 +8436,14 @@ up.emit = up.event.emit;
|
|
8143
8436
|
|
8144
8437
|
|
8145
8438
|
/***/ }),
|
8146
|
-
/*
|
8439
|
+
/* 85 */
|
8147
8440
|
/***/ (() => {
|
8148
8441
|
|
8149
8442
|
up.protocol = (function () {
|
8150
8443
|
const u = up.util;
|
8151
8444
|
const e = up.element;
|
8152
8445
|
const headerize = function (camel) {
|
8153
|
-
const header = camel.replace(/(^.|[A-Z])/g, char => '-' + char.toUpperCase());
|
8446
|
+
const header = camel.replace(/(^.|[A-Z])/g, (char) => '-' + char.toUpperCase());
|
8154
8447
|
return 'X-Up' + header;
|
8155
8448
|
};
|
8156
8449
|
const extractHeader = function (xhr, shortHeader, parseFn = u.identity) {
|
@@ -8190,6 +8483,9 @@ up.protocol = (function () {
|
|
8190
8483
|
function eventPlansFromXHR(xhr) {
|
8191
8484
|
return extractHeader(xhr, 'events', u.parseRelaxedJSON);
|
8192
8485
|
}
|
8486
|
+
function openLayerFromXHR(xhr) {
|
8487
|
+
return extractHeader(xhr, 'openLayer', u.parseRelaxedJSON);
|
8488
|
+
}
|
8193
8489
|
function acceptLayerFromXHR(xhr) {
|
8194
8490
|
return extractHeader(xhr, 'acceptLayer', u.parseRelaxedJSON);
|
8195
8491
|
}
|
@@ -8225,21 +8521,27 @@ up.protocol = (function () {
|
|
8225
8521
|
function cspNonce() {
|
8226
8522
|
return u.evalOption(config.cspNonce);
|
8227
8523
|
}
|
8228
|
-
|
8229
|
-
|
8524
|
+
const NONCE_PATTERN = /'nonce-([^']+)'/g;
|
8525
|
+
function findNonces(cspPart) {
|
8526
|
+
let matches = cspPart.matchAll(NONCE_PATTERN);
|
8527
|
+
return u.map(matches, '1');
|
8528
|
+
}
|
8529
|
+
function cspInfoFromHeader(cspHeader) {
|
8530
|
+
var _a;
|
8531
|
+
let results = {};
|
8230
8532
|
if (cspHeader) {
|
8231
|
-
let
|
8232
|
-
for (let
|
8233
|
-
|
8234
|
-
|
8235
|
-
|
8236
|
-
|
8237
|
-
nonces
|
8238
|
-
}
|
8533
|
+
let declarations = cspHeader.split(/\s*;\s*/);
|
8534
|
+
for (let declaration of declarations) {
|
8535
|
+
let directive = (_a = declaration.match(/^(script|default)-src:/)) === null || _a === void 0 ? void 0 : _a[1];
|
8536
|
+
if (directive) {
|
8537
|
+
results[directive] = {
|
8538
|
+
declaration: declaration,
|
8539
|
+
nonces: findNonces(declaration)
|
8540
|
+
};
|
8239
8541
|
}
|
8240
8542
|
}
|
8241
8543
|
}
|
8242
|
-
return
|
8544
|
+
return results.script || results.default || {};
|
8243
8545
|
}
|
8244
8546
|
function wrapMethod(method, params) {
|
8245
8547
|
params.add(config.methodParam, method);
|
@@ -8251,6 +8553,7 @@ up.protocol = (function () {
|
|
8251
8553
|
titleFromXHR,
|
8252
8554
|
targetFromXHR,
|
8253
8555
|
methodFromXHR,
|
8556
|
+
openLayerFromXHR,
|
8254
8557
|
acceptLayerFromXHR,
|
8255
8558
|
contextFromXHR,
|
8256
8559
|
dismissLayerFromXHR,
|
@@ -8264,13 +8567,13 @@ up.protocol = (function () {
|
|
8264
8567
|
initialRequestMethod,
|
8265
8568
|
headerize,
|
8266
8569
|
wrapMethod,
|
8267
|
-
|
8570
|
+
cspInfoFromHeader,
|
8268
8571
|
};
|
8269
8572
|
})();
|
8270
8573
|
|
8271
8574
|
|
8272
8575
|
/***/ }),
|
8273
|
-
/*
|
8576
|
+
/* 86 */
|
8274
8577
|
/***/ (() => {
|
8275
8578
|
|
8276
8579
|
up.log = (function () {
|
@@ -8283,24 +8586,26 @@ up.log = (function () {
|
|
8283
8586
|
}
|
8284
8587
|
const printToWarn = (...args) => printToStream('warn', ...args);
|
8285
8588
|
const printToError = (...args) => printToStream('error', ...args);
|
8286
|
-
function printToStream(stream,
|
8287
|
-
printToStreamStyled(stream,
|
8589
|
+
function printToStream(stream, prefix, message, ...args) {
|
8590
|
+
printToStreamStyled(stream, prefix, '', message, ...args);
|
8288
8591
|
}
|
8289
|
-
function printToStreamStyled(stream,
|
8592
|
+
function printToStreamStyled(stream, prefix, customStyles, message, ...args) {
|
8290
8593
|
if (message) {
|
8291
8594
|
if (config.format) {
|
8292
|
-
console[stream](`%c${
|
8595
|
+
console[stream](`%c${prefix}%c ${message}`, 'color: #666666; padding: 1px 3px; border: 1px solid #bbbbbb; border-radius: 2px; font-size: 90%; display: inline-block;' + customStyles, '', ...args);
|
8293
8596
|
}
|
8294
8597
|
else {
|
8295
|
-
console[stream](`[${
|
8598
|
+
console[stream](`[${prefix}] ${u.sprintf(message, ...args)}`);
|
8296
8599
|
}
|
8297
8600
|
}
|
8298
8601
|
}
|
8602
|
+
let lastPrintedUserEvent;
|
8299
8603
|
function printUserEvent(event) {
|
8300
|
-
if (config.enabled) {
|
8301
|
-
|
8604
|
+
if (config.enabled && lastPrintedUserEvent !== event) {
|
8605
|
+
lastPrintedUserEvent = event;
|
8606
|
+
let originalEvent = event.originalEvent || event;
|
8302
8607
|
let color = '#5566cc';
|
8303
|
-
printToStreamStyled('log',
|
8608
|
+
printToStreamStyled('log', originalEvent.type, `color: white; border-color: ${color}; background-color: ${color}`, 'Interaction on %o', originalEvent.target);
|
8304
8609
|
}
|
8305
8610
|
}
|
8306
8611
|
function printBanner() {
|
@@ -8351,7 +8656,7 @@ up.warn = up.log.warn;
|
|
8351
8656
|
|
8352
8657
|
|
8353
8658
|
/***/ }),
|
8354
|
-
/*
|
8659
|
+
/* 87 */
|
8355
8660
|
/***/ (() => {
|
8356
8661
|
|
8357
8662
|
up.script = (function () {
|
@@ -8529,16 +8834,41 @@ up.script = (function () {
|
|
8529
8834
|
up.event.assertEmitted('up:assets:changed', { oldAssets, newAssets, renderOptions });
|
8530
8835
|
}
|
8531
8836
|
}
|
8532
|
-
function
|
8533
|
-
|
8837
|
+
function disableScriptsInSubtree(root, guard = () => true) {
|
8838
|
+
for (let script of findScripts(root)) {
|
8839
|
+
if (guard(script)) {
|
8840
|
+
script.type = 'up-disabled-script';
|
8841
|
+
}
|
8842
|
+
}
|
8534
8843
|
}
|
8535
|
-
function
|
8536
|
-
let selector = config.selector('scriptSelectors');
|
8537
|
-
|
8844
|
+
function findScripts(root, selectorSuffix = '') {
|
8845
|
+
let selector = config.selector('scriptSelectors') + selectorSuffix;
|
8846
|
+
return e.subtree(root, selector);
|
8538
8847
|
}
|
8539
8848
|
function isScript(value) {
|
8540
8849
|
return config.matches(value, 'scriptSelectors');
|
8541
8850
|
}
|
8851
|
+
function adoptNoncesInSubtree(root, responseNonces) {
|
8852
|
+
let pageNonce = up.protocol.cspNonce();
|
8853
|
+
if (!(responseNonces === null || responseNonces === void 0 ? void 0 : responseNonces.length) || !pageNonce)
|
8854
|
+
return;
|
8855
|
+
for (let script of findScripts(root, '[nonce]')) {
|
8856
|
+
if (responseNonces.includes(script.nonce)) {
|
8857
|
+
script.nonce = pageNonce;
|
8858
|
+
}
|
8859
|
+
}
|
8860
|
+
for (let attribute of config.nonceableAttributes) {
|
8861
|
+
let matches = e.subtree(root, `[${attribute}^="nonce-"]`);
|
8862
|
+
for (let match of matches) {
|
8863
|
+
let attributeValue = match.getAttribute(attribute);
|
8864
|
+
let callback = up.NonceableCallback.fromString(attributeValue);
|
8865
|
+
if (responseNonces.includes(callback.nonce)) {
|
8866
|
+
callback.nonce = pageNonce;
|
8867
|
+
match.setAttribute(attribute, callback.toString());
|
8868
|
+
}
|
8869
|
+
}
|
8870
|
+
}
|
8871
|
+
}
|
8542
8872
|
function reset() {
|
8543
8873
|
registeredCompilers = u.filter(registeredCompilers, 'isDefault');
|
8544
8874
|
registeredMacros = u.filter(registeredMacros, 'isDefault');
|
@@ -8556,6 +8886,7 @@ up.script = (function () {
|
|
8556
8886
|
findAssets,
|
8557
8887
|
assertAssetsOK,
|
8558
8888
|
disableSubtree: disableScriptsInSubtree,
|
8889
|
+
adoptNoncesInSubtree,
|
8559
8890
|
isScript,
|
8560
8891
|
};
|
8561
8892
|
})();
|
@@ -8568,7 +8899,7 @@ up.attribute = up.script.attrCompiler;
|
|
8568
8899
|
|
8569
8900
|
|
8570
8901
|
/***/ }),
|
8571
|
-
/*
|
8902
|
+
/* 88 */
|
8572
8903
|
/***/ (() => {
|
8573
8904
|
|
8574
8905
|
up.history = (function () {
|
@@ -8594,60 +8925,76 @@ up.history = (function () {
|
|
8594
8925
|
}));
|
8595
8926
|
let previousLocation;
|
8596
8927
|
let nextPreviousLocation;
|
8928
|
+
let nextTrackOptions;
|
8929
|
+
let adoptedBases = new up.FIFOCache({ capacity: 100, normalizeKey: getBase });
|
8930
|
+
function isAdopted(location) {
|
8931
|
+
return !!adoptedBases.get(location);
|
8932
|
+
}
|
8597
8933
|
function reset() {
|
8598
8934
|
previousLocation = undefined;
|
8599
8935
|
nextPreviousLocation = undefined;
|
8600
|
-
|
8936
|
+
nextTrackOptions = undefined;
|
8937
|
+
adoptedBases.clear();
|
8938
|
+
trackCurrentLocation({ reason: null, alreadyHandled: true });
|
8939
|
+
adopt();
|
8601
8940
|
}
|
8602
8941
|
function currentLocation() {
|
8603
8942
|
return u.normalizeURL(location.href);
|
8604
8943
|
}
|
8605
|
-
function trackCurrentLocation() {
|
8606
|
-
|
8607
|
-
|
8944
|
+
function trackCurrentLocation(trackOptions) {
|
8945
|
+
var _a, _b;
|
8946
|
+
let { reason, alreadyHandled } = nextTrackOptions || trackOptions;
|
8947
|
+
let location = currentLocation();
|
8948
|
+
if (nextPreviousLocation !== location) {
|
8608
8949
|
previousLocation = nextPreviousLocation;
|
8609
|
-
nextPreviousLocation =
|
8950
|
+
nextPreviousLocation = location;
|
8951
|
+
if (reason === 'detect') {
|
8952
|
+
reason = (getBase(location) === getBase(previousLocation)) ? 'hash' : 'pop';
|
8953
|
+
}
|
8954
|
+
let willHandle = !alreadyHandled && isAdopted(location);
|
8955
|
+
let locationChangedEvent = up.event.build('up:location:changed', {
|
8956
|
+
reason,
|
8957
|
+
location,
|
8958
|
+
previousLocation,
|
8959
|
+
alreadyHandled,
|
8960
|
+
willHandle,
|
8961
|
+
log: `New location is ${location}`
|
8962
|
+
});
|
8963
|
+
(_b = (_a = up.migrate).prepareLocationChangedEvent) === null || _b === void 0 ? void 0 : _b.call(_a, locationChangedEvent);
|
8964
|
+
if (reason) {
|
8965
|
+
up.emit(locationChangedEvent);
|
8966
|
+
reactToChange(locationChangedEvent);
|
8967
|
+
}
|
8610
8968
|
}
|
8611
8969
|
}
|
8612
|
-
|
8970
|
+
function splitLocation(location) {
|
8971
|
+
return (location === null || location === void 0 ? void 0 : location.split(/(?=#)/)) || [];
|
8972
|
+
}
|
8973
|
+
function getBase(location) {
|
8974
|
+
return splitLocation(location)[0];
|
8975
|
+
}
|
8613
8976
|
function isLocation(url, options) {
|
8614
8977
|
return u.matchURLs(url, location.href, Object.assign({ hash: true }, options));
|
8615
8978
|
}
|
8616
|
-
function replace(location,
|
8617
|
-
location
|
8618
|
-
if (manipulate('replaceState', location) && (options.event !== false)) {
|
8619
|
-
emitLocationChanged({ location, reason: 'replace', log: `Replaced state for ${location}` });
|
8620
|
-
}
|
8621
|
-
}
|
8622
|
-
function push(location) {
|
8623
|
-
location = u.normalizeURL(location);
|
8624
|
-
if (!isLocation(location) && manipulate('pushState', location)) {
|
8625
|
-
emitLocationChanged({ location, reason: 'push', log: `Advanced to location ${location}` });
|
8626
|
-
}
|
8979
|
+
function replace(location, trackOptions) {
|
8980
|
+
placeAdoptedHistoryEntry('replaceState', location, trackOptions);
|
8627
8981
|
}
|
8628
|
-
function
|
8629
|
-
|
8630
|
-
let event = up.event.build('up:location:changed', props);
|
8631
|
-
(_b = (_a = up.migrate) === null || _a === void 0 ? void 0 : _a.renamedProperty) === null || _b === void 0 ? void 0 : _b.call(_a, event, 'url', 'location');
|
8632
|
-
up.emit(event);
|
8982
|
+
function push(location, trackOptions) {
|
8983
|
+
placeAdoptedHistoryEntry('pushState', location, trackOptions);
|
8633
8984
|
}
|
8634
|
-
function
|
8985
|
+
function placeAdoptedHistoryEntry(method, location, trackOptions) {
|
8986
|
+
adopt(location);
|
8635
8987
|
if (config.enabled) {
|
8636
|
-
|
8637
|
-
|
8638
|
-
|
8639
|
-
return true;
|
8988
|
+
nextTrackOptions = trackOptions;
|
8989
|
+
history[method](null, '', location);
|
8990
|
+
nextTrackOptions = undefined;
|
8640
8991
|
}
|
8641
8992
|
}
|
8642
|
-
function
|
8643
|
-
|
8993
|
+
function adopt(location = currentLocation()) {
|
8994
|
+
location = u.normalizeURL(location);
|
8995
|
+
adoptedBases.set(location, true);
|
8644
8996
|
}
|
8645
|
-
function
|
8646
|
-
if (!(state === null || state === void 0 ? void 0 : state.up)) {
|
8647
|
-
up.puts('popstate', 'Ignoring a history state not owned by Unpoly');
|
8648
|
-
return;
|
8649
|
-
}
|
8650
|
-
let location = currentLocation();
|
8997
|
+
function restoreLocation(location) {
|
8651
8998
|
up.error.muteUncriticalRejection(up.render({
|
8652
8999
|
guardEvent: up.event.build('up:location:restore', { location, log: `Restoring location ${location}` }),
|
8653
9000
|
url: location,
|
@@ -8665,28 +9012,23 @@ up.history = (function () {
|
|
8665
9012
|
focus: ['restore', 'auto'],
|
8666
9013
|
}));
|
8667
9014
|
}
|
8668
|
-
function
|
8669
|
-
|
8670
|
-
|
8671
|
-
emitLocationChanged({ location, reason: 'pop', log: `Navigated to history entry ${location}` });
|
8672
|
-
up.viewport.saveFocus({ location: previousLocation });
|
8673
|
-
up.viewport.saveScroll({ location: previousLocation });
|
8674
|
-
restoreStateOnPop(event.state);
|
8675
|
-
}
|
8676
|
-
function register() {
|
8677
|
-
window.addEventListener('popstate', onPop);
|
8678
|
-
if (up.protocol.initialRequestMethod() === 'GET') {
|
8679
|
-
replace(currentLocation(), { event: false });
|
9015
|
+
function reactToChange(event) {
|
9016
|
+
if (event.alreadyHandled) {
|
9017
|
+
return;
|
8680
9018
|
}
|
8681
|
-
|
8682
|
-
|
8683
|
-
|
8684
|
-
register();
|
9019
|
+
if (!event.willHandle) {
|
9020
|
+
up.puts('up.history', 'Ignoring history entry owned by foreign script');
|
9021
|
+
return;
|
8685
9022
|
}
|
8686
|
-
|
8687
|
-
|
9023
|
+
if (event.reason === 'pop') {
|
9024
|
+
up.viewport.saveFocus({ location: event.previousLocation });
|
9025
|
+
up.viewport.saveScroll({ location: event.previousLocation });
|
9026
|
+
restoreLocation(event.location);
|
8688
9027
|
}
|
8689
|
-
|
9028
|
+
else if (event.reason === 'hash') {
|
9029
|
+
up.viewport.revealHash(event.hash, { strong: true });
|
9030
|
+
}
|
9031
|
+
}
|
8690
9032
|
function findMetaTags(head = document.head) {
|
8691
9033
|
return head.querySelectorAll(config.selector('metaTagSelectors'));
|
8692
9034
|
}
|
@@ -8708,6 +9050,63 @@ up.history = (function () {
|
|
8708
9050
|
function updateLang(newLang) {
|
8709
9051
|
e.setAttrPresence(e.root, 'lang', newLang, !!newLang);
|
8710
9052
|
}
|
9053
|
+
function patchHistoryAPI() {
|
9054
|
+
const originalPushState = history.pushState;
|
9055
|
+
history.pushState = function (...args) {
|
9056
|
+
originalPushState.apply(this, args);
|
9057
|
+
trackCurrentLocation({ reason: 'push', alreadyHandled: true });
|
9058
|
+
};
|
9059
|
+
const originalReplaceState = history.replaceState;
|
9060
|
+
history.replaceState = function (...args) {
|
9061
|
+
originalReplaceState.apply(this, args);
|
9062
|
+
trackCurrentLocation({ reason: 'replace', alreadyHandled: true });
|
9063
|
+
};
|
9064
|
+
}
|
9065
|
+
function adoptInitialHistoryEntry() {
|
9066
|
+
if (up.protocol.initialRequestMethod() === 'GET') {
|
9067
|
+
adopt();
|
9068
|
+
}
|
9069
|
+
}
|
9070
|
+
up.on('up:framework:boot', function () {
|
9071
|
+
trackCurrentLocation({ reason: null, alreadyHandled: true });
|
9072
|
+
patchHistoryAPI();
|
9073
|
+
adoptInitialHistoryEntry();
|
9074
|
+
});
|
9075
|
+
up.on('DOMContentLoaded', function () {
|
9076
|
+
up.viewport.revealHash({ strong: true });
|
9077
|
+
u.task(up.viewport.revealHash);
|
9078
|
+
});
|
9079
|
+
up.on(window, 'hashchange, popstate', () => {
|
9080
|
+
trackCurrentLocation({ reason: 'detect', alreadyHandled: false });
|
9081
|
+
});
|
9082
|
+
function onJumpLinkClicked(event, link) {
|
9083
|
+
var _a;
|
9084
|
+
if (event.defaultPrevented)
|
9085
|
+
return;
|
9086
|
+
if (up.event.isModified(event))
|
9087
|
+
return;
|
9088
|
+
let [currentBase, currentHash] = splitLocation(up.layer.current.location);
|
9089
|
+
let [linkBase, linkHash] = splitLocation(u.normalizeURL(link));
|
9090
|
+
let verbatimHREF = link.getAttribute('href');
|
9091
|
+
let isJumpLink = (currentBase === linkBase) || verbatimHREF.startsWith('#');
|
9092
|
+
if (!isJumpLink)
|
9093
|
+
return;
|
9094
|
+
let behavior = (_a = link.getAttribute('up-scroll-behavior')) !== null && _a !== void 0 ? _a : 'auto';
|
9095
|
+
let layer = up.layer.get(link);
|
9096
|
+
let revealFn = up.viewport.revealHashFn(linkHash, { layer, behavior });
|
9097
|
+
if (revealFn) {
|
9098
|
+
up.event.halt(event);
|
9099
|
+
up.log.putsEvent(event);
|
9100
|
+
if (linkHash !== currentHash && layer.showsLiveHistory()) {
|
9101
|
+
let newHREF = currentBase + linkHash;
|
9102
|
+
push(newHREF, { reason: 'hash', alreadyHandled: true });
|
9103
|
+
}
|
9104
|
+
revealFn();
|
9105
|
+
}
|
9106
|
+
else {
|
9107
|
+
}
|
9108
|
+
}
|
9109
|
+
up.on('up:click', 'a[href*="#"]', onJumpLinkClicked);
|
8711
9110
|
up.macro('[up-back]', function (link) {
|
8712
9111
|
if (previousLocation) {
|
8713
9112
|
e.setMissingAttrs(link, {
|
@@ -8735,10 +9134,10 @@ up.history = (function () {
|
|
8735
9134
|
|
8736
9135
|
|
8737
9136
|
/***/ }),
|
8738
|
-
/*
|
9137
|
+
/* 89 */
|
8739
9138
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
8740
9139
|
|
8741
|
-
__webpack_require__(
|
9140
|
+
__webpack_require__(90);
|
8742
9141
|
const u = up.util;
|
8743
9142
|
const e = up.element;
|
8744
9143
|
up.fragment = (function () {
|
@@ -8783,6 +9182,7 @@ up.fragment = (function () {
|
|
8783
9182
|
saveScroll: true,
|
8784
9183
|
saveFocus: true,
|
8785
9184
|
focus: 'keep',
|
9185
|
+
focusVisible: 'auto',
|
8786
9186
|
abort: 'target',
|
8787
9187
|
failOptions: true,
|
8788
9188
|
feedback: true,
|
@@ -8797,7 +9197,7 @@ up.fragment = (function () {
|
|
8797
9197
|
peel: true,
|
8798
9198
|
},
|
8799
9199
|
match: 'region',
|
8800
|
-
runScripts:
|
9200
|
+
runScripts: false,
|
8801
9201
|
autoHistoryTargets: [':main'],
|
8802
9202
|
autoFocus: ['hash', 'autofocus', 'main-if-main', 'keep', 'target-if-lost'],
|
8803
9203
|
autoScroll: ['hash', 'layer-if-main'],
|
@@ -8839,6 +9239,9 @@ up.fragment = (function () {
|
|
8839
9239
|
return render(Object.assign(Object.assign({}, options), { navigate: true }));
|
8840
9240
|
});
|
8841
9241
|
function emitFragmentInserted(element) {
|
9242
|
+
if (element.upInserted)
|
9243
|
+
return;
|
9244
|
+
element.upInserted = true;
|
8842
9245
|
return up.emit(element, 'up:fragment:inserted', {
|
8843
9246
|
log: ['Inserted fragment %o', element],
|
8844
9247
|
});
|
@@ -8846,8 +9249,9 @@ up.fragment = (function () {
|
|
8846
9249
|
function emitFragmentKeep(keepPlan) {
|
8847
9250
|
let { oldElement, newElement: newFragment, newData, renderOptions } = keepPlan;
|
8848
9251
|
const log = ['Keeping fragment %o', oldElement];
|
8849
|
-
const callback = e.callbackAttr(oldElement, 'up-on-keep', { exposedKeys: ['newFragment', 'newData'] });
|
8850
|
-
|
9252
|
+
const callback = e.callbackAttr(keepPlan.oldElement, 'up-on-keep', { exposedKeys: ['newFragment', 'newData'] });
|
9253
|
+
const event = up.event.build('up:fragment:keep', { newFragment, newData, renderOptions });
|
9254
|
+
return up.emit(oldElement, event, { log, callback });
|
8851
9255
|
}
|
8852
9256
|
function emitFragmentDestroyed(fragment, options) {
|
8853
9257
|
var _a;
|
@@ -8926,7 +9330,7 @@ up.fragment = (function () {
|
|
8926
9330
|
}
|
8927
9331
|
function markFragmentAsDestroying(element) {
|
8928
9332
|
element.classList.add('up-destroying');
|
8929
|
-
element.setAttribute('
|
9333
|
+
element.setAttribute('inert', '');
|
8930
9334
|
}
|
8931
9335
|
function reload(...args) {
|
8932
9336
|
var _a, _b;
|
@@ -8984,8 +9388,8 @@ up.fragment = (function () {
|
|
8984
9388
|
function toTarget(element, options) {
|
8985
9389
|
return u.presence(element, u.isString) || tryToTarget(element, options) || cannotTarget(element);
|
8986
9390
|
}
|
8987
|
-
function isTargetable(element) {
|
8988
|
-
return !!tryToTarget(element);
|
9391
|
+
function isTargetable(element, options) {
|
9392
|
+
return !!tryToTarget(element, options);
|
8989
9393
|
}
|
8990
9394
|
function untargetableMessage(element) {
|
8991
9395
|
return `Cannot derive good target selector from a <${e.tagName(element)}> element without identifying attributes. Try setting an [id] or configure up.fragment.config.targetDerivers.`;
|
@@ -9203,7 +9607,7 @@ up.fragment = (function () {
|
|
9203
9607
|
if (steps.length < 2)
|
9204
9608
|
return steps;
|
9205
9609
|
let compressed = u.uniqBy(steps, 'oldElement');
|
9206
|
-
compressed = u.reject(compressed, step => isContainedByRivalStep(compressed, step));
|
9610
|
+
compressed = u.reject(compressed, (step) => isContainedByRivalStep(compressed, step));
|
9207
9611
|
return compressed;
|
9208
9612
|
}
|
9209
9613
|
function abort(...args) {
|
@@ -9301,6 +9705,11 @@ up.fragment = (function () {
|
|
9301
9705
|
return () => up.destroy(tempElement);
|
9302
9706
|
}
|
9303
9707
|
}
|
9708
|
+
function trackSelector(...args) {
|
9709
|
+
let parsedArgs = u.args(args, 'val', 'options', 'callback');
|
9710
|
+
let tracker = new up.SelectorTracker(...parsedArgs);
|
9711
|
+
return tracker.start();
|
9712
|
+
}
|
9304
9713
|
up.on('up:framework:boot', function () {
|
9305
9714
|
const { documentElement } = document;
|
9306
9715
|
documentElement.setAttribute('up-source', normalizeSource(location.href));
|
@@ -9353,6 +9762,7 @@ up.fragment = (function () {
|
|
9353
9762
|
insertTemp,
|
9354
9763
|
provideNodes,
|
9355
9764
|
cloneTemplate,
|
9765
|
+
trackSelector,
|
9356
9766
|
};
|
9357
9767
|
})();
|
9358
9768
|
up.reload = up.fragment.reload;
|
@@ -9365,16 +9775,16 @@ u.delegate(up, ['context'], () => up.layer.current);
|
|
9365
9775
|
|
9366
9776
|
|
9367
9777
|
/***/ }),
|
9368
|
-
/*
|
9778
|
+
/* 90 */
|
9369
9779
|
/***/ (() => {
|
9370
9780
|
|
9371
9781
|
|
9372
9782
|
|
9373
9783
|
/***/ }),
|
9374
|
-
/*
|
9784
|
+
/* 91 */
|
9375
9785
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
9376
9786
|
|
9377
|
-
__webpack_require__(
|
9787
|
+
__webpack_require__(92);
|
9378
9788
|
up.viewport = (function () {
|
9379
9789
|
const u = up.util;
|
9380
9790
|
const e = up.element;
|
@@ -9437,10 +9847,26 @@ up.viewport = (function () {
|
|
9437
9847
|
doFocus(element, options);
|
9438
9848
|
return element === document.activeElement;
|
9439
9849
|
}
|
9440
|
-
function revealHash(
|
9441
|
-
|
9850
|
+
function revealHash(...args) {
|
9851
|
+
var _a;
|
9852
|
+
return (_a = revealHashFn(...args)) === null || _a === void 0 ? void 0 : _a();
|
9853
|
+
}
|
9854
|
+
function revealHashFn(hash = location.hash, { strong, layer, origin, behavior = 'instant' } = {}) {
|
9855
|
+
if (!hash)
|
9856
|
+
return;
|
9857
|
+
let match = firstHashTarget(hash, { layer, origin });
|
9442
9858
|
if (match) {
|
9443
|
-
return
|
9859
|
+
return () => {
|
9860
|
+
let doReveal = () => reveal(match, { top: true, behavior });
|
9861
|
+
if (strong)
|
9862
|
+
u.task(doReveal);
|
9863
|
+
return doReveal();
|
9864
|
+
};
|
9865
|
+
}
|
9866
|
+
else if (hash === '#top') {
|
9867
|
+
return () => {
|
9868
|
+
return scrollTo(0, { behavior });
|
9869
|
+
};
|
9444
9870
|
}
|
9445
9871
|
}
|
9446
9872
|
function allSelector() {
|
@@ -9512,7 +9938,7 @@ up.viewport = (function () {
|
|
9512
9938
|
const { location } = options.layer;
|
9513
9939
|
const locationScrollTops = options.layer.lastScrollTops.get(location);
|
9514
9940
|
if (locationScrollTops) {
|
9515
|
-
|
9941
|
+
setScrollPositions(viewports, locationScrollTops, 0);
|
9516
9942
|
up.puts('up.viewport.restoreScroll()', 'Restored scroll positions to %o', locationScrollTops);
|
9517
9943
|
return true;
|
9518
9944
|
}
|
@@ -9558,14 +9984,16 @@ up.viewport = (function () {
|
|
9558
9984
|
}
|
9559
9985
|
return [viewports, options];
|
9560
9986
|
}
|
9561
|
-
function
|
9562
|
-
const [viewports,
|
9563
|
-
|
9987
|
+
function scrollTo(position, ...args) {
|
9988
|
+
const [viewports, options] = parseOptions(args);
|
9989
|
+
setScrollPositions(viewports, {}, position, options.behavior);
|
9990
|
+
return true;
|
9564
9991
|
}
|
9565
|
-
function
|
9992
|
+
function setScrollPositions(viewports, tops, defaultTop, behavior = 'instant') {
|
9566
9993
|
for (let viewport of viewports) {
|
9567
9994
|
const key = scrollTopKey(viewport);
|
9568
|
-
|
9995
|
+
const top = tops[key] || defaultTop;
|
9996
|
+
viewport.scrollTo({ top, behavior });
|
9569
9997
|
}
|
9570
9998
|
}
|
9571
9999
|
function absolutize(element, options = {}) {
|
@@ -9607,7 +10035,8 @@ up.viewport = (function () {
|
|
9607
10035
|
};
|
9608
10036
|
}
|
9609
10037
|
function firstHashTarget(hash, options = {}) {
|
9610
|
-
|
10038
|
+
hash = pureHash(hash);
|
10039
|
+
if (hash) {
|
9611
10040
|
const selector = [
|
9612
10041
|
e.idSelector(hash),
|
9613
10042
|
'a' + e.attrSelector('name', hash)
|
@@ -9635,22 +10064,10 @@ up.viewport = (function () {
|
|
9635
10064
|
}
|
9636
10065
|
return to;
|
9637
10066
|
}
|
9638
|
-
document.addEventListener('DOMContentLoaded', function () {
|
9639
|
-
revealHash();
|
9640
|
-
u.task(revealHash);
|
9641
|
-
});
|
9642
|
-
up.on(window, 'hashchange', () => revealHash());
|
9643
|
-
up.on('up:click', 'a[href^="#"]', function (event, link) {
|
9644
|
-
if (link.hash !== location.hash)
|
9645
|
-
return;
|
9646
|
-
if (up.link.isFollowable(link))
|
9647
|
-
return;
|
9648
|
-
if (revealHash(link.hash))
|
9649
|
-
up.event.halt(event);
|
9650
|
-
});
|
9651
10067
|
return {
|
9652
10068
|
reveal,
|
9653
10069
|
revealHash,
|
10070
|
+
revealHashFn,
|
9654
10071
|
firstHashTarget,
|
9655
10072
|
config,
|
9656
10073
|
get: closest,
|
@@ -9663,7 +10080,7 @@ up.viewport = (function () {
|
|
9663
10080
|
rootScrollbarWidth,
|
9664
10081
|
saveScroll,
|
9665
10082
|
restoreScroll,
|
9666
|
-
|
10083
|
+
scrollTo,
|
9667
10084
|
saveFocus,
|
9668
10085
|
restoreFocus,
|
9669
10086
|
absolutize,
|
@@ -9680,13 +10097,13 @@ up.reveal = up.viewport.reveal;
|
|
9680
10097
|
|
9681
10098
|
|
9682
10099
|
/***/ }),
|
9683
|
-
/*
|
10100
|
+
/* 92 */
|
9684
10101
|
/***/ (() => {
|
9685
10102
|
|
9686
10103
|
|
9687
10104
|
|
9688
10105
|
/***/ }),
|
9689
|
-
/*
|
10106
|
+
/* 93 */
|
9690
10107
|
/***/ (function() {
|
9691
10108
|
|
9692
10109
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -9701,21 +10118,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9701
10118
|
up.motion = (function () {
|
9702
10119
|
const u = up.util;
|
9703
10120
|
const e = up.element;
|
9704
|
-
let namedAnimations = {};
|
9705
|
-
let namedTransitions = {};
|
9706
10121
|
const motionController = new up.MotionController('motion');
|
9707
10122
|
const config = new up.Config(() => ({
|
9708
10123
|
duration: 175,
|
9709
10124
|
easing: 'ease',
|
9710
10125
|
enabled: !matchMedia('(prefers-reduced-motion: reduce)').matches
|
9711
10126
|
}));
|
9712
|
-
|
9713
|
-
|
9714
|
-
}
|
10127
|
+
let namedAnimations = new up.Registry('animation', findAnimationFn);
|
10128
|
+
let namedTransitions = new up.Registry('transition', findTransitionFn);
|
9715
10129
|
function reset() {
|
9716
10130
|
motionController.reset();
|
9717
|
-
namedAnimations = pickDefault(namedAnimations);
|
9718
|
-
namedTransitions = pickDefault(namedTransitions);
|
9719
10131
|
}
|
9720
10132
|
function isEnabled() {
|
9721
10133
|
return config.enabled;
|
@@ -9756,9 +10168,6 @@ up.motion = (function () {
|
|
9756
10168
|
(_a = options.easing) !== null && _a !== void 0 ? _a : (options.easing = config.easing);
|
9757
10169
|
(_b = options.duration) !== null && _b !== void 0 ? _b : (options.duration = config.duration);
|
9758
10170
|
}
|
9759
|
-
function findNamedAnimation(name) {
|
9760
|
-
return namedAnimations[name] || up.fail("Unknown animation %o", name);
|
9761
|
-
}
|
9762
10171
|
function finish(element) {
|
9763
10172
|
return motionController.finish(element);
|
9764
10173
|
}
|
@@ -9811,27 +10220,21 @@ up.motion = (function () {
|
|
9811
10220
|
return Promise.resolve();
|
9812
10221
|
}
|
9813
10222
|
}
|
9814
|
-
function findTransitionFn(
|
9815
|
-
if (isNone(
|
10223
|
+
function findTransitionFn(value) {
|
10224
|
+
if (isNone(value)) {
|
9816
10225
|
return undefined;
|
9817
10226
|
}
|
9818
|
-
else if (u.isFunction(
|
9819
|
-
return
|
10227
|
+
else if (u.isFunction(value)) {
|
10228
|
+
return value;
|
9820
10229
|
}
|
9821
|
-
else if (u.isArray(
|
9822
|
-
return composeTransitionFn(...
|
10230
|
+
else if (u.isArray(value)) {
|
10231
|
+
return composeTransitionFn(...value);
|
9823
10232
|
}
|
9824
|
-
else if (u.isString(
|
9825
|
-
|
9826
|
-
if (object.indexOf('/') >= 0) {
|
9827
|
-
return composeTransitionFn(...object.split('/'));
|
9828
|
-
}
|
9829
|
-
else if (namedTransition = namedTransitions[object]) {
|
9830
|
-
return findTransitionFn(namedTransition);
|
9831
|
-
}
|
10233
|
+
else if (u.isString(value) && value.includes('/')) {
|
10234
|
+
return composeTransitionFn(...value.split('/'));
|
9832
10235
|
}
|
9833
10236
|
else {
|
9834
|
-
|
10237
|
+
return namedTransitions.get(value);
|
9835
10238
|
}
|
9836
10239
|
}
|
9837
10240
|
function composeTransitionFn(oldAnimation, newAnimation) {
|
@@ -9844,21 +10247,18 @@ up.motion = (function () {
|
|
9844
10247
|
]);
|
9845
10248
|
}
|
9846
10249
|
}
|
9847
|
-
function findAnimationFn(
|
9848
|
-
if (isNone(
|
10250
|
+
function findAnimationFn(value) {
|
10251
|
+
if (isNone(value)) {
|
9849
10252
|
return undefined;
|
9850
10253
|
}
|
9851
|
-
else if (u.isFunction(
|
9852
|
-
return
|
9853
|
-
}
|
9854
|
-
else if (u.isString(object)) {
|
9855
|
-
return findNamedAnimation(object);
|
10254
|
+
else if (u.isFunction(value)) {
|
10255
|
+
return value;
|
9856
10256
|
}
|
9857
|
-
else if (u.isOptions(
|
9858
|
-
return (element, options) => animateNow(element,
|
10257
|
+
else if (u.isOptions(value)) {
|
10258
|
+
return (element, options) => animateNow(element, value, options);
|
9859
10259
|
}
|
9860
10260
|
else {
|
9861
|
-
|
10261
|
+
return namedAnimations.get(value);
|
9862
10262
|
}
|
9863
10263
|
}
|
9864
10264
|
const swapElementsDirectly = up.mockable(function (oldElement, newElement) {
|
@@ -9873,16 +10273,6 @@ up.motion = (function () {
|
|
9873
10273
|
parser.number('duration');
|
9874
10274
|
return options;
|
9875
10275
|
}
|
9876
|
-
function registerTransition(name, transition) {
|
9877
|
-
const fn = findTransitionFn(transition);
|
9878
|
-
fn.isDefault = up.framework.evaling;
|
9879
|
-
namedTransitions[name] = fn;
|
9880
|
-
}
|
9881
|
-
function registerAnimation(name, animation) {
|
9882
|
-
const fn = findAnimationFn(animation);
|
9883
|
-
fn.isDefault = up.framework.evaling;
|
9884
|
-
namedAnimations[name] = fn;
|
9885
|
-
}
|
9886
10276
|
up.on('up:framework:boot', function () {
|
9887
10277
|
if (!isEnabled()) {
|
9888
10278
|
up.puts('up.motion', 'Animations are disabled');
|
@@ -9892,7 +10282,7 @@ up.motion = (function () {
|
|
9892
10282
|
return !animationOrTransition || animationOrTransition === 'none';
|
9893
10283
|
}
|
9894
10284
|
function registerOpacityAnimation(name, from, to) {
|
9895
|
-
|
10285
|
+
namedAnimations.put(name, function (element, options) {
|
9896
10286
|
element.style.opacity = 0;
|
9897
10287
|
e.setStyle(element, { opacity: from });
|
9898
10288
|
return animateNow(element, { opacity: to }, options);
|
@@ -9913,12 +10303,12 @@ up.motion = (function () {
|
|
9913
10303
|
function registerMoveAnimations(direction, boxToTransform) {
|
9914
10304
|
const animationToName = `move-to-${direction}`;
|
9915
10305
|
const animationFromName = `move-from-${direction}`;
|
9916
|
-
|
10306
|
+
namedAnimations.put(animationToName, function (element, options) {
|
9917
10307
|
const box = untranslatedBox(element);
|
9918
10308
|
const transform = boxToTransform(box);
|
9919
10309
|
return animateNow(element, transform, options);
|
9920
10310
|
});
|
9921
|
-
|
10311
|
+
namedAnimations.put(animationFromName, function (element, options) {
|
9922
10312
|
const box = untranslatedBox(element);
|
9923
10313
|
const transform = boxToTransform(box);
|
9924
10314
|
e.setStyle(element, transform);
|
@@ -9941,19 +10331,19 @@ up.motion = (function () {
|
|
9941
10331
|
const travelDistance = up.viewport.rootWidth() - box.left;
|
9942
10332
|
return translateCSS(travelDistance, 0);
|
9943
10333
|
});
|
9944
|
-
|
9945
|
-
|
9946
|
-
|
9947
|
-
|
9948
|
-
|
10334
|
+
namedTransitions.put('cross-fade', ['fade-out', 'fade-in']);
|
10335
|
+
namedTransitions.put('move-left', ['move-to-left', 'move-from-right']);
|
10336
|
+
namedTransitions.put('move-right', ['move-to-right', 'move-from-left']);
|
10337
|
+
namedTransitions.put('move-up', ['move-to-top', 'move-from-bottom']);
|
10338
|
+
namedTransitions.put('move-down', ['move-to-bottom', 'move-from-top']);
|
9949
10339
|
up.on('up:framework:reset', reset);
|
9950
10340
|
return {
|
9951
10341
|
morph,
|
9952
10342
|
animate,
|
9953
10343
|
finish,
|
9954
10344
|
finishCount() { return motionController.finishCount; },
|
9955
|
-
transition:
|
9956
|
-
animation:
|
10345
|
+
transition: namedTransitions.put,
|
10346
|
+
animation: namedAnimations.put,
|
9957
10347
|
config,
|
9958
10348
|
isEnabled,
|
9959
10349
|
isNone,
|
@@ -9969,10 +10359,10 @@ up.animate = up.motion.animate;
|
|
9969
10359
|
|
9970
10360
|
|
9971
10361
|
/***/ }),
|
9972
|
-
/*
|
10362
|
+
/* 94 */
|
9973
10363
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
9974
10364
|
|
9975
|
-
__webpack_require__(
|
10365
|
+
__webpack_require__(95);
|
9976
10366
|
const u = up.util;
|
9977
10367
|
up.network = (function () {
|
9978
10368
|
const config = new up.Config(() => ({
|
@@ -9984,7 +10374,7 @@ up.network = (function () {
|
|
9984
10374
|
lateDelay: 400,
|
9985
10375
|
fail(response) { return (response.status < 200 || response.status > 299) && response.status !== 304; },
|
9986
10376
|
autoCache(request) { return request.isSafe(); },
|
9987
|
-
expireCache(request
|
10377
|
+
expireCache(request) { return !request.isSafe(); },
|
9988
10378
|
evictCache: false,
|
9989
10379
|
progressBar: true,
|
9990
10380
|
timeout: 90000,
|
@@ -10012,6 +10402,9 @@ up.network = (function () {
|
|
10012
10402
|
return options;
|
10013
10403
|
}
|
10014
10404
|
function processRequest(request) {
|
10405
|
+
var _a, _b, _c, _d;
|
10406
|
+
cache.expire((_b = (_a = request.expireCache) !== null && _a !== void 0 ? _a : u.evalOption(config.expireCache, request)) !== null && _b !== void 0 ? _b : false);
|
10407
|
+
cache.evict((_d = (_c = request.evictCache) !== null && _c !== void 0 ? _c : u.evalOption(config.evictCache, request)) !== null && _d !== void 0 ? _d : false);
|
10015
10408
|
useCachedRequest(request) || queueRequest(request);
|
10016
10409
|
}
|
10017
10410
|
function useCachedRequest(newRequest) {
|
@@ -10037,15 +10430,9 @@ up.network = (function () {
|
|
10037
10430
|
request.onLoading = () => cache.reindex(request);
|
10038
10431
|
}
|
10039
10432
|
u.always(request, function (responseOrError) {
|
10040
|
-
var _a, _b
|
10041
|
-
|
10042
|
-
|
10043
|
-
cache.expire(expireCache, { except: request });
|
10044
|
-
}
|
10045
|
-
let evictCache = (_d = (_c = responseOrError.evictCache) !== null && _c !== void 0 ? _c : request.evictCache) !== null && _d !== void 0 ? _d : u.evalOption(config.evictCache, request, responseOrError);
|
10046
|
-
if (evictCache) {
|
10047
|
-
cache.evict(evictCache, { except: request });
|
10048
|
-
}
|
10433
|
+
var _a, _b;
|
10434
|
+
cache.expire((_a = responseOrError.expireCache) !== null && _a !== void 0 ? _a : false, { except: request });
|
10435
|
+
cache.evict((_b = responseOrError.evictCache) !== null && _b !== void 0 ? _b : false, { except: request });
|
10049
10436
|
let hasCacheEntry = cache.get(request);
|
10050
10437
|
let isResponse = responseOrError instanceof up.Response;
|
10051
10438
|
let isNetworkError = !isResponse;
|
@@ -10115,13 +10502,13 @@ up.cache = up.network.cache;
|
|
10115
10502
|
|
10116
10503
|
|
10117
10504
|
/***/ }),
|
10118
|
-
/*
|
10505
|
+
/* 95 */
|
10119
10506
|
/***/ (() => {
|
10120
10507
|
|
10121
10508
|
|
10122
10509
|
|
10123
10510
|
/***/ }),
|
10124
|
-
/*
|
10511
|
+
/* 96 */
|
10125
10512
|
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
10126
10513
|
|
10127
10514
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -10133,7 +10520,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10133
10520
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
10134
10521
|
});
|
10135
10522
|
};
|
10136
|
-
__webpack_require__(
|
10523
|
+
__webpack_require__(97);
|
10137
10524
|
const u = up.util;
|
10138
10525
|
const e = up.element;
|
10139
10526
|
up.layer = (function () {
|
@@ -10309,7 +10696,7 @@ up.layer = (function () {
|
|
10309
10696
|
});
|
10310
10697
|
}
|
10311
10698
|
function anySelector() {
|
10312
|
-
return u.map(LAYER_CLASSES, Class => Class.selector()).join();
|
10699
|
+
return u.map(LAYER_CLASSES, (Class) => Class.selector()).join();
|
10313
10700
|
}
|
10314
10701
|
function optionToString(option) {
|
10315
10702
|
if (u.isString(option)) {
|
@@ -10379,20 +10766,22 @@ up.layer = (function () {
|
|
10379
10766
|
|
10380
10767
|
|
10381
10768
|
/***/ }),
|
10382
|
-
/*
|
10769
|
+
/* 97 */
|
10383
10770
|
/***/ (() => {
|
10384
10771
|
|
10385
10772
|
|
10386
10773
|
|
10387
10774
|
/***/ }),
|
10388
|
-
/*
|
10775
|
+
/* 98 */
|
10389
10776
|
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
10390
10777
|
|
10391
|
-
__webpack_require__(
|
10778
|
+
__webpack_require__(99);
|
10392
10779
|
up.link = (function () {
|
10393
10780
|
const u = up.util;
|
10394
10781
|
const e = up.element;
|
10782
|
+
let lastTouchstartTarget = null;
|
10395
10783
|
let lastMousedownTarget = null;
|
10784
|
+
let lastInstantTarget = null;
|
10396
10785
|
const ATTRS_WITH_LOCAL_HTML = '[up-content], [up-fragment], [up-document]';
|
10397
10786
|
const ATTRS_SUGGESTING_FOLLOW = `${ATTRS_WITH_LOCAL_HTML}, [up-target], [up-layer], [up-transition], [up-preload]`;
|
10398
10787
|
const DEFAULT_INTERACTIVE_ELEMENT = 'a[href], button';
|
@@ -10422,7 +10811,9 @@ up.link = (function () {
|
|
10422
10811
|
}
|
10423
10812
|
}
|
10424
10813
|
function reset() {
|
10814
|
+
lastTouchstartTarget = null;
|
10425
10815
|
lastMousedownTarget = null;
|
10816
|
+
lastInstantTarget = null;
|
10426
10817
|
}
|
10427
10818
|
const follow = up.mockable(function (link, options, parserOptions) {
|
10428
10819
|
return up.render(followOptions(link, options, parserOptions));
|
@@ -10444,6 +10835,7 @@ up.link = (function () {
|
|
10444
10835
|
parser.string('contentType');
|
10445
10836
|
parser.booleanOrNumber('lateDelay');
|
10446
10837
|
parser.number('timeout');
|
10838
|
+
parser.booleanOrString('fail');
|
10447
10839
|
return options;
|
10448
10840
|
}
|
10449
10841
|
function followOptions(link, options, parserOptions) {
|
@@ -10453,7 +10845,6 @@ up.link = (function () {
|
|
10453
10845
|
const parser = new up.OptionsParser(link, options, Object.assign({ fail: true }, parserOptions));
|
10454
10846
|
parser.include(parseRequestOptions);
|
10455
10847
|
options.origin || (options.origin = link);
|
10456
|
-
parser.boolean('fail');
|
10457
10848
|
parser.boolean('navigate', { default: true });
|
10458
10849
|
parser.string('confirm', { attr: ['up-confirm', 'data-confirm'] });
|
10459
10850
|
parser.string('target');
|
@@ -10487,9 +10878,12 @@ up.link = (function () {
|
|
10487
10878
|
parser.string('dismissEvent');
|
10488
10879
|
parser.string('acceptLocation');
|
10489
10880
|
parser.string('dismissLocation');
|
10490
|
-
parser.booleanOrString('
|
10881
|
+
parser.booleanOrString('closeAnimation');
|
10882
|
+
parser.string('closeEasing');
|
10883
|
+
parser.number('closeDuration');
|
10491
10884
|
parser.include(up.status.statusOptions);
|
10492
10885
|
parser.booleanOrString('focus');
|
10886
|
+
parser.booleanOrString('focusVisible');
|
10493
10887
|
parser.boolean('saveScroll');
|
10494
10888
|
parser.boolean('saveFocus');
|
10495
10889
|
parser.booleanOrString('scroll');
|
@@ -10514,7 +10908,7 @@ up.link = (function () {
|
|
10514
10908
|
return Promise.reject(new up.Error(issue));
|
10515
10909
|
}
|
10516
10910
|
const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });
|
10517
|
-
return follow(link, Object.assign(Object.assign(Object.assign(Object.assign({ abort: false, abortable: false, background: true, cache: true }, up.RenderOptions.NO_INPUT_INTERFERENCE), up.RenderOptions.NO_PREVIEWS),
|
10911
|
+
return follow(link, Object.assign(Object.assign(Object.assign(Object.assign({ abort: false, abortable: false, background: true, cache: true }, options), up.RenderOptions.NO_INPUT_INTERFERENCE), up.RenderOptions.NO_PREVIEWS), { guardEvent, preload: true }));
|
10518
10912
|
}
|
10519
10913
|
function preloadIssue(link) {
|
10520
10914
|
if (!isSafe(link)) {
|
@@ -10570,27 +10964,37 @@ up.link = (function () {
|
|
10570
10964
|
}
|
10571
10965
|
function convertClicks(layer) {
|
10572
10966
|
layer.on('click', function (event, element) {
|
10573
|
-
if (
|
10967
|
+
if (up.event.isModified(event)) {
|
10574
10968
|
return;
|
10575
10969
|
}
|
10576
|
-
if (isInstant(element) &&
|
10970
|
+
if (isInstant(element) && lastInstantTarget === element) {
|
10577
10971
|
up.event.halt(event);
|
10578
10972
|
}
|
10579
10973
|
else if (up.event.inputDevice === 'key' || up.event.isSyntheticClick(event) || (layer.wasHitByMouseEvent(event) && !didUserDragAway(event))) {
|
10580
10974
|
forkEventAsUpClick(event);
|
10581
10975
|
}
|
10582
|
-
|
10976
|
+
lastMousedownTarget = null;
|
10977
|
+
lastInstantTarget = null;
|
10978
|
+
});
|
10979
|
+
layer.on('touchstart', { passive: true }, function (event, element) {
|
10980
|
+
lastTouchstartTarget = element;
|
10583
10981
|
});
|
10584
10982
|
layer.on('mousedown', function (event, element) {
|
10585
|
-
if (
|
10983
|
+
if (up.event.isModified(event)) {
|
10586
10984
|
return;
|
10587
10985
|
}
|
10588
|
-
lastMousedownTarget =
|
10589
|
-
if (isInstant(element)) {
|
10986
|
+
lastMousedownTarget = element;
|
10987
|
+
if (isInstant(element) && !isLongPressPossible(event)) {
|
10988
|
+
lastInstantTarget = element;
|
10590
10989
|
forkEventAsUpClick(event);
|
10591
10990
|
}
|
10991
|
+
lastTouchstartTarget = null;
|
10592
10992
|
});
|
10593
10993
|
}
|
10994
|
+
function isLongPressPossible(mousedownEvent) {
|
10995
|
+
let mousedownTarget = mousedownEvent.target;
|
10996
|
+
return (lastTouchstartTarget === mousedownTarget) && mousedownTarget.closest('[href]');
|
10997
|
+
}
|
10594
10998
|
function didUserDragAway(clickEvent) {
|
10595
10999
|
return lastMousedownTarget && (lastMousedownTarget !== clickEvent.target);
|
10596
11000
|
}
|
@@ -10679,13 +11083,13 @@ up.deferred = { load: up.link.loadDeferred };
|
|
10679
11083
|
|
10680
11084
|
|
10681
11085
|
/***/ }),
|
10682
|
-
/*
|
11086
|
+
/* 99 */
|
10683
11087
|
/***/ (() => {
|
10684
11088
|
|
10685
11089
|
|
10686
11090
|
|
10687
11091
|
/***/ }),
|
10688
|
-
/*
|
11092
|
+
/* 100 */
|
10689
11093
|
/***/ (() => {
|
10690
11094
|
|
10691
11095
|
up.form = (function () {
|
@@ -10698,12 +11102,14 @@ up.form = (function () {
|
|
10698
11102
|
noSubmitSelectors: ['[up-submit=false]', '[target]', e.crossOriginSelector('action')],
|
10699
11103
|
submitButtonSelectors: ['input[type=submit]', 'input[type=image]', 'button[type=submit]', 'button:not([type])'],
|
10700
11104
|
genericButtonSelectors: ['input[type=button]', 'button[type=button]'],
|
11105
|
+
validateBatch: true,
|
10701
11106
|
watchInputEvents: ['input', 'change'],
|
10702
11107
|
watchInputDelay: 0,
|
10703
11108
|
watchChangeEvents: ['change'],
|
11109
|
+
watchableEvents: ['input', 'change'],
|
10704
11110
|
}));
|
10705
11111
|
function fieldSelector(suffix = '') {
|
10706
|
-
return config.fieldSelectors.map(field => field + suffix).join();
|
11112
|
+
return config.fieldSelectors.map((field) => field + suffix).join();
|
10707
11113
|
}
|
10708
11114
|
function isField(element) {
|
10709
11115
|
return element.matches(fieldSelector());
|
@@ -10714,11 +11120,17 @@ up.form = (function () {
|
|
10714
11120
|
if (root.matches('form[id]')) {
|
10715
11121
|
const outsideFieldSelector = fieldSelector(e.attrSelector('form', root.getAttribute('id')));
|
10716
11122
|
const outsideFields = up.fragment.all(outsideFieldSelector, { layer: root });
|
10717
|
-
fields.
|
10718
|
-
fields = u.uniq(fields);
|
11123
|
+
fields = u.uniq([...fields, ...outsideFields]);
|
10719
11124
|
}
|
10720
11125
|
return fields;
|
10721
11126
|
}
|
11127
|
+
function findFieldsAndButtons(container) {
|
11128
|
+
return [
|
11129
|
+
...findFields(container),
|
11130
|
+
...findSubmitButtons(container),
|
11131
|
+
...findGenericButtons(container),
|
11132
|
+
];
|
11133
|
+
}
|
10722
11134
|
function findSubmitButtons(root) {
|
10723
11135
|
return e.subtree(root, submitButtonSelector());
|
10724
11136
|
}
|
@@ -10752,16 +11164,18 @@ up.form = (function () {
|
|
10752
11164
|
return options;
|
10753
11165
|
}
|
10754
11166
|
function watchOptions(field, options, parserOptions = {}) {
|
10755
|
-
var _a;
|
11167
|
+
var _a, _b, _c;
|
10756
11168
|
options = u.options(options);
|
10757
|
-
|
10758
|
-
|
11169
|
+
(_a = parserOptions.closest) !== null && _a !== void 0 ? _a : (parserOptions.closest = true);
|
11170
|
+
(_b = parserOptions.attrPrefix) !== null && _b !== void 0 ? _b : (parserOptions.attrPrefix = 'up-watch-');
|
11171
|
+
let parser = new up.OptionsParser(field, options, parserOptions);
|
11172
|
+
parser.include(up.status.statusOptions, parserOptions);
|
10759
11173
|
parser.string('event');
|
10760
11174
|
parser.number('delay');
|
10761
11175
|
let config = up.form.config;
|
10762
11176
|
if (options.event === 'input') {
|
10763
11177
|
options.event = u.evalOption(config.watchInputEvents, field);
|
10764
|
-
(
|
11178
|
+
(_c = options.delay) !== null && _c !== void 0 ? _c : (options.delay = config.watchInputDelay);
|
10765
11179
|
}
|
10766
11180
|
else if (options.event === 'change') {
|
10767
11181
|
options.event = u.evalOption(config.watchChangeEvents, field);
|
@@ -10769,15 +11183,20 @@ up.form = (function () {
|
|
10769
11183
|
options.origin || (options.origin = field);
|
10770
11184
|
return options;
|
10771
11185
|
}
|
10772
|
-
function
|
10773
|
-
|
10774
|
-
|
10775
|
-
|
10776
|
-
|
10777
|
-
|
10778
|
-
|
11186
|
+
function validateOptions(field, options, parserOptions = {}) {
|
11187
|
+
options = u.options(options);
|
11188
|
+
let parser = new up.OptionsParser(field, options, Object.assign(Object.assign({}, parserOptions), { closest: true, attrPrefix: 'up-validate-' }));
|
11189
|
+
parser.string('url');
|
11190
|
+
parser.string('method', { normalize: u.normalizeMethod });
|
11191
|
+
parser.boolean('batch', { default: config.validateBatch });
|
11192
|
+
parser.include(watchOptions, { defaults: { event: 'change' } });
|
11193
|
+
return options;
|
11194
|
+
}
|
11195
|
+
function disableContainerTemp(container) {
|
11196
|
+
let controls = findFieldsAndButtons(container);
|
11197
|
+
return u.sequence(u.map(controls, disableControlTemp));
|
10779
11198
|
}
|
10780
|
-
function
|
11199
|
+
function disableControlTemp(control) {
|
10781
11200
|
if (control.disabled)
|
10782
11201
|
return;
|
10783
11202
|
let focusFallback;
|
@@ -10792,7 +11211,7 @@ up.form = (function () {
|
|
10792
11211
|
return () => { control.disabled = false; };
|
10793
11212
|
}
|
10794
11213
|
function getDisableContainers(disable, origin) {
|
10795
|
-
let originScope = () =>
|
11214
|
+
let originScope = () => getRegion(origin);
|
10796
11215
|
if (disable === true) {
|
10797
11216
|
return [originScope()];
|
10798
11217
|
}
|
@@ -10817,6 +11236,11 @@ up.form = (function () {
|
|
10817
11236
|
}
|
10818
11237
|
};
|
10819
11238
|
}
|
11239
|
+
function setContainerDisabled(container, disabled) {
|
11240
|
+
for (let control of findFieldsAndButtons(container)) {
|
11241
|
+
control.disabled = disabled;
|
11242
|
+
}
|
11243
|
+
}
|
10820
11244
|
function destinationOptions(form, options, parserOptions) {
|
10821
11245
|
var _a;
|
10822
11246
|
options = u.options(options);
|
@@ -10849,8 +11273,7 @@ up.form = (function () {
|
|
10849
11273
|
root = up.element.get(root);
|
10850
11274
|
callback || (callback = watchCallbackFromElement(root) || up.fail('No callback given for up.watch()'));
|
10851
11275
|
const watcher = new up.FieldWatcher(root, options, callback);
|
10852
|
-
watcher.start();
|
10853
|
-
return () => watcher.stop();
|
11276
|
+
return watcher.start();
|
10854
11277
|
}
|
10855
11278
|
function watchCallbackFromElement(element) {
|
10856
11279
|
let rawCallback = element.getAttribute('up-watch');
|
@@ -10860,7 +11283,7 @@ up.form = (function () {
|
|
10860
11283
|
}
|
10861
11284
|
function autosubmit(target, options = {}) {
|
10862
11285
|
const onChange = (_diff, renderOptions) => submit(target, renderOptions);
|
10863
|
-
return watch(target, Object.assign(Object.assign({}, options), { batch: true }), onChange);
|
11286
|
+
return watch(target, Object.assign(Object.assign({ logPrefix: 'up.autosubmit()' }, options), { batch: true }), onChange);
|
10864
11287
|
}
|
10865
11288
|
function getGroupSelectors() {
|
10866
11289
|
var _a, _b;
|
@@ -10889,7 +11312,8 @@ up.form = (function () {
|
|
10889
11312
|
}
|
10890
11313
|
function validate(...args) {
|
10891
11314
|
let options = parseValidateArgs(...args);
|
10892
|
-
let
|
11315
|
+
let form = getForm(options.origin);
|
11316
|
+
let validator = getFormValidator(form);
|
10893
11317
|
return validator.validate(options);
|
10894
11318
|
}
|
10895
11319
|
function parseValidateArgs(originOrTarget, ...args) {
|
@@ -10902,88 +11326,20 @@ up.form = (function () {
|
|
10902
11326
|
}
|
10903
11327
|
return options;
|
10904
11328
|
}
|
10905
|
-
function switcherValues(field) {
|
10906
|
-
let value;
|
10907
|
-
let meta;
|
10908
|
-
if (field.matches('input[type=checkbox]')) {
|
10909
|
-
if (field.checked) {
|
10910
|
-
value = field.value;
|
10911
|
-
meta = ':checked';
|
10912
|
-
}
|
10913
|
-
else {
|
10914
|
-
meta = ':unchecked';
|
10915
|
-
}
|
10916
|
-
}
|
10917
|
-
else if (field.matches('input[type=radio]')) {
|
10918
|
-
const form = getScope(field);
|
10919
|
-
const groupName = field.getAttribute('name');
|
10920
|
-
const checkedButton = form.querySelector(`input[type=radio]${e.attrSelector('name', groupName)}:checked`);
|
10921
|
-
if (checkedButton) {
|
10922
|
-
meta = ':checked';
|
10923
|
-
value = checkedButton.value;
|
10924
|
-
}
|
10925
|
-
else {
|
10926
|
-
meta = ':unchecked';
|
10927
|
-
}
|
10928
|
-
}
|
10929
|
-
else {
|
10930
|
-
value = field.value;
|
10931
|
-
}
|
10932
|
-
const values = [];
|
10933
|
-
if (u.isPresent(value)) {
|
10934
|
-
values.push(value);
|
10935
|
-
values.push(':present');
|
10936
|
-
}
|
10937
|
-
else {
|
10938
|
-
values.push(':blank');
|
10939
|
-
}
|
10940
|
-
if (u.isPresent(meta)) {
|
10941
|
-
values.push(meta);
|
10942
|
-
}
|
10943
|
-
return values;
|
10944
|
-
}
|
10945
|
-
function switchTargets(switcher, options = {}) {
|
10946
|
-
const targetSelector = options.target || options.target || switcher.getAttribute('up-switch');
|
10947
|
-
const form = getScope(switcher);
|
10948
|
-
targetSelector || up.fail("No switch target given for %o", switcher);
|
10949
|
-
const fieldValues = switcherValues(switcher);
|
10950
|
-
for (let target of up.fragment.all(form, targetSelector)) {
|
10951
|
-
switchTarget(target, fieldValues);
|
10952
|
-
}
|
10953
|
-
}
|
10954
|
-
const switchTarget = up.mockable(function (target, fieldValues) {
|
10955
|
-
let show;
|
10956
|
-
fieldValues || (fieldValues = switcherValues(findSwitcherForTarget(target)));
|
10957
|
-
let hideValues = target.getAttribute('up-hide-for');
|
10958
|
-
if (hideValues) {
|
10959
|
-
hideValues = parseSwitchTokens(hideValues);
|
10960
|
-
show = u.intersect(fieldValues, hideValues).length === 0;
|
10961
|
-
}
|
10962
|
-
else {
|
10963
|
-
let showValues = target.getAttribute('up-show-for');
|
10964
|
-
showValues = showValues ? parseSwitchTokens(showValues) : [':present', ':checked'];
|
10965
|
-
show = u.intersect(fieldValues, showValues).length > 0;
|
10966
|
-
}
|
10967
|
-
e.toggle(target, show);
|
10968
|
-
target.classList.add('up-switched');
|
10969
|
-
});
|
10970
|
-
function parseSwitchTokens(str) {
|
10971
|
-
return u.getSimpleTokens(str, { json: true });
|
10972
|
-
}
|
10973
|
-
function findSwitcherForTarget(target) {
|
10974
|
-
const form = getScope(target);
|
10975
|
-
const switchers = form.querySelectorAll('[up-switch]');
|
10976
|
-
const switcher = u.find(switchers, function (switcher) {
|
10977
|
-
const targetSelector = switcher.getAttribute('up-switch');
|
10978
|
-
return target.matches(targetSelector);
|
10979
|
-
});
|
10980
|
-
return switcher || up.fail('Could not find [up-switch] field for %o', target);
|
10981
|
-
}
|
10982
11329
|
function getForm(elementOrSelector, options = {}) {
|
10983
11330
|
const element = up.fragment.get(elementOrSelector, options);
|
10984
11331
|
return element.form || element.closest('form');
|
10985
11332
|
}
|
10986
|
-
function
|
11333
|
+
function getFormValidator(form) {
|
11334
|
+
return form.upFormValidator || (form.upFormValidator = setupFormValidator(form));
|
11335
|
+
}
|
11336
|
+
function setupFormValidator(form) {
|
11337
|
+
const validator = new up.FormValidator(form);
|
11338
|
+
const stop = validator.start();
|
11339
|
+
up.destructor(form, stop);
|
11340
|
+
return validator;
|
11341
|
+
}
|
11342
|
+
function getRegion(origin, options) {
|
10987
11343
|
if (origin) {
|
10988
11344
|
return getForm(origin, options) || up.layer.get(origin).element;
|
10989
11345
|
}
|
@@ -10991,6 +11347,19 @@ up.form = (function () {
|
|
10991
11347
|
return up.layer.current.element;
|
10992
11348
|
}
|
10993
11349
|
}
|
11350
|
+
function trackFields(...args) {
|
11351
|
+
let [root, { guard }, callback] = u.args(args, 'val', 'options', 'callback');
|
11352
|
+
let filter = function (fields) {
|
11353
|
+
let scope = getRegion(root);
|
11354
|
+
return u.filter(fields, function (field) {
|
11355
|
+
return (root === scope || root.contains(field))
|
11356
|
+
&& (getForm(field) === scope)
|
11357
|
+
&& (!guard || guard(field));
|
11358
|
+
});
|
11359
|
+
};
|
11360
|
+
const live = true;
|
11361
|
+
return up.fragment.trackSelector(fieldSelector(), { filter, live }, callback);
|
11362
|
+
}
|
10994
11363
|
function focusedField() {
|
10995
11364
|
return u.presence(document.activeElement, isField);
|
10996
11365
|
}
|
@@ -11005,49 +11374,39 @@ up.form = (function () {
|
|
11005
11374
|
up.event.halt(event, { log: true });
|
11006
11375
|
up.error.muteUncriticalRejection(submit(form, { submitButton }));
|
11007
11376
|
});
|
11008
|
-
up.compiler(
|
11009
|
-
|
11010
|
-
validator.watchContainer(fieldOrForm);
|
11377
|
+
up.compiler('form', function (form) {
|
11378
|
+
getFormValidator(form);
|
11011
11379
|
});
|
11012
|
-
function validatingFieldSelector() {
|
11013
|
-
let includes = config.fieldSelectors.map((selector) => `${selector}[up-validate], [up-validate] ${selector}`);
|
11014
|
-
let excludes = ['[up-validate=false]'];
|
11015
|
-
return e.unionSelector(includes, excludes);
|
11016
|
-
}
|
11017
11380
|
up.compiler('[up-switch]', (switcher) => {
|
11018
|
-
|
11019
|
-
});
|
11020
|
-
up.on('change', '[up-switch]', (_event, switcher) => {
|
11021
|
-
switchTargets(switcher);
|
11022
|
-
});
|
11023
|
-
up.compiler('[up-show-for]:not(.up-switched), [up-hide-for]:not(.up-switched)', (element) => {
|
11024
|
-
switchTarget(element);
|
11381
|
+
return new up.Switcher(switcher).start();
|
11025
11382
|
});
|
11026
11383
|
up.attribute('up-watch', (formOrField) => watch(formOrField));
|
11027
|
-
up.attribute('up-autosubmit', (formOrField) => autosubmit(formOrField));
|
11384
|
+
up.attribute('up-autosubmit', (formOrField) => autosubmit(formOrField, { logPrefix: '[up-autosubmit]' }));
|
11028
11385
|
return {
|
11029
11386
|
config,
|
11030
11387
|
submit,
|
11031
11388
|
submitOptions,
|
11032
11389
|
destinationOptions,
|
11033
11390
|
watchOptions,
|
11391
|
+
validateOptions,
|
11034
11392
|
isSubmittable,
|
11035
11393
|
watch,
|
11036
11394
|
validate,
|
11037
11395
|
autosubmit,
|
11038
11396
|
fieldSelector,
|
11039
11397
|
fields: findFields,
|
11398
|
+
trackFields,
|
11040
11399
|
isField,
|
11041
11400
|
submitButtons: findSubmitButtons,
|
11042
11401
|
focusedField,
|
11043
|
-
|
11044
|
-
|
11402
|
+
disableTemp: disableContainerTemp,
|
11403
|
+
setDisabled: setContainerDisabled,
|
11045
11404
|
getDisablePreviewFn,
|
11046
11405
|
group: findGroup,
|
11047
11406
|
groupSolution: findGroupSolution,
|
11048
11407
|
groupSelectors: getGroupSelectors,
|
11049
11408
|
get: getForm,
|
11050
|
-
|
11409
|
+
getRegion,
|
11051
11410
|
};
|
11052
11411
|
})();
|
11053
11412
|
up.submit = up.form.submit;
|
@@ -11057,13 +11416,12 @@ up.validate = up.form.validate;
|
|
11057
11416
|
|
11058
11417
|
|
11059
11418
|
/***/ }),
|
11060
|
-
/*
|
11419
|
+
/* 101 */
|
11061
11420
|
/***/ (() => {
|
11062
11421
|
|
11063
11422
|
up.status = (function () {
|
11064
11423
|
const u = up.util;
|
11065
11424
|
const e = up.element;
|
11066
|
-
let namedPreviewFns = {};
|
11067
11425
|
const config = new up.Config(() => ({
|
11068
11426
|
currentClasses: ['up-current'],
|
11069
11427
|
activeClasses: ['up-active'],
|
@@ -11071,9 +11429,9 @@ up.status = (function () {
|
|
11071
11429
|
navSelectors: ['[up-nav]', 'nav'],
|
11072
11430
|
noNavSelectors: ['[up-nav=false]'],
|
11073
11431
|
}));
|
11432
|
+
let namedPreviewFns = new up.Registry('preview');
|
11074
11433
|
function reset() {
|
11075
11434
|
up.layer.root.feedbackLocation = null;
|
11076
|
-
namedPreviewFns = u.pickBy(namedPreviewFns, 'isDefault');
|
11077
11435
|
}
|
11078
11436
|
const SELECTOR_LINK = 'a, [up-href]';
|
11079
11437
|
function linkCurrentURLs(link) {
|
@@ -11104,7 +11462,7 @@ up.status = (function () {
|
|
11104
11462
|
let focusCapsule = up.FocusCapsule.preserve(bindLayer);
|
11105
11463
|
let applyPreviews = () => doRunPreviews(request, renderOptions);
|
11106
11464
|
let revertPreviews = bindLayer.asCurrent(applyPreviews);
|
11107
|
-
|
11465
|
+
focusCapsule === null || focusCapsule === void 0 ? void 0 : focusCapsule.autoVoid();
|
11108
11466
|
return () => {
|
11109
11467
|
bindLayer.asCurrent(revertPreviews);
|
11110
11468
|
focusCapsule === null || focusCapsule === void 0 ? void 0 : focusCapsule.restore(bindLayer, { preventScroll: true });
|
@@ -11149,7 +11507,7 @@ up.status = (function () {
|
|
11149
11507
|
}
|
11150
11508
|
function resolvePreviewString(str) {
|
11151
11509
|
return u.map(u.parseScalarJSONPairs(str), ([name, parsedOptions]) => {
|
11152
|
-
let previewFn = namedPreviewFns
|
11510
|
+
let previewFn = namedPreviewFns.get(name);
|
11153
11511
|
return function (preview, runOptions) {
|
11154
11512
|
up.puts('[up-preview]', 'Showing preview %o', name);
|
11155
11513
|
return previewFn(preview, parsedOptions || runOptions);
|
@@ -11160,10 +11518,6 @@ up.status = (function () {
|
|
11160
11518
|
activeElements || (activeElements = u.wrapList(origin));
|
11161
11519
|
return activeElements.map(findActivatableArea);
|
11162
11520
|
}
|
11163
|
-
function registerPreview(name, previewFn) {
|
11164
|
-
previewFn.isDefault = up.framework.evaling;
|
11165
|
-
namedPreviewFns[name] = previewFn;
|
11166
|
-
}
|
11167
11521
|
function getFeedbackClassesPreviewFn(feedbackOption, fragments) {
|
11168
11522
|
if (!feedbackOption)
|
11169
11523
|
return;
|
@@ -11208,7 +11562,7 @@ up.status = (function () {
|
|
11208
11562
|
up.on('up:framework:reset', reset);
|
11209
11563
|
return {
|
11210
11564
|
config,
|
11211
|
-
preview:
|
11565
|
+
preview: namedPreviewFns.put,
|
11212
11566
|
resolvePreviewFns,
|
11213
11567
|
runPreviews,
|
11214
11568
|
statusOptions,
|
@@ -11218,7 +11572,7 @@ up.preview = up.status.preview;
|
|
11218
11572
|
|
11219
11573
|
|
11220
11574
|
/***/ }),
|
11221
|
-
/*
|
11575
|
+
/* 102 */
|
11222
11576
|
/***/ (() => {
|
11223
11577
|
|
11224
11578
|
up.radio = (function () {
|
@@ -11301,7 +11655,7 @@ up.radio = (function () {
|
|
11301
11655
|
|
11302
11656
|
|
11303
11657
|
/***/ }),
|
11304
|
-
/*
|
11658
|
+
/* 103 */
|
11305
11659
|
/***/ (() => {
|
11306
11660
|
|
11307
11661
|
(function () {
|
@@ -11440,15 +11794,18 @@ __webpack_require__(83);
|
|
11440
11794
|
__webpack_require__(84);
|
11441
11795
|
__webpack_require__(85);
|
11442
11796
|
__webpack_require__(86);
|
11797
|
+
__webpack_require__(87);
|
11443
11798
|
__webpack_require__(88);
|
11444
|
-
__webpack_require__(
|
11799
|
+
__webpack_require__(89);
|
11445
11800
|
__webpack_require__(91);
|
11446
11801
|
__webpack_require__(93);
|
11447
|
-
__webpack_require__(
|
11448
|
-
__webpack_require__(
|
11802
|
+
__webpack_require__(94);
|
11803
|
+
__webpack_require__(96);
|
11449
11804
|
__webpack_require__(98);
|
11450
|
-
__webpack_require__(99);
|
11451
11805
|
__webpack_require__(100);
|
11806
|
+
__webpack_require__(101);
|
11807
|
+
__webpack_require__(102);
|
11808
|
+
__webpack_require__(103);
|
11452
11809
|
up.framework.onEvaled();
|
11453
11810
|
|
11454
11811
|
})();
|