unpoly-rails 3.10.2 → 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.
@@ -5,7 +5,7 @@
5
5
  /***/ (() => {
6
6
 
7
7
  window.up = {
8
- version: '3.10.2'
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
- const merger = function (object, pair) {
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(object) {
151
- return object === null;
146
+ function isNull(value) {
147
+ return value === null;
152
148
  }
153
- function isUndefined(object) {
154
- return object === undefined;
149
+ function isUndefined(value) {
150
+ return value === undefined;
155
151
  }
156
152
  const isDefined = negate(isUndefined);
157
- function isMissing(object) {
158
- return isUndefined(object) || isNull(object);
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(object) {
184
- return typeof (object) === 'function';
179
+ function isFunction(value) {
180
+ return typeof (value) === 'function';
185
181
  }
186
- function isString(object) {
187
- return (typeof (object) === 'string') || object instanceof String;
182
+ function isString(value) {
183
+ return (typeof (value) === 'string') || value instanceof String;
188
184
  }
189
- function isBoolean(object) {
190
- return (typeof (object) === 'boolean') || object instanceof Boolean;
185
+ function isBoolean(value) {
186
+ return (typeof (value) === 'boolean') || value instanceof Boolean;
191
187
  }
192
- function isNumber(object) {
193
- return (typeof (object) === 'number') || object instanceof Number;
188
+ function isNumber(value) {
189
+ return (typeof (value) === 'number') || value instanceof Number;
194
190
  }
195
- function isOptions(object) {
196
- return (typeof (object) === 'object') && !isNull(object) && (isUndefined(object.constructor) || (object.constructor === Object));
191
+ function isOptions(value) {
192
+ return (typeof (value) === 'object') && !isNull(value) && (isUndefined(value.constructor) || (value.constructor === Object));
197
193
  }
198
- function isObject(object) {
199
- const typeOfResult = typeof (object);
200
- return ((typeOfResult === 'object') && !isNull(object)) || (typeOfResult === 'function');
194
+ function isObject(value) {
195
+ const typeOfResult = typeof (value);
196
+ return ((typeOfResult === 'object') && !isNull(value)) || (typeOfResult === 'function');
201
197
  }
202
- function isElement(object) {
203
- return object instanceof Element;
198
+ function isElement(value) {
199
+ return value instanceof Element;
204
200
  }
205
- function isTextNode(object) {
206
- return object instanceof Text;
201
+ function isTextNode(value) {
202
+ return value instanceof Text;
207
203
  }
208
- function isRegExp(object) {
209
- return object instanceof RegExp;
204
+ function isRegExp(value) {
205
+ return value instanceof RegExp;
210
206
  }
211
- function isError(object) {
212
- return object instanceof Error;
207
+ function isError(value) {
208
+ return value instanceof Error;
213
209
  }
214
- function isJQuery(object) {
215
- return up.browser.canJQuery() && object instanceof jQuery;
210
+ function isJQuery(value) {
211
+ return up.browser.canJQuery() && value instanceof jQuery;
216
212
  }
217
- function isElementLike(object) {
213
+ function isElementLike(value) {
218
214
  var _a;
219
- return !!(object && (object.addEventListener || (isJQuery(object) && ((_a = object[0]) === null || _a === void 0 ? void 0 : _a.addEventListener))));
215
+ return !!(value && (value.addEventListener || (isJQuery(value) && ((_a = value[0]) === null || _a === void 0 ? void 0 : _a.addEventListener))));
220
216
  }
221
- function isPromise(object) {
222
- return isObject(object) && isFunction(object.then);
217
+ function isPromise(value) {
218
+ return isObject(value) && isFunction(value.then);
223
219
  }
224
220
  const { isArray } = Array;
225
- function isFormData(object) {
226
- return object instanceof FormData;
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
- return setTimeout(task);
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(functions) {
496
- functions = compact(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);
@@ -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 results = [];
1094
+ const descendantMatches = root.querySelectorAll(selector);
1093
1095
  if (elementLikeMatches(root, selector)) {
1094
- results.push(root);
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 = first(selector)) === null || _a === void 0 ? void 0 : _a.getAttribute('content');
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 fixParserDamage(scriptish) {
1344
- let clone = createFromHTML(scriptish.outerHTML);
1345
- scriptish.replaceWith(clone);
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
- fixParserDamage,
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._parserOptions);
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
- /* 20 */
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
- /* 21 */
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
- /* 22 */
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
- /* 23 */
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
- /* 24 */
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
- /* 25 */
2202
+ /* 26 */
2158
2203
  /***/ (function() {
2159
2204
 
2160
2205
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -2290,7 +2335,7 @@ up.RenderJob = (_a = class RenderJob {
2290
2335
 
2291
2336
 
2292
2337
  /***/ }),
2293
- /* 26 */
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._wipe();
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._wipe();
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
- _wipe() {
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
- /* 27 */
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
- /* 28 */
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
- /* 29 */
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._preserveKeepables(step);
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._restoreKeepables(step);
2779
+ this._restoreDescendantKeepables(step);
2735
2780
  this.responseDoc.finalizeElement(step.newElement);
2736
- this._unmarkKeepables(step);
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
- _preserveKeepables(step) {
2808
- const keepPlans = [];
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 = viewports.map(function (viewport) {
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._willChangeElement(document.body)) {
2867
+ if (this._willChangeBody()) {
2823
2868
  keepPlan.newElement.replaceWith(keepable);
2824
2869
  }
2825
2870
  else {
2826
- document.body.append(keepable);
2871
+ e.preservingAppend(document.body, keepable);
2827
2872
  }
2828
- keepPlans.push(keepPlan);
2873
+ descendantKeepPlans.push(keepPlan);
2829
2874
  }
2830
2875
  }
2831
2876
  }
2832
- step.keepPlans = keepPlans;
2877
+ step.descendantKeepPlans = descendantKeepPlans;
2833
2878
  }
2834
- _restoreKeepables(step) {
2835
- for (let keepPlan of step.keepPlans) {
2836
- keepPlan.newElement.replaceWith(keepPlan.oldElement);
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
- _unmarkKeepables(step) {
2843
- for (let keepPlan of step.keepPlans) {
2892
+ _finalizeDescendantKeepables(step) {
2893
+ for (let keepPlan of step.descendantKeepPlans) {
2844
2894
  keepPlan.oldElement.classList.remove('up-keeping');
2845
2895
  }
2846
2896
  }
2847
- _willChangeElement(element) {
2848
- return u.some(this._steps, (step) => step.oldElement.contains(element));
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
- /* 30 */
2912
+ /* 31 */
2863
2913
  /***/ (() => {
2864
2914
 
2865
2915
  const u = up.util;
@@ -2939,7 +2989,7 @@ up.Change.CloseLayer = class CloseLayer extends up.Change {
2939
2989
 
2940
2990
 
2941
2991
  /***/ }),
2942
- /* 31 */
2992
+ /* 32 */
2943
2993
  /***/ (function() {
2944
2994
 
2945
2995
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -2969,7 +3019,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
2969
3019
  return request;
2970
3020
  (_e = (_d = this.options).handleAbort) === null || _e === void 0 ? void 0 : _e.call(_d, request);
2971
3021
  request.runPreviews(this.options);
2972
- return yield u.always(request, responseOrError => this._onRequestSettled(responseOrError));
3022
+ return yield u.always(request, (responseOrError) => this._onRequestSettled(responseOrError));
2973
3023
  });
2974
3024
  }
2975
3025
  _newPageReason() {
@@ -3024,7 +3074,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
3024
3074
 
3025
3075
 
3026
3076
  /***/ }),
3027
- /* 32 */
3077
+ /* 33 */
3028
3078
  /***/ (function() {
3029
3079
 
3030
3080
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -3140,6 +3190,11 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
3140
3190
  renderOptions.source = this.improveHistoryValue(renderOptions.source, 'keep');
3141
3191
  renderOptions.history = !!renderOptions.location;
3142
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
+ }
3143
3198
  renderOptions.location = this.improveHistoryValue(renderOptions.location, serverLocation);
3144
3199
  renderOptions.title = this.improveHistoryValue(renderOptions.title, this._response.title);
3145
3200
  renderOptions.eventPlans = this._response.eventPlans;
@@ -3154,7 +3209,7 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
3154
3209
  renderOptions.target = ':none';
3155
3210
  }
3156
3211
  renderOptions.context = u.merge(renderOptions.context, this._response.context);
3157
- renderOptions.cspNonces = this._response.cspNonces;
3212
+ renderOptions.cspInfo = this._response.cspInfo;
3158
3213
  (_b = renderOptions.time) !== null && _b !== void 0 ? _b : (renderOptions.time = this._response.lastModified);
3159
3214
  (_c = renderOptions.etag) !== null && _c !== void 0 ? _c : (renderOptions.etag = this._response.etag);
3160
3215
  }
@@ -3168,7 +3223,7 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
3168
3223
 
3169
3224
 
3170
3225
  /***/ }),
3171
- /* 33 */
3226
+ /* 34 */
3172
3227
  /***/ (() => {
3173
3228
 
3174
3229
  var _a;
@@ -3242,7 +3297,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3242
3297
  'fragment',
3243
3298
  'document',
3244
3299
  'html',
3245
- 'cspNonces',
3300
+ 'cspInfo',
3246
3301
  'origin',
3247
3302
  'data',
3248
3303
  ]);
@@ -3274,7 +3329,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3274
3329
  return this._expandTargets(target || ':main', layer)[0];
3275
3330
  }
3276
3331
  getPreflightProps(opts = {}) {
3277
- const getPlanProps = plan => plan.getPreflightProps();
3332
+ const getPlanProps = (plan) => plan.getPreflightProps();
3278
3333
  return this._seekPlan(getPlanProps) || opts.optional || this._cannotMatchPreflightTarget();
3279
3334
  }
3280
3335
  _cannotMatchPreflightTarget() {
@@ -3326,7 +3381,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3326
3381
 
3327
3382
 
3328
3383
  /***/ }),
3329
- /* 34 */
3384
+ /* 35 */
3330
3385
  /***/ (() => {
3331
3386
 
3332
3387
  const u = up.util;
@@ -3422,7 +3477,7 @@ up.CompilerPass = class CompilerPass {
3422
3477
 
3423
3478
 
3424
3479
  /***/ }),
3425
- /* 35 */
3480
+ /* 36 */
3426
3481
  /***/ (() => {
3427
3482
 
3428
3483
  const u = up.util;
@@ -3529,7 +3584,7 @@ up.CSSTransition = class CSSTransition {
3529
3584
 
3530
3585
 
3531
3586
  /***/ }),
3532
- /* 36 */
3587
+ /* 37 */
3533
3588
  /***/ (() => {
3534
3589
 
3535
3590
  const u = up.util;
@@ -3552,7 +3607,7 @@ up.DestructorPass = class DestructorPass {
3552
3607
 
3553
3608
 
3554
3609
  /***/ }),
3555
- /* 37 */
3610
+ /* 38 */
3556
3611
  /***/ (() => {
3557
3612
 
3558
3613
  const u = up.util;
@@ -3652,7 +3707,7 @@ up.EventEmitter = class EventEmitter extends up.Record {
3652
3707
 
3653
3708
 
3654
3709
  /***/ }),
3655
- /* 38 */
3710
+ /* 39 */
3656
3711
  /***/ (() => {
3657
3712
 
3658
3713
  const u = up.util;
@@ -3705,7 +3760,8 @@ up.EventListener = class EventListener extends up.Record {
3705
3760
  }
3706
3761
  let element = event.target;
3707
3762
  if (this.selector) {
3708
- element = element.closest(u.evalOption(this.selector));
3763
+ let selector = u.evalOption(this.selector);
3764
+ element = element.closest(selector);
3709
3765
  }
3710
3766
  if (this.guard && !this.guard(event)) {
3711
3767
  return;
@@ -3759,7 +3815,7 @@ up.EventListener = class EventListener extends up.Record {
3759
3815
 
3760
3816
 
3761
3817
  /***/ }),
3762
- /* 39 */
3818
+ /* 40 */
3763
3819
  /***/ (() => {
3764
3820
 
3765
3821
  const u = up.util;
@@ -3805,7 +3861,7 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
3805
3861
  }
3806
3862
  });
3807
3863
  }
3808
- static fromBindArgs(args, defaults) {
3864
+ static fromBindArgs(args, overrides) {
3809
3865
  args = u.copy(args);
3810
3866
  const callback = args.pop();
3811
3867
  let elements;
@@ -3825,14 +3881,64 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
3825
3881
  }
3826
3882
  const options = u.extractOptions(args);
3827
3883
  const selector = args[0];
3828
- const attributes = Object.assign(Object.assign({ elements, eventTypes, selector, callback }, options), defaults);
3884
+ const attributes = Object.assign(Object.assign({ elements, eventTypes, selector, callback }, options), overrides);
3829
3885
  return new (this)(attributes);
3830
3886
  }
3831
3887
  };
3832
3888
 
3833
3889
 
3834
3890
  /***/ }),
3835
- /* 40 */
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 */
3836
3942
  /***/ (function() {
3837
3943
 
3838
3944
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -3847,42 +3953,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
3847
3953
  const u = up.util;
3848
3954
  up.FieldWatcher = class FieldWatcher {
3849
3955
  constructor(root, options, callback) {
3956
+ var _a;
3850
3957
  this._options = options;
3851
3958
  this._root = root;
3852
- this._scope = up.form.getScope(root);
3853
3959
  this._callback = callback;
3854
3960
  this._batch = options.batch;
3961
+ this._logPrefix = (_a = options.logPrefix) !== null && _a !== void 0 ? _a : 'up.watch()';
3962
+ this._ensureWatchable();
3855
3963
  }
3856
3964
  start() {
3857
3965
  this._scheduledValues = null;
3858
3966
  this._processedValues = this._readFieldValues();
3859
3967
  this._currentTimer = null;
3860
3968
  this._callbackRunning = false;
3861
- this._cleaner = u.cleaner();
3862
- this._watchFieldsWithin(this._root);
3863
- this._root.addEventListener('up:fragment:inserted', ({ target }) => {
3864
- if (target !== this._root)
3865
- this._watchFieldsWithin(target);
3866
- });
3867
- this._cleaner(up.fragment.onAborted(this._scope, () => this._abort()));
3868
- 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());
3869
3970
  }
3870
- stop() {
3871
- this._abort();
3872
- this._cleaner.clean();
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);
3873
3990
  }
3874
3991
  _fieldOptions(field) {
3875
3992
  let rootOptions = u.copy(this._options);
3876
3993
  return up.form.watchOptions(field, rootOptions, { defaults: { event: 'input' } });
3877
3994
  }
3878
- _watchFieldsWithin(container) {
3879
- for (let field of up.form.fields(container)) {
3880
- this._watchField(field);
3881
- }
3882
- }
3883
3995
  _watchField(field) {
3884
3996
  let fieldOptions = this._fieldOptions(field);
3885
- this._cleaner(up.on(field, fieldOptions.event, () => this._check(fieldOptions)));
3997
+ let eventType = fieldOptions.event;
3998
+ return up.on(field, eventType, (event) => this._check(event, fieldOptions));
3886
3999
  }
3887
4000
  _abort() {
3888
4001
  this._scheduledValues = null;
@@ -3908,7 +4021,7 @@ up.FieldWatcher = class FieldWatcher {
3908
4021
  return;
3909
4022
  if (this._currentTimer)
3910
4023
  return;
3911
- if (!this._scope.isConnected)
4024
+ if (!up.fragment.isAlive(this._region))
3912
4025
  return;
3913
4026
  let callbackOptions = u.omit(this._scheduledFieldOptions, ['event', 'delay']);
3914
4027
  const diff = this._changedValues(this._processedValues, this._scheduledValues);
@@ -3954,20 +4067,143 @@ up.FieldWatcher = class FieldWatcher {
3954
4067
  _readFieldValues() {
3955
4068
  return up.Params.fromContainer(this._root).toObject();
3956
4069
  }
3957
- _check(fieldOptions = {}) {
4070
+ _check(event, fieldOptions = {}) {
4071
+ up.log.putsEvent(event);
3958
4072
  const values = this._readFieldValues();
3959
4073
  if (this._isNewValues(values)) {
3960
4074
  this._scheduleValues(values, fieldOptions);
3961
4075
  }
3962
4076
  }
3963
- _onFormReset() {
3964
- u.task(() => this._check());
4077
+ _onFormReset(event) {
4078
+ u.task(() => this._check(event));
3965
4079
  }
3966
4080
  };
3967
4081
 
3968
4082
 
3969
4083
  /***/ }),
3970
- /* 41 */
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 */
3971
4207
  /***/ (function() {
3972
4208
 
3973
4209
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -3998,41 +4234,52 @@ up.FormValidator = class FormValidator {
3998
4234
  this._dirtySolutions = [];
3999
4235
  this._nextRenderTimer = null;
4000
4236
  this._rendering = false;
4001
- this._resetNextRenderPromise();
4002
4237
  this._honorAbort();
4003
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
+ }
4004
4254
  _honorAbort() {
4005
4255
  up.fragment.onAborted(this._form, (event) => this._onAborted(event));
4006
4256
  }
4007
4257
  _onAborted(event) {
4008
- if (this._dirtySolutions.length) {
4009
- this._dirtySolutions = [];
4010
- this._nextRenderPromise.reject(new up.Aborted(event.reason));
4011
- this._resetNextRenderPromise();
4258
+ let abortedError = new up.Aborted(event.reason);
4259
+ let solution;
4260
+ while (solution = this._dirtySolutions.shift()) {
4261
+ solution.deferred.reject(abortedError);
4012
4262
  }
4013
4263
  }
4014
- _resetNextRenderPromise() {
4015
- this._nextRenderPromise = u.newDeferred();
4016
- }
4017
- watchContainer(fieldOrForm) {
4018
- let { event } = this._originOptions(fieldOrForm);
4019
- let guard = () => up.fragment.isAlive(fieldOrForm);
4020
- let callback = () => up.error.muteUncriticalRejection(this.validate({ origin: fieldOrForm }));
4021
- up.on(fieldOrForm, event, { guard }, callback);
4022
- }
4023
4264
  validate(options = {}) {
4024
- let solutions = this._getSolutions(options);
4025
- this._dirtySolutions.push(...solutions);
4265
+ var _a;
4266
+ let newSolutions = this._getSolutions(options);
4267
+ this._dirtySolutions.push(...newSolutions);
4026
4268
  this._scheduleNextRender();
4027
- return this._nextRenderPromise;
4269
+ return (_a = newSolutions[0]) === null || _a === void 0 ? void 0 : _a.deferred;
4028
4270
  }
4029
4271
  _getSolutions(options) {
4030
4272
  let solutions = this._getTargetSelectorSolutions(options)
4031
4273
  || this._getFieldSolutions(options)
4032
4274
  || this._getElementSolutions(options.origin);
4275
+ let deferred = u.newDeferred();
4033
4276
  for (let solution of solutions) {
4034
- solution.renderOptions = this._originOptions(solution.origin, options);
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}`;
4035
4281
  solution.target = up.fragment.resolveOrigin(solution.target, solution);
4282
+ solution.deferred = deferred;
4036
4283
  }
4037
4284
  return solutions;
4038
4285
  }
@@ -4085,9 +4332,6 @@ up.FormValidator = class FormValidator {
4085
4332
  return this._getTargetSelectorSolutions({ target, origin: field });
4086
4333
  }
4087
4334
  }
4088
- _originOptions(element, overrideOptions) {
4089
- return up.form.watchOptions(element, overrideOptions, { defaults: { event: 'change' } });
4090
- }
4091
4335
  _scheduleNextRender() {
4092
4336
  let solutionDelays = this._dirtySolutions.map((solution) => solution.renderOptions.delay);
4093
4337
  let shortestDelay = Math.min(...solutionDelays) || 0;
@@ -4108,14 +4352,15 @@ up.FormValidator = class FormValidator {
4108
4352
  return;
4109
4353
  if (this._nextRenderTimer)
4110
4354
  return;
4111
- let options = this._mergeRenderOptions(this._dirtySolutions);
4112
- this._dirtySolutions = [];
4355
+ let solutionsBatch = this._selectDirtySolutionsBatch();
4356
+ let renderOptions = this._mergeRenderOptions(solutionsBatch);
4113
4357
  this._rendering = true;
4114
- let renderingPromise = this._nextRenderPromise;
4115
- this._resetNextRenderPromise();
4116
4358
  try {
4117
- renderingPromise.resolve(up.render(options));
4118
- yield renderingPromise;
4359
+ let renderPromise = up.render(renderOptions);
4360
+ for (let solution of solutionsBatch) {
4361
+ solution.deferred.resolve(renderPromise);
4362
+ }
4363
+ yield renderPromise;
4119
4364
  }
4120
4365
  finally {
4121
4366
  this._rendering = false;
@@ -4123,20 +4368,39 @@ up.FormValidator = class FormValidator {
4123
4368
  }
4124
4369
  });
4125
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
+ }
4126
4389
  _mergeRenderOptions(dirtySolutions) {
4127
4390
  var _a;
4128
4391
  let dirtyOrigins = u.map(dirtySolutions, 'origin');
4129
4392
  let dirtyFields = u.flatMap(dirtyOrigins, up.form.fields);
4130
4393
  let dirtyNames = u.uniq(u.map(dirtyFields, 'name'));
4131
4394
  let dirtyRenderOptionsList = u.map(dirtySolutions, 'renderOptions');
4132
- let options = u.mergeDefined(...dirtyRenderOptionsList, up.form.destinationOptions(this._form));
4395
+ let formDestinationOptions = up.form.destinationOptions(this._form);
4396
+ let options = u.mergeDefined(formDestinationOptions, ...dirtyRenderOptionsList);
4133
4397
  options.target = u.map(dirtySolutions, 'target').join(', ');
4134
4398
  options.origin = this._form;
4135
4399
  (_a = options.focus) !== null && _a !== void 0 ? _a : (options.focus = 'keep');
4136
4400
  options.failOptions = false;
4137
4401
  options.defaultMaybe = true;
4138
- options.params = up.Params.merge(options.params, ...u.map(dirtyRenderOptionsList, 'params'));
4139
- options.headers = u.merge(options.headers, ...u.map(dirtyRenderOptionsList, 'headers'));
4402
+ options.params = up.Params.merge(formDestinationOptions.params, ...u.map(dirtyRenderOptionsList, 'params'));
4403
+ options.headers = u.merge(formDestinationOptions.headers, ...u.map(dirtyRenderOptionsList, 'headers'));
4140
4404
  this._addValidateHeader(options.headers, dirtyNames);
4141
4405
  options.feedback = u.some(dirtyRenderOptionsList, 'feedback');
4142
4406
  options.data = undefined;
@@ -4164,15 +4428,11 @@ up.FormValidator = class FormValidator {
4164
4428
  value = ':unknown';
4165
4429
  headers[key] = value;
4166
4430
  }
4167
- static forElement(element) {
4168
- let form = up.form.get(element);
4169
- return form.upFormValidator || (form.upFormValidator = new this(form));
4170
- }
4171
4431
  };
4172
4432
 
4173
4433
 
4174
4434
  /***/ }),
4175
- /* 42 */
4435
+ /* 45 */
4176
4436
  /***/ (() => {
4177
4437
 
4178
4438
  up.FocusCapsule = class FocusCapsule {
@@ -4211,7 +4471,7 @@ up.FocusCapsule = class FocusCapsule {
4211
4471
 
4212
4472
 
4213
4473
  /***/ }),
4214
- /* 43 */
4474
+ /* 46 */
4215
4475
  /***/ (() => {
4216
4476
 
4217
4477
  const u = up.util;
@@ -4254,7 +4514,7 @@ up.FragmentProcessor = class FragmentProcessor extends up.Record {
4254
4514
  return this.processPrimitive(opt);
4255
4515
  }
4256
4516
  processArray(array) {
4257
- return u.find(array, opt => this.tryProcess(opt));
4517
+ return u.find(array, (opt) => this.tryProcess(opt));
4258
4518
  }
4259
4519
  resolveCondition(condition) {
4260
4520
  if (condition === 'main') {
@@ -4276,7 +4536,7 @@ up.FragmentProcessor = class FragmentProcessor extends up.Record {
4276
4536
 
4277
4537
 
4278
4538
  /***/ }),
4279
- /* 44 */
4539
+ /* 47 */
4280
4540
  /***/ (() => {
4281
4541
 
4282
4542
  const u = up.util;
@@ -4327,7 +4587,7 @@ up.FragmentFinder = class FragmentFinder {
4327
4587
 
4328
4588
 
4329
4589
  /***/ }),
4330
- /* 45 */
4590
+ /* 48 */
4331
4591
  /***/ (() => {
4332
4592
 
4333
4593
  const u = up.util;
@@ -4337,6 +4597,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
4337
4597
  keys() {
4338
4598
  return super.keys().concat([
4339
4599
  'hash',
4600
+ 'focusVisible',
4340
4601
  'focusCapsule',
4341
4602
  'inputDevice',
4342
4603
  ]);
@@ -4394,7 +4655,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
4394
4655
  }
4395
4656
  _focusElement(element) {
4396
4657
  if (element) {
4397
- 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 }));
4398
4659
  return true;
4399
4660
  }
4400
4661
  }
@@ -4412,7 +4673,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
4412
4673
 
4413
4674
 
4414
4675
  /***/ }),
4415
- /* 46 */
4676
+ /* 49 */
4416
4677
  /***/ (() => {
4417
4678
 
4418
4679
  const e = up.element;
@@ -4499,6 +4760,11 @@ up.FragmentPolling = class FragmentPolling {
4499
4760
  if (this._state !== 'started') {
4500
4761
  return;
4501
4762
  }
4763
+ if (!up.fragment.isAlive(this._fragment)) {
4764
+ this._stop();
4765
+ up.puts('[up-poll]', 'Stopped polling a detached fragment');
4766
+ return;
4767
+ }
4502
4768
  if (!this._isFragmentVisible()) {
4503
4769
  up.puts('[up-poll]', 'Will not poll hidden fragment');
4504
4770
  return;
@@ -4570,7 +4836,7 @@ up.FragmentPolling = class FragmentPolling {
4570
4836
 
4571
4837
 
4572
4838
  /***/ }),
4573
- /* 47 */
4839
+ /* 50 */
4574
4840
  /***/ (() => {
4575
4841
 
4576
4842
  const u = up.util;
@@ -4587,8 +4853,10 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
4587
4853
  }
4588
4854
  processPrimitive(opt) {
4589
4855
  switch (opt) {
4590
- case 'reset':
4591
- return this._reset();
4856
+ case 'top':
4857
+ return this._scrollTo(0);
4858
+ case 'bottom':
4859
+ return this._scrollTo(99999999);
4592
4860
  case 'layer':
4593
4861
  return this._revealLayer();
4594
4862
  case 'main':
@@ -4623,9 +4891,8 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
4623
4891
  _revealLayer() {
4624
4892
  return this._revealElement(this.layer.getBoxElement());
4625
4893
  }
4626
- _reset() {
4627
- up.viewport.resetScroll(Object.assign(Object.assign({}, this.attributes()), { around: this.fragment }));
4628
- return true;
4894
+ _scrollTo(position) {
4895
+ return up.viewport.scrollTo(position, Object.assign(Object.assign({}, this.attributes()), { around: this.fragment }));
4629
4896
  }
4630
4897
  _restore() {
4631
4898
  return up.viewport.restoreScroll(Object.assign(Object.assign({}, this.attributes()), { around: this.fragment }));
@@ -4634,7 +4901,7 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
4634
4901
 
4635
4902
 
4636
4903
  /***/ }),
4637
- /* 48 */
4904
+ /* 51 */
4638
4905
  /***/ (() => {
4639
4906
 
4640
4907
  const e = up.element;
@@ -4872,7 +5139,7 @@ up.Layer = class Layer extends up.Record {
4872
5139
  up.history.push(location);
4873
5140
  }
4874
5141
  if (!this.opening) {
4875
- this.emit('up:layer:location:changed', { location });
5142
+ this.emit('up:layer:location:changed', { location, log: false });
4876
5143
  }
4877
5144
  }
4878
5145
  }
@@ -4902,7 +5169,7 @@ up.Layer = class Layer extends up.Record {
4902
5169
 
4903
5170
 
4904
5171
  /***/ }),
4905
- /* 49 */
5172
+ /* 52 */
4906
5173
  /***/ (function() {
4907
5174
 
4908
5175
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -5012,7 +5279,7 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
5012
5279
  }
5013
5280
  if (this._supportsDismissMethod('outside')) {
5014
5281
  if (this.viewportElement) {
5015
- up.on(this.viewportElement, 'up:click', event => {
5282
+ up.on(this.viewportElement, 'up:click', (event) => {
5016
5283
  if (event.target === this.viewportElement) {
5017
5284
  this._onOutsideClicked(event, true);
5018
5285
  }
@@ -5028,17 +5295,17 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
5028
5295
  }
5029
5296
  }
5030
5297
  if (this._supportsDismissMethod('key')) {
5031
- this.unbindEscapePressed = up.event.onEscape(event => this.onEscapePressed(event));
5298
+ this.unbindEscapePressed = up.event.onEscape((event) => this.onEscapePressed(event));
5032
5299
  }
5033
- this.registerClickCloser('up-accept', (value, closeOptions) => {
5300
+ this.registerAttrCloser('up-accept', (value, closeOptions) => {
5034
5301
  this.accept(value, closeOptions);
5035
5302
  });
5036
- this.registerClickCloser('up-dismiss', (value, closeOptions) => {
5303
+ this.registerAttrCloser('up-dismiss', (value, closeOptions) => {
5037
5304
  this.dismiss(value, closeOptions);
5038
5305
  });
5039
5306
  (_c = (_b = up.migrate).registerLayerCloser) === null || _c === void 0 ? void 0 : _c.call(_b, this);
5040
- this._registerEventCloser(this.acceptEvent, this.accept);
5041
- this._registerEventCloser(this.dismissEvent, this.dismiss);
5307
+ this._registerExternalEventCloser(this.acceptEvent, this.accept);
5308
+ this._registerExternalEventCloser(this.dismissEvent, this.dismiss);
5042
5309
  this.on('up:click', 'label[for]', (event, label) => this._onLabelClicked(event, label));
5043
5310
  }
5044
5311
  _onLabelClicked(event, label) {
@@ -5073,26 +5340,38 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
5073
5340
  }
5074
5341
  }
5075
5342
  }
5076
- registerClickCloser(attribute, closeFn) {
5077
- let selector = `[${attribute}]`;
5078
- this.on('up:click', selector, function (event) {
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) => {
5079
5356
  up.event.halt(event, { log: true });
5080
- const origin = event.target.closest(selector);
5081
- const value = e.jsonAttr(origin, attribute);
5082
- const closeOptions = { origin };
5083
- const parser = new up.OptionsParser(origin, closeOptions);
5084
- parser.booleanOrString('animation');
5085
- parser.string('easing');
5086
- parser.number('duration');
5087
- parser.string('confirm');
5088
- up.error.muteUncriticalSync(() => closeFn(value, closeOptions));
5357
+ const value = up.Params.fromForm(form);
5358
+ this._onAttrCloserActivated(form, value, closeFn);
5089
5359
  });
5090
5360
  }
5091
- _registerEventCloser(eventTypes, closeFn) {
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) {
5092
5371
  if (!eventTypes) {
5093
5372
  return;
5094
5373
  }
5095
- return this.on(eventTypes, event => {
5374
+ return this.on(eventTypes, (event) => {
5096
5375
  event.preventDefault();
5097
5376
  up.error.muteUncriticalSync(() => closeFn.call(this, event, { response: event.response }));
5098
5377
  });
@@ -5201,11 +5480,12 @@ up.Layer.Overlay = (_a = class Overlay extends up.Layer {
5201
5480
  'closeEasing',
5202
5481
  'trapFocus',
5203
5482
  ],
5483
+ _a.UNSET_VISUALS = u.spanObject(_a.VISUAL_KEYS, undefined),
5204
5484
  _a);
5205
5485
 
5206
5486
 
5207
5487
  /***/ }),
5208
- /* 50 */
5488
+ /* 53 */
5209
5489
  /***/ (() => {
5210
5490
 
5211
5491
  up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
@@ -5244,7 +5524,7 @@ up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
5244
5524
 
5245
5525
 
5246
5526
  /***/ }),
5247
- /* 51 */
5527
+ /* 54 */
5248
5528
  /***/ (() => {
5249
5529
 
5250
5530
  up.Layer.OverlayWithViewport = class OverlayWithViewport extends up.Layer.Overlay {
@@ -5273,7 +5553,7 @@ up.Layer.OverlayWithViewport = class OverlayWithViewport extends up.Layer.Overla
5273
5553
 
5274
5554
 
5275
5555
  /***/ }),
5276
- /* 52 */
5556
+ /* 55 */
5277
5557
  /***/ (() => {
5278
5558
 
5279
5559
  var _a;
@@ -5319,7 +5599,7 @@ up.Layer.Root = (_a = class Root extends up.Layer {
5319
5599
 
5320
5600
 
5321
5601
  /***/ }),
5322
- /* 53 */
5602
+ /* 56 */
5323
5603
  /***/ (() => {
5324
5604
 
5325
5605
  var _a;
@@ -5330,7 +5610,7 @@ up.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {
5330
5610
 
5331
5611
 
5332
5612
  /***/ }),
5333
- /* 54 */
5613
+ /* 57 */
5334
5614
  /***/ (() => {
5335
5615
 
5336
5616
  var _a;
@@ -5341,7 +5621,7 @@ up.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {
5341
5621
 
5342
5622
 
5343
5623
  /***/ }),
5344
- /* 55 */
5624
+ /* 58 */
5345
5625
  /***/ (() => {
5346
5626
 
5347
5627
  var _a;
@@ -5352,7 +5632,7 @@ up.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {
5352
5632
 
5353
5633
 
5354
5634
  /***/ }),
5355
- /* 56 */
5635
+ /* 59 */
5356
5636
  /***/ (() => {
5357
5637
 
5358
5638
  var _a;
@@ -5363,7 +5643,7 @@ up.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {
5363
5643
 
5364
5644
 
5365
5645
  /***/ }),
5366
- /* 57 */
5646
+ /* 60 */
5367
5647
  /***/ (() => {
5368
5648
 
5369
5649
  var _a;
@@ -5379,7 +5659,7 @@ up.LayerLookup = (_a = class LayerLookup {
5379
5659
  this._values = u.getSimpleTokens(options.layer);
5380
5660
  }
5381
5661
  all() {
5382
- let results = u.flatMap(this._values, value => this._resolveValue(value));
5662
+ let results = u.flatMap(this._values, (value) => this._resolveValue(value));
5383
5663
  results = u.compact(results);
5384
5664
  results = u.uniq(results);
5385
5665
  return results;
@@ -5394,7 +5674,7 @@ up.LayerLookup = (_a = class LayerLookup {
5394
5674
  }
5395
5675
  _forElement(element) {
5396
5676
  element = e.get(element);
5397
- return u.find(this._stack.reversed(), layer => layer.contains(element));
5677
+ return u.find(this._stack.reversed(), (layer) => layer.contains(element));
5398
5678
  }
5399
5679
  _forIndex(value) {
5400
5680
  return this._stack.at(value);
@@ -5476,7 +5756,7 @@ up.LayerLookup = (_a = class LayerLookup {
5476
5756
 
5477
5757
 
5478
5758
  /***/ }),
5479
- /* 58 */
5759
+ /* 61 */
5480
5760
  /***/ (() => {
5481
5761
 
5482
5762
  const u = up.util;
@@ -5590,7 +5870,7 @@ up.LayerStack = class LayerStack {
5590
5870
 
5591
5871
 
5592
5872
  /***/ }),
5593
- /* 59 */
5873
+ /* 62 */
5594
5874
  /***/ (() => {
5595
5875
 
5596
5876
  const u = up.util;
@@ -5625,7 +5905,7 @@ up.LinkCurrentURLs = class LinkCurrentURLs {
5625
5905
 
5626
5906
 
5627
5907
  /***/ }),
5628
- /* 60 */
5908
+ /* 63 */
5629
5909
  /***/ (() => {
5630
5910
 
5631
5911
  const u = up.util;
@@ -5668,13 +5948,15 @@ up.LinkFollowIntent = class LinkFollowIntent {
5668
5948
  }
5669
5949
  _runCallback(event) {
5670
5950
  up.log.putsEvent(event);
5951
+ if (!up.fragment.isAlive(this._link))
5952
+ return;
5671
5953
  this._callback({ onRequestKnown: (request) => this._lastRequest = request });
5672
5954
  }
5673
5955
  };
5674
5956
 
5675
5957
 
5676
5958
  /***/ }),
5677
- /* 61 */
5959
+ /* 64 */
5678
5960
  /***/ (function() {
5679
5961
 
5680
5962
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -5727,7 +6009,7 @@ up.MotionController = class MotionController {
5727
6009
  }
5728
6010
  _expandFinishRequest(elements) {
5729
6011
  if (elements) {
5730
- 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)));
5731
6013
  }
5732
6014
  else {
5733
6015
  return document.querySelectorAll(this._selector);
@@ -5783,10 +6065,9 @@ up.MotionController = class MotionController {
5783
6065
 
5784
6066
 
5785
6067
  /***/ }),
5786
- /* 62 */
6068
+ /* 65 */
5787
6069
  /***/ (() => {
5788
6070
 
5789
- const u = up.util;
5790
6071
  const e = up.element;
5791
6072
  up.NonceableCallback = class NonceableCallback {
5792
6073
  constructor(script, nonce) {
@@ -5840,37 +6121,11 @@ up.NonceableCallback = class NonceableCallback {
5840
6121
  }
5841
6122
  }
5842
6123
  }
5843
- _allowedBy(allowedNonces) {
5844
- return this.nonce && u.contains(allowedNonces, this.nonce);
5845
- }
5846
- static adoptNonces(element, allowedNonces) {
5847
- if (!(allowedNonces === null || allowedNonces === void 0 ? void 0 : allowedNonces.length)) {
5848
- return;
5849
- }
5850
- const getPageNonce = u.memoize(up.protocol.cspNonce);
5851
- u.each(up.script.config.nonceableAttributes, (attribute) => {
5852
- let matches = e.subtree(element, `[${attribute}^="nonce-"]`);
5853
- u.each(matches, (match) => {
5854
- let attributeValue = match.getAttribute(attribute);
5855
- let callback = this.fromString(attributeValue);
5856
- let warn = (message, ...args) => up.log.warn('up.render()', `Cannot use callback [${attribute}="${attributeValue}"]: ${message}`, ...args);
5857
- if (!callback._allowedBy(allowedNonces)) {
5858
- return warn("Callback's CSP nonce (%o) does not match response header (%o)", callback.nonce, allowedNonces);
5859
- }
5860
- let pageNonce = getPageNonce();
5861
- if (!pageNonce) {
5862
- return warn("Current page's CSP nonce is unknown");
5863
- }
5864
- callback.nonce = pageNonce;
5865
- match.setAttribute(attribute, callback.toString());
5866
- });
5867
- });
5868
- }
5869
6124
  };
5870
6125
 
5871
6126
 
5872
6127
  /***/ }),
5873
- /* 63 */
6128
+ /* 66 */
5874
6129
  /***/ (() => {
5875
6130
 
5876
6131
  const e = up.element;
@@ -5892,7 +6147,7 @@ up.OverlayFocus = class OverlayFocus {
5892
6147
  'aria-modal': this._trapFocus.toString()
5893
6148
  });
5894
6149
  if (this._trapFocus) {
5895
- this._untrapFocus = up.on('focusin', event => this._onFocus(event));
6150
+ this._untrapFocus = up.on('focusin', (event) => this._onFocus(event));
5896
6151
  this._focusTrapBefore = e.affix(this._focusElement, 'beforebegin', 'up-focus-trap[tabindex=0]');
5897
6152
  this._focusTrapAfter = e.affix(this._focusElement, 'afterend', 'up-focus-trap[tabindex=0]');
5898
6153
  }
@@ -5943,7 +6198,7 @@ up.OverlayFocus = class OverlayFocus {
5943
6198
 
5944
6199
 
5945
6200
  /***/ }),
5946
- /* 64 */
6201
+ /* 67 */
5947
6202
  /***/ (() => {
5948
6203
 
5949
6204
  const u = up.util;
@@ -6080,7 +6335,7 @@ up.Params = class Params {
6080
6335
  this.entries = u.reject(this.entries, this._matchEntryFn(name));
6081
6336
  }
6082
6337
  _matchEntryFn(name) {
6083
- return entry => entry.name === name;
6338
+ return (entry) => entry.name === name;
6084
6339
  }
6085
6340
  get(name) {
6086
6341
  if (this._isArrayKey(name)) {
@@ -6177,7 +6432,7 @@ up.Params = class Params {
6177
6432
 
6178
6433
 
6179
6434
  /***/ }),
6180
- /* 65 */
6435
+ /* 68 */
6181
6436
  /***/ (() => {
6182
6437
 
6183
6438
  const u = up.util;
@@ -6248,7 +6503,7 @@ up.Preview = class Preview {
6248
6503
  }
6249
6504
  disable(...args) {
6250
6505
  let [element] = this._parseMutatorArgs(args, 'val');
6251
- this.undo(up.form.disable(element));
6506
+ this.undo(up.form.disableTemp(element));
6252
6507
  }
6253
6508
  insert(...args) {
6254
6509
  let [reference, position = 'beforeend', tempValue] = this._parseMutatorArgs(args, 'val', u.isAdjacentPosition, 'val');
@@ -6305,7 +6560,7 @@ up.Preview = class Preview {
6305
6560
 
6306
6561
 
6307
6562
  /***/ }),
6308
- /* 66 */
6563
+ /* 69 */
6309
6564
  /***/ (() => {
6310
6565
 
6311
6566
  const e = up.element;
@@ -6355,7 +6610,7 @@ up.ProgressBar = class ProgressBar {
6355
6610
 
6356
6611
 
6357
6612
  /***/ }),
6358
- /* 67 */
6613
+ /* 70 */
6359
6614
  /***/ (() => {
6360
6615
 
6361
6616
  const u = up.util;
@@ -6452,7 +6707,7 @@ up.RenderOptions = (function () {
6452
6707
  return u.merge(preprocessedOptions.defaults, lateDefaults, preprocessedOptions);
6453
6708
  }
6454
6709
  function assertContentGiven(options) {
6455
- if (!u.some(CONTENT_KEYS, contentKey => u.isGiven(options[contentKey]))) {
6710
+ if (!u.some(CONTENT_KEYS, (contentKey) => u.isGiven(options[contentKey]))) {
6456
6711
  if (options.defaultToEmptyContent) {
6457
6712
  options.content = '';
6458
6713
  }
@@ -6494,7 +6749,7 @@ up.RenderOptions = (function () {
6494
6749
 
6495
6750
 
6496
6751
  /***/ }),
6497
- /* 68 */
6752
+ /* 71 */
6498
6753
  /***/ (function() {
6499
6754
 
6500
6755
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -6553,7 +6808,7 @@ up.RenderResult = class RenderResult extends up.Record {
6553
6808
 
6554
6809
 
6555
6810
  /***/ }),
6556
- /* 69 */
6811
+ /* 72 */
6557
6812
  /***/ (() => {
6558
6813
 
6559
6814
  var _a;
@@ -6580,6 +6835,8 @@ up.Request = (_a = class Request extends up.Record {
6580
6835
  'failMode',
6581
6836
  'failContext',
6582
6837
  'origin',
6838
+ 'originLayer',
6839
+ 'originMode',
6583
6840
  'builtAt',
6584
6841
  'wrapMethod',
6585
6842
  'contentType',
@@ -6592,31 +6849,32 @@ up.Request = (_a = class Request extends up.Record {
6592
6849
  ];
6593
6850
  }
6594
6851
  defaults() {
6852
+ let config = up.network.config;
6595
6853
  return {
6596
6854
  state: 'new',
6597
6855
  abortable: true,
6598
6856
  headers: {},
6599
- timeout: up.network.config.timeout,
6857
+ timeout: config.timeout,
6600
6858
  builtAt: new Date(),
6601
6859
  previews: [],
6860
+ wrapMethod: config.wrapMethod,
6602
6861
  };
6603
6862
  }
6604
6863
  constructor(options) {
6605
- var _b, _c;
6864
+ var _b, _c, _d;
6606
6865
  super(options);
6607
6866
  this.params = new up.Params(this.params);
6608
- if (this.wrapMethod == null) {
6609
- this.wrapMethod = up.network.config.wrapMethod;
6610
- }
6611
6867
  this._normalize();
6612
6868
  if ((this.target || this.layer || this.origin) && !options.basic) {
6613
6869
  const layerLookupOptions = { origin: this.origin };
6614
6870
  this.layer = up.layer.get(this.layer, layerLookupOptions);
6615
- this.failLayer = up.layer.get(this.failLayer, layerLookupOptions);
6616
6871
  this.context || (this.context = this.layer.context || {});
6617
- this.failContext || (this.failContext = ((_b = this.failLayer) === null || _b === void 0 ? void 0 : _b.context) || {});
6618
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) || {});
6619
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);
6620
6878
  }
6621
6879
  this.bindLayer = options.bindLayer || this.layer;
6622
6880
  this._fragments = options.fragments;
@@ -6666,8 +6924,9 @@ up.Request = (_a = class Request extends up.Record {
6666
6924
  u.task(() => {
6667
6925
  this.layer = undefined;
6668
6926
  this.failLayer = undefined;
6669
- this._bindLayer = undefined;
6927
+ this.bindLayer = undefined;
6670
6928
  this.origin = undefined;
6929
+ this.originLayer = undefined;
6671
6930
  this._fragments = undefined;
6672
6931
  this._bindFragments = undefined;
6673
6932
  });
@@ -6824,6 +7083,7 @@ up.Request = (_a = class Request extends up.Record {
6824
7083
  status: this.xhr.status,
6825
7084
  title: up.protocol.titleFromXHR(this.xhr),
6826
7085
  target: up.protocol.targetFromXHR(this.xhr),
7086
+ openLayer: up.protocol.openLayerFromXHR(this.xhr),
6827
7087
  acceptLayer: up.protocol.acceptLayerFromXHR(this.xhr),
6828
7088
  dismissLayer: up.protocol.dismissLayerFromXHR(this.xhr),
6829
7089
  eventPlans: up.protocol.eventPlansFromXHR(this.xhr),
@@ -6877,7 +7137,7 @@ up.Request = (_a = class Request extends up.Record {
6877
7137
  return this.headers[name];
6878
7138
  }
6879
7139
  _setAutoHeaders() {
6880
- for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext']) {
7140
+ for (let key of ['target', 'failTarget', 'mode', 'failMode', 'context', 'failContext', 'originMode']) {
6881
7141
  this._setPropertyHeader(key);
6882
7142
  }
6883
7143
  let csrfHeader, csrfToken;
@@ -6938,7 +7198,7 @@ up.Request = (_a = class Request extends up.Record {
6938
7198
 
6939
7199
 
6940
7200
  /***/ }),
6941
- /* 70 */
7201
+ /* 73 */
6942
7202
  /***/ (function() {
6943
7203
 
6944
7204
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -7119,7 +7379,7 @@ up.Request.Cache = class Cache {
7119
7379
 
7120
7380
 
7121
7381
  /***/ }),
7122
- /* 71 */
7382
+ /* 74 */
7123
7383
  /***/ (() => {
7124
7384
 
7125
7385
  const u = up.util;
@@ -7137,7 +7397,7 @@ up.Request.Queue = class Queue {
7137
7397
  }
7138
7398
  asap(request) {
7139
7399
  request.runQueuedCallbacks();
7140
- u.always(request, responseOrError => this._onRequestSettled(request, responseOrError));
7400
+ u.always(request, (responseOrError) => this._onRequestSettled(request, responseOrError));
7141
7401
  this._scheduleSlowTimer(request);
7142
7402
  this._queueRequest(request);
7143
7403
  queueMicrotask(() => this._poke());
@@ -7168,7 +7428,7 @@ up.Request.Queue = class Queue {
7168
7428
  this._queuedRequests.push(request);
7169
7429
  }
7170
7430
  _pluckNextRequest() {
7171
- let request = u.find(this._queuedRequests, request => !request.background);
7431
+ let request = u.find(this._queuedRequests, (request) => !request.background);
7172
7432
  request || (request = this._queuedRequests[0]);
7173
7433
  return u.remove(this._queuedRequests, request);
7174
7434
  }
@@ -7230,7 +7490,7 @@ up.Request.Queue = class Queue {
7230
7490
 
7231
7491
 
7232
7492
  /***/ }),
7233
- /* 72 */
7493
+ /* 75 */
7234
7494
  /***/ (() => {
7235
7495
 
7236
7496
  const u = up.util;
@@ -7269,7 +7529,7 @@ up.Request.FormRenderer = class FormRenderer {
7269
7529
 
7270
7530
 
7271
7531
  /***/ }),
7272
- /* 73 */
7532
+ /* 76 */
7273
7533
  /***/ (() => {
7274
7534
 
7275
7535
  var _a;
@@ -7340,7 +7600,7 @@ up.Request.XHRRenderer = (_a = class XHRRenderer {
7340
7600
 
7341
7601
 
7342
7602
  /***/ }),
7343
- /* 74 */
7603
+ /* 77 */
7344
7604
  /***/ (() => {
7345
7605
 
7346
7606
  const u = up.util;
@@ -7355,6 +7615,7 @@ up.Response = class Response extends up.Record {
7355
7615
  'xhr',
7356
7616
  'target',
7357
7617
  'title',
7618
+ 'openLayer',
7358
7619
  'acceptLayer',
7359
7620
  'dismissLayer',
7360
7621
  'eventPlans',
@@ -7369,7 +7630,7 @@ up.Response = class Response extends up.Record {
7369
7630
  defaults() {
7370
7631
  return {
7371
7632
  headers: {},
7372
- loadedAt: new Date()
7633
+ loadedAt: new Date(),
7373
7634
  };
7374
7635
  }
7375
7636
  get ok() {
@@ -7390,8 +7651,9 @@ up.Response = class Response extends up.Record {
7390
7651
  get contentType() {
7391
7652
  return this.header('Content-Type');
7392
7653
  }
7393
- get cspNonces() {
7394
- return up.protocol.cspNoncesFromHeader(this.header('Content-Security-Policy') || this.header('Content-Security-Policy-Report-Only'));
7654
+ get cspInfo() {
7655
+ let policy = this.header('Content-Security-Policy') || this.header('Content-Security-Policy-Report-Only');
7656
+ return up.protocol.cspInfoFromHeader(policy);
7395
7657
  }
7396
7658
  get lastModified() {
7397
7659
  let header = this.header('Last-Modified');
@@ -7420,15 +7682,15 @@ up.Response = class Response extends up.Record {
7420
7682
 
7421
7683
 
7422
7684
  /***/ }),
7423
- /* 75 */
7685
+ /* 78 */
7424
7686
  /***/ (() => {
7425
7687
 
7426
7688
  var _a;
7427
7689
  const u = up.util;
7428
7690
  const e = up.element;
7429
- const FULL_DOCUMENT_PATTERN = /^\s*<(html|!DOCTYPE)\b/i;
7691
+ const FULL_DOCUMENT_PATTERN = /^\s*(<!--[^-]*.*?-->\s*)*<(html|!DOCTYPE)\b/i;
7430
7692
  up.ResponseDoc = (_a = class ResponseDoc {
7431
- constructor({ document, fragment, content, target, origin, data, cspNonces, match }) {
7693
+ constructor({ document, fragment, content, target, origin, data, cspInfo, match }) {
7432
7694
  if (document) {
7433
7695
  this._parseDocument(document, origin, data);
7434
7696
  }
@@ -7438,7 +7700,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
7438
7700
  else {
7439
7701
  this._parseContent(content || '', origin, target, data);
7440
7702
  }
7441
- this._cspNonces = cspNonces;
7703
+ this._cspInfo = cspInfo || {};
7442
7704
  if (origin) {
7443
7705
  let originSelector = up.fragment.tryToTarget(origin);
7444
7706
  if (originSelector) {
@@ -7467,9 +7729,6 @@ up.ResponseDoc = (_a = class ResponseDoc {
7467
7729
  this._document = this._buildFauxDocument(value);
7468
7730
  }
7469
7731
  }
7470
- _parseDocumentFromHTML(html) {
7471
- return e.createBrokenDocumentFromHTML(html);
7472
- }
7473
7732
  _parseFragment(value, origin, data) {
7474
7733
  let element = e.extractSingular(up.fragment.provideNodes(value, { origin, data }));
7475
7734
  this._document = this._buildFauxDocument(element);
@@ -7507,7 +7766,14 @@ up.ResponseDoc = (_a = class ResponseDoc {
7507
7766
  return this._fromHead(up.history.findMetaTags);
7508
7767
  }
7509
7768
  get assets() {
7510
- return this._fromHead(up.script.findAssets);
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
+ });
7511
7777
  }
7512
7778
  get lang() {
7513
7779
  if (this._isFullDocument) {
@@ -7560,21 +7826,44 @@ up.ResponseDoc = (_a = class ResponseDoc {
7560
7826
  throw new up.CannotMatch();
7561
7827
  }
7562
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
+ }
7563
7857
  commitElement(element) {
7564
7858
  if (this._document.contains(element)) {
7565
- if (!up.fragment.config.runScripts) {
7566
- up.script.disableSubtree(element);
7567
- }
7859
+ this._adoptNoncesInSubtree(element);
7860
+ this._disableScriptsInSubtree(element);
7568
7861
  element.remove();
7569
7862
  return true;
7570
7863
  }
7571
7864
  }
7572
7865
  finalizeElement(element) {
7573
- up.NonceableCallback.adoptNonces(element, this._cspNonces);
7574
- if (this._document instanceof Document) {
7575
- let brokenElements = e.subtree(element, ':is(noscript,script,audio,video):not(.up-keeping, .up-keeping *)');
7576
- u.each(brokenElements, e.fixParserDamage);
7577
- }
7866
+ this._reviveSubtreeInPlace(element);
7578
7867
  }
7579
7868
  },
7580
7869
  (() => {
@@ -7586,7 +7875,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
7586
7875
 
7587
7876
 
7588
7877
  /***/ }),
7589
- /* 76 */
7878
+ /* 79 */
7590
7879
  /***/ (() => {
7591
7880
 
7592
7881
  const e = up.element;
@@ -7677,7 +7966,7 @@ up.RevealMotion = class RevealMotion {
7677
7966
 
7678
7967
 
7679
7968
  /***/ }),
7680
- /* 77 */
7969
+ /* 80 */
7681
7970
  /***/ (() => {
7682
7971
 
7683
7972
  const u = up.util;
@@ -7700,7 +7989,7 @@ up.Selector = class Selector {
7700
7989
  this._layers = up.layer.getAll(options);
7701
7990
  if (!this._layers.length)
7702
7991
  throw new up.CannotMatch(["Unknown layer: %o", options.layer]);
7703
- 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)));
7704
7993
  expandTargetLayer = this._layers[0];
7705
7994
  }
7706
7995
  this._selectors = up.fragment.expandTargets(selector, Object.assign(Object.assign({}, options), { layer: expandTargetLayer }));
@@ -7735,7 +8024,7 @@ up.Selector = class Selector {
7735
8024
  });
7736
8025
  }
7737
8026
  _passesFilter(element) {
7738
- return element && u.every(this._filters, filter => filter(element));
8027
+ return element && u.every(this._filters, (filter) => filter(element));
7739
8028
  }
7740
8029
  _filterOne(element) {
7741
8030
  return u.presence(element, this._passesFilter.bind(this));
@@ -7747,7 +8036,7 @@ up.Selector = class Selector {
7747
8036
 
7748
8037
 
7749
8038
  /***/ }),
7750
- /* 78 */
8039
+ /* 81 */
7751
8040
  /***/ (() => {
7752
8041
 
7753
8042
  const u = up.util;
@@ -7868,7 +8157,7 @@ up.Tether = class Tether {
7868
8157
 
7869
8158
 
7870
8159
  /***/ }),
7871
- /* 79 */
8160
+ /* 82 */
7872
8161
  /***/ (() => {
7873
8162
 
7874
8163
  const u = up.util;
@@ -7942,7 +8231,7 @@ up.URLPattern = class URLPattern {
7942
8231
 
7943
8232
 
7944
8233
  /***/ }),
7945
- /* 80 */
8234
+ /* 83 */
7946
8235
  /***/ (() => {
7947
8236
 
7948
8237
  up.framework = (function () {
@@ -8031,7 +8320,7 @@ up.boot = up.framework.boot;
8031
8320
 
8032
8321
 
8033
8322
  /***/ }),
8034
- /* 81 */
8323
+ /* 84 */
8035
8324
  /***/ (() => {
8036
8325
 
8037
8326
  up.event = (function () {
@@ -8083,9 +8372,8 @@ up.event = (function () {
8083
8372
  event.preventDefault();
8084
8373
  }
8085
8374
  const keyModifiers = ['metaKey', 'shiftKey', 'ctrlKey', 'altKey'];
8086
- function isUnmodified(event) {
8087
- return (u.isUndefined(event.button) || (event.button === 0)) &&
8088
- !u.some(keyModifiers, modifier => event[modifier]);
8375
+ function isModified(event) {
8376
+ return (event.button > 0) || u.some(keyModifiers, (modifier) => event[modifier]);
8089
8377
  }
8090
8378
  function isSyntheticClick(event) {
8091
8379
  return u.isMissing(event.clientX);
@@ -8106,7 +8394,7 @@ up.event = (function () {
8106
8394
  return newEvent;
8107
8395
  }
8108
8396
  function executeEmitAttr(event, element) {
8109
- if (!isUnmodified(event)) {
8397
+ if (isModified(event)) {
8110
8398
  return;
8111
8399
  }
8112
8400
  const eventType = e.attr(element, 'up-emit');
@@ -8135,7 +8423,7 @@ up.event = (function () {
8135
8423
  assertEmitted,
8136
8424
  onEscape,
8137
8425
  halt,
8138
- isUnmodified,
8426
+ isModified,
8139
8427
  isSyntheticClick,
8140
8428
  fork,
8141
8429
  keyModifiers,
@@ -8148,14 +8436,14 @@ up.emit = up.event.emit;
8148
8436
 
8149
8437
 
8150
8438
  /***/ }),
8151
- /* 82 */
8439
+ /* 85 */
8152
8440
  /***/ (() => {
8153
8441
 
8154
8442
  up.protocol = (function () {
8155
8443
  const u = up.util;
8156
8444
  const e = up.element;
8157
8445
  const headerize = function (camel) {
8158
- const header = camel.replace(/(^.|[A-Z])/g, char => '-' + char.toUpperCase());
8446
+ const header = camel.replace(/(^.|[A-Z])/g, (char) => '-' + char.toUpperCase());
8159
8447
  return 'X-Up' + header;
8160
8448
  };
8161
8449
  const extractHeader = function (xhr, shortHeader, parseFn = u.identity) {
@@ -8195,6 +8483,9 @@ up.protocol = (function () {
8195
8483
  function eventPlansFromXHR(xhr) {
8196
8484
  return extractHeader(xhr, 'events', u.parseRelaxedJSON);
8197
8485
  }
8486
+ function openLayerFromXHR(xhr) {
8487
+ return extractHeader(xhr, 'openLayer', u.parseRelaxedJSON);
8488
+ }
8198
8489
  function acceptLayerFromXHR(xhr) {
8199
8490
  return extractHeader(xhr, 'acceptLayer', u.parseRelaxedJSON);
8200
8491
  }
@@ -8230,21 +8521,27 @@ up.protocol = (function () {
8230
8521
  function cspNonce() {
8231
8522
  return u.evalOption(config.cspNonce);
8232
8523
  }
8233
- function cspNoncesFromHeader(cspHeader) {
8234
- let nonces = [];
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 = {};
8235
8532
  if (cspHeader) {
8236
- let parts = cspHeader.split(/\s*;\s*/);
8237
- for (let part of parts) {
8238
- if (part.indexOf('script-src') === 0) {
8239
- let noncePattern = /'nonce-([^']+)'/g;
8240
- let match;
8241
- while (match = noncePattern.exec(part)) {
8242
- nonces.push(match[1]);
8243
- }
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
+ };
8244
8541
  }
8245
8542
  }
8246
8543
  }
8247
- return nonces;
8544
+ return results.script || results.default || {};
8248
8545
  }
8249
8546
  function wrapMethod(method, params) {
8250
8547
  params.add(config.methodParam, method);
@@ -8256,6 +8553,7 @@ up.protocol = (function () {
8256
8553
  titleFromXHR,
8257
8554
  targetFromXHR,
8258
8555
  methodFromXHR,
8556
+ openLayerFromXHR,
8259
8557
  acceptLayerFromXHR,
8260
8558
  contextFromXHR,
8261
8559
  dismissLayerFromXHR,
@@ -8269,13 +8567,13 @@ up.protocol = (function () {
8269
8567
  initialRequestMethod,
8270
8568
  headerize,
8271
8569
  wrapMethod,
8272
- cspNoncesFromHeader,
8570
+ cspInfoFromHeader,
8273
8571
  };
8274
8572
  })();
8275
8573
 
8276
8574
 
8277
8575
  /***/ }),
8278
- /* 83 */
8576
+ /* 86 */
8279
8577
  /***/ (() => {
8280
8578
 
8281
8579
  up.log = (function () {
@@ -8288,24 +8586,26 @@ up.log = (function () {
8288
8586
  }
8289
8587
  const printToWarn = (...args) => printToStream('warn', ...args);
8290
8588
  const printToError = (...args) => printToStream('error', ...args);
8291
- function printToStream(stream, trace, message, ...args) {
8292
- printToStreamStyled(stream, trace, '', message, ...args);
8589
+ function printToStream(stream, prefix, message, ...args) {
8590
+ printToStreamStyled(stream, prefix, '', message, ...args);
8293
8591
  }
8294
- function printToStreamStyled(stream, trace, customStyles, message, ...args) {
8592
+ function printToStreamStyled(stream, prefix, customStyles, message, ...args) {
8295
8593
  if (message) {
8296
8594
  if (config.format) {
8297
- console[stream](`%c${trace}%c ${message}`, 'color: #666666; padding: 1px 3px; border: 1px solid #bbbbbb; border-radius: 2px; font-size: 90%; display: inline-block;' + customStyles, '', ...args);
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);
8298
8596
  }
8299
8597
  else {
8300
- console[stream](`[${trace}] ${u.sprintf(message, ...args)}`);
8598
+ console[stream](`[${prefix}] ${u.sprintf(message, ...args)}`);
8301
8599
  }
8302
8600
  }
8303
8601
  }
8602
+ let lastPrintedUserEvent;
8304
8603
  function printUserEvent(event) {
8305
- if (config.enabled) {
8306
- event = event.originalEvent || event;
8604
+ if (config.enabled && lastPrintedUserEvent !== event) {
8605
+ lastPrintedUserEvent = event;
8606
+ let originalEvent = event.originalEvent || event;
8307
8607
  let color = '#5566cc';
8308
- printToStreamStyled('log', event.type, `color: white; border-color: ${color}; background-color: ${color}`, 'Interaction on %o', event.target);
8608
+ printToStreamStyled('log', originalEvent.type, `color: white; border-color: ${color}; background-color: ${color}`, 'Interaction on %o', originalEvent.target);
8309
8609
  }
8310
8610
  }
8311
8611
  function printBanner() {
@@ -8356,7 +8656,7 @@ up.warn = up.log.warn;
8356
8656
 
8357
8657
 
8358
8658
  /***/ }),
8359
- /* 84 */
8659
+ /* 87 */
8360
8660
  /***/ (() => {
8361
8661
 
8362
8662
  up.script = (function () {
@@ -8534,16 +8834,41 @@ up.script = (function () {
8534
8834
  up.event.assertEmitted('up:assets:changed', { oldAssets, newAssets, renderOptions });
8535
8835
  }
8536
8836
  }
8537
- function disableScript(scriptElement) {
8538
- scriptElement.type = 'up-disabled-script';
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
+ }
8539
8843
  }
8540
- function disableScriptsInSubtree(root) {
8541
- let selector = config.selector('scriptSelectors');
8542
- u.each(e.subtree(root, selector), disableScript);
8844
+ function findScripts(root, selectorSuffix = '') {
8845
+ let selector = config.selector('scriptSelectors') + selectorSuffix;
8846
+ return e.subtree(root, selector);
8543
8847
  }
8544
8848
  function isScript(value) {
8545
8849
  return config.matches(value, 'scriptSelectors');
8546
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
+ }
8547
8872
  function reset() {
8548
8873
  registeredCompilers = u.filter(registeredCompilers, 'isDefault');
8549
8874
  registeredMacros = u.filter(registeredMacros, 'isDefault');
@@ -8561,6 +8886,7 @@ up.script = (function () {
8561
8886
  findAssets,
8562
8887
  assertAssetsOK,
8563
8888
  disableSubtree: disableScriptsInSubtree,
8889
+ adoptNoncesInSubtree,
8564
8890
  isScript,
8565
8891
  };
8566
8892
  })();
@@ -8573,7 +8899,7 @@ up.attribute = up.script.attrCompiler;
8573
8899
 
8574
8900
 
8575
8901
  /***/ }),
8576
- /* 85 */
8902
+ /* 88 */
8577
8903
  /***/ (() => {
8578
8904
 
8579
8905
  up.history = (function () {
@@ -8599,60 +8925,76 @@ up.history = (function () {
8599
8925
  }));
8600
8926
  let previousLocation;
8601
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
+ }
8602
8933
  function reset() {
8603
8934
  previousLocation = undefined;
8604
8935
  nextPreviousLocation = undefined;
8605
- trackCurrentLocation();
8936
+ nextTrackOptions = undefined;
8937
+ adoptedBases.clear();
8938
+ trackCurrentLocation({ reason: null, alreadyHandled: true });
8939
+ adopt();
8606
8940
  }
8607
8941
  function currentLocation() {
8608
8942
  return u.normalizeURL(location.href);
8609
8943
  }
8610
- function trackCurrentLocation() {
8611
- const url = currentLocation();
8612
- if (nextPreviousLocation !== url) {
8944
+ function trackCurrentLocation(trackOptions) {
8945
+ var _a, _b;
8946
+ let { reason, alreadyHandled } = nextTrackOptions || trackOptions;
8947
+ let location = currentLocation();
8948
+ if (nextPreviousLocation !== location) {
8613
8949
  previousLocation = nextPreviousLocation;
8614
- nextPreviousLocation = url;
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
+ }
8615
8968
  }
8616
8969
  }
8617
- trackCurrentLocation();
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
+ }
8618
8976
  function isLocation(url, options) {
8619
8977
  return u.matchURLs(url, location.href, Object.assign({ hash: true }, options));
8620
8978
  }
8621
- function replace(location, options = {}) {
8622
- location = u.normalizeURL(location);
8623
- if (manipulate('replaceState', location) && (options.event !== false)) {
8624
- emitLocationChanged({ location, reason: 'replace', log: `Replaced state for ${location}` });
8625
- }
8979
+ function replace(location, trackOptions) {
8980
+ placeAdoptedHistoryEntry('replaceState', location, trackOptions);
8626
8981
  }
8627
- function push(location) {
8628
- location = u.normalizeURL(location);
8629
- if (!isLocation(location) && manipulate('pushState', location)) {
8630
- emitLocationChanged({ location, reason: 'push', log: `Advanced to location ${location}` });
8631
- }
8632
- }
8633
- function emitLocationChanged(props) {
8634
- var _a, _b;
8635
- let event = up.event.build('up:location:changed', props);
8636
- (_b = (_a = up.migrate) === null || _a === void 0 ? void 0 : _a.renamedProperty) === null || _b === void 0 ? void 0 : _b.call(_a, event, 'url', 'location');
8637
- up.emit(event);
8982
+ function push(location, trackOptions) {
8983
+ placeAdoptedHistoryEntry('pushState', location, trackOptions);
8638
8984
  }
8639
- function manipulate(method, url) {
8985
+ function placeAdoptedHistoryEntry(method, location, trackOptions) {
8986
+ adopt(location);
8640
8987
  if (config.enabled) {
8641
- const state = buildState();
8642
- window.history[method](state, '', url);
8643
- trackCurrentLocation();
8644
- return true;
8988
+ nextTrackOptions = trackOptions;
8989
+ history[method](null, '', location);
8990
+ nextTrackOptions = undefined;
8645
8991
  }
8646
8992
  }
8647
- function buildState() {
8648
- return { up: {} };
8993
+ function adopt(location = currentLocation()) {
8994
+ location = u.normalizeURL(location);
8995
+ adoptedBases.set(location, true);
8649
8996
  }
8650
- function restoreStateOnPop(state) {
8651
- if (!(state === null || state === void 0 ? void 0 : state.up)) {
8652
- up.puts('popstate', 'Ignoring a history state not owned by Unpoly');
8653
- return;
8654
- }
8655
- let location = currentLocation();
8997
+ function restoreLocation(location) {
8656
8998
  up.error.muteUncriticalRejection(up.render({
8657
8999
  guardEvent: up.event.build('up:location:restore', { location, log: `Restoring location ${location}` }),
8658
9000
  url: location,
@@ -8670,28 +9012,23 @@ up.history = (function () {
8670
9012
  focus: ['restore', 'auto'],
8671
9013
  }));
8672
9014
  }
8673
- function onPop(event) {
8674
- trackCurrentLocation();
8675
- let location = currentLocation();
8676
- emitLocationChanged({ location, reason: 'pop', log: `Navigated to history entry ${location}` });
8677
- up.viewport.saveFocus({ location: previousLocation });
8678
- up.viewport.saveScroll({ location: previousLocation });
8679
- restoreStateOnPop(event.state);
8680
- }
8681
- function register() {
8682
- window.addEventListener('popstate', onPop);
8683
- if (up.protocol.initialRequestMethod() === 'GET') {
8684
- replace(currentLocation(), { event: false });
9015
+ function reactToChange(event) {
9016
+ if (event.alreadyHandled) {
9017
+ return;
8685
9018
  }
8686
- }
8687
- up.on('up:framework:boot', function () {
8688
- if ('jasmine' in window) {
8689
- register();
9019
+ if (!event.willHandle) {
9020
+ up.puts('up.history', 'Ignoring history entry owned by foreign script');
9021
+ return;
8690
9022
  }
8691
- else {
8692
- setTimeout(register, 100);
9023
+ if (event.reason === 'pop') {
9024
+ up.viewport.saveFocus({ location: event.previousLocation });
9025
+ up.viewport.saveScroll({ location: event.previousLocation });
9026
+ restoreLocation(event.location);
8693
9027
  }
8694
- });
9028
+ else if (event.reason === 'hash') {
9029
+ up.viewport.revealHash(event.hash, { strong: true });
9030
+ }
9031
+ }
8695
9032
  function findMetaTags(head = document.head) {
8696
9033
  return head.querySelectorAll(config.selector('metaTagSelectors'));
8697
9034
  }
@@ -8713,6 +9050,63 @@ up.history = (function () {
8713
9050
  function updateLang(newLang) {
8714
9051
  e.setAttrPresence(e.root, 'lang', newLang, !!newLang);
8715
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);
8716
9110
  up.macro('[up-back]', function (link) {
8717
9111
  if (previousLocation) {
8718
9112
  e.setMissingAttrs(link, {
@@ -8740,10 +9134,10 @@ up.history = (function () {
8740
9134
 
8741
9135
 
8742
9136
  /***/ }),
8743
- /* 86 */
9137
+ /* 89 */
8744
9138
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8745
9139
 
8746
- __webpack_require__(87);
9140
+ __webpack_require__(90);
8747
9141
  const u = up.util;
8748
9142
  const e = up.element;
8749
9143
  up.fragment = (function () {
@@ -8788,6 +9182,7 @@ up.fragment = (function () {
8788
9182
  saveScroll: true,
8789
9183
  saveFocus: true,
8790
9184
  focus: 'keep',
9185
+ focusVisible: 'auto',
8791
9186
  abort: 'target',
8792
9187
  failOptions: true,
8793
9188
  feedback: true,
@@ -8802,7 +9197,7 @@ up.fragment = (function () {
8802
9197
  peel: true,
8803
9198
  },
8804
9199
  match: 'region',
8805
- runScripts: true,
9200
+ runScripts: false,
8806
9201
  autoHistoryTargets: [':main'],
8807
9202
  autoFocus: ['hash', 'autofocus', 'main-if-main', 'keep', 'target-if-lost'],
8808
9203
  autoScroll: ['hash', 'layer-if-main'],
@@ -8844,6 +9239,9 @@ up.fragment = (function () {
8844
9239
  return render(Object.assign(Object.assign({}, options), { navigate: true }));
8845
9240
  });
8846
9241
  function emitFragmentInserted(element) {
9242
+ if (element.upInserted)
9243
+ return;
9244
+ element.upInserted = true;
8847
9245
  return up.emit(element, 'up:fragment:inserted', {
8848
9246
  log: ['Inserted fragment %o', element],
8849
9247
  });
@@ -8851,8 +9249,9 @@ up.fragment = (function () {
8851
9249
  function emitFragmentKeep(keepPlan) {
8852
9250
  let { oldElement, newElement: newFragment, newData, renderOptions } = keepPlan;
8853
9251
  const log = ['Keeping fragment %o', oldElement];
8854
- const callback = e.callbackAttr(oldElement, 'up-on-keep', { exposedKeys: ['newFragment', 'newData'] });
8855
- return up.emit(oldElement, 'up:fragment:keep', { newFragment, newData, renderOptions, log, callback });
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 });
8856
9255
  }
8857
9256
  function emitFragmentDestroyed(fragment, options) {
8858
9257
  var _a;
@@ -8931,7 +9330,7 @@ up.fragment = (function () {
8931
9330
  }
8932
9331
  function markFragmentAsDestroying(element) {
8933
9332
  element.classList.add('up-destroying');
8934
- element.setAttribute('aria-hidden', 'true');
9333
+ element.setAttribute('inert', '');
8935
9334
  }
8936
9335
  function reload(...args) {
8937
9336
  var _a, _b;
@@ -8989,8 +9388,8 @@ up.fragment = (function () {
8989
9388
  function toTarget(element, options) {
8990
9389
  return u.presence(element, u.isString) || tryToTarget(element, options) || cannotTarget(element);
8991
9390
  }
8992
- function isTargetable(element) {
8993
- return !!tryToTarget(element);
9391
+ function isTargetable(element, options) {
9392
+ return !!tryToTarget(element, options);
8994
9393
  }
8995
9394
  function untargetableMessage(element) {
8996
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.`;
@@ -9208,7 +9607,7 @@ up.fragment = (function () {
9208
9607
  if (steps.length < 2)
9209
9608
  return steps;
9210
9609
  let compressed = u.uniqBy(steps, 'oldElement');
9211
- compressed = u.reject(compressed, step => isContainedByRivalStep(compressed, step));
9610
+ compressed = u.reject(compressed, (step) => isContainedByRivalStep(compressed, step));
9212
9611
  return compressed;
9213
9612
  }
9214
9613
  function abort(...args) {
@@ -9306,6 +9705,11 @@ up.fragment = (function () {
9306
9705
  return () => up.destroy(tempElement);
9307
9706
  }
9308
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
+ }
9309
9713
  up.on('up:framework:boot', function () {
9310
9714
  const { documentElement } = document;
9311
9715
  documentElement.setAttribute('up-source', normalizeSource(location.href));
@@ -9358,6 +9762,7 @@ up.fragment = (function () {
9358
9762
  insertTemp,
9359
9763
  provideNodes,
9360
9764
  cloneTemplate,
9765
+ trackSelector,
9361
9766
  };
9362
9767
  })();
9363
9768
  up.reload = up.fragment.reload;
@@ -9370,16 +9775,16 @@ u.delegate(up, ['context'], () => up.layer.current);
9370
9775
 
9371
9776
 
9372
9777
  /***/ }),
9373
- /* 87 */
9778
+ /* 90 */
9374
9779
  /***/ (() => {
9375
9780
 
9376
9781
 
9377
9782
 
9378
9783
  /***/ }),
9379
- /* 88 */
9784
+ /* 91 */
9380
9785
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9381
9786
 
9382
- __webpack_require__(89);
9787
+ __webpack_require__(92);
9383
9788
  up.viewport = (function () {
9384
9789
  const u = up.util;
9385
9790
  const e = up.element;
@@ -9442,10 +9847,26 @@ up.viewport = (function () {
9442
9847
  doFocus(element, options);
9443
9848
  return element === document.activeElement;
9444
9849
  }
9445
- function revealHash(hash = location.hash, options) {
9446
- let match = firstHashTarget(hash, options);
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 });
9447
9858
  if (match) {
9448
- return reveal(match, { top: true });
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
+ };
9449
9870
  }
9450
9871
  }
9451
9872
  function allSelector() {
@@ -9517,7 +9938,7 @@ up.viewport = (function () {
9517
9938
  const { location } = options.layer;
9518
9939
  const locationScrollTops = options.layer.lastScrollTops.get(location);
9519
9940
  if (locationScrollTops) {
9520
- setScrollTops(viewports, locationScrollTops);
9941
+ setScrollPositions(viewports, locationScrollTops, 0);
9521
9942
  up.puts('up.viewport.restoreScroll()', 'Restored scroll positions to %o', locationScrollTops);
9522
9943
  return true;
9523
9944
  }
@@ -9563,14 +9984,16 @@ up.viewport = (function () {
9563
9984
  }
9564
9985
  return [viewports, options];
9565
9986
  }
9566
- function resetScroll(...args) {
9567
- const [viewports, _options] = parseOptions(args);
9568
- setScrollTops(viewports, {});
9987
+ function scrollTo(position, ...args) {
9988
+ const [viewports, options] = parseOptions(args);
9989
+ setScrollPositions(viewports, {}, position, options.behavior);
9990
+ return true;
9569
9991
  }
9570
- function setScrollTops(viewports, tops) {
9992
+ function setScrollPositions(viewports, tops, defaultTop, behavior = 'instant') {
9571
9993
  for (let viewport of viewports) {
9572
9994
  const key = scrollTopKey(viewport);
9573
- viewport.scrollTop = tops[key] || 0;
9995
+ const top = tops[key] || defaultTop;
9996
+ viewport.scrollTo({ top, behavior });
9574
9997
  }
9575
9998
  }
9576
9999
  function absolutize(element, options = {}) {
@@ -9612,7 +10035,8 @@ up.viewport = (function () {
9612
10035
  };
9613
10036
  }
9614
10037
  function firstHashTarget(hash, options = {}) {
9615
- if (hash = pureHash(hash)) {
10038
+ hash = pureHash(hash);
10039
+ if (hash) {
9616
10040
  const selector = [
9617
10041
  e.idSelector(hash),
9618
10042
  'a' + e.attrSelector('name', hash)
@@ -9640,22 +10064,10 @@ up.viewport = (function () {
9640
10064
  }
9641
10065
  return to;
9642
10066
  }
9643
- document.addEventListener('DOMContentLoaded', function () {
9644
- revealHash();
9645
- u.task(revealHash);
9646
- });
9647
- up.on(window, 'hashchange', () => revealHash());
9648
- up.on('up:click', 'a[href^="#"]', function (event, link) {
9649
- if (link.hash !== location.hash)
9650
- return;
9651
- if (up.link.isFollowable(link))
9652
- return;
9653
- if (revealHash(link.hash))
9654
- up.event.halt(event);
9655
- });
9656
10067
  return {
9657
10068
  reveal,
9658
10069
  revealHash,
10070
+ revealHashFn,
9659
10071
  firstHashTarget,
9660
10072
  config,
9661
10073
  get: closest,
@@ -9668,7 +10080,7 @@ up.viewport = (function () {
9668
10080
  rootScrollbarWidth,
9669
10081
  saveScroll,
9670
10082
  restoreScroll,
9671
- resetScroll,
10083
+ scrollTo,
9672
10084
  saveFocus,
9673
10085
  restoreFocus,
9674
10086
  absolutize,
@@ -9685,13 +10097,13 @@ up.reveal = up.viewport.reveal;
9685
10097
 
9686
10098
 
9687
10099
  /***/ }),
9688
- /* 89 */
10100
+ /* 92 */
9689
10101
  /***/ (() => {
9690
10102
 
9691
10103
 
9692
10104
 
9693
10105
  /***/ }),
9694
- /* 90 */
10106
+ /* 93 */
9695
10107
  /***/ (function() {
9696
10108
 
9697
10109
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -9706,21 +10118,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9706
10118
  up.motion = (function () {
9707
10119
  const u = up.util;
9708
10120
  const e = up.element;
9709
- let namedAnimations = {};
9710
- let namedTransitions = {};
9711
10121
  const motionController = new up.MotionController('motion');
9712
10122
  const config = new up.Config(() => ({
9713
10123
  duration: 175,
9714
10124
  easing: 'ease',
9715
10125
  enabled: !matchMedia('(prefers-reduced-motion: reduce)').matches
9716
10126
  }));
9717
- function pickDefault(registry) {
9718
- return u.pickBy(registry, 'isDefault');
9719
- }
10127
+ let namedAnimations = new up.Registry('animation', findAnimationFn);
10128
+ let namedTransitions = new up.Registry('transition', findTransitionFn);
9720
10129
  function reset() {
9721
10130
  motionController.reset();
9722
- namedAnimations = pickDefault(namedAnimations);
9723
- namedTransitions = pickDefault(namedTransitions);
9724
10131
  }
9725
10132
  function isEnabled() {
9726
10133
  return config.enabled;
@@ -9761,9 +10168,6 @@ up.motion = (function () {
9761
10168
  (_a = options.easing) !== null && _a !== void 0 ? _a : (options.easing = config.easing);
9762
10169
  (_b = options.duration) !== null && _b !== void 0 ? _b : (options.duration = config.duration);
9763
10170
  }
9764
- function findNamedAnimation(name) {
9765
- return namedAnimations[name] || up.fail("Unknown animation %o", name);
9766
- }
9767
10171
  function finish(element) {
9768
10172
  return motionController.finish(element);
9769
10173
  }
@@ -9816,27 +10220,21 @@ up.motion = (function () {
9816
10220
  return Promise.resolve();
9817
10221
  }
9818
10222
  }
9819
- function findTransitionFn(object) {
9820
- if (isNone(object)) {
10223
+ function findTransitionFn(value) {
10224
+ if (isNone(value)) {
9821
10225
  return undefined;
9822
10226
  }
9823
- else if (u.isFunction(object)) {
9824
- return object;
10227
+ else if (u.isFunction(value)) {
10228
+ return value;
9825
10229
  }
9826
- else if (u.isArray(object)) {
9827
- return composeTransitionFn(...object);
10230
+ else if (u.isArray(value)) {
10231
+ return composeTransitionFn(...value);
9828
10232
  }
9829
- else if (u.isString(object)) {
9830
- let namedTransition;
9831
- if (object.indexOf('/') >= 0) {
9832
- return composeTransitionFn(...object.split('/'));
9833
- }
9834
- else if (namedTransition = namedTransitions[object]) {
9835
- return findTransitionFn(namedTransition);
9836
- }
10233
+ else if (u.isString(value) && value.includes('/')) {
10234
+ return composeTransitionFn(...value.split('/'));
9837
10235
  }
9838
10236
  else {
9839
- up.fail("Unknown transition %o", object);
10237
+ return namedTransitions.get(value);
9840
10238
  }
9841
10239
  }
9842
10240
  function composeTransitionFn(oldAnimation, newAnimation) {
@@ -9849,21 +10247,18 @@ up.motion = (function () {
9849
10247
  ]);
9850
10248
  }
9851
10249
  }
9852
- function findAnimationFn(object) {
9853
- if (isNone(object)) {
10250
+ function findAnimationFn(value) {
10251
+ if (isNone(value)) {
9854
10252
  return undefined;
9855
10253
  }
9856
- else if (u.isFunction(object)) {
9857
- return object;
9858
- }
9859
- else if (u.isString(object)) {
9860
- return findNamedAnimation(object);
10254
+ else if (u.isFunction(value)) {
10255
+ return value;
9861
10256
  }
9862
- else if (u.isOptions(object)) {
9863
- return (element, options) => animateNow(element, object, options);
10257
+ else if (u.isOptions(value)) {
10258
+ return (element, options) => animateNow(element, value, options);
9864
10259
  }
9865
10260
  else {
9866
- up.fail('Unknown animation %o', object);
10261
+ return namedAnimations.get(value);
9867
10262
  }
9868
10263
  }
9869
10264
  const swapElementsDirectly = up.mockable(function (oldElement, newElement) {
@@ -9878,16 +10273,6 @@ up.motion = (function () {
9878
10273
  parser.number('duration');
9879
10274
  return options;
9880
10275
  }
9881
- function registerTransition(name, transition) {
9882
- const fn = findTransitionFn(transition);
9883
- fn.isDefault = up.framework.evaling;
9884
- namedTransitions[name] = fn;
9885
- }
9886
- function registerAnimation(name, animation) {
9887
- const fn = findAnimationFn(animation);
9888
- fn.isDefault = up.framework.evaling;
9889
- namedAnimations[name] = fn;
9890
- }
9891
10276
  up.on('up:framework:boot', function () {
9892
10277
  if (!isEnabled()) {
9893
10278
  up.puts('up.motion', 'Animations are disabled');
@@ -9897,7 +10282,7 @@ up.motion = (function () {
9897
10282
  return !animationOrTransition || animationOrTransition === 'none';
9898
10283
  }
9899
10284
  function registerOpacityAnimation(name, from, to) {
9900
- registerAnimation(name, function (element, options) {
10285
+ namedAnimations.put(name, function (element, options) {
9901
10286
  element.style.opacity = 0;
9902
10287
  e.setStyle(element, { opacity: from });
9903
10288
  return animateNow(element, { opacity: to }, options);
@@ -9918,12 +10303,12 @@ up.motion = (function () {
9918
10303
  function registerMoveAnimations(direction, boxToTransform) {
9919
10304
  const animationToName = `move-to-${direction}`;
9920
10305
  const animationFromName = `move-from-${direction}`;
9921
- registerAnimation(animationToName, function (element, options) {
10306
+ namedAnimations.put(animationToName, function (element, options) {
9922
10307
  const box = untranslatedBox(element);
9923
10308
  const transform = boxToTransform(box);
9924
10309
  return animateNow(element, transform, options);
9925
10310
  });
9926
- registerAnimation(animationFromName, function (element, options) {
10311
+ namedAnimations.put(animationFromName, function (element, options) {
9927
10312
  const box = untranslatedBox(element);
9928
10313
  const transform = boxToTransform(box);
9929
10314
  e.setStyle(element, transform);
@@ -9946,19 +10331,19 @@ up.motion = (function () {
9946
10331
  const travelDistance = up.viewport.rootWidth() - box.left;
9947
10332
  return translateCSS(travelDistance, 0);
9948
10333
  });
9949
- registerTransition('cross-fade', ['fade-out', 'fade-in']);
9950
- registerTransition('move-left', ['move-to-left', 'move-from-right']);
9951
- registerTransition('move-right', ['move-to-right', 'move-from-left']);
9952
- registerTransition('move-up', ['move-to-top', 'move-from-bottom']);
9953
- registerTransition('move-down', ['move-to-bottom', 'move-from-top']);
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']);
9954
10339
  up.on('up:framework:reset', reset);
9955
10340
  return {
9956
10341
  morph,
9957
10342
  animate,
9958
10343
  finish,
9959
10344
  finishCount() { return motionController.finishCount; },
9960
- transition: registerTransition,
9961
- animation: registerAnimation,
10345
+ transition: namedTransitions.put,
10346
+ animation: namedAnimations.put,
9962
10347
  config,
9963
10348
  isEnabled,
9964
10349
  isNone,
@@ -9974,10 +10359,10 @@ up.animate = up.motion.animate;
9974
10359
 
9975
10360
 
9976
10361
  /***/ }),
9977
- /* 91 */
10362
+ /* 94 */
9978
10363
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9979
10364
 
9980
- __webpack_require__(92);
10365
+ __webpack_require__(95);
9981
10366
  const u = up.util;
9982
10367
  up.network = (function () {
9983
10368
  const config = new up.Config(() => ({
@@ -9989,7 +10374,7 @@ up.network = (function () {
9989
10374
  lateDelay: 400,
9990
10375
  fail(response) { return (response.status < 200 || response.status > 299) && response.status !== 304; },
9991
10376
  autoCache(request) { return request.isSafe(); },
9992
- expireCache(request, _response) { return !request.isSafe(); },
10377
+ expireCache(request) { return !request.isSafe(); },
9993
10378
  evictCache: false,
9994
10379
  progressBar: true,
9995
10380
  timeout: 90000,
@@ -10017,6 +10402,9 @@ up.network = (function () {
10017
10402
  return options;
10018
10403
  }
10019
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);
10020
10408
  useCachedRequest(request) || queueRequest(request);
10021
10409
  }
10022
10410
  function useCachedRequest(newRequest) {
@@ -10042,15 +10430,9 @@ up.network = (function () {
10042
10430
  request.onLoading = () => cache.reindex(request);
10043
10431
  }
10044
10432
  u.always(request, function (responseOrError) {
10045
- var _a, _b, _c, _d;
10046
- let expireCache = (_b = (_a = responseOrError.expireCache) !== null && _a !== void 0 ? _a : request.expireCache) !== null && _b !== void 0 ? _b : u.evalOption(config.expireCache, request, responseOrError);
10047
- if (expireCache) {
10048
- cache.expire(expireCache, { except: request });
10049
- }
10050
- let evictCache = (_d = (_c = responseOrError.evictCache) !== null && _c !== void 0 ? _c : request.evictCache) !== null && _d !== void 0 ? _d : u.evalOption(config.evictCache, request, responseOrError);
10051
- if (evictCache) {
10052
- cache.evict(evictCache, { except: request });
10053
- }
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 });
10054
10436
  let hasCacheEntry = cache.get(request);
10055
10437
  let isResponse = responseOrError instanceof up.Response;
10056
10438
  let isNetworkError = !isResponse;
@@ -10120,13 +10502,13 @@ up.cache = up.network.cache;
10120
10502
 
10121
10503
 
10122
10504
  /***/ }),
10123
- /* 92 */
10505
+ /* 95 */
10124
10506
  /***/ (() => {
10125
10507
 
10126
10508
 
10127
10509
 
10128
10510
  /***/ }),
10129
- /* 93 */
10511
+ /* 96 */
10130
10512
  /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
10131
10513
 
10132
10514
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -10138,7 +10520,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10138
10520
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10139
10521
  });
10140
10522
  };
10141
- __webpack_require__(94);
10523
+ __webpack_require__(97);
10142
10524
  const u = up.util;
10143
10525
  const e = up.element;
10144
10526
  up.layer = (function () {
@@ -10314,7 +10696,7 @@ up.layer = (function () {
10314
10696
  });
10315
10697
  }
10316
10698
  function anySelector() {
10317
- return u.map(LAYER_CLASSES, Class => Class.selector()).join();
10699
+ return u.map(LAYER_CLASSES, (Class) => Class.selector()).join();
10318
10700
  }
10319
10701
  function optionToString(option) {
10320
10702
  if (u.isString(option)) {
@@ -10384,20 +10766,22 @@ up.layer = (function () {
10384
10766
 
10385
10767
 
10386
10768
  /***/ }),
10387
- /* 94 */
10769
+ /* 97 */
10388
10770
  /***/ (() => {
10389
10771
 
10390
10772
 
10391
10773
 
10392
10774
  /***/ }),
10393
- /* 95 */
10775
+ /* 98 */
10394
10776
  /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10395
10777
 
10396
- __webpack_require__(96);
10778
+ __webpack_require__(99);
10397
10779
  up.link = (function () {
10398
10780
  const u = up.util;
10399
10781
  const e = up.element;
10782
+ let lastTouchstartTarget = null;
10400
10783
  let lastMousedownTarget = null;
10784
+ let lastInstantTarget = null;
10401
10785
  const ATTRS_WITH_LOCAL_HTML = '[up-content], [up-fragment], [up-document]';
10402
10786
  const ATTRS_SUGGESTING_FOLLOW = `${ATTRS_WITH_LOCAL_HTML}, [up-target], [up-layer], [up-transition], [up-preload]`;
10403
10787
  const DEFAULT_INTERACTIVE_ELEMENT = 'a[href], button';
@@ -10427,7 +10811,9 @@ up.link = (function () {
10427
10811
  }
10428
10812
  }
10429
10813
  function reset() {
10814
+ lastTouchstartTarget = null;
10430
10815
  lastMousedownTarget = null;
10816
+ lastInstantTarget = null;
10431
10817
  }
10432
10818
  const follow = up.mockable(function (link, options, parserOptions) {
10433
10819
  return up.render(followOptions(link, options, parserOptions));
@@ -10449,6 +10835,7 @@ up.link = (function () {
10449
10835
  parser.string('contentType');
10450
10836
  parser.booleanOrNumber('lateDelay');
10451
10837
  parser.number('timeout');
10838
+ parser.booleanOrString('fail');
10452
10839
  return options;
10453
10840
  }
10454
10841
  function followOptions(link, options, parserOptions) {
@@ -10458,7 +10845,6 @@ up.link = (function () {
10458
10845
  const parser = new up.OptionsParser(link, options, Object.assign({ fail: true }, parserOptions));
10459
10846
  parser.include(parseRequestOptions);
10460
10847
  options.origin || (options.origin = link);
10461
- parser.boolean('fail');
10462
10848
  parser.boolean('navigate', { default: true });
10463
10849
  parser.string('confirm', { attr: ['up-confirm', 'data-confirm'] });
10464
10850
  parser.string('target');
@@ -10492,9 +10878,12 @@ up.link = (function () {
10492
10878
  parser.string('dismissEvent');
10493
10879
  parser.string('acceptLocation');
10494
10880
  parser.string('dismissLocation');
10495
- parser.booleanOrString('history');
10881
+ parser.booleanOrString('closeAnimation');
10882
+ parser.string('closeEasing');
10883
+ parser.number('closeDuration');
10496
10884
  parser.include(up.status.statusOptions);
10497
10885
  parser.booleanOrString('focus');
10886
+ parser.booleanOrString('focusVisible');
10498
10887
  parser.boolean('saveScroll');
10499
10888
  parser.boolean('saveFocus');
10500
10889
  parser.booleanOrString('scroll');
@@ -10519,7 +10908,7 @@ up.link = (function () {
10519
10908
  return Promise.reject(new up.Error(issue));
10520
10909
  }
10521
10910
  const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });
10522
- 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), options), { guardEvent, preload: true }));
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 }));
10523
10912
  }
10524
10913
  function preloadIssue(link) {
10525
10914
  if (!isSafe(link)) {
@@ -10575,27 +10964,37 @@ up.link = (function () {
10575
10964
  }
10576
10965
  function convertClicks(layer) {
10577
10966
  layer.on('click', function (event, element) {
10578
- if (!up.event.isUnmodified(event)) {
10967
+ if (up.event.isModified(event)) {
10579
10968
  return;
10580
10969
  }
10581
- if (isInstant(element) && lastMousedownTarget) {
10970
+ if (isInstant(element) && lastInstantTarget === element) {
10582
10971
  up.event.halt(event);
10583
10972
  }
10584
10973
  else if (up.event.inputDevice === 'key' || up.event.isSyntheticClick(event) || (layer.wasHitByMouseEvent(event) && !didUserDragAway(event))) {
10585
10974
  forkEventAsUpClick(event);
10586
10975
  }
10587
- return lastMousedownTarget = null;
10976
+ lastMousedownTarget = null;
10977
+ lastInstantTarget = null;
10978
+ });
10979
+ layer.on('touchstart', { passive: true }, function (event, element) {
10980
+ lastTouchstartTarget = element;
10588
10981
  });
10589
10982
  layer.on('mousedown', function (event, element) {
10590
- if (!up.event.isUnmodified(event)) {
10983
+ if (up.event.isModified(event)) {
10591
10984
  return;
10592
10985
  }
10593
- lastMousedownTarget = event.target;
10594
- if (isInstant(element)) {
10986
+ lastMousedownTarget = element;
10987
+ if (isInstant(element) && !isLongPressPossible(event)) {
10988
+ lastInstantTarget = element;
10595
10989
  forkEventAsUpClick(event);
10596
10990
  }
10991
+ lastTouchstartTarget = null;
10597
10992
  });
10598
10993
  }
10994
+ function isLongPressPossible(mousedownEvent) {
10995
+ let mousedownTarget = mousedownEvent.target;
10996
+ return (lastTouchstartTarget === mousedownTarget) && mousedownTarget.closest('[href]');
10997
+ }
10599
10998
  function didUserDragAway(clickEvent) {
10600
10999
  return lastMousedownTarget && (lastMousedownTarget !== clickEvent.target);
10601
11000
  }
@@ -10684,13 +11083,13 @@ up.deferred = { load: up.link.loadDeferred };
10684
11083
 
10685
11084
 
10686
11085
  /***/ }),
10687
- /* 96 */
11086
+ /* 99 */
10688
11087
  /***/ (() => {
10689
11088
 
10690
11089
 
10691
11090
 
10692
11091
  /***/ }),
10693
- /* 97 */
11092
+ /* 100 */
10694
11093
  /***/ (() => {
10695
11094
 
10696
11095
  up.form = (function () {
@@ -10703,12 +11102,14 @@ up.form = (function () {
10703
11102
  noSubmitSelectors: ['[up-submit=false]', '[target]', e.crossOriginSelector('action')],
10704
11103
  submitButtonSelectors: ['input[type=submit]', 'input[type=image]', 'button[type=submit]', 'button:not([type])'],
10705
11104
  genericButtonSelectors: ['input[type=button]', 'button[type=button]'],
11105
+ validateBatch: true,
10706
11106
  watchInputEvents: ['input', 'change'],
10707
11107
  watchInputDelay: 0,
10708
11108
  watchChangeEvents: ['change'],
11109
+ watchableEvents: ['input', 'change'],
10709
11110
  }));
10710
11111
  function fieldSelector(suffix = '') {
10711
- return config.fieldSelectors.map(field => field + suffix).join();
11112
+ return config.fieldSelectors.map((field) => field + suffix).join();
10712
11113
  }
10713
11114
  function isField(element) {
10714
11115
  return element.matches(fieldSelector());
@@ -10719,11 +11120,17 @@ up.form = (function () {
10719
11120
  if (root.matches('form[id]')) {
10720
11121
  const outsideFieldSelector = fieldSelector(e.attrSelector('form', root.getAttribute('id')));
10721
11122
  const outsideFields = up.fragment.all(outsideFieldSelector, { layer: root });
10722
- fields.push(...outsideFields);
10723
- fields = u.uniq(fields);
11123
+ fields = u.uniq([...fields, ...outsideFields]);
10724
11124
  }
10725
11125
  return fields;
10726
11126
  }
11127
+ function findFieldsAndButtons(container) {
11128
+ return [
11129
+ ...findFields(container),
11130
+ ...findSubmitButtons(container),
11131
+ ...findGenericButtons(container),
11132
+ ];
11133
+ }
10727
11134
  function findSubmitButtons(root) {
10728
11135
  return e.subtree(root, submitButtonSelector());
10729
11136
  }
@@ -10757,16 +11164,18 @@ up.form = (function () {
10757
11164
  return options;
10758
11165
  }
10759
11166
  function watchOptions(field, options, parserOptions = {}) {
10760
- var _a;
11167
+ var _a, _b, _c;
10761
11168
  options = u.options(options);
10762
- let parser = new up.OptionsParser(field, options, Object.assign(Object.assign({}, parserOptions), { closest: true, attrPrefix: 'up-watch-' }));
10763
- parser.include(up.status.statusOptions);
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);
10764
11173
  parser.string('event');
10765
11174
  parser.number('delay');
10766
11175
  let config = up.form.config;
10767
11176
  if (options.event === 'input') {
10768
11177
  options.event = u.evalOption(config.watchInputEvents, field);
10769
- (_a = options.delay) !== null && _a !== void 0 ? _a : (options.delay = config.watchInputDelay);
11178
+ (_c = options.delay) !== null && _c !== void 0 ? _c : (options.delay = config.watchInputDelay);
10770
11179
  }
10771
11180
  else if (options.event === 'change') {
10772
11181
  options.event = u.evalOption(config.watchChangeEvents, field);
@@ -10774,15 +11183,20 @@ up.form = (function () {
10774
11183
  options.origin || (options.origin = field);
10775
11184
  return options;
10776
11185
  }
10777
- function disableContainer(container) {
10778
- let controls = [
10779
- ...findFields(container),
10780
- ...findSubmitButtons(container),
10781
- ...findGenericButtons(container),
10782
- ];
10783
- return u.sequence(u.map(controls, disableControl));
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));
10784
11198
  }
10785
- function disableControl(control) {
11199
+ function disableControlTemp(control) {
10786
11200
  if (control.disabled)
10787
11201
  return;
10788
11202
  let focusFallback;
@@ -10797,7 +11211,7 @@ up.form = (function () {
10797
11211
  return () => { control.disabled = false; };
10798
11212
  }
10799
11213
  function getDisableContainers(disable, origin) {
10800
- let originScope = () => getScope(origin);
11214
+ let originScope = () => getRegion(origin);
10801
11215
  if (disable === true) {
10802
11216
  return [originScope()];
10803
11217
  }
@@ -10822,6 +11236,11 @@ up.form = (function () {
10822
11236
  }
10823
11237
  };
10824
11238
  }
11239
+ function setContainerDisabled(container, disabled) {
11240
+ for (let control of findFieldsAndButtons(container)) {
11241
+ control.disabled = disabled;
11242
+ }
11243
+ }
10825
11244
  function destinationOptions(form, options, parserOptions) {
10826
11245
  var _a;
10827
11246
  options = u.options(options);
@@ -10854,8 +11273,7 @@ up.form = (function () {
10854
11273
  root = up.element.get(root);
10855
11274
  callback || (callback = watchCallbackFromElement(root) || up.fail('No callback given for up.watch()'));
10856
11275
  const watcher = new up.FieldWatcher(root, options, callback);
10857
- watcher.start();
10858
- return () => watcher.stop();
11276
+ return watcher.start();
10859
11277
  }
10860
11278
  function watchCallbackFromElement(element) {
10861
11279
  let rawCallback = element.getAttribute('up-watch');
@@ -10865,7 +11283,7 @@ up.form = (function () {
10865
11283
  }
10866
11284
  function autosubmit(target, options = {}) {
10867
11285
  const onChange = (_diff, renderOptions) => submit(target, renderOptions);
10868
- 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);
10869
11287
  }
10870
11288
  function getGroupSelectors() {
10871
11289
  var _a, _b;
@@ -10894,7 +11312,8 @@ up.form = (function () {
10894
11312
  }
10895
11313
  function validate(...args) {
10896
11314
  let options = parseValidateArgs(...args);
10897
- let validator = up.FormValidator.forElement(options.origin);
11315
+ let form = getForm(options.origin);
11316
+ let validator = getFormValidator(form);
10898
11317
  return validator.validate(options);
10899
11318
  }
10900
11319
  function parseValidateArgs(originOrTarget, ...args) {
@@ -10907,88 +11326,20 @@ up.form = (function () {
10907
11326
  }
10908
11327
  return options;
10909
11328
  }
10910
- function switcherValues(field) {
10911
- let value;
10912
- let meta;
10913
- if (field.matches('input[type=checkbox]')) {
10914
- if (field.checked) {
10915
- value = field.value;
10916
- meta = ':checked';
10917
- }
10918
- else {
10919
- meta = ':unchecked';
10920
- }
10921
- }
10922
- else if (field.matches('input[type=radio]')) {
10923
- const form = getScope(field);
10924
- const groupName = field.getAttribute('name');
10925
- const checkedButton = form.querySelector(`input[type=radio]${e.attrSelector('name', groupName)}:checked`);
10926
- if (checkedButton) {
10927
- meta = ':checked';
10928
- value = checkedButton.value;
10929
- }
10930
- else {
10931
- meta = ':unchecked';
10932
- }
10933
- }
10934
- else {
10935
- value = field.value;
10936
- }
10937
- const values = [];
10938
- if (u.isPresent(value)) {
10939
- values.push(value);
10940
- values.push(':present');
10941
- }
10942
- else {
10943
- values.push(':blank');
10944
- }
10945
- if (u.isPresent(meta)) {
10946
- values.push(meta);
10947
- }
10948
- return values;
10949
- }
10950
- function switchTargets(switcher, options = {}) {
10951
- const targetSelector = options.target || options.target || switcher.getAttribute('up-switch');
10952
- const form = getScope(switcher);
10953
- targetSelector || up.fail("No switch target given for %o", switcher);
10954
- const fieldValues = switcherValues(switcher);
10955
- for (let target of up.fragment.all(form, targetSelector)) {
10956
- switchTarget(target, fieldValues);
10957
- }
10958
- }
10959
- const switchTarget = up.mockable(function (target, fieldValues) {
10960
- let show;
10961
- fieldValues || (fieldValues = switcherValues(findSwitcherForTarget(target)));
10962
- let hideValues = target.getAttribute('up-hide-for');
10963
- if (hideValues) {
10964
- hideValues = parseSwitchTokens(hideValues);
10965
- show = u.intersect(fieldValues, hideValues).length === 0;
10966
- }
10967
- else {
10968
- let showValues = target.getAttribute('up-show-for');
10969
- showValues = showValues ? parseSwitchTokens(showValues) : [':present', ':checked'];
10970
- show = u.intersect(fieldValues, showValues).length > 0;
10971
- }
10972
- e.toggle(target, show);
10973
- target.classList.add('up-switched');
10974
- });
10975
- function parseSwitchTokens(str) {
10976
- return u.getSimpleTokens(str, { json: true });
10977
- }
10978
- function findSwitcherForTarget(target) {
10979
- const form = getScope(target);
10980
- const switchers = form.querySelectorAll('[up-switch]');
10981
- const switcher = u.find(switchers, function (switcher) {
10982
- const targetSelector = switcher.getAttribute('up-switch');
10983
- return target.matches(targetSelector);
10984
- });
10985
- return switcher || up.fail('Could not find [up-switch] field for %o', target);
10986
- }
10987
11329
  function getForm(elementOrSelector, options = {}) {
10988
11330
  const element = up.fragment.get(elementOrSelector, options);
10989
11331
  return element.form || element.closest('form');
10990
11332
  }
10991
- function getScope(origin, options) {
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) {
10992
11343
  if (origin) {
10993
11344
  return getForm(origin, options) || up.layer.get(origin).element;
10994
11345
  }
@@ -10996,6 +11347,19 @@ up.form = (function () {
10996
11347
  return up.layer.current.element;
10997
11348
  }
10998
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
+ }
10999
11363
  function focusedField() {
11000
11364
  return u.presence(document.activeElement, isField);
11001
11365
  }
@@ -11010,49 +11374,39 @@ up.form = (function () {
11010
11374
  up.event.halt(event, { log: true });
11011
11375
  up.error.muteUncriticalRejection(submit(form, { submitButton }));
11012
11376
  });
11013
- up.compiler(validatingFieldSelector, function (fieldOrForm) {
11014
- let validator = up.FormValidator.forElement(fieldOrForm);
11015
- validator.watchContainer(fieldOrForm);
11377
+ up.compiler('form', function (form) {
11378
+ getFormValidator(form);
11016
11379
  });
11017
- function validatingFieldSelector() {
11018
- let includes = config.fieldSelectors.map((selector) => `${selector}[up-validate], [up-validate] ${selector}`);
11019
- let excludes = ['[up-validate=false]'];
11020
- return e.unionSelector(includes, excludes);
11021
- }
11022
11380
  up.compiler('[up-switch]', (switcher) => {
11023
- switchTargets(switcher);
11024
- });
11025
- up.on('change', '[up-switch]', (_event, switcher) => {
11026
- switchTargets(switcher);
11027
- });
11028
- up.compiler('[up-show-for]:not(.up-switched), [up-hide-for]:not(.up-switched)', (element) => {
11029
- switchTarget(element);
11381
+ return new up.Switcher(switcher).start();
11030
11382
  });
11031
11383
  up.attribute('up-watch', (formOrField) => watch(formOrField));
11032
- up.attribute('up-autosubmit', (formOrField) => autosubmit(formOrField));
11384
+ up.attribute('up-autosubmit', (formOrField) => autosubmit(formOrField, { logPrefix: '[up-autosubmit]' }));
11033
11385
  return {
11034
11386
  config,
11035
11387
  submit,
11036
11388
  submitOptions,
11037
11389
  destinationOptions,
11038
11390
  watchOptions,
11391
+ validateOptions,
11039
11392
  isSubmittable,
11040
11393
  watch,
11041
11394
  validate,
11042
11395
  autosubmit,
11043
11396
  fieldSelector,
11044
11397
  fields: findFields,
11398
+ trackFields,
11045
11399
  isField,
11046
11400
  submitButtons: findSubmitButtons,
11047
11401
  focusedField,
11048
- switchTarget,
11049
- disable: disableContainer,
11402
+ disableTemp: disableContainerTemp,
11403
+ setDisabled: setContainerDisabled,
11050
11404
  getDisablePreviewFn,
11051
11405
  group: findGroup,
11052
11406
  groupSolution: findGroupSolution,
11053
11407
  groupSelectors: getGroupSelectors,
11054
11408
  get: getForm,
11055
- getScope,
11409
+ getRegion,
11056
11410
  };
11057
11411
  })();
11058
11412
  up.submit = up.form.submit;
@@ -11062,13 +11416,12 @@ up.validate = up.form.validate;
11062
11416
 
11063
11417
 
11064
11418
  /***/ }),
11065
- /* 98 */
11419
+ /* 101 */
11066
11420
  /***/ (() => {
11067
11421
 
11068
11422
  up.status = (function () {
11069
11423
  const u = up.util;
11070
11424
  const e = up.element;
11071
- let namedPreviewFns = {};
11072
11425
  const config = new up.Config(() => ({
11073
11426
  currentClasses: ['up-current'],
11074
11427
  activeClasses: ['up-active'],
@@ -11076,9 +11429,9 @@ up.status = (function () {
11076
11429
  navSelectors: ['[up-nav]', 'nav'],
11077
11430
  noNavSelectors: ['[up-nav=false]'],
11078
11431
  }));
11432
+ let namedPreviewFns = new up.Registry('preview');
11079
11433
  function reset() {
11080
11434
  up.layer.root.feedbackLocation = null;
11081
- namedPreviewFns = u.pickBy(namedPreviewFns, 'isDefault');
11082
11435
  }
11083
11436
  const SELECTOR_LINK = 'a, [up-href]';
11084
11437
  function linkCurrentURLs(link) {
@@ -11154,7 +11507,7 @@ up.status = (function () {
11154
11507
  }
11155
11508
  function resolvePreviewString(str) {
11156
11509
  return u.map(u.parseScalarJSONPairs(str), ([name, parsedOptions]) => {
11157
- let previewFn = namedPreviewFns[name] || up.fail('Unknown preview "%s"', name);
11510
+ let previewFn = namedPreviewFns.get(name);
11158
11511
  return function (preview, runOptions) {
11159
11512
  up.puts('[up-preview]', 'Showing preview %o', name);
11160
11513
  return previewFn(preview, parsedOptions || runOptions);
@@ -11165,10 +11518,6 @@ up.status = (function () {
11165
11518
  activeElements || (activeElements = u.wrapList(origin));
11166
11519
  return activeElements.map(findActivatableArea);
11167
11520
  }
11168
- function registerPreview(name, previewFn) {
11169
- previewFn.isDefault = up.framework.evaling;
11170
- namedPreviewFns[name] = previewFn;
11171
- }
11172
11521
  function getFeedbackClassesPreviewFn(feedbackOption, fragments) {
11173
11522
  if (!feedbackOption)
11174
11523
  return;
@@ -11213,7 +11562,7 @@ up.status = (function () {
11213
11562
  up.on('up:framework:reset', reset);
11214
11563
  return {
11215
11564
  config,
11216
- preview: registerPreview,
11565
+ preview: namedPreviewFns.put,
11217
11566
  resolvePreviewFns,
11218
11567
  runPreviews,
11219
11568
  statusOptions,
@@ -11223,7 +11572,7 @@ up.preview = up.status.preview;
11223
11572
 
11224
11573
 
11225
11574
  /***/ }),
11226
- /* 99 */
11575
+ /* 102 */
11227
11576
  /***/ (() => {
11228
11577
 
11229
11578
  up.radio = (function () {
@@ -11306,7 +11655,7 @@ up.radio = (function () {
11306
11655
 
11307
11656
 
11308
11657
  /***/ }),
11309
- /* 100 */
11658
+ /* 103 */
11310
11659
  /***/ (() => {
11311
11660
 
11312
11661
  (function () {
@@ -11445,15 +11794,18 @@ __webpack_require__(83);
11445
11794
  __webpack_require__(84);
11446
11795
  __webpack_require__(85);
11447
11796
  __webpack_require__(86);
11797
+ __webpack_require__(87);
11448
11798
  __webpack_require__(88);
11449
- __webpack_require__(90);
11799
+ __webpack_require__(89);
11450
11800
  __webpack_require__(91);
11451
11801
  __webpack_require__(93);
11452
- __webpack_require__(95);
11453
- __webpack_require__(97);
11802
+ __webpack_require__(94);
11803
+ __webpack_require__(96);
11454
11804
  __webpack_require__(98);
11455
- __webpack_require__(99);
11456
11805
  __webpack_require__(100);
11806
+ __webpack_require__(101);
11807
+ __webpack_require__(102);
11808
+ __webpack_require__(103);
11457
11809
  up.framework.onEvaled();
11458
11810
 
11459
11811
  })();