unpoly-rails 3.9.5 → 3.10.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/unpoly/unpoly-bootstrap3.js +3 -2
- data/assets/unpoly/unpoly-bootstrap3.min.js +1 -1
- data/assets/unpoly/unpoly-bootstrap4.js +3 -2
- data/assets/unpoly/unpoly-bootstrap4.min.js +1 -1
- data/assets/unpoly/unpoly-bootstrap5.js +3 -2
- data/assets/unpoly/unpoly-bootstrap5.min.js +1 -1
- data/assets/unpoly/unpoly-migrate.js +29 -6
- data/assets/unpoly/unpoly-migrate.min.js +1 -1
- data/assets/unpoly/unpoly.es6.js +1552 -1015
- data/assets/unpoly/unpoly.es6.min.js +1 -1
- data/assets/unpoly/unpoly.js +1526 -995
- data/assets/unpoly/unpoly.min.js +1 -1
- data/lib/unpoly/rails/version.rb +1 -1
- metadata +4 -4
data/assets/unpoly/unpoly.es6.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
/***/ (() => {
|
6
6
|
|
7
7
|
window.up = {
|
8
|
-
version: '3.
|
8
|
+
version: '3.10.0-rc1'
|
9
9
|
};
|
10
10
|
|
11
11
|
|
@@ -202,6 +202,9 @@ up.util = (function () {
|
|
202
202
|
function isElement(object) {
|
203
203
|
return object instanceof Element;
|
204
204
|
}
|
205
|
+
function isTextNode(object) {
|
206
|
+
return object instanceof Text;
|
207
|
+
}
|
205
208
|
function isRegExp(object) {
|
206
209
|
return object instanceof RegExp;
|
207
210
|
}
|
@@ -211,9 +214,9 @@ up.util = (function () {
|
|
211
214
|
function isJQuery(object) {
|
212
215
|
return up.browser.canJQuery() && object instanceof jQuery;
|
213
216
|
}
|
214
|
-
function
|
217
|
+
function isElementLike(object) {
|
215
218
|
var _a;
|
216
|
-
return !!(object && (object.addEventListener || ((_a = object[0]) === null || _a === void 0 ? void 0 : _a.addEventListener)));
|
219
|
+
return !!(object && (object.addEventListener || (isJQuery(object) && ((_a = object[0]) === null || _a === void 0 ? void 0 : _a.addEventListener))));
|
217
220
|
}
|
218
221
|
function isPromise(object) {
|
219
222
|
return isObject(object) && isFunction(object.then);
|
@@ -241,6 +244,9 @@ up.util = (function () {
|
|
241
244
|
function isArguments(value) {
|
242
245
|
return Object.prototype.toString.call(value) === '[object Arguments]';
|
243
246
|
}
|
247
|
+
function isAdjacentPosition(value) {
|
248
|
+
return /^(before|after)/.test(value);
|
249
|
+
}
|
244
250
|
function wrapList(value) {
|
245
251
|
if (isList(value)) {
|
246
252
|
return value;
|
@@ -298,10 +304,9 @@ up.util = (function () {
|
|
298
304
|
}
|
299
305
|
}
|
300
306
|
function parseArgIntoOptions(args, argKey) {
|
301
|
-
let options =
|
302
|
-
if (isDefined(
|
303
|
-
options =
|
304
|
-
options[argKey] = args[0];
|
307
|
+
let [positionalArg, options] = parseArgs(args, 'val', 'options');
|
308
|
+
if (isDefined(positionalArg)) {
|
309
|
+
options[argKey] = positionalArg;
|
305
310
|
}
|
306
311
|
return options;
|
307
312
|
}
|
@@ -469,7 +474,9 @@ up.util = (function () {
|
|
469
474
|
return value;
|
470
475
|
}
|
471
476
|
function renameKey(object, oldKey, newKey) {
|
472
|
-
|
477
|
+
if (oldKey in object) {
|
478
|
+
object[newKey] = pluckKey(object, oldKey);
|
479
|
+
}
|
473
480
|
}
|
474
481
|
function extractLastArg(args, tester) {
|
475
482
|
if (tester(last(args))) {
|
@@ -555,26 +562,35 @@ up.util = (function () {
|
|
555
562
|
function isEqualList(a, b) {
|
556
563
|
return (a.length === b.length) && every(a, (elem, index) => isEqual(elem, b[index]));
|
557
564
|
}
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
if (isString(value)) {
|
565
|
-
value = value.trim();
|
566
|
-
if (options.json && /^\[.*]$/.test(value)) {
|
567
|
-
return JSON.parse(value);
|
568
|
-
}
|
569
|
-
else {
|
570
|
-
let separator = options.separator || 'space/or';
|
571
|
-
let pattern = PARSE_TOKEN_PATTERNS[separator];
|
572
|
-
return value.split(pattern);
|
573
|
-
}
|
565
|
+
function getSimpleTokens(value, { json = false, separator = /[,\s]/ } = {}) {
|
566
|
+
if (!isString(value)) {
|
567
|
+
return wrapList(value);
|
568
|
+
}
|
569
|
+
else if (json && /^\[.*]$/.test(value)) {
|
570
|
+
return parseRelaxedJSON(value);
|
574
571
|
}
|
575
572
|
else {
|
573
|
+
return splitSimpleTokenString(value, separator);
|
574
|
+
}
|
575
|
+
}
|
576
|
+
function splitSimpleTokenString(value, separator) {
|
577
|
+
var _a, _b;
|
578
|
+
let parts = ((_b = (_a = up.migrate).splitAtOr) === null || _b === void 0 ? void 0 : _b.call(_a, value)) || value.split(separator);
|
579
|
+
return parts.map((s) => s.trim()).filter(identity);
|
580
|
+
}
|
581
|
+
function getComplexTokens(value) {
|
582
|
+
if (!isString(value)) {
|
576
583
|
return wrapList(value);
|
577
584
|
}
|
585
|
+
else {
|
586
|
+
let { maskedTokens, restore } = complexTokenOutlines(value);
|
587
|
+
return maskedTokens.map((token) => restore(token));
|
588
|
+
}
|
589
|
+
}
|
590
|
+
function complexTokenOutlines(string) {
|
591
|
+
let { masked, restore } = expressionOutline(string);
|
592
|
+
let maskedTokens = splitSimpleTokenString(masked, ',');
|
593
|
+
return { maskedTokens, restore };
|
578
594
|
}
|
579
595
|
function wrapValue(constructor, ...args) {
|
580
596
|
return (args[0] instanceof constructor) ? args[0] : new constructor(...args);
|
@@ -586,18 +602,13 @@ up.util = (function () {
|
|
586
602
|
function reverse(list) {
|
587
603
|
return copy(list).reverse();
|
588
604
|
}
|
589
|
-
function
|
590
|
-
if (value === matchValue) {
|
591
|
-
return replacementValue;
|
592
|
-
}
|
593
|
-
else {
|
594
|
-
return value;
|
595
|
-
}
|
596
|
-
}
|
597
|
-
function renameKeys(object, renameKeyFn) {
|
605
|
+
function withRenamedKeys(object, renameKeyFn) {
|
598
606
|
const renamed = {};
|
599
607
|
for (let key in object) {
|
600
|
-
|
608
|
+
let transformed = renameKeyFn(key);
|
609
|
+
if (isGiven(transformed)) {
|
610
|
+
renamed[transformed] = object[key];
|
611
|
+
}
|
601
612
|
}
|
602
613
|
return renamed;
|
603
614
|
}
|
@@ -628,6 +639,9 @@ up.util = (function () {
|
|
628
639
|
});
|
629
640
|
}
|
630
641
|
}
|
642
|
+
function delegatePromise(object, promiseProp) {
|
643
|
+
return defineDelegates(object, ['then', 'catch', 'finally'], function () { return this[promiseProp]; });
|
644
|
+
}
|
631
645
|
function stringifyArg(arg, placeholder = '%o') {
|
632
646
|
let string;
|
633
647
|
const maxLength = 200;
|
@@ -738,6 +752,122 @@ up.util = (function () {
|
|
738
752
|
Object.assign(variant, changes);
|
739
753
|
return variant;
|
740
754
|
}
|
755
|
+
function parseArgs(args, ...specs) {
|
756
|
+
let results = [];
|
757
|
+
while (specs.length) {
|
758
|
+
let lastSpec = specs.pop();
|
759
|
+
if (lastSpec === 'options') {
|
760
|
+
results.unshift(extractOptions(args));
|
761
|
+
}
|
762
|
+
else if (lastSpec === 'callback') {
|
763
|
+
results.unshift(extractCallback(args));
|
764
|
+
}
|
765
|
+
else if (lastSpec === 'val') {
|
766
|
+
results.unshift(args.pop());
|
767
|
+
}
|
768
|
+
else if (isFunction(lastSpec)) {
|
769
|
+
let value = lastSpec(last(args)) ? args.pop() : undefined;
|
770
|
+
results.unshift(value);
|
771
|
+
}
|
772
|
+
}
|
773
|
+
return results;
|
774
|
+
}
|
775
|
+
function scanFunctions(...values) {
|
776
|
+
return values.flat().filter(isFunction);
|
777
|
+
}
|
778
|
+
function cleaner() {
|
779
|
+
let fns = [];
|
780
|
+
let track = function (values, transform) {
|
781
|
+
values = scanFunctions(...values).map(transform);
|
782
|
+
fns.push(...scanFunctions(...values));
|
783
|
+
};
|
784
|
+
let api = function (...values) {
|
785
|
+
track(values, identity);
|
786
|
+
};
|
787
|
+
api.guard = function (...values) {
|
788
|
+
track(values, up.error.guardFn);
|
789
|
+
};
|
790
|
+
api.clean = function (...args) {
|
791
|
+
let { length } = fns;
|
792
|
+
for (let i = length - 1; i >= 0; i--)
|
793
|
+
fns[i](...args);
|
794
|
+
fns = [];
|
795
|
+
};
|
796
|
+
return api;
|
797
|
+
}
|
798
|
+
function maskPattern(str, patterns, { keepDelimiters = false } = {}) {
|
799
|
+
let maskCount = 0;
|
800
|
+
let maskPattern = /§(\d+)/g;
|
801
|
+
let matches = [];
|
802
|
+
let replaceLayers = 0;
|
803
|
+
let replace = (replacePattern) => {
|
804
|
+
let didReplace = false;
|
805
|
+
str = str.replaceAll(replacePattern, function (match) {
|
806
|
+
didReplace = true;
|
807
|
+
let glyph = '§' + (maskCount++);
|
808
|
+
let mask;
|
809
|
+
let masked;
|
810
|
+
if (keepDelimiters) {
|
811
|
+
let startDelimiter = match[0];
|
812
|
+
let endDelimiter = match.slice(-1);
|
813
|
+
masked = match.slice(1, -1);
|
814
|
+
mask = startDelimiter + glyph + endDelimiter;
|
815
|
+
}
|
816
|
+
else {
|
817
|
+
masked = match;
|
818
|
+
mask = glyph;
|
819
|
+
}
|
820
|
+
matches.push(masked);
|
821
|
+
return mask;
|
822
|
+
});
|
823
|
+
if (didReplace)
|
824
|
+
replaceLayers++;
|
825
|
+
};
|
826
|
+
[maskPattern, ...patterns].forEach(replace);
|
827
|
+
let restore = (s, transform = identity) => {
|
828
|
+
for (let i = 0; i < replaceLayers; i++) {
|
829
|
+
s = s.replace(maskPattern, (match, placeholderIndex) => transform(matches[placeholderIndex]));
|
830
|
+
}
|
831
|
+
return s;
|
832
|
+
};
|
833
|
+
return { masked: str, restore };
|
834
|
+
}
|
835
|
+
const QUOTED_STRING_PATTERN = /'(?:\\\\|\\'|[^'])*'|"(?:\\\\|\\"|[^"])*"/g;
|
836
|
+
const NESTED_GROUP_PATTERN = /{(?:[^{}]|{[^{}]*})*}|\((?:[^\(\)]|\([^\(\)]*\))*\)|\[(?:[^\[\]]|\[[^\[\]]*\])*\]/g;
|
837
|
+
function expressionOutline(str) {
|
838
|
+
return maskPattern(str, [QUOTED_STRING_PATTERN, NESTED_GROUP_PATTERN], { keepDelimiters: true });
|
839
|
+
}
|
840
|
+
function ensureDoubleQuotes(str) {
|
841
|
+
if (str[0] === '"')
|
842
|
+
return str;
|
843
|
+
str = str.slice(1, -1);
|
844
|
+
let transformed = str.replace(/(\\\\)|(\\')|(\\")|(")/g, function (_match, escapedBackslash, escapedSingleQuote, _doubleQuote) {
|
845
|
+
return escapedBackslash
|
846
|
+
|| (escapedSingleQuote && "'")
|
847
|
+
|| '\\"';
|
848
|
+
});
|
849
|
+
return '"' + transformed + '"';
|
850
|
+
}
|
851
|
+
function parseString(value) {
|
852
|
+
return JSON.parse(ensureDoubleQuotes(value));
|
853
|
+
}
|
854
|
+
function parseRelaxedJSON(str) {
|
855
|
+
let { masked, restore } = maskPattern(str, [QUOTED_STRING_PATTERN]);
|
856
|
+
masked = masked.replace(/([a-z_$][\w$]*:)/gi, (unquotedProperty) => ('"' + unquotedProperty.slice(0, -1) + '":'));
|
857
|
+
masked = masked.replace(/,\s*([}\]])/g, '$1');
|
858
|
+
masked = restore(masked, ensureDoubleQuotes);
|
859
|
+
return JSON.parse(masked);
|
860
|
+
}
|
861
|
+
function parseScalarJSONPairs(str) {
|
862
|
+
let { maskedTokens, restore } = complexTokenOutlines(str);
|
863
|
+
return maskedTokens.map((maskedToken) => {
|
864
|
+
let [_match, string, json] = maskedToken.match(/([^{]+)({[^}]*})?/);
|
865
|
+
return [
|
866
|
+
restore(string.trim()),
|
867
|
+
json && parseRelaxedJSON(restore(json))
|
868
|
+
];
|
869
|
+
});
|
870
|
+
}
|
741
871
|
return {
|
742
872
|
parseURL,
|
743
873
|
normalizeURL,
|
@@ -781,14 +911,16 @@ up.util = (function () {
|
|
781
911
|
isBoolean,
|
782
912
|
isNumber,
|
783
913
|
isElement,
|
914
|
+
isTextNode,
|
784
915
|
isJQuery,
|
785
|
-
|
916
|
+
isElementLike,
|
786
917
|
isPromise,
|
787
918
|
isOptions,
|
788
919
|
isArray,
|
789
920
|
isFormData,
|
790
921
|
isList,
|
791
922
|
isRegExp,
|
923
|
+
isAdjacentPosition,
|
792
924
|
timer: scheduleTimer,
|
793
925
|
contains,
|
794
926
|
containsAll,
|
@@ -819,21 +951,30 @@ up.util = (function () {
|
|
819
951
|
isCrossOrigin,
|
820
952
|
task: queueTask,
|
821
953
|
isEqual,
|
822
|
-
|
954
|
+
getSimpleTokens,
|
955
|
+
getComplexTokens,
|
823
956
|
wrapList,
|
824
957
|
wrapValue,
|
825
958
|
uid,
|
826
959
|
upperCaseFirst,
|
827
960
|
lowerCaseFirst,
|
828
961
|
delegate: defineDelegates,
|
962
|
+
delegatePromise,
|
829
963
|
reverse,
|
830
964
|
camelToKebabCase,
|
831
|
-
replaceValue,
|
832
965
|
sprintf,
|
833
|
-
|
966
|
+
withRenamedKeys,
|
834
967
|
memoizeMethod,
|
835
968
|
safeStringifyJSON,
|
836
969
|
variant,
|
970
|
+
cleaner,
|
971
|
+
scanFunctions,
|
972
|
+
args: parseArgs,
|
973
|
+
parseRelaxedJSON,
|
974
|
+
parseScalarJSONPairs,
|
975
|
+
maskPattern,
|
976
|
+
expressionOutline,
|
977
|
+
parseString,
|
837
978
|
};
|
838
979
|
})();
|
839
980
|
|
@@ -865,17 +1006,12 @@ up.error = (function () {
|
|
865
1006
|
throw value;
|
866
1007
|
}
|
867
1008
|
}
|
868
|
-
function
|
869
|
-
console.error('Uncaught %o', error);
|
870
|
-
let event = new ErrorEvent('error', { error, message: 'Uncaught ' + error });
|
871
|
-
window.dispatchEvent(event);
|
872
|
-
}
|
873
|
-
function guard(fn) {
|
1009
|
+
function guard(fn, ...args) {
|
874
1010
|
try {
|
875
|
-
return fn();
|
1011
|
+
return fn(...args);
|
876
1012
|
}
|
877
1013
|
catch (error) {
|
878
|
-
|
1014
|
+
reportError(error);
|
879
1015
|
}
|
880
1016
|
}
|
881
1017
|
function guardFn(fn) {
|
@@ -907,7 +1043,6 @@ up.migrate = {
|
|
907
1043
|
/***/ (() => {
|
908
1044
|
|
909
1045
|
up.browser = (function () {
|
910
|
-
const u = up.util;
|
911
1046
|
function submitForm(form) {
|
912
1047
|
form.submit();
|
913
1048
|
}
|
@@ -917,7 +1052,6 @@ up.browser = (function () {
|
|
917
1052
|
function canJQuery() {
|
918
1053
|
return !!window.jQuery;
|
919
1054
|
}
|
920
|
-
const canHasSelector = u.memoize(() => CSS.supports('selector(:has(*))'));
|
921
1055
|
function popCookie(name) {
|
922
1056
|
var _a;
|
923
1057
|
let value = (_a = document.cookie.match(new RegExp(name + "=(\\w+)"))) === null || _a === void 0 ? void 0 : _a[1];
|
@@ -939,7 +1073,6 @@ up.browser = (function () {
|
|
939
1073
|
canJQuery,
|
940
1074
|
assertConfirmed,
|
941
1075
|
popCookie,
|
942
|
-
canHasSelector,
|
943
1076
|
};
|
944
1077
|
})();
|
945
1078
|
|
@@ -952,18 +1085,23 @@ __webpack_require__(8);
|
|
952
1085
|
up.element = (function () {
|
953
1086
|
const u = up.util;
|
954
1087
|
function first(...args) {
|
955
|
-
|
956
|
-
const root = args[0] || document;
|
1088
|
+
let [root = document, selector] = u.args(args, 'val', 'val');
|
957
1089
|
return root.querySelector(selector);
|
958
1090
|
}
|
959
1091
|
function subtree(root, selector) {
|
960
1092
|
const results = [];
|
961
|
-
if (root
|
1093
|
+
if (elementLikeMatches(root, selector)) {
|
962
1094
|
results.push(root);
|
963
1095
|
}
|
964
1096
|
results.push(...root.querySelectorAll(selector));
|
965
1097
|
return results;
|
966
1098
|
}
|
1099
|
+
function subtreeFirst(root, selector) {
|
1100
|
+
return elementLikeMatches(root, selector) ? root : root.querySelector(selector);
|
1101
|
+
}
|
1102
|
+
function elementLikeMatches(elementLike, selector) {
|
1103
|
+
return u.isElement(elementLike) && elementLike.matches(selector);
|
1104
|
+
}
|
967
1105
|
function contains(root, selectorOrElement) {
|
968
1106
|
const element = getOne(selectorOrElement);
|
969
1107
|
return Node.prototype.contains.call(root, element);
|
@@ -1005,24 +1143,38 @@ up.element = (function () {
|
|
1005
1143
|
}
|
1006
1144
|
}
|
1007
1145
|
function hide(element) {
|
1008
|
-
element
|
1146
|
+
setVisible(element, false);
|
1009
1147
|
}
|
1010
1148
|
function show(element) {
|
1011
|
-
element
|
1012
|
-
if (element.style.display === 'none') {
|
1013
|
-
element.style.display = '';
|
1014
|
-
}
|
1149
|
+
setVisible(element, true);
|
1015
1150
|
}
|
1016
|
-
function
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1151
|
+
function showTemp(element) {
|
1152
|
+
return setVisibleTemp(element, true);
|
1153
|
+
}
|
1154
|
+
function hideTemp(element) {
|
1155
|
+
return setVisibleTemp(element, false);
|
1021
1156
|
}
|
1022
|
-
function
|
1023
|
-
if (
|
1024
|
-
|
1157
|
+
function setVisibleTemp(element, newVisible) {
|
1158
|
+
if (newVisible === isVisible(element))
|
1159
|
+
return u.noop;
|
1160
|
+
setVisible(element, newVisible);
|
1161
|
+
return () => setVisible(element, !newVisible);
|
1162
|
+
}
|
1163
|
+
function setVisible(element, newVisible) {
|
1164
|
+
if (newVisible) {
|
1165
|
+
element.removeAttribute('hidden');
|
1166
|
+
if (element.style.display === 'none') {
|
1167
|
+
element.style.display = '';
|
1168
|
+
}
|
1169
|
+
}
|
1170
|
+
else {
|
1171
|
+
element.setAttribute('hidden', '');
|
1025
1172
|
}
|
1173
|
+
}
|
1174
|
+
function toggle(element, newVisible = !isVisible(element)) {
|
1175
|
+
setVisible(element, newVisible);
|
1176
|
+
}
|
1177
|
+
function setAttrPresence(element, attr, value, newPresent) {
|
1026
1178
|
if (newPresent) {
|
1027
1179
|
return element.setAttribute(attr, value);
|
1028
1180
|
}
|
@@ -1041,11 +1193,9 @@ up.element = (function () {
|
|
1041
1193
|
}
|
1042
1194
|
}
|
1043
1195
|
}
|
1044
|
-
function
|
1045
|
-
|
1046
|
-
|
1047
|
-
oldAttrs[key] = element.getAttribute(key);
|
1048
|
-
}
|
1196
|
+
function setAttrsTemp(element, attrs) {
|
1197
|
+
let keys = Object.keys(attrs);
|
1198
|
+
let oldAttrs = pickAttrs(element, keys);
|
1049
1199
|
setAttrs(element, attrs);
|
1050
1200
|
return () => setAttrs(element, oldAttrs);
|
1051
1201
|
}
|
@@ -1054,8 +1204,8 @@ up.element = (function () {
|
|
1054
1204
|
const selector = "meta" + attrSelector('name', name);
|
1055
1205
|
return (_a = first(selector)) === null || _a === void 0 ? void 0 : _a.getAttribute('content');
|
1056
1206
|
}
|
1057
|
-
function insertBefore(
|
1058
|
-
|
1207
|
+
function insertBefore(existingNode, newNode) {
|
1208
|
+
existingNode.parentNode.insertBefore(newNode, existingNode);
|
1059
1209
|
}
|
1060
1210
|
function createFromSelector(selector, attrs = {}) {
|
1061
1211
|
let { includePath } = parseSelector(selector);
|
@@ -1063,7 +1213,7 @@ up.element = (function () {
|
|
1063
1213
|
let depthElement;
|
1064
1214
|
let previousElement;
|
1065
1215
|
for (let includeSegment of includePath) {
|
1066
|
-
let { tagName
|
1216
|
+
let { tagName } = includeSegment;
|
1067
1217
|
if (!tagName || tagName === '*') {
|
1068
1218
|
tagName = 'div';
|
1069
1219
|
}
|
@@ -1071,25 +1221,14 @@ up.element = (function () {
|
|
1071
1221
|
if (!rootElement) {
|
1072
1222
|
rootElement = depthElement;
|
1073
1223
|
}
|
1074
|
-
|
1075
|
-
depthElement.id = id;
|
1076
|
-
}
|
1077
|
-
for (let className of classNames) {
|
1078
|
-
depthElement.classList.add(className);
|
1079
|
-
}
|
1080
|
-
for (let attributeName in attributes) {
|
1081
|
-
let attributeValue = attributes[attributeName];
|
1082
|
-
depthElement.setAttribute(attributeName, attributeValue || '');
|
1083
|
-
}
|
1224
|
+
makeVariation(depthElement, includeSegment);
|
1084
1225
|
previousElement === null || previousElement === void 0 ? void 0 : previousElement.appendChild(depthElement);
|
1085
1226
|
previousElement = depthElement;
|
1086
1227
|
}
|
1087
1228
|
for (let key in attrs) {
|
1088
1229
|
let value = attrs[key];
|
1089
1230
|
if (key === 'class') {
|
1090
|
-
|
1091
|
-
rootElement.classList.add(klass);
|
1092
|
-
}
|
1231
|
+
addClasses(rootElement, u.wrapList(value));
|
1093
1232
|
}
|
1094
1233
|
else if (key === 'style') {
|
1095
1234
|
setInlineStyle(rootElement, value);
|
@@ -1098,7 +1237,12 @@ up.element = (function () {
|
|
1098
1237
|
rootElement.textContent = value;
|
1099
1238
|
}
|
1100
1239
|
else if (key === 'content') {
|
1101
|
-
|
1240
|
+
if (u.isString(value)) {
|
1241
|
+
rootElement.innerHTML = value;
|
1242
|
+
}
|
1243
|
+
else {
|
1244
|
+
rootElement.append(...u.wrapList(value));
|
1245
|
+
}
|
1102
1246
|
}
|
1103
1247
|
else {
|
1104
1248
|
rootElement.setAttribute(key, value);
|
@@ -1106,14 +1250,24 @@ up.element = (function () {
|
|
1106
1250
|
}
|
1107
1251
|
return rootElement;
|
1108
1252
|
}
|
1109
|
-
function
|
1253
|
+
function makeVariation(element, { id, classNames, attributes }) {
|
1254
|
+
if (id) {
|
1255
|
+
element.id = id;
|
1256
|
+
}
|
1257
|
+
for (let [name, value] of Object.entries(attributes)) {
|
1258
|
+
element.setAttribute(name, value);
|
1259
|
+
}
|
1260
|
+
addClasses(element, classNames);
|
1261
|
+
}
|
1262
|
+
function parseSelector(rawSelector) {
|
1110
1263
|
let excludeRaw;
|
1111
|
-
const
|
1112
|
-
|
1264
|
+
const { masked: selectorOutline, restore: restoreSelectorLiterals, } = u.expressionOutline(rawSelector);
|
1265
|
+
const includeWithoutAttrs = selectorOutline.replace(/:not\([^)]*\)/, function (match) {
|
1266
|
+
excludeRaw = restoreSelectorLiterals(match);
|
1113
1267
|
return '';
|
1114
1268
|
});
|
1115
|
-
|
1116
|
-
const includeSegments =
|
1269
|
+
let includeRaw = restoreSelectorLiterals(includeWithoutAttrs);
|
1270
|
+
const includeSegments = includeWithoutAttrs.split(/[ >]+/);
|
1117
1271
|
let includePath = includeSegments.map(function (depthSelector) {
|
1118
1272
|
let parsed = {
|
1119
1273
|
tagName: null,
|
@@ -1133,14 +1287,15 @@ up.element = (function () {
|
|
1133
1287
|
parsed.classNames.push(className);
|
1134
1288
|
return '';
|
1135
1289
|
});
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1290
|
+
depthSelector = depthSelector.replace(/\[[^\]]*]/g, function (attr) {
|
1291
|
+
attr = restoreSelectorLiterals(attr);
|
1292
|
+
let [_raw, name, _operator, quote, value] = attr.match(/\[([\w-]+)(?:([~|^$*]?=)(["'])?([^\3\]]*?)\3)?]/);
|
1293
|
+
quote || (quote = '"');
|
1294
|
+
parsed.attributes[name] = value ? u.parseString(quote + value + quote) : '';
|
1295
|
+
return '';
|
1296
|
+
});
|
1142
1297
|
if (depthSelector) {
|
1143
|
-
up.fail('Cannot parse selector: ' +
|
1298
|
+
up.fail('Cannot parse selector: ' + rawSelector);
|
1144
1299
|
}
|
1145
1300
|
return parsed;
|
1146
1301
|
});
|
@@ -1150,33 +1305,8 @@ up.element = (function () {
|
|
1150
1305
|
excludeRaw,
|
1151
1306
|
};
|
1152
1307
|
}
|
1153
|
-
|
1154
|
-
|
1155
|
-
return string.replace(ATTR_SELECTOR_PATTERN, function (_match, name, operator, quote, value) {
|
1156
|
-
if (value) {
|
1157
|
-
value = value.replace(/\\([\\"'])/, '$1');
|
1158
|
-
}
|
1159
|
-
return replacement({ name, operator, quote, value });
|
1160
|
-
});
|
1161
|
-
}
|
1162
|
-
function removeAttrSelectorValues(selector) {
|
1163
|
-
let values = [];
|
1164
|
-
selector = replaceAttrSelectors(selector, function ({ name, value }) {
|
1165
|
-
values.push(value);
|
1166
|
-
return `[${name}]`;
|
1167
|
-
});
|
1168
|
-
return [selector, values];
|
1169
|
-
}
|
1170
|
-
function affix(parent, ...args) {
|
1171
|
-
let position, selector;
|
1172
|
-
const attributes = u.extractOptions(args);
|
1173
|
-
if (args.length === 2) {
|
1174
|
-
[position, selector] = args;
|
1175
|
-
}
|
1176
|
-
else {
|
1177
|
-
position = 'beforeend';
|
1178
|
-
selector = args[0];
|
1179
|
-
}
|
1308
|
+
function affix(...args) {
|
1309
|
+
let [parent, position = 'beforeend', selector, attributes] = u.args(args, 'val', u.isAdjacentPosition, 'val', 'options');
|
1180
1310
|
const element = createFromSelector(selector, attributes);
|
1181
1311
|
parent.insertAdjacentElement(position, element);
|
1182
1312
|
return element;
|
@@ -1215,14 +1345,22 @@ up.element = (function () {
|
|
1215
1345
|
scriptish.replaceWith(clone);
|
1216
1346
|
}
|
1217
1347
|
function createFromHTML(html) {
|
1348
|
+
return extractSingular(createNodesFromHTML(html));
|
1349
|
+
}
|
1350
|
+
function extractSingular(nodes) {
|
1351
|
+
if (nodes.length === 1 && u.isElementLike(nodes[0])) {
|
1352
|
+
return nodes[0];
|
1353
|
+
}
|
1354
|
+
else {
|
1355
|
+
up.fail('Expected a single element, but got %d elements', nodes.length);
|
1356
|
+
}
|
1357
|
+
}
|
1358
|
+
function createNodesFromHTML(html) {
|
1359
|
+
html = html.trim();
|
1218
1360
|
const range = document.createRange();
|
1219
1361
|
range.setStart(document.body, 0);
|
1220
|
-
const fragment = range.createContextualFragment(html
|
1221
|
-
|
1222
|
-
if (elements.length !== 1) {
|
1223
|
-
throw new Error('HTML must have a single root element');
|
1224
|
-
}
|
1225
|
-
return elements[0];
|
1362
|
+
const fragment = range.createContextualFragment(html);
|
1363
|
+
return fragment.childNodes;
|
1226
1364
|
}
|
1227
1365
|
function getRoot() {
|
1228
1366
|
return document.documentElement;
|
@@ -1231,7 +1369,7 @@ up.element = (function () {
|
|
1231
1369
|
element.offsetHeight;
|
1232
1370
|
}
|
1233
1371
|
function concludeCSSTransition(element) {
|
1234
|
-
const undo =
|
1372
|
+
const undo = setStyleTemp(element, { transition: 'none' });
|
1235
1373
|
paint(element);
|
1236
1374
|
return undo;
|
1237
1375
|
}
|
@@ -1264,19 +1402,28 @@ up.element = (function () {
|
|
1264
1402
|
}
|
1265
1403
|
function unwrap(wrapper) {
|
1266
1404
|
preservingFocus(function () {
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1405
|
+
let childNodes = [...wrapper.childNodes];
|
1406
|
+
for (let child of childNodes)
|
1407
|
+
insertBefore(wrapper, child);
|
1408
|
+
wrapper.remove();
|
1271
1409
|
});
|
1272
1410
|
}
|
1273
|
-
function
|
1274
|
-
let childNode;
|
1411
|
+
function wrapNodes(nodeOrNodes) {
|
1275
1412
|
const wrapper = document.createElement('up-wrapper');
|
1276
|
-
|
1277
|
-
|
1413
|
+
wrapper.append(...u.wrapList(nodeOrNodes));
|
1414
|
+
return wrapper;
|
1415
|
+
}
|
1416
|
+
function wrapIfRequired(nodes) {
|
1417
|
+
if (nodes.length === 1 && u.isElement(nodes[0])) {
|
1418
|
+
return nodes[0];
|
1419
|
+
}
|
1420
|
+
else {
|
1421
|
+
return wrapNodes(nodes);
|
1278
1422
|
}
|
1279
|
-
|
1423
|
+
}
|
1424
|
+
function wrapChildren(element) {
|
1425
|
+
const wrapper = wrapNodes(element.childNodes);
|
1426
|
+
element.append(wrapper);
|
1280
1427
|
return wrapper;
|
1281
1428
|
}
|
1282
1429
|
function preservingFocus(fn) {
|
@@ -1290,77 +1437,91 @@ up.element = (function () {
|
|
1290
1437
|
}
|
1291
1438
|
}
|
1292
1439
|
}
|
1440
|
+
function parseAttr(element, attribute, ...parsers) {
|
1441
|
+
var _a;
|
1442
|
+
if (!((_a = element.hasAttribute) === null || _a === void 0 ? void 0 : _a.call(element, attribute)))
|
1443
|
+
return undefined;
|
1444
|
+
let rawValue = element.getAttribute(attribute);
|
1445
|
+
for (let parser of parsers) {
|
1446
|
+
let parserResult = parser(rawValue, attribute, element);
|
1447
|
+
if (u.isDefined(parserResult))
|
1448
|
+
return parserResult;
|
1449
|
+
}
|
1450
|
+
}
|
1293
1451
|
function stringAttr(element, attribute) {
|
1294
|
-
|
1295
|
-
return u.replaceValue(value, null, undefined);
|
1452
|
+
return parseAttr(element, attribute, tryParseString);
|
1296
1453
|
}
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1454
|
+
let tryParseString = u.identity;
|
1455
|
+
function booleanAttr(element, attribute) {
|
1456
|
+
return parseAttr(element, attribute, tryParseBoolean);
|
1457
|
+
}
|
1458
|
+
function tryParseBoolean(value, attribute) {
|
1301
1459
|
switch (value) {
|
1302
1460
|
case 'false': {
|
1303
1461
|
return false;
|
1304
1462
|
}
|
1305
1463
|
case 'true':
|
1306
1464
|
case '':
|
1307
|
-
case attribute:
|
1308
|
-
|
1309
|
-
}
|
1310
|
-
default: {
|
1311
|
-
if (pass) {
|
1312
|
-
return value;
|
1313
|
-
}
|
1314
|
-
else {
|
1465
|
+
case attribute:
|
1466
|
+
{
|
1315
1467
|
return true;
|
1316
1468
|
}
|
1317
|
-
}
|
1318
1469
|
}
|
1319
1470
|
}
|
1320
|
-
function booleanOrStringAttr(element, attribute
|
1321
|
-
|
1322
|
-
|
1471
|
+
function booleanOrStringAttr(element, attribute) {
|
1472
|
+
return parseAttr(element, attribute, tryParseBoolean, tryParseString);
|
1473
|
+
}
|
1474
|
+
function booleanOrNumberAttr(element, attribute) {
|
1475
|
+
return parseAttr(element, attribute, tryParseBoolean, tryParseNumber);
|
1323
1476
|
}
|
1324
1477
|
function numberAttr(element, attribute) {
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1478
|
+
return parseAttr(element, attribute, tryParseNumber);
|
1479
|
+
}
|
1480
|
+
function tryParseNumber(value) {
|
1481
|
+
value = value.replaceAll('_', '');
|
1482
|
+
if (value.match(/^-?[\d.]+$/)) {
|
1483
|
+
return parseFloat(value);
|
1331
1484
|
}
|
1332
1485
|
}
|
1333
1486
|
function jsonAttr(element, attribute) {
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
}
|
1340
|
-
function callbackAttr(link, attr, { exposedKeys = [], mainKey = 'event' } = {}) {
|
1341
|
-
let code = link.getAttribute(attr);
|
1342
|
-
if (code) {
|
1343
|
-
const callback = up.NonceableCallback.fromString(code).toFunction(mainKey, ...exposedKeys);
|
1344
|
-
return function (event) {
|
1345
|
-
const exposedValues = Object.values(u.pick(event, exposedKeys));
|
1346
|
-
return callback.call(link, event, ...exposedValues);
|
1347
|
-
};
|
1487
|
+
return parseAttr(element, attribute, tryParseJSON);
|
1488
|
+
}
|
1489
|
+
function tryParseJSON(value) {
|
1490
|
+
if (value === null || value === void 0 ? void 0 : value.trim()) {
|
1491
|
+
return u.parseRelaxedJSON(value);
|
1348
1492
|
}
|
1349
1493
|
}
|
1350
|
-
function
|
1494
|
+
function callbackAttr(link, attr, callbackOptions) {
|
1495
|
+
return parseAttr(link, attr, (value) => tryParseCallback(value, link, callbackOptions));
|
1496
|
+
}
|
1497
|
+
function tryParseCallback(code, link, { exposedKeys = [], mainKey = 'event' } = {}) {
|
1498
|
+
const callback = up.NonceableCallback.fromString(code).toFunction(mainKey, ...exposedKeys);
|
1499
|
+
return function (event) {
|
1500
|
+
const exposedValues = Object.values(u.pick(event, exposedKeys));
|
1501
|
+
return callback.call(link, event, ...exposedValues);
|
1502
|
+
};
|
1503
|
+
}
|
1504
|
+
function closestAttr(element, attr, readAttrFn = stringAttr) {
|
1351
1505
|
let match = element.closest('[' + attr + ']');
|
1352
1506
|
if (match) {
|
1353
|
-
return
|
1507
|
+
return readAttrFn(match, attr);
|
1354
1508
|
}
|
1355
1509
|
}
|
1356
|
-
function
|
1357
|
-
|
1358
|
-
|
1359
|
-
return () => setInlineStyle(element, oldStyles);
|
1510
|
+
function addClasses(element, classes) {
|
1511
|
+
for (let klass of classes)
|
1512
|
+
element.classList.add(klass);
|
1360
1513
|
}
|
1361
|
-
function
|
1362
|
-
element
|
1363
|
-
|
1514
|
+
function addClassTemp(element, klass) {
|
1515
|
+
return setClassStateTemp(element, klass, true);
|
1516
|
+
}
|
1517
|
+
function removeClassTemp(element, klass) {
|
1518
|
+
return setClassStateTemp(element, klass, false);
|
1519
|
+
}
|
1520
|
+
function setClassStateTemp(element, klass, targetState) {
|
1521
|
+
if (element.classList.contains(klass) === targetState)
|
1522
|
+
return u.noop;
|
1523
|
+
element.classList.toggle(klass, targetState);
|
1524
|
+
return () => element.classList.toggle(klass, !targetState);
|
1364
1525
|
}
|
1365
1526
|
function computedStyle(element, props) {
|
1366
1527
|
const style = window.getComputedStyle(element);
|
@@ -1400,16 +1561,24 @@ up.element = (function () {
|
|
1400
1561
|
}
|
1401
1562
|
}
|
1402
1563
|
}
|
1564
|
+
function setStyleTemp(element, newStyles) {
|
1565
|
+
const oldStyles = inlineStyle(element, Object.keys(newStyles));
|
1566
|
+
setInlineStyle(element, newStyles);
|
1567
|
+
return () => setInlineStyle(element, oldStyles);
|
1568
|
+
}
|
1403
1569
|
function isVisible(element) {
|
1404
1570
|
return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
|
1405
1571
|
}
|
1406
1572
|
function isUpPrefixed(string) {
|
1407
1573
|
return /^up-/.test(string);
|
1408
1574
|
}
|
1409
|
-
function
|
1410
|
-
let attrNames = u.filter(element.getAttributeNames(), isUpPrefixed);
|
1575
|
+
function pickAttrs(element, attrNames) {
|
1411
1576
|
return u.mapObject(attrNames, (name) => [name, element.getAttribute(name)]);
|
1412
1577
|
}
|
1578
|
+
function upAttrs(element) {
|
1579
|
+
let attrNames = element.getAttributeNames().filter(isUpPrefixed);
|
1580
|
+
return pickAttrs(element, attrNames);
|
1581
|
+
}
|
1413
1582
|
function upClasses(element) {
|
1414
1583
|
return u.filter(element.classList.values(), isUpPrefixed);
|
1415
1584
|
}
|
@@ -1436,8 +1605,29 @@ up.element = (function () {
|
|
1436
1605
|
selector += `:not(${excludes.join()})`;
|
1437
1606
|
return selector;
|
1438
1607
|
}
|
1608
|
+
function matchSelectorMap(selectorMap, element) {
|
1609
|
+
let matches = [];
|
1610
|
+
if (selectorMap) {
|
1611
|
+
for (let [selector, value] of Object.entries(selectorMap)) {
|
1612
|
+
if (u.isDefined(value) && element.matches(selector)) {
|
1613
|
+
matches.push(value);
|
1614
|
+
}
|
1615
|
+
}
|
1616
|
+
}
|
1617
|
+
return matches;
|
1618
|
+
}
|
1619
|
+
function documentPosition(element) {
|
1620
|
+
let nextSibling = element.nextElementSibling;
|
1621
|
+
if (nextSibling) {
|
1622
|
+
return [nextSibling, 'beforebegin'];
|
1623
|
+
}
|
1624
|
+
else {
|
1625
|
+
return [element.parentElement, 'beforeend'];
|
1626
|
+
}
|
1627
|
+
}
|
1439
1628
|
return {
|
1440
1629
|
subtree,
|
1630
|
+
subtreeFirst,
|
1441
1631
|
contains,
|
1442
1632
|
closestAttr,
|
1443
1633
|
ancestor,
|
@@ -1446,12 +1636,14 @@ up.element = (function () {
|
|
1446
1636
|
list: getList,
|
1447
1637
|
toggle,
|
1448
1638
|
hide,
|
1639
|
+
hideTemp,
|
1449
1640
|
show,
|
1641
|
+
showTemp,
|
1450
1642
|
metaContent,
|
1451
1643
|
insertBefore,
|
1452
1644
|
createFromSelector,
|
1453
1645
|
setAttrs,
|
1454
|
-
|
1646
|
+
setAttrsTemp,
|
1455
1647
|
affix,
|
1456
1648
|
idSelector,
|
1457
1649
|
classSelector,
|
@@ -1460,7 +1652,9 @@ up.element = (function () {
|
|
1460
1652
|
tagName: elementTagName,
|
1461
1653
|
createBrokenDocumentFromHTML,
|
1462
1654
|
fixParserDamage,
|
1655
|
+
createNodesFromHTML,
|
1463
1656
|
createFromHTML,
|
1657
|
+
extractSingular,
|
1464
1658
|
get root() { return getRoot(); },
|
1465
1659
|
paint,
|
1466
1660
|
concludeCSSTransition,
|
@@ -1470,13 +1664,15 @@ up.element = (function () {
|
|
1470
1664
|
setMissingAttr,
|
1471
1665
|
unwrap,
|
1472
1666
|
wrapChildren,
|
1667
|
+
wrapIfRequired,
|
1473
1668
|
attr: stringAttr,
|
1474
1669
|
booleanAttr,
|
1475
1670
|
numberAttr,
|
1476
1671
|
jsonAttr,
|
1477
1672
|
callbackAttr,
|
1478
1673
|
booleanOrStringAttr,
|
1479
|
-
|
1674
|
+
booleanOrNumberAttr,
|
1675
|
+
setStyleTemp,
|
1480
1676
|
style: computedStyle,
|
1481
1677
|
styleNumber: computedStyleNumber,
|
1482
1678
|
inlineStyle,
|
@@ -1484,14 +1680,19 @@ up.element = (function () {
|
|
1484
1680
|
isVisible,
|
1485
1681
|
upAttrs,
|
1486
1682
|
upClasses,
|
1487
|
-
|
1488
|
-
|
1683
|
+
setAttrPresence,
|
1684
|
+
addClasses,
|
1685
|
+
addClassTemp,
|
1686
|
+
removeClassTemp,
|
1489
1687
|
cleanJQuery,
|
1490
1688
|
parseSelector,
|
1491
1689
|
isEmpty,
|
1492
1690
|
crossOriginSelector,
|
1493
1691
|
isIntersectingWindow,
|
1494
1692
|
unionSelector,
|
1693
|
+
matchSelectorMap,
|
1694
|
+
elementLikeMatches,
|
1695
|
+
documentPosition,
|
1495
1696
|
};
|
1496
1697
|
})();
|
1497
1698
|
|
@@ -1685,6 +1886,9 @@ up.OptionsParser = class OptionsParser {
|
|
1685
1886
|
booleanOrString(key, keyOptions) {
|
1686
1887
|
this.parse(e.booleanOrStringAttr, key, keyOptions);
|
1687
1888
|
}
|
1889
|
+
booleanOrNumber(key, keyOptions) {
|
1890
|
+
this.parse(e.booleanOrNumberAttr, key, keyOptions);
|
1891
|
+
}
|
1688
1892
|
json(key, keyOptions) {
|
1689
1893
|
this.parse(e.jsonAttr, key, keyOptions);
|
1690
1894
|
}
|
@@ -1805,16 +2009,17 @@ up.Rect = class Rect extends up.Record {
|
|
1805
2009
|
/***/ (() => {
|
1806
2010
|
|
1807
2011
|
const e = up.element;
|
2012
|
+
const u = up.util;
|
1808
2013
|
const SHIFT_CLASS = 'up-scrollbar-away';
|
1809
2014
|
up.BodyShifter = class BodyShifter {
|
1810
2015
|
constructor() {
|
1811
2016
|
this._anchoredElements = new Set();
|
1812
2017
|
this._stack = 0;
|
1813
|
-
this.
|
2018
|
+
this._cleaner = u.cleaner();
|
1814
2019
|
}
|
1815
2020
|
lowerStack() {
|
1816
2021
|
if (--this._stack === 0)
|
1817
|
-
this.
|
2022
|
+
this._cleaner.clean();
|
1818
2023
|
}
|
1819
2024
|
raiseStack() {
|
1820
2025
|
if (++this._stack === 1)
|
@@ -1830,7 +2035,7 @@ up.BodyShifter = class BodyShifter {
|
|
1830
2035
|
}
|
1831
2036
|
_shiftNow() {
|
1832
2037
|
this._rootScrollbarWidth = up.viewport.rootScrollbarWidth();
|
1833
|
-
this.
|
2038
|
+
this._cleaner(e.setStyleTemp(e.root, {
|
1834
2039
|
'--up-scrollbar-width': this._rootScrollbarWidth + 'px'
|
1835
2040
|
}));
|
1836
2041
|
this._shiftElement(document.body, 'padding-right');
|
@@ -1842,13 +2047,7 @@ up.BodyShifter = class BodyShifter {
|
|
1842
2047
|
if (!this._isShifted())
|
1843
2048
|
return;
|
1844
2049
|
let originalValue = e.style(element, styleProp);
|
1845
|
-
this.
|
1846
|
-
}
|
1847
|
-
_unshiftNow() {
|
1848
|
-
let cleaner;
|
1849
|
-
while (cleaner = this._cleaners.pop()) {
|
1850
|
-
cleaner();
|
1851
|
-
}
|
2050
|
+
this._cleaner(e.setStyleTemp(element, { ['--up-original-' + styleProp]: originalValue }), e.addClassTemp(element, SHIFT_CLASS));
|
1852
2051
|
}
|
1853
2052
|
};
|
1854
2053
|
|
@@ -1865,10 +2064,6 @@ up.Change = class Change {
|
|
1865
2064
|
execute() {
|
1866
2065
|
throw new up.NotImplemented();
|
1867
2066
|
}
|
1868
|
-
onFinished(renderResult) {
|
1869
|
-
var _a, _b;
|
1870
|
-
return (_b = (_a = this.options).onFinished) === null || _b === void 0 ? void 0 : _b.call(_a, renderResult);
|
1871
|
-
}
|
1872
2067
|
improveHistoryValue(existingValue, newValue) {
|
1873
2068
|
if ((existingValue === false) || u.isString(existingValue)) {
|
1874
2069
|
return existingValue;
|
@@ -1899,30 +2094,30 @@ up.Change.Addition = class Addition extends up.Change {
|
|
1899
2094
|
}
|
1900
2095
|
handleLayerChangeRequests() {
|
1901
2096
|
if (this.layer.isOverlay()) {
|
1902
|
-
this.
|
2097
|
+
this._tryAcceptLayerFromServer();
|
1903
2098
|
this.abortWhenLayerClosed();
|
1904
|
-
this.layer.tryAcceptForLocation(this.
|
2099
|
+
this.layer.tryAcceptForLocation(this._responseOptions());
|
1905
2100
|
this.abortWhenLayerClosed();
|
1906
|
-
this.
|
2101
|
+
this._tryDismissLayerFromServer();
|
1907
2102
|
this.abortWhenLayerClosed();
|
1908
|
-
this.layer.tryDismissForLocation(this.
|
2103
|
+
this.layer.tryDismissForLocation(this._responseOptions());
|
1909
2104
|
this.abortWhenLayerClosed();
|
1910
2105
|
}
|
1911
2106
|
this.layer.asCurrent(() => {
|
1912
2107
|
for (let eventPlan of this._eventPlans) {
|
1913
|
-
up.emit(Object.assign(Object.assign({}, eventPlan), this.
|
2108
|
+
up.emit(Object.assign(Object.assign({}, eventPlan), this._responseOptions()));
|
1914
2109
|
this.abortWhenLayerClosed();
|
1915
2110
|
}
|
1916
2111
|
});
|
1917
2112
|
}
|
1918
|
-
|
2113
|
+
_tryAcceptLayerFromServer() {
|
1919
2114
|
if (u.isDefined(this._acceptLayer) && this.layer.isOverlay()) {
|
1920
|
-
this.layer.accept(this._acceptLayer, this.
|
2115
|
+
this.layer.accept(this._acceptLayer, this._responseOptions());
|
1921
2116
|
}
|
1922
2117
|
}
|
1923
|
-
|
2118
|
+
_tryDismissLayerFromServer() {
|
1924
2119
|
if (u.isDefined(this._dismissLayer) && this.layer.isOverlay()) {
|
1925
|
-
this.layer.dismiss(this._dismissLayer, this.
|
2120
|
+
this.layer.dismiss(this._dismissLayer, this._responseOptions());
|
1926
2121
|
}
|
1927
2122
|
}
|
1928
2123
|
abortWhenLayerClosed(layer = this.layer) {
|
@@ -1930,7 +2125,7 @@ up.Change.Addition = class Addition extends up.Change {
|
|
1930
2125
|
throw new up.Aborted('Layer was closed');
|
1931
2126
|
}
|
1932
2127
|
}
|
1933
|
-
|
2128
|
+
_setSource({ oldElement, newElement, source }) {
|
1934
2129
|
if (source === 'keep') {
|
1935
2130
|
source = (oldElement && up.fragment.source(oldElement));
|
1936
2131
|
}
|
@@ -1938,18 +2133,18 @@ up.Change.Addition = class Addition extends up.Change {
|
|
1938
2133
|
e.setMissingAttr(newElement, 'up-source', up.fragment.normalizeSource(source));
|
1939
2134
|
}
|
1940
2135
|
}
|
1941
|
-
|
2136
|
+
_setTime({ newElement, time }) {
|
1942
2137
|
e.setMissingAttr(newElement, 'up-time', time ? time.toUTCString() : false);
|
1943
2138
|
}
|
1944
|
-
|
2139
|
+
_setETag({ newElement, etag }) {
|
1945
2140
|
e.setMissingAttr(newElement, 'up-etag', etag || false);
|
1946
2141
|
}
|
1947
2142
|
setReloadAttrs(options) {
|
1948
|
-
this.
|
1949
|
-
this.
|
1950
|
-
this.
|
2143
|
+
this._setSource(options);
|
2144
|
+
this._setTime(options);
|
2145
|
+
this._setETag(options);
|
1951
2146
|
}
|
1952
|
-
|
2147
|
+
_responseOptions() {
|
1953
2148
|
return { response: this._response };
|
1954
2149
|
}
|
1955
2150
|
executeSteps(steps, responseDoc, noneOptions) {
|
@@ -1984,8 +2179,10 @@ up.RenderJob = (_a = class RenderJob {
|
|
1984
2179
|
_executePromise() {
|
1985
2180
|
return __awaiter(this, void 0, void 0, function* () {
|
1986
2181
|
try {
|
1987
|
-
this.
|
2182
|
+
this._emitGuardEvent();
|
1988
2183
|
this.options = up.RenderOptions.preprocess(this.options);
|
2184
|
+
up.browser.assertConfirmed(this.options);
|
2185
|
+
up.RenderOptions.assertContentGiven(this.options);
|
1989
2186
|
let result = yield this._getChange().execute();
|
1990
2187
|
this._handleResult(result);
|
1991
2188
|
return result;
|
@@ -2034,20 +2231,20 @@ up.RenderJob = (_a = class RenderJob {
|
|
2034
2231
|
}
|
2035
2232
|
_getChange() {
|
2036
2233
|
if (this.options.url) {
|
2037
|
-
let
|
2038
|
-
return new up.Change.FromURL(Object.assign(Object.assign({}, this.options), {
|
2039
|
-
}
|
2040
|
-
else if (this.options.response) {
|
2041
|
-
let onRender = () => this._handleAbortOption(null);
|
2042
|
-
return new up.Change.FromResponse(Object.assign(Object.assign({}, this.options), { onRender }));
|
2234
|
+
let onRequestProcessed = (request) => this._handleAbortOption(request);
|
2235
|
+
return new up.Change.FromURL(Object.assign(Object.assign({}, this.options), { onRequestProcessed }));
|
2043
2236
|
}
|
2044
2237
|
else {
|
2045
2238
|
let onRender = () => this._handleAbortOption(null);
|
2046
|
-
|
2239
|
+
if (this.options.response) {
|
2240
|
+
return new up.Change.FromResponse(Object.assign(Object.assign({}, this.options), { onRender }));
|
2241
|
+
}
|
2242
|
+
else {
|
2243
|
+
return new up.Change.FromContent(Object.assign(Object.assign({}, this.options), { onRender }));
|
2244
|
+
}
|
2047
2245
|
}
|
2048
2246
|
}
|
2049
|
-
|
2050
|
-
up.browser.assertConfirmed(this.options);
|
2247
|
+
_emitGuardEvent() {
|
2051
2248
|
let guardEvent = u.pluckKey(this.options, 'guardEvent');
|
2052
2249
|
if (guardEvent) {
|
2053
2250
|
guardEvent.renderOptions = this.options;
|
@@ -2055,24 +2252,23 @@ up.RenderJob = (_a = class RenderJob {
|
|
2055
2252
|
throw new up.Aborted(`Rendering was prevented by ${guardEvent.type} listener`);
|
2056
2253
|
}
|
2057
2254
|
}
|
2058
|
-
up.RenderOptions.assertContentGiven(this.options);
|
2059
2255
|
}
|
2060
2256
|
_handleAbortOption(request) {
|
2061
2257
|
let { abort } = this.options;
|
2062
2258
|
if (!abort || !up.network.isBusy())
|
2063
2259
|
return;
|
2064
|
-
let {
|
2260
|
+
let { bindFragments, bindLayer, origin, layer } = this._getChange().getPreflightProps();
|
2065
2261
|
let abortOptions = {
|
2066
2262
|
except: request,
|
2067
2263
|
logOnce: ['up.render()', 'Change with { abort } option will abort other requests'],
|
2068
|
-
newLayer,
|
2264
|
+
newLayer: (layer === 'new'),
|
2069
2265
|
origin,
|
2070
2266
|
};
|
2071
2267
|
if (abort === 'target') {
|
2072
|
-
up.fragment.abort(
|
2268
|
+
up.fragment.abort(bindFragments, Object.assign({}, abortOptions));
|
2073
2269
|
}
|
2074
2270
|
else if (abort === 'layer') {
|
2075
|
-
up.fragment.abort(Object.assign(Object.assign({}, abortOptions), { layer }));
|
2271
|
+
up.fragment.abort(Object.assign(Object.assign({}, abortOptions), { layer: bindLayer }));
|
2076
2272
|
}
|
2077
2273
|
else if (abort === 'all' || abort === true) {
|
2078
2274
|
up.fragment.abort(Object.assign(Object.assign({}, abortOptions), { layer: 'any' }));
|
@@ -2081,12 +2277,12 @@ up.RenderJob = (_a = class RenderJob {
|
|
2081
2277
|
abort(abortOptions);
|
2082
2278
|
}
|
2083
2279
|
else {
|
2084
|
-
up.fragment.abort(abort, Object.assign(Object.assign({}, abortOptions), { layer }));
|
2280
|
+
up.fragment.abort(abort, Object.assign(Object.assign({}, abortOptions), { layer: bindLayer }));
|
2085
2281
|
}
|
2086
2282
|
}
|
2087
2283
|
},
|
2088
2284
|
(() => {
|
2089
|
-
u.
|
2285
|
+
u.delegatePromise(_a.prototype, '_rendered');
|
2090
2286
|
u.memoizeMethod(_a.prototype, {
|
2091
2287
|
_awaitFinished: true,
|
2092
2288
|
_getChange: true,
|
@@ -2097,14 +2293,6 @@ up.RenderJob = (_a = class RenderJob {
|
|
2097
2293
|
|
2098
2294
|
/***/ }),
|
2099
2295
|
/* 26 */
|
2100
|
-
/***/ (() => {
|
2101
|
-
|
2102
|
-
up.Change.Removal = class Removal extends up.Change {
|
2103
|
-
};
|
2104
|
-
|
2105
|
-
|
2106
|
-
/***/ }),
|
2107
|
-
/* 27 */
|
2108
2296
|
/***/ (function() {
|
2109
2297
|
|
2110
2298
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -2116,13 +2304,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
2116
2304
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
2117
2305
|
});
|
2118
2306
|
};
|
2119
|
-
up.Change.DestroyFragment = class DestroyFragment extends up.Change
|
2307
|
+
up.Change.DestroyFragment = class DestroyFragment extends up.Change {
|
2120
2308
|
constructor(options) {
|
2121
2309
|
super(options);
|
2122
2310
|
this._layer = up.layer.get(options) || up.layer.current;
|
2123
2311
|
this._element = this.options.element;
|
2124
2312
|
this._animation = this.options.animation;
|
2125
2313
|
this._log = this.options.log;
|
2314
|
+
this._onFinished = this.options.onFinished;
|
2126
2315
|
}
|
2127
2316
|
execute() {
|
2128
2317
|
this._parent = this._element.parentNode;
|
@@ -2135,17 +2324,19 @@ up.Change.DestroyFragment = class DestroyFragment extends up.Change.Removal {
|
|
2135
2324
|
}
|
2136
2325
|
}
|
2137
2326
|
_destroyAfterAnimation() {
|
2327
|
+
var _a;
|
2138
2328
|
return __awaiter(this, void 0, void 0, function* () {
|
2139
2329
|
this._emitDestroyed();
|
2140
2330
|
yield this._animate();
|
2141
2331
|
this._wipe();
|
2142
|
-
this.
|
2332
|
+
(_a = this._onFinished) === null || _a === void 0 ? void 0 : _a.call(this);
|
2143
2333
|
});
|
2144
2334
|
}
|
2145
2335
|
_destroyNow() {
|
2336
|
+
var _a;
|
2146
2337
|
this._wipe();
|
2147
2338
|
this._emitDestroyed();
|
2148
|
-
this.
|
2339
|
+
(_a = this._onFinished) === null || _a === void 0 ? void 0 : _a.call(this);
|
2149
2340
|
}
|
2150
2341
|
_animate() {
|
2151
2342
|
return up.motion.animate(this._element, this._animation, this.options);
|
@@ -2165,7 +2356,7 @@ up.Change.DestroyFragment = class DestroyFragment extends up.Change.Removal {
|
|
2165
2356
|
|
2166
2357
|
|
2167
2358
|
/***/ }),
|
2168
|
-
/*
|
2359
|
+
/* 27 */
|
2169
2360
|
/***/ (function() {
|
2170
2361
|
|
2171
2362
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -2191,9 +2382,10 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
|
|
2191
2382
|
context: this._buildLayer().context,
|
2192
2383
|
origin: this.options.origin,
|
2193
2384
|
target: this.target,
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2385
|
+
bindLayer: this._baseLayer,
|
2386
|
+
layer: 'new',
|
2387
|
+
bindFragments: u.compact([up.fragment.get(':main', { layer: this._baseLayer })]),
|
2388
|
+
fragments: [],
|
2197
2389
|
};
|
2198
2390
|
}
|
2199
2391
|
execute(responseDoc, onApplicable) {
|
@@ -2243,7 +2435,7 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
|
|
2243
2435
|
fragments: [this._content],
|
2244
2436
|
target: this.target,
|
2245
2437
|
});
|
2246
|
-
up.hello(this.layer.element, Object.assign(Object.assign({}, this.options), { layer: this.layer }));
|
2438
|
+
up.hello(this.layer.element, Object.assign(Object.assign({}, this.options), { layer: this.layer, dataRoot: this._content }));
|
2247
2439
|
this._handleScroll();
|
2248
2440
|
this._newOverlayResult.finished = this._finish();
|
2249
2441
|
this.layer.opening = false;
|
@@ -2323,7 +2515,7 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
|
|
2323
2515
|
|
2324
2516
|
|
2325
2517
|
/***/ }),
|
2326
|
-
/*
|
2518
|
+
/* 28 */
|
2327
2519
|
/***/ (() => {
|
2328
2520
|
|
2329
2521
|
var _a;
|
@@ -2339,14 +2531,16 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
|
|
2339
2531
|
}
|
2340
2532
|
getPreflightProps() {
|
2341
2533
|
this._matchPreflight();
|
2534
|
+
let fragments = this._getFragments();
|
2342
2535
|
return {
|
2343
2536
|
layer: this.layer,
|
2537
|
+
bindLayer: this.layer,
|
2344
2538
|
mode: this.layer.mode,
|
2345
2539
|
context: u.merge(this.layer.context, this._context),
|
2346
2540
|
origin: this.options.origin,
|
2347
2541
|
target: this._bestPreflightSelector(),
|
2348
|
-
fragments
|
2349
|
-
|
2542
|
+
fragments,
|
2543
|
+
bindFragments: fragments,
|
2350
2544
|
};
|
2351
2545
|
}
|
2352
2546
|
_bestPreflightSelector() {
|
@@ -2468,7 +2662,7 @@ up.Change.UpdateLayer = (_a = class UpdateLayer extends up.Change.Addition {
|
|
2468
2662
|
|
2469
2663
|
|
2470
2664
|
/***/ }),
|
2471
|
-
/*
|
2665
|
+
/* 29 */
|
2472
2666
|
/***/ (function() {
|
2473
2667
|
|
2474
2668
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -2547,7 +2741,7 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2547
2741
|
}, beforeDetach: () => {
|
2548
2742
|
up.script.clean(step.oldElement, { layer: step.layer });
|
2549
2743
|
}, afterDetach() {
|
2550
|
-
|
2744
|
+
e.cleanJQuery();
|
2551
2745
|
up.fragment.emitDestroyed(step.oldElement, { parent, log: false });
|
2552
2746
|
}, scrollNew: () => {
|
2553
2747
|
this._handleFocus(step.newElement, step);
|
@@ -2583,7 +2777,7 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2583
2777
|
}
|
2584
2778
|
}
|
2585
2779
|
_findKeepPlan(options) {
|
2586
|
-
if (!options.
|
2780
|
+
if (!options.keep) {
|
2587
2781
|
return;
|
2588
2782
|
}
|
2589
2783
|
const { oldElement, newElement } = options;
|
@@ -2598,7 +2792,7 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2598
2792
|
partner = up.fragment.get(newElement, partnerSelector, lookupOpts);
|
2599
2793
|
}
|
2600
2794
|
else {
|
2601
|
-
partner =
|
2795
|
+
partner = e.subtreeFirst(newElement, partnerSelector, lookupOpts);
|
2602
2796
|
}
|
2603
2797
|
if (partner && e.booleanAttr(partner, 'up-keep') !== false) {
|
2604
2798
|
const plan = {
|
@@ -2614,7 +2808,7 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2614
2808
|
}
|
2615
2809
|
_preserveKeepables(step) {
|
2616
2810
|
const keepPlans = [];
|
2617
|
-
if (step.
|
2811
|
+
if (step.keep) {
|
2618
2812
|
for (let keepable of step.oldElement.querySelectorAll('[up-keep]')) {
|
2619
2813
|
let keepPlan = this._findKeepPlan(Object.assign(Object.assign({}, step), { oldElement: keepable, descendantsOnly: true }));
|
2620
2814
|
if (keepPlan) {
|
@@ -2667,11 +2861,11 @@ up.Change.UpdateSteps = class UpdateSteps extends up.Change.Addition {
|
|
2667
2861
|
|
2668
2862
|
|
2669
2863
|
/***/ }),
|
2670
|
-
/*
|
2864
|
+
/* 30 */
|
2671
2865
|
/***/ (() => {
|
2672
2866
|
|
2673
2867
|
const u = up.util;
|
2674
|
-
up.Change.CloseLayer = class CloseLayer extends up.Change
|
2868
|
+
up.Change.CloseLayer = class CloseLayer extends up.Change {
|
2675
2869
|
constructor(options) {
|
2676
2870
|
var _a, _b;
|
2677
2871
|
super(options);
|
@@ -2745,28 +2939,41 @@ up.Change.CloseLayer = class CloseLayer extends up.Change.Removal {
|
|
2745
2939
|
|
2746
2940
|
|
2747
2941
|
/***/ }),
|
2748
|
-
/*
|
2749
|
-
/***/ (()
|
2942
|
+
/* 31 */
|
2943
|
+
/***/ (function() {
|
2750
2944
|
|
2945
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2946
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
2947
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
2948
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
2949
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
2950
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
2951
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
2952
|
+
});
|
2953
|
+
};
|
2751
2954
|
var _a;
|
2752
2955
|
const u = up.util;
|
2753
2956
|
up.Change.FromURL = (_a = class FromURL extends up.Change {
|
2754
2957
|
execute() {
|
2958
|
+
return __awaiter(this, void 0, void 0, function* () {
|
2959
|
+
let newPageReason = this._newPageReason();
|
2960
|
+
if (newPageReason) {
|
2961
|
+
up.puts('up.render()', newPageReason);
|
2962
|
+
up.network.loadPage(this.options);
|
2963
|
+
return u.unresolvablePromise();
|
2964
|
+
}
|
2965
|
+
this.request = up.request(this._getRequestAttrs());
|
2966
|
+
if (this.options.preload) {
|
2967
|
+
return this.request;
|
2968
|
+
}
|
2969
|
+
this._onRequestProcessed();
|
2970
|
+
return yield u.always(this.request, responseOrError => this._onRequestSettled(responseOrError));
|
2971
|
+
});
|
2972
|
+
}
|
2973
|
+
_onRequestProcessed() {
|
2755
2974
|
var _b, _c;
|
2756
|
-
|
2757
|
-
|
2758
|
-
up.puts('up.render()', _newPageReason);
|
2759
|
-
up.network.loadPage(this.options);
|
2760
|
-
return u.unresolvablePromise();
|
2761
|
-
}
|
2762
|
-
this.request = up.request(this._getRequestAttrs());
|
2763
|
-
(_c = (_b = this.options).onRequest) === null || _c === void 0 ? void 0 : _c.call(_b, this.request);
|
2764
|
-
up.feedback.showAroundRequest(this.request, this.options);
|
2765
|
-
up.form.disableWhile(this.request, this.options);
|
2766
|
-
if (this.options.preload) {
|
2767
|
-
return this.request;
|
2768
|
-
}
|
2769
|
-
return u.always(this.request, responseOrError => this._onRequestSettled(responseOrError));
|
2975
|
+
(_c = (_b = this.options).onRequestProcessed) === null || _c === void 0 ? void 0 : _c.call(_b, this.request);
|
2976
|
+
this.request.runPreviews(this.options);
|
2770
2977
|
}
|
2771
2978
|
_newPageReason() {
|
2772
2979
|
if (u.isCrossOrigin(this.options.url)) {
|
@@ -2779,14 +2986,14 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2779
2986
|
_getRequestAttrs() {
|
2780
2987
|
const successAttrs = this._preflightPropsForRenderOptions(this.options);
|
2781
2988
|
const failAttrs = this._preflightPropsForRenderOptions(this.deriveFailOptions(), { optional: true });
|
2782
|
-
return Object.assign(Object.assign(Object.assign({}, this.options), successAttrs), u.
|
2989
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, this.options), successAttrs), u.withRenamedKeys(failAttrs, up.fragment.failKey)), { onProcessed: this._onRequestProcessed.bind(this) });
|
2783
2990
|
}
|
2784
2991
|
getPreflightProps() {
|
2785
2992
|
return this._getRequestAttrs();
|
2786
2993
|
}
|
2787
|
-
_preflightPropsForRenderOptions(renderOptions,
|
2788
|
-
const
|
2789
|
-
return
|
2994
|
+
_preflightPropsForRenderOptions(renderOptions, getPreflightPropsOptions) {
|
2995
|
+
const preflightChange = new up.Change.FromContent(Object.assign(Object.assign({}, renderOptions), { preflight: true }));
|
2996
|
+
return preflightChange.getPreflightProps(getPreflightPropsOptions);
|
2790
2997
|
}
|
2791
2998
|
_onRequestSettled(response) {
|
2792
2999
|
if (response instanceof up.Response) {
|
@@ -2820,7 +3027,7 @@ up.Change.FromURL = (_a = class FromURL extends up.Change {
|
|
2820
3027
|
|
2821
3028
|
|
2822
3029
|
/***/ }),
|
2823
|
-
/*
|
3030
|
+
/* 32 */
|
2824
3031
|
/***/ (function() {
|
2825
3032
|
|
2826
3033
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -2887,7 +3094,7 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
|
|
2887
3094
|
}
|
2888
3095
|
else {
|
2889
3096
|
up.puts('up.render()', 'Revalidating cached response for target "%s"', effectiveTarget);
|
2890
|
-
let verifyResult = yield up.reload(effectiveTarget, Object.assign(Object.assign({}, originalRenderOptions), { preferOldElements: renderResult.fragments, layer: renderResult.layer, onFinished: null,
|
3097
|
+
let verifyResult = yield up.reload(effectiveTarget, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, originalRenderOptions), up.RenderOptions.NO_MOTION), up.RenderOptions.NO_INPUT_INTERFERENCE), up.RenderOptions.NO_PREVIEWS), { preferOldElements: renderResult.fragments, layer: renderResult.layer, onFinished: null, expiredResponse: this._response, preview: this._revalidatePreview(originalRenderOptions), abort: false, cache: false, background: true }));
|
2891
3098
|
if (!verifyResult.none) {
|
2892
3099
|
renderResult = verifyResult;
|
2893
3100
|
}
|
@@ -2895,6 +3102,14 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
|
|
2895
3102
|
return renderResult;
|
2896
3103
|
});
|
2897
3104
|
}
|
3105
|
+
_revalidatePreview({ preview, revalidatePreview }) {
|
3106
|
+
if (revalidatePreview === true) {
|
3107
|
+
return preview;
|
3108
|
+
}
|
3109
|
+
else {
|
3110
|
+
return revalidatePreview;
|
3111
|
+
}
|
3112
|
+
}
|
2898
3113
|
_loadedEventProps() {
|
2899
3114
|
const { expiredResponse } = this.options;
|
2900
3115
|
return {
|
@@ -2956,7 +3171,7 @@ up.Change.FromResponse = (_a = class FromResponse extends up.Change {
|
|
2956
3171
|
|
2957
3172
|
|
2958
3173
|
/***/ }),
|
2959
|
-
/*
|
3174
|
+
/* 33 */
|
2960
3175
|
/***/ (() => {
|
2961
3176
|
|
2962
3177
|
var _a;
|
@@ -2965,7 +3180,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
2965
3180
|
constructor(options) {
|
2966
3181
|
super(options);
|
2967
3182
|
this._origin = options.origin;
|
2968
|
-
this.
|
3183
|
+
this._preflight = options.preflight;
|
2969
3184
|
this._layers = up.layer.getAll(options);
|
2970
3185
|
}
|
2971
3186
|
_getPlans() {
|
@@ -3022,7 +3237,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3022
3237
|
}
|
3023
3238
|
_getResponseDoc() {
|
3024
3239
|
var _b, _c;
|
3025
|
-
if (this.
|
3240
|
+
if (this._preflight)
|
3026
3241
|
return;
|
3027
3242
|
const docOptions = u.pick(this.options, [
|
3028
3243
|
'target',
|
@@ -3032,6 +3247,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3032
3247
|
'html',
|
3033
3248
|
'cspNonces',
|
3034
3249
|
'origin',
|
3250
|
+
'data',
|
3035
3251
|
]);
|
3036
3252
|
(_c = (_b = up.migrate).handleResponseDocOptions) === null || _c === void 0 ? void 0 : _c.call(_b, docOptions);
|
3037
3253
|
if (this._defaultPlacement() === 'content') {
|
@@ -3041,7 +3257,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3041
3257
|
}
|
3042
3258
|
_improveOptionsFromResponseDoc() {
|
3043
3259
|
var _b;
|
3044
|
-
if (this.
|
3260
|
+
if (this._preflight)
|
3045
3261
|
return;
|
3046
3262
|
let responseDoc = this._getResponseDoc();
|
3047
3263
|
if (this.options.fragment) {
|
@@ -3113,17 +3329,18 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
|
|
3113
3329
|
|
3114
3330
|
|
3115
3331
|
/***/ }),
|
3116
|
-
/*
|
3332
|
+
/* 34 */
|
3117
3333
|
/***/ (() => {
|
3118
3334
|
|
3119
3335
|
const u = up.util;
|
3120
3336
|
up.CompilerPass = class CompilerPass {
|
3121
|
-
constructor(root, compilers, { layer, data, dataMap, meta }) {
|
3337
|
+
constructor(root, compilers, { layer, data, dataRoot, dataMap, meta }) {
|
3122
3338
|
layer || (layer = up.layer.get(root) || up.layer.current);
|
3123
3339
|
this._root = root;
|
3124
3340
|
this._compilers = compilers;
|
3125
3341
|
this._layer = layer;
|
3126
3342
|
this._data = data;
|
3343
|
+
this._dataRoot = dataRoot || root;
|
3127
3344
|
this._dataMap = dataMap;
|
3128
3345
|
meta || (meta = {});
|
3129
3346
|
meta.layer = layer;
|
@@ -3139,7 +3356,7 @@ up.CompilerPass = class CompilerPass {
|
|
3139
3356
|
}
|
3140
3357
|
setCompileData() {
|
3141
3358
|
if (this._data) {
|
3142
|
-
this.
|
3359
|
+
this._dataRoot.upCompileData = this._data;
|
3143
3360
|
}
|
3144
3361
|
if (this._dataMap) {
|
3145
3362
|
for (let selector in this._dataMap) {
|
@@ -3175,10 +3392,7 @@ up.CompilerPass = class CompilerPass {
|
|
3175
3392
|
compileArgs.push(data, this._meta);
|
3176
3393
|
}
|
3177
3394
|
const result = this._applyCompilerFunction(compiler, element, compileArgs);
|
3178
|
-
|
3179
|
-
if (destructorOrDestructors) {
|
3180
|
-
up.destructor(element, destructorOrDestructors);
|
3181
|
-
}
|
3395
|
+
up.destructor(element, result);
|
3182
3396
|
}
|
3183
3397
|
_compileBatch(compiler, elements) {
|
3184
3398
|
const compileArgs = [elements];
|
@@ -3187,18 +3401,13 @@ up.CompilerPass = class CompilerPass {
|
|
3187
3401
|
compileArgs.push(dataList, this._meta);
|
3188
3402
|
}
|
3189
3403
|
const result = this._applyCompilerFunction(compiler, elements, compileArgs);
|
3190
|
-
if (
|
3404
|
+
if (result) {
|
3191
3405
|
up.fail('Compilers with { batch: true } cannot return destructors');
|
3192
3406
|
}
|
3193
3407
|
}
|
3194
3408
|
_applyCompilerFunction(compiler, elementOrElements, compileArgs) {
|
3195
3409
|
return up.error.guard(() => compiler.apply(elementOrElements, compileArgs));
|
3196
3410
|
}
|
3197
|
-
_destructorPresence(result) {
|
3198
|
-
if (u.isFunction(result) || (u.isArray(result) && (u.every(result, u.isFunction)))) {
|
3199
|
-
return result;
|
3200
|
-
}
|
3201
|
-
}
|
3202
3411
|
_select(selector) {
|
3203
3412
|
return up.fragment.subtree(this._root, u.evalOption(selector), { layer: this._layer });
|
3204
3413
|
}
|
@@ -3216,7 +3425,7 @@ up.CompilerPass = class CompilerPass {
|
|
3216
3425
|
|
3217
3426
|
|
3218
3427
|
/***/ }),
|
3219
|
-
/*
|
3428
|
+
/* 35 */
|
3220
3429
|
/***/ (() => {
|
3221
3430
|
|
3222
3431
|
const u = up.util;
|
@@ -3301,7 +3510,7 @@ up.CSSTransition = class CSSTransition {
|
|
3301
3510
|
if (oldTransition['transition-property'] !== 'all') {
|
3302
3511
|
const oldTransitionProperties = oldTransition['transition-property'].split(/\s*,\s*/);
|
3303
3512
|
const oldTransitionFrame = e.style(this._element, oldTransitionProperties);
|
3304
|
-
this._setOldTransitionTargetFrame = e.
|
3513
|
+
this._setOldTransitionTargetFrame = e.setStyleTemp(this._element, oldTransitionFrame);
|
3305
3514
|
}
|
3306
3515
|
this._setOldTransition = e.concludeCSSTransition(this._element);
|
3307
3516
|
}
|
@@ -3323,7 +3532,7 @@ up.CSSTransition = class CSSTransition {
|
|
3323
3532
|
|
3324
3533
|
|
3325
3534
|
/***/ }),
|
3326
|
-
/*
|
3535
|
+
/* 36 */
|
3327
3536
|
/***/ (() => {
|
3328
3537
|
|
3329
3538
|
const u = up.util;
|
@@ -3334,27 +3543,19 @@ up.DestructorPass = class DestructorPass {
|
|
3334
3543
|
}
|
3335
3544
|
run() {
|
3336
3545
|
for (let cleanable of this._selectCleanables()) {
|
3337
|
-
let
|
3338
|
-
|
3339
|
-
for (let destructor of destructors) {
|
3340
|
-
this._applyDestructorFunction(destructor, cleanable);
|
3341
|
-
}
|
3342
|
-
}
|
3343
|
-
cleanable.classList.remove('up-can-clean');
|
3546
|
+
let registry = u.pluckKey(cleanable, 'upDestructors');
|
3547
|
+
registry === null || registry === void 0 ? void 0 : registry.clean(cleanable);
|
3344
3548
|
}
|
3345
3549
|
}
|
3346
3550
|
_selectCleanables() {
|
3347
3551
|
const selectOptions = Object.assign(Object.assign({}, this._options), { destroying: true });
|
3348
3552
|
return up.fragment.subtree(this._fragment, '.up-can-clean', selectOptions);
|
3349
3553
|
}
|
3350
|
-
_applyDestructorFunction(destructor, element) {
|
3351
|
-
up.error.guard(() => destructor(element));
|
3352
|
-
}
|
3353
3554
|
};
|
3354
3555
|
|
3355
3556
|
|
3356
3557
|
/***/ }),
|
3357
|
-
/*
|
3558
|
+
/* 37 */
|
3358
3559
|
/***/ (() => {
|
3359
3560
|
|
3360
3561
|
const u = up.util;
|
@@ -3417,7 +3618,7 @@ up.EventEmitter = class EventEmitter extends up.Record {
|
|
3417
3618
|
var _a, _b;
|
3418
3619
|
let options = u.extractOptions(args);
|
3419
3620
|
options = u.merge(defaults, options);
|
3420
|
-
if (u.
|
3621
|
+
if (u.isElementLike(args[0])) {
|
3421
3622
|
options.target = e.get(args.shift());
|
3422
3623
|
}
|
3423
3624
|
else if (args[0] instanceof up.Layer) {
|
@@ -3454,7 +3655,7 @@ up.EventEmitter = class EventEmitter extends up.Record {
|
|
3454
3655
|
|
3455
3656
|
|
3456
3657
|
/***/ }),
|
3457
|
-
/*
|
3658
|
+
/* 38 */
|
3458
3659
|
/***/ (() => {
|
3459
3660
|
|
3460
3661
|
const u = up.util;
|
@@ -3561,7 +3762,7 @@ up.EventListener = class EventListener extends up.Record {
|
|
3561
3762
|
|
3562
3763
|
|
3563
3764
|
/***/ }),
|
3564
|
-
/*
|
3765
|
+
/* 39 */
|
3565
3766
|
/***/ (() => {
|
3566
3767
|
|
3567
3768
|
const u = up.util;
|
@@ -3581,13 +3782,13 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
|
|
3581
3782
|
];
|
3582
3783
|
}
|
3583
3784
|
bind() {
|
3584
|
-
const
|
3785
|
+
const cleaner = u.cleaner();
|
3585
3786
|
this._eachListenerAttributes(function (attrs) {
|
3586
3787
|
const listener = new up.EventListener(attrs);
|
3587
3788
|
listener.bind();
|
3588
|
-
return
|
3789
|
+
return cleaner(listener.unbind.bind(listener));
|
3589
3790
|
});
|
3590
|
-
return
|
3791
|
+
return cleaner.clean;
|
3591
3792
|
}
|
3592
3793
|
_eachListenerAttributes(fn) {
|
3593
3794
|
for (let element of this.elements) {
|
@@ -3620,7 +3821,7 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
|
|
3620
3821
|
else {
|
3621
3822
|
elements = [document];
|
3622
3823
|
}
|
3623
|
-
let eventTypes = u.
|
3824
|
+
let eventTypes = u.getSimpleTokens(args.shift());
|
3624
3825
|
let fixTypes = up.migrate.fixEventTypes;
|
3625
3826
|
if (fixTypes) {
|
3626
3827
|
eventTypes = fixTypes(eventTypes);
|
@@ -3634,7 +3835,7 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
|
|
3634
3835
|
|
3635
3836
|
|
3636
3837
|
/***/ }),
|
3637
|
-
/*
|
3838
|
+
/* 40 */
|
3638
3839
|
/***/ (function() {
|
3639
3840
|
|
3640
3841
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -3654,26 +3855,24 @@ up.FieldWatcher = class FieldWatcher {
|
|
3654
3855
|
this._scope = up.form.getScope(root);
|
3655
3856
|
this._callback = callback;
|
3656
3857
|
this._batch = options.batch;
|
3657
|
-
this._abortable = options.abortable;
|
3658
3858
|
}
|
3659
3859
|
start() {
|
3660
3860
|
this._scheduledValues = null;
|
3661
3861
|
this._processedValues = this._readFieldValues();
|
3662
3862
|
this._currentTimer = null;
|
3663
3863
|
this._callbackRunning = false;
|
3664
|
-
this.
|
3864
|
+
this._cleaner = u.cleaner();
|
3665
3865
|
this._watchFieldsWithin(this._root);
|
3666
3866
|
this._root.addEventListener('up:fragment:inserted', ({ target }) => {
|
3667
3867
|
if (target !== this._root)
|
3668
3868
|
this._watchFieldsWithin(target);
|
3669
3869
|
});
|
3670
|
-
this.
|
3671
|
-
this.
|
3870
|
+
this._cleaner(up.fragment.onAborted(this._scope, () => this._abort()));
|
3871
|
+
this._cleaner(up.on(this._scope, 'reset', () => this._onFormReset()));
|
3672
3872
|
}
|
3673
3873
|
stop() {
|
3674
3874
|
this._abort();
|
3675
|
-
|
3676
|
-
unbindFn();
|
3875
|
+
this._cleaner.clean();
|
3677
3876
|
}
|
3678
3877
|
_fieldOptions(field) {
|
3679
3878
|
let rootOptions = u.copy(this._options);
|
@@ -3686,7 +3885,7 @@ up.FieldWatcher = class FieldWatcher {
|
|
3686
3885
|
}
|
3687
3886
|
_watchField(field) {
|
3688
3887
|
let fieldOptions = this._fieldOptions(field);
|
3689
|
-
this.
|
3888
|
+
this._cleaner(up.on(field, fieldOptions.event, () => this._check(fieldOptions)));
|
3690
3889
|
}
|
3691
3890
|
_abort() {
|
3692
3891
|
this._scheduledValues = null;
|
@@ -3714,13 +3913,12 @@ up.FieldWatcher = class FieldWatcher {
|
|
3714
3913
|
return;
|
3715
3914
|
if (!this._scope.isConnected)
|
3716
3915
|
return;
|
3717
|
-
let
|
3916
|
+
let callbackOptions = u.omit(this._scheduledFieldOptions, ['event', 'delay']);
|
3718
3917
|
const diff = this._changedValues(this._processedValues, this._scheduledValues);
|
3719
3918
|
this._processedValues = this._scheduledValues;
|
3720
3919
|
this._scheduledValues = null;
|
3721
3920
|
this._callbackRunning = true;
|
3722
3921
|
this._scheduledFieldOptions = null;
|
3723
|
-
let callbackOptions = Object.assign(Object.assign({}, fieldOptions), { disable: false });
|
3724
3922
|
const callbackReturnValues = [];
|
3725
3923
|
if (this._batch) {
|
3726
3924
|
callbackReturnValues.push(this._runCallback(diff, callbackOptions));
|
@@ -3733,7 +3931,6 @@ up.FieldWatcher = class FieldWatcher {
|
|
3733
3931
|
}
|
3734
3932
|
if (u.some(callbackReturnValues, u.isPromise)) {
|
3735
3933
|
let callbackDone = Promise.allSettled(callbackReturnValues);
|
3736
|
-
up.form.disableWhile(callbackDone, fieldOptions);
|
3737
3934
|
yield callbackDone;
|
3738
3935
|
}
|
3739
3936
|
this._callbackRunning = false;
|
@@ -3741,7 +3938,7 @@ up.FieldWatcher = class FieldWatcher {
|
|
3741
3938
|
});
|
3742
3939
|
}
|
3743
3940
|
_runCallback(...args) {
|
3744
|
-
return up.error.guard(
|
3941
|
+
return up.error.guard(this._callback, ...args);
|
3745
3942
|
}
|
3746
3943
|
_changedValues(previous, next) {
|
3747
3944
|
const changes = {};
|
@@ -3773,7 +3970,7 @@ up.FieldWatcher = class FieldWatcher {
|
|
3773
3970
|
|
3774
3971
|
|
3775
3972
|
/***/ }),
|
3776
|
-
/*
|
3973
|
+
/* 41 */
|
3777
3974
|
/***/ (function() {
|
3778
3975
|
|
3779
3976
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -3907,7 +4104,6 @@ up.FormValidator = class FormValidator {
|
|
3907
4104
|
up.error.muteUncriticalRejection(this._doRenderDirtySolutions());
|
3908
4105
|
}
|
3909
4106
|
_doRenderDirtySolutions() {
|
3910
|
-
var _a;
|
3911
4107
|
return __awaiter(this, void 0, void 0, function* () {
|
3912
4108
|
if (!this._dirtySolutions.length)
|
3913
4109
|
return;
|
@@ -3915,39 +4111,11 @@ up.FormValidator = class FormValidator {
|
|
3915
4111
|
return;
|
3916
4112
|
if (this._nextRenderTimer)
|
3917
4113
|
return;
|
3918
|
-
let
|
4114
|
+
let options = this._mergeRenderOptions(this._dirtySolutions);
|
3919
4115
|
this._dirtySolutions = [];
|
3920
|
-
let dirtyOrigins = u.map(dirtySolutions, 'origin');
|
3921
|
-
let dirtyFields = u.flatMap(dirtyOrigins, up.form.fields);
|
3922
|
-
let dirtyNames = u.uniq(u.map(dirtyFields, 'name'));
|
3923
|
-
let dataMap = this._buildDataMap(dirtySolutions);
|
3924
|
-
let dirtyRenderOptionsList = u.map(dirtySolutions, 'renderOptions');
|
3925
|
-
let options = u.mergeDefined(...dirtyRenderOptionsList, { dataMap }, up.form.destinationOptions(this._form));
|
3926
|
-
options.target = u.map(dirtySolutions, 'target').join(', ');
|
3927
|
-
options.feedback = u.some(dirtyRenderOptionsList, 'feedback');
|
3928
|
-
options.origin = this._form;
|
3929
|
-
(_a = options.focus) !== null && _a !== void 0 ? _a : (options.focus = 'keep');
|
3930
|
-
options.failOptions = false;
|
3931
|
-
options.defaultMaybe = true;
|
3932
|
-
options.params = up.Params.merge(options.params, ...u.map(dirtyRenderOptionsList, 'params'));
|
3933
|
-
options.headers = u.merge(...u.map(dirtyRenderOptionsList, 'headers'));
|
3934
|
-
this._addValidateHeader(options.headers, dirtyNames);
|
3935
|
-
options.guardEvent = up.event.build('up:form:validate', {
|
3936
|
-
fields: dirtyFields,
|
3937
|
-
log: 'Validating form',
|
3938
|
-
params: options.params,
|
3939
|
-
form: this._form,
|
3940
|
-
});
|
3941
4116
|
this._rendering = true;
|
3942
4117
|
let renderingPromise = this._nextRenderPromise;
|
3943
4118
|
this._resetNextRenderPromise();
|
3944
|
-
options.disable = false;
|
3945
|
-
for (let solution of dirtySolutions) {
|
3946
|
-
up.form.disableWhile(renderingPromise, {
|
3947
|
-
disable: solution.renderOptions.disable,
|
3948
|
-
origin: solution.origin,
|
3949
|
-
});
|
3950
|
-
}
|
3951
4119
|
try {
|
3952
4120
|
renderingPromise.resolve(up.render(options));
|
3953
4121
|
yield renderingPromise;
|
@@ -3958,6 +4126,40 @@ up.FormValidator = class FormValidator {
|
|
3958
4126
|
}
|
3959
4127
|
});
|
3960
4128
|
}
|
4129
|
+
_mergeRenderOptions(dirtySolutions) {
|
4130
|
+
var _a;
|
4131
|
+
let dirtyOrigins = u.map(dirtySolutions, 'origin');
|
4132
|
+
let dirtyFields = u.flatMap(dirtyOrigins, up.form.fields);
|
4133
|
+
let dirtyNames = u.uniq(u.map(dirtyFields, 'name'));
|
4134
|
+
let dirtyRenderOptionsList = u.map(dirtySolutions, 'renderOptions');
|
4135
|
+
let options = u.mergeDefined(...dirtyRenderOptionsList, up.form.destinationOptions(this._form));
|
4136
|
+
options.target = u.map(dirtySolutions, 'target').join(', ');
|
4137
|
+
options.origin = this._form;
|
4138
|
+
(_a = options.focus) !== null && _a !== void 0 ? _a : (options.focus = 'keep');
|
4139
|
+
options.failOptions = false;
|
4140
|
+
options.defaultMaybe = true;
|
4141
|
+
options.params = up.Params.merge(options.params, ...u.map(dirtyRenderOptionsList, 'params'));
|
4142
|
+
options.headers = u.merge(options.headers, ...u.map(dirtyRenderOptionsList, 'headers'));
|
4143
|
+
this._addValidateHeader(options.headers, dirtyNames);
|
4144
|
+
options.feedback = u.some(dirtyRenderOptionsList, 'feedback');
|
4145
|
+
options.data = undefined;
|
4146
|
+
options.dataMap = u.mapObject(dirtySolutions, ({ target, element, renderOptions: { data, keepData } }) => [
|
4147
|
+
target,
|
4148
|
+
keepData ? up.data(element) : data
|
4149
|
+
]);
|
4150
|
+
options.preview = undefined;
|
4151
|
+
options.previewMap = u.mapObject(dirtySolutions, ({ target, renderOptions: { preview } }) => [target, preview]);
|
4152
|
+
options.placeholder = undefined;
|
4153
|
+
options.placeholderMap = u.mapObject(dirtySolutions, ({ target, renderOptions: { placeholder } }) => [target, placeholder]);
|
4154
|
+
options.disable = dirtySolutions.map((solution) => up.fragment.resolveOrigin(solution.renderOptions.disable, solution));
|
4155
|
+
options.guardEvent = up.event.build('up:form:validate', {
|
4156
|
+
fields: dirtyFields,
|
4157
|
+
log: 'Validating form',
|
4158
|
+
params: options.params,
|
4159
|
+
form: this._form,
|
4160
|
+
});
|
4161
|
+
return options;
|
4162
|
+
}
|
3961
4163
|
_addValidateHeader(headers, names) {
|
3962
4164
|
let key = up.protocol.headerize('validate');
|
3963
4165
|
let value = names.join(' ');
|
@@ -3965,20 +4167,6 @@ up.FormValidator = class FormValidator {
|
|
3965
4167
|
value = ':unknown';
|
3966
4168
|
headers[key] = value;
|
3967
4169
|
}
|
3968
|
-
_buildDataMap(solutions) {
|
3969
|
-
let dataMap = {};
|
3970
|
-
for (let solution of solutions) {
|
3971
|
-
let data = u.pluckKey(solution.renderOptions, 'data');
|
3972
|
-
let keepData = u.pluckKey(solution.renderOptions, 'keepData');
|
3973
|
-
if (keepData) {
|
3974
|
-
data = up.data(solution.element);
|
3975
|
-
}
|
3976
|
-
if (data) {
|
3977
|
-
dataMap[solution.target] = data;
|
3978
|
-
}
|
3979
|
-
}
|
3980
|
-
return dataMap;
|
3981
|
-
}
|
3982
4170
|
static forElement(element) {
|
3983
4171
|
let form = up.form.get(element);
|
3984
4172
|
return form.upFormValidator || (form.upFormValidator = new this(form));
|
@@ -3987,19 +4175,23 @@ up.FormValidator = class FormValidator {
|
|
3987
4175
|
|
3988
4176
|
|
3989
4177
|
/***/ }),
|
3990
|
-
/*
|
4178
|
+
/* 42 */
|
3991
4179
|
/***/ (() => {
|
3992
4180
|
|
3993
4181
|
up.FocusCapsule = class FocusCapsule {
|
3994
|
-
constructor(target, cursorProps) {
|
4182
|
+
constructor(element, target, cursorProps) {
|
4183
|
+
this._element = element;
|
3995
4184
|
this._target = target;
|
3996
4185
|
this._cursorProps = cursorProps;
|
3997
4186
|
}
|
3998
|
-
|
4187
|
+
wasLost() {
|
4188
|
+
return document.activeElement !== this._element;
|
4189
|
+
}
|
4190
|
+
restore(layer, focusOptions) {
|
3999
4191
|
let rediscoveredElement = up.fragment.get(this._target, { layer });
|
4000
4192
|
if (rediscoveredElement) {
|
4001
4193
|
up.viewport.copyCursorProps(this._cursorProps, rediscoveredElement);
|
4002
|
-
up.focus(rediscoveredElement,
|
4194
|
+
up.focus(rediscoveredElement, focusOptions);
|
4003
4195
|
return true;
|
4004
4196
|
}
|
4005
4197
|
}
|
@@ -4011,13 +4203,13 @@ up.FocusCapsule = class FocusCapsule {
|
|
4011
4203
|
if (!target)
|
4012
4204
|
return;
|
4013
4205
|
const cursorProps = up.viewport.copyCursorProps(focusedElement);
|
4014
|
-
return new this(target, cursorProps);
|
4206
|
+
return new this(focusedElement, target, cursorProps);
|
4015
4207
|
}
|
4016
4208
|
};
|
4017
4209
|
|
4018
4210
|
|
4019
4211
|
/***/ }),
|
4020
|
-
/*
|
4212
|
+
/* 43 */
|
4021
4213
|
/***/ (() => {
|
4022
4214
|
|
4023
4215
|
const u = up.util;
|
@@ -4035,14 +4227,14 @@ up.FragmentProcessor = class FragmentProcessor extends up.Record {
|
|
4035
4227
|
return this.tryProcess(preprocessed);
|
4036
4228
|
}
|
4037
4229
|
preprocess(opt) {
|
4038
|
-
return u.
|
4230
|
+
return u.getComplexTokens(opt);
|
4039
4231
|
}
|
4040
4232
|
tryProcess(opt) {
|
4041
4233
|
if (u.isArray(opt)) {
|
4042
4234
|
return this.processArray(opt);
|
4043
4235
|
}
|
4044
4236
|
if (u.isFunction(opt)) {
|
4045
|
-
let result = up.error.guard(
|
4237
|
+
let result = up.error.guard(opt, this.fragment, this.attributes());
|
4046
4238
|
return this.tryProcess(result);
|
4047
4239
|
}
|
4048
4240
|
if (u.isElement(opt)) {
|
@@ -4082,7 +4274,7 @@ up.FragmentProcessor = class FragmentProcessor extends up.Record {
|
|
4082
4274
|
|
4083
4275
|
|
4084
4276
|
/***/ }),
|
4085
|
-
/*
|
4277
|
+
/* 44 */
|
4086
4278
|
/***/ (() => {
|
4087
4279
|
|
4088
4280
|
const u = up.util;
|
@@ -4121,19 +4313,19 @@ up.FragmentFinder = class FragmentFinder {
|
|
4121
4313
|
if (parts) {
|
4122
4314
|
let parent = up.fragment.closest(this._origin, parts[1], this._options);
|
4123
4315
|
if (parent) {
|
4124
|
-
return up.fragment.
|
4316
|
+
return up.fragment.getFirstDescendant(parent, parts[2]);
|
4125
4317
|
}
|
4126
4318
|
}
|
4127
4319
|
});
|
4128
4320
|
}
|
4129
4321
|
_findFirst() {
|
4130
|
-
return up.fragment.
|
4322
|
+
return up.fragment.getFirstDescendant(this._document, this._selector, this._options);
|
4131
4323
|
}
|
4132
4324
|
};
|
4133
4325
|
|
4134
4326
|
|
4135
4327
|
/***/ }),
|
4136
|
-
/*
|
4328
|
+
/* 45 */
|
4137
4329
|
/***/ (() => {
|
4138
4330
|
|
4139
4331
|
const u = up.util;
|
@@ -4195,7 +4387,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
|
|
4195
4387
|
return up.viewport.restoreFocus({ layer: this.layer });
|
4196
4388
|
}
|
4197
4389
|
_autofocus() {
|
4198
|
-
let autofocusElement = this.fragment && e.
|
4390
|
+
let autofocusElement = this.fragment && e.subtreeFirst(this.fragment, '[autofocus]');
|
4199
4391
|
if (autofocusElement) {
|
4200
4392
|
return this._focusElement(autofocusElement);
|
4201
4393
|
}
|
@@ -4213,13 +4405,14 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
|
|
4213
4405
|
}
|
4214
4406
|
}
|
4215
4407
|
_wasFocusLost() {
|
4216
|
-
|
4408
|
+
var _a;
|
4409
|
+
return (_a = this.focusCapsule) === null || _a === void 0 ? void 0 : _a.wasLost();
|
4217
4410
|
}
|
4218
4411
|
};
|
4219
4412
|
|
4220
4413
|
|
4221
4414
|
/***/ }),
|
4222
|
-
/*
|
4415
|
+
/* 46 */
|
4223
4416
|
/***/ (() => {
|
4224
4417
|
|
4225
4418
|
const e = up.element;
|
@@ -4289,17 +4482,17 @@ up.FragmentPolling = class FragmentPolling {
|
|
4289
4482
|
(this._options.ifLayer === 'any' || this._isOnFrontLayer());
|
4290
4483
|
}
|
4291
4484
|
_clearReloadTimer() {
|
4292
|
-
clearTimeout(this.
|
4293
|
-
this.
|
4485
|
+
clearTimeout(this._reloadTimer);
|
4486
|
+
this._reloadTimer = null;
|
4294
4487
|
}
|
4295
4488
|
_scheduleRemainingTime() {
|
4296
|
-
if (!this.
|
4489
|
+
if (!this._reloadTimer && !this._loading) {
|
4297
4490
|
this._clearReloadTimer();
|
4298
|
-
this.
|
4491
|
+
this._reloadTimer = setTimeout(this._onTimerReached.bind(this), this._getRemainingDelay());
|
4299
4492
|
}
|
4300
4493
|
}
|
4301
4494
|
_onTimerReached() {
|
4302
|
-
this.
|
4495
|
+
this._reloadTimer = null;
|
4303
4496
|
this._tryReload();
|
4304
4497
|
}
|
4305
4498
|
_tryReload() {
|
@@ -4377,7 +4570,7 @@ up.FragmentPolling = class FragmentPolling {
|
|
4377
4570
|
|
4378
4571
|
|
4379
4572
|
/***/ }),
|
4380
|
-
/*
|
4573
|
+
/* 47 */
|
4381
4574
|
/***/ (() => {
|
4382
4575
|
|
4383
4576
|
const u = up.util;
|
@@ -4441,7 +4634,7 @@ up.FragmentScrolling = class FragmentScrolling extends up.FragmentProcessor {
|
|
4441
4634
|
|
4442
4635
|
|
4443
4636
|
/***/ }),
|
4444
|
-
/*
|
4637
|
+
/* 48 */
|
4445
4638
|
/***/ (() => {
|
4446
4639
|
|
4447
4640
|
const e = up.element;
|
@@ -4709,7 +4902,7 @@ up.Layer = class Layer extends up.Record {
|
|
4709
4902
|
|
4710
4903
|
|
4711
4904
|
/***/ }),
|
4712
|
-
/*
|
4905
|
+
/* 49 */
|
4713
4906
|
/***/ (function() {
|
4714
4907
|
|
4715
4908
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -4721,289 +4914,298 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
4721
4914
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
4722
4915
|
});
|
4723
4916
|
};
|
4917
|
+
var _a;
|
4724
4918
|
const e = up.element;
|
4725
4919
|
const u = up.util;
|
4726
|
-
up.Layer.Overlay = class Overlay extends up.Layer {
|
4727
|
-
|
4728
|
-
|
4729
|
-
|
4730
|
-
|
4731
|
-
|
4732
|
-
|
4733
|
-
|
4734
|
-
|
4735
|
-
|
4736
|
-
|
4737
|
-
|
4738
|
-
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
4742
|
-
'backdropCloseAnimation',
|
4743
|
-
'dismissable',
|
4744
|
-
'dismissLabel',
|
4745
|
-
'dismissAriaLabel',
|
4746
|
-
'trapFocus',
|
4747
|
-
'onOpened',
|
4748
|
-
'onAccept',
|
4749
|
-
'onAccepted',
|
4750
|
-
'onDismiss',
|
4751
|
-
'onDismissed',
|
4752
|
-
'acceptEvent',
|
4753
|
-
'dismissEvent',
|
4754
|
-
'acceptLocation',
|
4755
|
-
'dismissLocation',
|
4756
|
-
'opening'
|
4757
|
-
]);
|
4758
|
-
}
|
4759
|
-
constructor(options) {
|
4760
|
-
super(options);
|
4761
|
-
if (this.dismissable === true) {
|
4762
|
-
this.dismissable = ['button', 'key', 'outside'];
|
4920
|
+
up.Layer.Overlay = (_a = class Overlay extends up.Layer {
|
4921
|
+
keys() {
|
4922
|
+
return [
|
4923
|
+
...super.keys(),
|
4924
|
+
...this.constructor.VISUAL_KEYS,
|
4925
|
+
'onOpened',
|
4926
|
+
'onAccept',
|
4927
|
+
'onAccepted',
|
4928
|
+
'onDismiss',
|
4929
|
+
'onDismissed',
|
4930
|
+
'acceptEvent',
|
4931
|
+
'dismissEvent',
|
4932
|
+
'acceptLocation',
|
4933
|
+
'dismissLocation',
|
4934
|
+
'opening'
|
4935
|
+
];
|
4763
4936
|
}
|
4764
|
-
|
4765
|
-
|
4937
|
+
constructor(options) {
|
4938
|
+
super(options);
|
4939
|
+
if (this.dismissable === true) {
|
4940
|
+
this.dismissable = ['button', 'key', 'outside'];
|
4941
|
+
}
|
4942
|
+
else if (this.dismissable === false) {
|
4943
|
+
this.dismissable = [];
|
4944
|
+
}
|
4945
|
+
else {
|
4946
|
+
this.dismissable = u.getSimpleTokens(this.dismissable);
|
4947
|
+
}
|
4948
|
+
if (this.acceptLocation) {
|
4949
|
+
this.acceptLocation = new up.URLPattern(this.acceptLocation);
|
4950
|
+
}
|
4951
|
+
if (this.dismissLocation) {
|
4952
|
+
this.dismissLocation = new up.URLPattern(this.dismissLocation);
|
4953
|
+
}
|
4766
4954
|
}
|
4767
|
-
|
4768
|
-
|
4955
|
+
callback(name) {
|
4956
|
+
let fn = this[name];
|
4957
|
+
if (fn) {
|
4958
|
+
return fn.bind(this);
|
4959
|
+
}
|
4769
4960
|
}
|
4770
|
-
|
4771
|
-
this.
|
4961
|
+
createElement(parentElement) {
|
4962
|
+
this.nesting || (this.nesting = this._suggestVisualNesting());
|
4963
|
+
const elementAttrs = u.compactObject(u.pick(this, ['align', 'position', 'size', 'class', 'nesting']));
|
4964
|
+
this.element = this.affixPart(parentElement, null, elementAttrs);
|
4772
4965
|
}
|
4773
|
-
|
4774
|
-
this.
|
4966
|
+
createBackdropElement(parentElement) {
|
4967
|
+
this.backdropElement = this.affixPart(parentElement, 'backdrop');
|
4775
4968
|
}
|
4776
|
-
|
4777
|
-
|
4778
|
-
let fn = this[name];
|
4779
|
-
if (fn) {
|
4780
|
-
return fn.bind(this);
|
4969
|
+
createViewportElement(parentElement) {
|
4970
|
+
this.viewportElement = this.affixPart(parentElement, 'viewport', { 'up-viewport': '' });
|
4781
4971
|
}
|
4782
|
-
|
4783
|
-
|
4784
|
-
this.nesting || (this.nesting = this._suggestVisualNesting());
|
4785
|
-
const elementAttrs = u.compactObject(u.pick(this, ['align', 'position', 'size', 'class', 'nesting']));
|
4786
|
-
this.element = this.affixPart(parentElement, null, elementAttrs);
|
4787
|
-
}
|
4788
|
-
createBackdropElement(parentElement) {
|
4789
|
-
this.backdropElement = this.affixPart(parentElement, 'backdrop');
|
4790
|
-
}
|
4791
|
-
createViewportElement(parentElement) {
|
4792
|
-
this.viewportElement = this.affixPart(parentElement, 'viewport', { 'up-viewport': '' });
|
4793
|
-
}
|
4794
|
-
createBoxElement(parentElement) {
|
4795
|
-
this.boxElement = this.affixPart(parentElement, 'box');
|
4796
|
-
}
|
4797
|
-
createContentElement(parentElement) {
|
4798
|
-
this.contentElement = this.affixPart(parentElement, 'content');
|
4799
|
-
}
|
4800
|
-
setContent(content) {
|
4801
|
-
this.contentElement.append(content);
|
4802
|
-
this.onContentSet();
|
4803
|
-
}
|
4804
|
-
onContentSet() {
|
4805
|
-
}
|
4806
|
-
createDismissElement(parentElement) {
|
4807
|
-
this.dismissElement = this.affixPart(parentElement, 'dismiss', {
|
4808
|
-
'up-dismiss': '":button"',
|
4809
|
-
'aria-label': this.dismissAriaLabel
|
4810
|
-
});
|
4811
|
-
return e.affix(this.dismissElement, 'span[aria-hidden="true"]', { text: this.dismissLabel });
|
4812
|
-
}
|
4813
|
-
affixPart(parentElement, part, options = {}) {
|
4814
|
-
return e.affix(parentElement, this.selector(part), options);
|
4815
|
-
}
|
4816
|
-
static selector(part) {
|
4817
|
-
return u.compact(['up', this.mode, part]).join('-');
|
4818
|
-
}
|
4819
|
-
_suggestVisualNesting() {
|
4820
|
-
const { parent } = this;
|
4821
|
-
if (this.mode === parent.mode) {
|
4822
|
-
return 1 + parent._suggestVisualNesting();
|
4972
|
+
createBoxElement(parentElement) {
|
4973
|
+
this.boxElement = this.affixPart(parentElement, 'box');
|
4823
4974
|
}
|
4824
|
-
|
4825
|
-
|
4975
|
+
createContentElement(parentElement) {
|
4976
|
+
this.contentElement = this.affixPart(parentElement, 'content');
|
4826
4977
|
}
|
4827
|
-
|
4828
|
-
|
4829
|
-
|
4830
|
-
|
4831
|
-
|
4832
|
-
|
4833
|
-
|
4834
|
-
|
4835
|
-
|
4836
|
-
|
4837
|
-
|
4838
|
-
|
4839
|
-
|
4840
|
-
|
4841
|
-
|
4978
|
+
setContent(content) {
|
4979
|
+
this.contentElement.append(content);
|
4980
|
+
this.onContentSet();
|
4981
|
+
}
|
4982
|
+
onContentSet() {
|
4983
|
+
}
|
4984
|
+
createDismissElement(parentElement) {
|
4985
|
+
this.dismissElement = this.affixPart(parentElement, 'dismiss', {
|
4986
|
+
'up-dismiss': '":button"',
|
4987
|
+
'aria-label': this.dismissARIALabel
|
4988
|
+
});
|
4989
|
+
return e.affix(this.dismissElement, 'span[aria-hidden="true"]', { text: this.dismissLabel });
|
4990
|
+
}
|
4991
|
+
affixPart(parentElement, part, options = {}) {
|
4992
|
+
return e.affix(parentElement, this.selector(part), options);
|
4993
|
+
}
|
4994
|
+
static selector(part) {
|
4995
|
+
return u.compact(['up', this.mode, part]).join('-');
|
4996
|
+
}
|
4997
|
+
_suggestVisualNesting() {
|
4998
|
+
const { parent } = this;
|
4999
|
+
if (this.mode === parent.mode) {
|
5000
|
+
return 1 + parent._suggestVisualNesting();
|
4842
5001
|
}
|
4843
5002
|
else {
|
4844
|
-
|
4845
|
-
if (!up.layer.isWithinForeignOverlay(element)) {
|
4846
|
-
const originClicked = this.origin && this.origin.contains(element);
|
4847
|
-
this._onOutsideClicked(event, originClicked);
|
4848
|
-
}
|
4849
|
-
});
|
5003
|
+
return 0;
|
4850
5004
|
}
|
4851
5005
|
}
|
4852
|
-
|
4853
|
-
|
5006
|
+
setupHandlers() {
|
5007
|
+
var _b, _c;
|
5008
|
+
super.setupHandlers();
|
5009
|
+
this.overlayFocus = new up.OverlayFocus(this);
|
5010
|
+
if (this._supportsDismissMethod('button')) {
|
5011
|
+
this.createDismissElement(this.getBoxElement());
|
5012
|
+
}
|
5013
|
+
if (this._supportsDismissMethod('outside')) {
|
5014
|
+
if (this.viewportElement) {
|
5015
|
+
up.on(this.viewportElement, 'up:click', event => {
|
5016
|
+
if (event.target === this.viewportElement) {
|
5017
|
+
this._onOutsideClicked(event, true);
|
5018
|
+
}
|
5019
|
+
});
|
5020
|
+
}
|
5021
|
+
else {
|
5022
|
+
this.unbindParentClicked = this.parent.on('up:click', (event, element) => {
|
5023
|
+
if (!up.layer.isWithinForeignOverlay(element)) {
|
5024
|
+
const originClicked = this.origin && this.origin.contains(element);
|
5025
|
+
this._onOutsideClicked(event, originClicked);
|
5026
|
+
}
|
5027
|
+
});
|
5028
|
+
}
|
5029
|
+
}
|
5030
|
+
if (this._supportsDismissMethod('key')) {
|
5031
|
+
this.unbindEscapePressed = up.event.onEscape(event => this.onEscapePressed(event));
|
5032
|
+
}
|
5033
|
+
this.registerClickCloser('up-accept', (value, closeOptions) => {
|
5034
|
+
this.accept(value, closeOptions);
|
5035
|
+
});
|
5036
|
+
this.registerClickCloser('up-dismiss', (value, closeOptions) => {
|
5037
|
+
this.dismiss(value, closeOptions);
|
5038
|
+
});
|
5039
|
+
(_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);
|
5042
|
+
this.on('up:click', 'label[for]', (event, label) => this._onLabelClicked(event, label));
|
5043
|
+
}
|
5044
|
+
_onLabelClicked(event, label) {
|
5045
|
+
let id = label.getAttribute('for');
|
5046
|
+
let fieldSelector = up.form.fieldSelector(e.idSelector(id));
|
5047
|
+
let fieldsAnywhere = up.fragment.all(fieldSelector, { layer: 'any' });
|
5048
|
+
let fieldsInLayer = up.fragment.all(fieldSelector, { layer: this });
|
5049
|
+
if (fieldsAnywhere.length > 1 && fieldsInLayer[0] !== fieldsAnywhere[0]) {
|
5050
|
+
event.preventDefault();
|
5051
|
+
const field = fieldsInLayer[0];
|
5052
|
+
field.focus();
|
5053
|
+
if (field.matches('input[type=checkbox], input[type=radio]')) {
|
5054
|
+
field.click();
|
5055
|
+
}
|
5056
|
+
}
|
4854
5057
|
}
|
4855
|
-
|
4856
|
-
|
4857
|
-
|
4858
|
-
|
4859
|
-
this.dismiss(
|
4860
|
-
}
|
4861
|
-
(
|
4862
|
-
|
4863
|
-
|
4864
|
-
|
4865
|
-
|
4866
|
-
|
4867
|
-
|
4868
|
-
|
4869
|
-
|
4870
|
-
|
4871
|
-
if (fieldsAnywhere.length > 1 && fieldsInLayer[0] !== fieldsAnywhere[0]) {
|
4872
|
-
event.preventDefault();
|
4873
|
-
const field = fieldsInLayer[0];
|
4874
|
-
field.focus();
|
4875
|
-
if (field.matches('input[type=checkbox], input[type=radio]')) {
|
4876
|
-
field.click();
|
4877
|
-
}
|
4878
|
-
}
|
4879
|
-
}
|
4880
|
-
_onOutsideClicked(event, halt) {
|
4881
|
-
up.log.putsEvent(event);
|
4882
|
-
if (halt)
|
4883
|
-
up.event.halt(event);
|
4884
|
-
up.error.muteUncriticalSync(() => this.dismiss(':outside', { origin: event.target }));
|
4885
|
-
}
|
4886
|
-
onEscapePressed(event) {
|
4887
|
-
if (this.isFront()) {
|
4888
|
-
let field = up.form.focusedField();
|
4889
|
-
if (field) {
|
4890
|
-
field.blur();
|
5058
|
+
_onOutsideClicked(event, halt) {
|
5059
|
+
up.log.putsEvent(event);
|
5060
|
+
if (halt)
|
5061
|
+
up.event.halt(event);
|
5062
|
+
up.error.muteUncriticalSync(() => this.dismiss(':outside', { origin: event.target }));
|
5063
|
+
}
|
5064
|
+
onEscapePressed(event) {
|
5065
|
+
if (this.isFront()) {
|
5066
|
+
let field = up.form.focusedField();
|
5067
|
+
if (field) {
|
5068
|
+
field.blur();
|
5069
|
+
}
|
5070
|
+
else if (this._supportsDismissMethod('key')) {
|
5071
|
+
up.event.halt(event, { log: true });
|
5072
|
+
up.error.muteUncriticalSync(() => this.dismiss(':key'));
|
5073
|
+
}
|
4891
5074
|
}
|
4892
|
-
|
5075
|
+
}
|
5076
|
+
registerClickCloser(attribute, closeFn) {
|
5077
|
+
let selector = `[${attribute}]`;
|
5078
|
+
this.on('up:click', selector, function (event) {
|
4893
5079
|
up.event.halt(event, { log: true });
|
4894
|
-
|
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));
|
5089
|
+
});
|
5090
|
+
}
|
5091
|
+
_registerEventCloser(eventTypes, closeFn) {
|
5092
|
+
if (!eventTypes) {
|
5093
|
+
return;
|
4895
5094
|
}
|
5095
|
+
return this.on(eventTypes, event => {
|
5096
|
+
event.preventDefault();
|
5097
|
+
up.error.muteUncriticalSync(() => closeFn.call(this, event, { response: event.response }));
|
5098
|
+
});
|
4896
5099
|
}
|
4897
|
-
|
4898
|
-
|
4899
|
-
let selector = `[${attribute}]`;
|
4900
|
-
this.on('up:click', selector, function (event) {
|
4901
|
-
up.event.halt(event, { log: true });
|
4902
|
-
const origin = event.target.closest(selector);
|
4903
|
-
const value = e.jsonAttr(origin, attribute);
|
4904
|
-
const closeOptions = { origin };
|
4905
|
-
const parser = new up.OptionsParser(origin, closeOptions);
|
4906
|
-
parser.booleanOrString('animation');
|
4907
|
-
parser.string('easing');
|
4908
|
-
parser.number('duration');
|
4909
|
-
parser.string('confirm');
|
4910
|
-
up.error.muteUncriticalSync(() => closeFn(value, closeOptions));
|
4911
|
-
});
|
4912
|
-
}
|
4913
|
-
_registerEventCloser(eventTypes, closeFn) {
|
4914
|
-
if (!eventTypes) {
|
4915
|
-
return;
|
5100
|
+
tryAcceptForLocation(options) {
|
5101
|
+
this._tryCloseForLocation(this.acceptLocation, this.accept, options);
|
4916
5102
|
}
|
4917
|
-
|
4918
|
-
|
4919
|
-
up.error.muteUncriticalSync(() => closeFn.call(this, event, { response: event.response }));
|
4920
|
-
});
|
4921
|
-
}
|
4922
|
-
tryAcceptForLocation(options) {
|
4923
|
-
this._tryCloseForLocation(this.acceptLocation, this.accept, options);
|
4924
|
-
}
|
4925
|
-
tryDismissForLocation(options) {
|
4926
|
-
this._tryCloseForLocation(this.dismissLocation, this.dismiss, options);
|
4927
|
-
}
|
4928
|
-
_tryCloseForLocation(urlPattern, closeFn, options) {
|
4929
|
-
let location, resolution;
|
4930
|
-
if (urlPattern && (location = this.location) && (resolution = urlPattern.recognize(location))) {
|
4931
|
-
const closeValue = Object.assign(Object.assign({}, resolution), { location });
|
4932
|
-
up.error.muteUncriticalSync(() => closeFn.call(this, closeValue, options));
|
5103
|
+
tryDismissForLocation(options) {
|
5104
|
+
this._tryCloseForLocation(this.dismissLocation, this.dismiss, options);
|
4933
5105
|
}
|
4934
|
-
|
4935
|
-
|
4936
|
-
|
4937
|
-
|
4938
|
-
|
4939
|
-
|
4940
|
-
this.overlayFocus.teardown();
|
4941
|
-
}
|
4942
|
-
destroyElements(options) {
|
4943
|
-
const animation = () => this.startCloseAnimation(options);
|
4944
|
-
const onFinished = () => {
|
4945
|
-
var _a;
|
4946
|
-
this.onElementsRemoved();
|
4947
|
-
(_a = options.onFinished) === null || _a === void 0 ? void 0 : _a.call(options);
|
4948
|
-
};
|
4949
|
-
const destroyOptions = Object.assign(Object.assign({}, options), { animation, onFinished, log: false });
|
4950
|
-
up.destroy(this.element, destroyOptions);
|
4951
|
-
}
|
4952
|
-
onElementsRemoved() {
|
4953
|
-
}
|
4954
|
-
_startAnimation(options = {}) {
|
4955
|
-
const boxDone = up.animate(this.getBoxElement(), options.boxAnimation, options);
|
4956
|
-
let backdropDone;
|
4957
|
-
if (this.backdrop && !up.motion.isNone(options.boxAnimation)) {
|
4958
|
-
backdropDone = up.animate(this.backdropElement, options.backdropAnimation, options);
|
5106
|
+
_tryCloseForLocation(urlPattern, closeFn, options) {
|
5107
|
+
let location, resolution;
|
5108
|
+
if (urlPattern && (location = this.location) && (resolution = urlPattern.recognize(location))) {
|
5109
|
+
const closeValue = Object.assign(Object.assign({}, resolution), { location });
|
5110
|
+
up.error.muteUncriticalSync(() => closeFn.call(this, closeValue, options));
|
5111
|
+
}
|
4959
5112
|
}
|
4960
|
-
|
4961
|
-
|
4962
|
-
|
4963
|
-
|
4964
|
-
|
4965
|
-
|
4966
|
-
|
4967
|
-
|
4968
|
-
|
4969
|
-
|
5113
|
+
teardownHandlers() {
|
5114
|
+
var _b, _c;
|
5115
|
+
super.teardownHandlers();
|
5116
|
+
(_b = this.unbindParentClicked) === null || _b === void 0 ? void 0 : _b.call(this);
|
5117
|
+
(_c = this.unbindEscapePressed) === null || _c === void 0 ? void 0 : _c.call(this);
|
5118
|
+
this.overlayFocus.teardown();
|
5119
|
+
}
|
5120
|
+
destroyElements(options) {
|
5121
|
+
const animation = () => this.startCloseAnimation(options);
|
5122
|
+
const onFinished = () => {
|
5123
|
+
var _b;
|
5124
|
+
this.onElementsRemoved();
|
5125
|
+
(_b = options.onFinished) === null || _b === void 0 ? void 0 : _b.call(options);
|
5126
|
+
};
|
5127
|
+
const destroyOptions = Object.assign(Object.assign({}, options), { animation, onFinished, log: false });
|
5128
|
+
up.destroy(this.element, destroyOptions);
|
5129
|
+
}
|
5130
|
+
onElementsRemoved() {
|
5131
|
+
}
|
5132
|
+
_startAnimation(options = {}) {
|
5133
|
+
const boxDone = up.animate(this.getBoxElement(), options.boxAnimation, options);
|
5134
|
+
let backdropDone;
|
5135
|
+
if (this.backdrop && !up.motion.isNone(options.boxAnimation)) {
|
5136
|
+
backdropDone = up.animate(this.backdropElement, options.backdropAnimation, options);
|
5137
|
+
}
|
5138
|
+
return Promise.all([boxDone, backdropDone]);
|
5139
|
+
}
|
5140
|
+
startOpenAnimation(options = {}) {
|
5141
|
+
var _b;
|
5142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
5143
|
+
let boxAnimation = (_b = options.animation) !== null && _b !== void 0 ? _b : this.evalOption(this.openAnimation);
|
5144
|
+
let backdropAnimation = 'fade-in';
|
5145
|
+
yield this._startAnimation({
|
5146
|
+
boxAnimation,
|
5147
|
+
backdropAnimation,
|
5148
|
+
easing: options.easing || this.openEasing,
|
5149
|
+
duration: options.duration || this.openDuration
|
5150
|
+
});
|
5151
|
+
this.wasEverVisible = true;
|
4970
5152
|
});
|
4971
|
-
|
4972
|
-
})
|
4973
|
-
|
4974
|
-
|
4975
|
-
|
4976
|
-
|
4977
|
-
|
4978
|
-
|
4979
|
-
|
4980
|
-
|
4981
|
-
|
4982
|
-
|
4983
|
-
|
4984
|
-
|
4985
|
-
|
4986
|
-
|
4987
|
-
|
4988
|
-
|
4989
|
-
|
4990
|
-
|
4991
|
-
|
4992
|
-
|
4993
|
-
|
4994
|
-
|
4995
|
-
|
4996
|
-
|
4997
|
-
|
4998
|
-
|
4999
|
-
|
5000
|
-
|
5001
|
-
|
5002
|
-
}
|
5153
|
+
}
|
5154
|
+
startCloseAnimation(options = {}) {
|
5155
|
+
var _b;
|
5156
|
+
let boxAnimation = this.wasEverVisible && ((_b = options.animation) !== null && _b !== void 0 ? _b : this.evalOption(this.closeAnimation));
|
5157
|
+
let backdropAnimation = 'fade-out';
|
5158
|
+
return this._startAnimation({
|
5159
|
+
boxAnimation,
|
5160
|
+
backdropAnimation,
|
5161
|
+
easing: options.easing || this.closeEasing,
|
5162
|
+
duration: options.duration || this.closeDuration
|
5163
|
+
});
|
5164
|
+
}
|
5165
|
+
accept(value = null, options = {}) {
|
5166
|
+
return this._executeCloseChange('accept', value, options);
|
5167
|
+
}
|
5168
|
+
dismiss(value = null, options = {}) {
|
5169
|
+
return this._executeCloseChange('dismiss', value, options);
|
5170
|
+
}
|
5171
|
+
_supportsDismissMethod(method) {
|
5172
|
+
return u.contains(this.dismissable, method);
|
5173
|
+
}
|
5174
|
+
_executeCloseChange(verb, value, options) {
|
5175
|
+
options = Object.assign(Object.assign({}, options), { verb, value, layer: this });
|
5176
|
+
return new up.Change.CloseLayer(options).execute();
|
5177
|
+
}
|
5178
|
+
getFirstSwappableElement() {
|
5179
|
+
return this.getContentElement().children[0];
|
5180
|
+
}
|
5181
|
+
toString() {
|
5182
|
+
return `${this.mode} overlay`;
|
5183
|
+
}
|
5184
|
+
},
|
5185
|
+
_a.VISUAL_KEYS = [
|
5186
|
+
'mode',
|
5187
|
+
'position',
|
5188
|
+
'align',
|
5189
|
+
'size',
|
5190
|
+
'origin',
|
5191
|
+
'class',
|
5192
|
+
'backdrop',
|
5193
|
+
'dismissable',
|
5194
|
+
'dismissLabel',
|
5195
|
+
'dismissARIALabel',
|
5196
|
+
'openAnimation',
|
5197
|
+
'closeAnimation',
|
5198
|
+
'openDuration',
|
5199
|
+
'closeDuration',
|
5200
|
+
'openEasing',
|
5201
|
+
'closeEasing',
|
5202
|
+
'trapFocus',
|
5203
|
+
],
|
5204
|
+
_a);
|
5003
5205
|
|
5004
5206
|
|
5005
5207
|
/***/ }),
|
5006
|
-
/*
|
5208
|
+
/* 50 */
|
5007
5209
|
/***/ (() => {
|
5008
5210
|
|
5009
5211
|
up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
@@ -5042,7 +5244,7 @@ up.Layer.OverlayWithTether = class OverlayWithTether extends up.Layer.Overlay {
|
|
5042
5244
|
|
5043
5245
|
|
5044
5246
|
/***/ }),
|
5045
|
-
/*
|
5247
|
+
/* 51 */
|
5046
5248
|
/***/ (() => {
|
5047
5249
|
|
5048
5250
|
up.Layer.OverlayWithViewport = class OverlayWithViewport extends up.Layer.Overlay {
|
@@ -5071,7 +5273,7 @@ up.Layer.OverlayWithViewport = class OverlayWithViewport extends up.Layer.Overla
|
|
5071
5273
|
|
5072
5274
|
|
5073
5275
|
/***/ }),
|
5074
|
-
/*
|
5276
|
+
/* 52 */
|
5075
5277
|
/***/ (() => {
|
5076
5278
|
|
5077
5279
|
var _a;
|
@@ -5117,7 +5319,7 @@ up.Layer.Root = (_a = class Root extends up.Layer {
|
|
5117
5319
|
|
5118
5320
|
|
5119
5321
|
/***/ }),
|
5120
|
-
/*
|
5322
|
+
/* 53 */
|
5121
5323
|
/***/ (() => {
|
5122
5324
|
|
5123
5325
|
var _a;
|
@@ -5128,7 +5330,7 @@ up.Layer.Modal = (_a = class Modal extends up.Layer.OverlayWithViewport {
|
|
5128
5330
|
|
5129
5331
|
|
5130
5332
|
/***/ }),
|
5131
|
-
/*
|
5333
|
+
/* 54 */
|
5132
5334
|
/***/ (() => {
|
5133
5335
|
|
5134
5336
|
var _a;
|
@@ -5139,7 +5341,7 @@ up.Layer.Popup = (_a = class Popup extends up.Layer.OverlayWithTether {
|
|
5139
5341
|
|
5140
5342
|
|
5141
5343
|
/***/ }),
|
5142
|
-
/*
|
5344
|
+
/* 55 */
|
5143
5345
|
/***/ (() => {
|
5144
5346
|
|
5145
5347
|
var _a;
|
@@ -5150,7 +5352,7 @@ up.Layer.Drawer = (_a = class Drawer extends up.Layer.OverlayWithViewport {
|
|
5150
5352
|
|
5151
5353
|
|
5152
5354
|
/***/ }),
|
5153
|
-
/*
|
5355
|
+
/* 56 */
|
5154
5356
|
/***/ (() => {
|
5155
5357
|
|
5156
5358
|
var _a;
|
@@ -5161,7 +5363,7 @@ up.Layer.Cover = (_a = class Cover extends up.Layer.OverlayWithViewport {
|
|
5161
5363
|
|
5162
5364
|
|
5163
5365
|
/***/ }),
|
5164
|
-
/*
|
5366
|
+
/* 57 */
|
5165
5367
|
/***/ (() => {
|
5166
5368
|
|
5167
5369
|
var _a;
|
@@ -5174,7 +5376,7 @@ up.LayerLookup = (_a = class LayerLookup {
|
|
5174
5376
|
up.layer.normalizeOptions(options);
|
5175
5377
|
}
|
5176
5378
|
this._options = options;
|
5177
|
-
this._values = u.
|
5379
|
+
this._values = u.getSimpleTokens(options.layer);
|
5178
5380
|
}
|
5179
5381
|
all() {
|
5180
5382
|
let results = u.flatMap(this._values, value => this._resolveValue(value));
|
@@ -5207,7 +5409,7 @@ up.LayerLookup = (_a = class LayerLookup {
|
|
5207
5409
|
if (/^\d+$/.test(value)) {
|
5208
5410
|
return this._forIndex(Number(value));
|
5209
5411
|
}
|
5210
|
-
if (u.
|
5412
|
+
if (u.isElementLike(value)) {
|
5211
5413
|
return this._forElement(value);
|
5212
5414
|
}
|
5213
5415
|
switch (value) {
|
@@ -5274,7 +5476,7 @@ up.LayerLookup = (_a = class LayerLookup {
|
|
5274
5476
|
|
5275
5477
|
|
5276
5478
|
/***/ }),
|
5277
|
-
/*
|
5479
|
+
/* 58 */
|
5278
5480
|
/***/ (() => {
|
5279
5481
|
|
5280
5482
|
const u = up.util;
|
@@ -5388,11 +5590,11 @@ up.LayerStack = class LayerStack {
|
|
5388
5590
|
|
5389
5591
|
|
5390
5592
|
/***/ }),
|
5391
|
-
/*
|
5593
|
+
/* 59 */
|
5392
5594
|
/***/ (() => {
|
5393
5595
|
|
5394
5596
|
const u = up.util;
|
5395
|
-
up.
|
5597
|
+
up.LinkCurrentURLs = class LinkCurrentURLs {
|
5396
5598
|
constructor(link) {
|
5397
5599
|
this._isSafe = up.link.isSafe(link);
|
5398
5600
|
if (this._isSafe) {
|
@@ -5423,7 +5625,7 @@ up.LinkFeedbackURLs = class LinkFeedbackURLs {
|
|
5423
5625
|
|
5424
5626
|
|
5425
5627
|
/***/ }),
|
5426
|
-
/*
|
5628
|
+
/* 60 */
|
5427
5629
|
/***/ (() => {
|
5428
5630
|
|
5429
5631
|
const u = up.util;
|
@@ -5468,7 +5670,7 @@ up.LinkFollowIntent = class LinkFollowIntent {
|
|
5468
5670
|
|
5469
5671
|
|
5470
5672
|
/***/ }),
|
5471
|
-
/*
|
5673
|
+
/* 61 */
|
5472
5674
|
/***/ (function() {
|
5473
5675
|
|
5474
5676
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
@@ -5577,7 +5779,7 @@ up.MotionController = class MotionController {
|
|
5577
5779
|
|
5578
5780
|
|
5579
5781
|
/***/ }),
|
5580
|
-
/*
|
5782
|
+
/* 62 */
|
5581
5783
|
/***/ (() => {
|
5582
5784
|
|
5583
5785
|
const u = up.util;
|
@@ -5592,33 +5794,36 @@ up.NonceableCallback = class NonceableCallback {
|
|
5592
5794
|
return new this(match[3], match[2]);
|
5593
5795
|
}
|
5594
5796
|
toFunction(...argNames) {
|
5797
|
+
let scriptExpression = this.script;
|
5798
|
+
if (!/\b(;|return|throw)\b/.test(scriptExpression))
|
5799
|
+
scriptExpression = `return ${scriptExpression}`;
|
5595
5800
|
if (this.nonce) {
|
5596
5801
|
let callbackThis = this;
|
5597
5802
|
return function (...args) {
|
5598
|
-
return callbackThis._runAsNoncedFunction(this, argNames, args);
|
5803
|
+
return callbackThis._runAsNoncedFunction(scriptExpression, this, argNames, args);
|
5599
5804
|
};
|
5600
5805
|
}
|
5601
5806
|
else {
|
5602
|
-
return new Function(...argNames,
|
5807
|
+
return new Function(...argNames, scriptExpression);
|
5603
5808
|
}
|
5604
5809
|
}
|
5605
5810
|
toString() {
|
5606
5811
|
return `nonce-${this.nonce} ${this.script}`;
|
5607
5812
|
}
|
5608
|
-
_runAsNoncedFunction(thisArg, argNames, args) {
|
5813
|
+
_runAsNoncedFunction(script, thisArg, argNames, args) {
|
5609
5814
|
let wrappedScript = `
|
5610
5815
|
try {
|
5611
5816
|
up.noncedEval.value = (function(${argNames.join()}) {
|
5612
|
-
${
|
5817
|
+
${script}
|
5613
5818
|
}).apply(up.noncedEval.thisArg, up.noncedEval.args)
|
5614
5819
|
} catch (error) {
|
5615
5820
|
up.noncedEval.error = error
|
5616
5821
|
}
|
5617
5822
|
`;
|
5618
|
-
let
|
5823
|
+
let scriptElement;
|
5619
5824
|
try {
|
5620
5825
|
up.noncedEval = { args, thisArg: thisArg };
|
5621
|
-
|
5826
|
+
scriptElement = e.affix(document.body, 'script', { nonce: this.nonce, text: wrappedScript });
|
5622
5827
|
if (up.noncedEval.error) {
|
5623
5828
|
throw up.noncedEval.error;
|
5624
5829
|
}
|
@@ -5628,8 +5833,8 @@ up.NonceableCallback = class NonceableCallback {
|
|
5628
5833
|
}
|
5629
5834
|
finally {
|
5630
5835
|
up.noncedEval = undefined;
|
5631
|
-
if (
|
5632
|
-
|
5836
|
+
if (scriptElement) {
|
5837
|
+
scriptElement.remove();
|
5633
5838
|
}
|
5634
5839
|
}
|
5635
5840
|
}
|
@@ -5663,7 +5868,7 @@ up.NonceableCallback = class NonceableCallback {
|
|
5663
5868
|
|
5664
5869
|
|
5665
5870
|
/***/ }),
|
5666
|
-
/*
|
5871
|
+
/* 63 */
|
5667
5872
|
/***/ (() => {
|
5668
5873
|
|
5669
5874
|
const e = up.element;
|
@@ -5679,7 +5884,7 @@ up.OverlayFocus = class OverlayFocus {
|
|
5679
5884
|
return;
|
5680
5885
|
}
|
5681
5886
|
this._active = true;
|
5682
|
-
this._unsetAttrs = e.
|
5887
|
+
this._unsetAttrs = e.setAttrsTemp(this._focusElement, {
|
5683
5888
|
'tabindex': '0',
|
5684
5889
|
'role': 'dialog',
|
5685
5890
|
'aria-modal': this._trapFocus.toString()
|
@@ -5736,7 +5941,7 @@ up.OverlayFocus = class OverlayFocus {
|
|
5736
5941
|
|
5737
5942
|
|
5738
5943
|
/***/ }),
|
5739
|
-
/*
|
5944
|
+
/* 64 */
|
5740
5945
|
/***/ (() => {
|
5741
5946
|
|
5742
5947
|
const u = up.util;
|
@@ -5969,6 +6174,134 @@ up.Params = class Params {
|
|
5969
6174
|
};
|
5970
6175
|
|
5971
6176
|
|
6177
|
+
/***/ }),
|
6178
|
+
/* 65 */
|
6179
|
+
/***/ (() => {
|
6180
|
+
|
6181
|
+
const u = up.util;
|
6182
|
+
const e = up.element;
|
6183
|
+
up.Preview = class Preview {
|
6184
|
+
constructor({ fragment, request, renderOptions, cleaner }) {
|
6185
|
+
this.fragment = fragment;
|
6186
|
+
this.request = request;
|
6187
|
+
this.renderOptions = renderOptions;
|
6188
|
+
this._cleaner = cleaner;
|
6189
|
+
}
|
6190
|
+
undo(...args) {
|
6191
|
+
if (this.ended) {
|
6192
|
+
reportError(new up.Error('Preview used after end of request'));
|
6193
|
+
}
|
6194
|
+
else {
|
6195
|
+
this._cleaner.guard(...args);
|
6196
|
+
}
|
6197
|
+
}
|
6198
|
+
get origin() {
|
6199
|
+
return this.request.origin;
|
6200
|
+
}
|
6201
|
+
get params() {
|
6202
|
+
return this.request.params;
|
6203
|
+
}
|
6204
|
+
get layer() {
|
6205
|
+
return this.request.layer;
|
6206
|
+
}
|
6207
|
+
get ended() {
|
6208
|
+
return this.request.ended;
|
6209
|
+
}
|
6210
|
+
get expiredResponse() {
|
6211
|
+
return this.renderOptions.expiredResponse;
|
6212
|
+
}
|
6213
|
+
get revalidating() {
|
6214
|
+
return !!this.expiredResponse;
|
6215
|
+
}
|
6216
|
+
run(value, options = {}) {
|
6217
|
+
for (let fn of up.status.resolvePreviewFns(value)) {
|
6218
|
+
this.undo(up.error.guard(fn, this, options));
|
6219
|
+
}
|
6220
|
+
}
|
6221
|
+
revert() {
|
6222
|
+
this._cleaner.clean();
|
6223
|
+
}
|
6224
|
+
setAttrs(...args) {
|
6225
|
+
let [element, attrs] = this._parseMutatorArgs(args, 'val', 'val');
|
6226
|
+
this.undo(e.setAttrsTemp(element, attrs));
|
6227
|
+
}
|
6228
|
+
addClass(...args) {
|
6229
|
+
let [element, klass] = this._parseMutatorArgs(args, 'val', 'val');
|
6230
|
+
this.undo(e.addClassTemp(element, klass));
|
6231
|
+
}
|
6232
|
+
addClassBatch(elements, classes) {
|
6233
|
+
for (let element of elements) {
|
6234
|
+
for (let klass of classes) {
|
6235
|
+
this.addClass(element, klass);
|
6236
|
+
}
|
6237
|
+
}
|
6238
|
+
}
|
6239
|
+
removeClass(...args) {
|
6240
|
+
let [element, klass] = this._parseMutatorArgs(args, 'val', 'val');
|
6241
|
+
this.undo(e.removeClassTemp(element, klass));
|
6242
|
+
}
|
6243
|
+
setStyle(...args) {
|
6244
|
+
let [element, styles] = this._parseMutatorArgs(args, 'val', 'val');
|
6245
|
+
this.undo(e.setStyleTemp(element, styles));
|
6246
|
+
}
|
6247
|
+
disable(...args) {
|
6248
|
+
let [element] = this._parseMutatorArgs(args, 'val');
|
6249
|
+
this.undo(up.form.disable(element));
|
6250
|
+
}
|
6251
|
+
insert(...args) {
|
6252
|
+
let [reference, position = 'beforeend', tempValue] = this._parseMutatorArgs(args, 'val', u.isAdjacentPosition, 'val');
|
6253
|
+
this.undo(up.fragment.insertTemp(reference, position, tempValue));
|
6254
|
+
}
|
6255
|
+
show(...args) {
|
6256
|
+
let [element] = this._parseMutatorArgs(args, 'val');
|
6257
|
+
this.undo(e.showTemp(element));
|
6258
|
+
}
|
6259
|
+
hide(...args) {
|
6260
|
+
let [element] = this._parseMutatorArgs(args, 'val');
|
6261
|
+
this.undo(e.hideTemp(element));
|
6262
|
+
}
|
6263
|
+
hideContent(...args) {
|
6264
|
+
let [parent] = this._parseMutatorArgs(args, 'val');
|
6265
|
+
let wrapper = e.wrapChildren(parent);
|
6266
|
+
e.hide(wrapper);
|
6267
|
+
this.undo(() => e.unwrap(wrapper));
|
6268
|
+
}
|
6269
|
+
showPlaceholder(...args) {
|
6270
|
+
let [parent, placeholderReference] = this._parseMutatorArgs(args, 'val', 'val');
|
6271
|
+
let placeholderNodes = up.fragment.provideNodes(placeholderReference, { origin: this.origin });
|
6272
|
+
up.puts('[up-placeholder]', 'Showing placeholder %o', placeholderReference);
|
6273
|
+
if (parent) {
|
6274
|
+
this.swapContent(parent, placeholderNodes);
|
6275
|
+
}
|
6276
|
+
else if (this.layer === 'new') {
|
6277
|
+
this.openLayer(placeholderNodes, { closeAnimation: false });
|
6278
|
+
this.renderOptions.openAnimation = false;
|
6279
|
+
}
|
6280
|
+
}
|
6281
|
+
swapContent(...args) {
|
6282
|
+
let [parent, newContent] = this._parseMutatorArgs(args, 'val', 'val');
|
6283
|
+
this.hideContent(parent);
|
6284
|
+
this.insert(parent, newContent);
|
6285
|
+
}
|
6286
|
+
openLayer(content, options = {}) {
|
6287
|
+
let undoDismissValue = ':undo-preview';
|
6288
|
+
let onDismiss = ({ value }) => {
|
6289
|
+
if (value !== undoDismissValue)
|
6290
|
+
this.request.abort({ reason: 'Preview overlay dismissed' });
|
6291
|
+
};
|
6292
|
+
up.layer.open(Object.assign(Object.assign(Object.assign({}, u.pick(this.renderOptions, [...up.Layer.Overlay.VISUAL_KEYS, 'target'])), options), { content, abort: false, onDismiss }));
|
6293
|
+
let overlay = up.layer.front;
|
6294
|
+
this.undo(() => overlay.dismiss(undoDismissValue, { preventable: false }));
|
6295
|
+
return overlay;
|
6296
|
+
}
|
6297
|
+
_parseMutatorArgs(args, ...specs) {
|
6298
|
+
let [element, ...rest] = u.args(args, ...specs);
|
6299
|
+
element = up.fragment.get(element, { layer: this.layer, origin: this.origin }) || this.fragment;
|
6300
|
+
return [element, ...rest];
|
6301
|
+
}
|
6302
|
+
};
|
6303
|
+
|
6304
|
+
|
5972
6305
|
/***/ }),
|
5973
6306
|
/* 66 */
|
5974
6307
|
/***/ (() => {
|
@@ -5981,7 +6314,7 @@ up.ProgressBar = class ProgressBar {
|
|
5981
6314
|
this._element = e.affix(document.body, 'up-progress-bar');
|
5982
6315
|
this._element.style.transition = `width ${TRANSITION_DELAY}ms ease-out`;
|
5983
6316
|
this._moveTo(0);
|
5984
|
-
|
6317
|
+
e.paint(this._element);
|
5985
6318
|
this._width = 31;
|
5986
6319
|
this._nextStep();
|
5987
6320
|
}
|
@@ -6025,21 +6358,22 @@ up.ProgressBar = class ProgressBar {
|
|
6025
6358
|
|
6026
6359
|
const u = up.util;
|
6027
6360
|
up.RenderOptions = (function () {
|
6028
|
-
const
|
6029
|
-
|
6030
|
-
|
6031
|
-
|
6032
|
-
|
6033
|
-
focus: 'keep',
|
6034
|
-
abort: 'target',
|
6035
|
-
failOptions: true,
|
6361
|
+
const NO_PREVIEWS = {
|
6362
|
+
preview: false,
|
6363
|
+
disable: false,
|
6364
|
+
placeholder: false,
|
6365
|
+
feedback: false,
|
6036
6366
|
};
|
6037
|
-
const
|
6038
|
-
|
6367
|
+
const NO_INPUT_INTERFERENCE = {
|
6368
|
+
scroll: false,
|
6369
|
+
focus: 'keep',
|
6039
6370
|
confirm: false,
|
6040
|
-
|
6041
|
-
|
6042
|
-
|
6371
|
+
};
|
6372
|
+
const NO_MOTION = {
|
6373
|
+
transition: false,
|
6374
|
+
animation: false,
|
6375
|
+
openAnimation: false,
|
6376
|
+
closeAnimation: false,
|
6043
6377
|
};
|
6044
6378
|
const PREFLIGHT_KEYS = [
|
6045
6379
|
'url',
|
@@ -6053,9 +6387,13 @@ up.RenderOptions = (function () {
|
|
6053
6387
|
'abortable',
|
6054
6388
|
'confirm',
|
6055
6389
|
'feedback',
|
6390
|
+
'disable',
|
6391
|
+
'placeholder',
|
6392
|
+
'preview',
|
6056
6393
|
'origin',
|
6057
6394
|
'originLayer',
|
6058
6395
|
'baseLayer',
|
6396
|
+
'navigate',
|
6059
6397
|
'fail',
|
6060
6398
|
'onError',
|
6061
6399
|
];
|
@@ -6065,8 +6403,6 @@ up.RenderOptions = (function () {
|
|
6065
6403
|
'history',
|
6066
6404
|
'source',
|
6067
6405
|
'saveScroll',
|
6068
|
-
'navigate',
|
6069
|
-
'baseLayer',
|
6070
6406
|
]);
|
6071
6407
|
const CONTENT_KEYS = [
|
6072
6408
|
'url',
|
@@ -6090,16 +6426,18 @@ up.RenderOptions = (function () {
|
|
6090
6426
|
return { url: u.normalizeURL(url) };
|
6091
6427
|
}
|
6092
6428
|
}
|
6093
|
-
function
|
6094
|
-
|
6095
|
-
|
6096
|
-
|
6429
|
+
function removeUsePrefix(options) {
|
6430
|
+
u.renameKey(options, 'useData', 'data');
|
6431
|
+
u.renameKey(options, 'useHungry', 'hungry');
|
6432
|
+
u.renameKey(options, 'useKeep', 'keep');
|
6097
6433
|
}
|
6098
6434
|
function preprocess(options) {
|
6099
6435
|
var _a, _b;
|
6100
6436
|
(_b = (_a = up.migrate).preprocessRenderOptions) === null || _b === void 0 ? void 0 : _b.call(_a, options);
|
6101
|
-
|
6102
|
-
|
6437
|
+
up.layer.normalizeOptions(options);
|
6438
|
+
removeUsePrefix(options);
|
6439
|
+
const defaults = u.merge(up.fragment.config.renderOptions, navigateDefaults(options));
|
6440
|
+
return u.merge(u.omit(defaults, LATE_KEYS), { defaults }, { inputDevice: up.event.inputDevice }, options, normalizeURL(options), rememberOriginLayer(options));
|
6103
6441
|
}
|
6104
6442
|
function rememberOriginLayer({ origin, originLayer }) {
|
6105
6443
|
if (origin && !originLayer) {
|
@@ -6134,12 +6472,11 @@ up.RenderOptions = (function () {
|
|
6134
6472
|
}
|
6135
6473
|
function deriveFailOptions(preprocessedOptions) {
|
6136
6474
|
let overrides = failOverrides(preprocessedOptions);
|
6137
|
-
let layers = rememberOriginLayer(overrides);
|
6138
6475
|
if (preprocessedOptions.failOptions) {
|
6139
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(
|
6476
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, preprocessedOptions.defaults), u.pick(preprocessedOptions, SHARED_KEYS)), overrides), { failPrefixForced: true });
|
6140
6477
|
}
|
6141
6478
|
else {
|
6142
|
-
return Object.assign(Object.assign(
|
6479
|
+
return Object.assign(Object.assign({}, preprocessedOptions), overrides);
|
6143
6480
|
}
|
6144
6481
|
}
|
6145
6482
|
return {
|
@@ -6147,6 +6484,9 @@ up.RenderOptions = (function () {
|
|
6147
6484
|
finalize,
|
6148
6485
|
assertContentGiven,
|
6149
6486
|
deriveFailOptions,
|
6487
|
+
NO_PREVIEWS,
|
6488
|
+
NO_MOTION,
|
6489
|
+
NO_INPUT_INTERFERENCE,
|
6150
6490
|
};
|
6151
6491
|
})();
|
6152
6492
|
|
@@ -6238,7 +6578,6 @@ up.Request = (_a = class Request extends up.Record {
|
|
6238
6578
|
'failMode',
|
6239
6579
|
'failContext',
|
6240
6580
|
'origin',
|
6241
|
-
'fragments',
|
6242
6581
|
'builtAt',
|
6243
6582
|
'wrapMethod',
|
6244
6583
|
'contentType',
|
@@ -6246,7 +6585,8 @@ up.Request = (_a = class Request extends up.Record {
|
|
6246
6585
|
'onLoading',
|
6247
6586
|
'fail',
|
6248
6587
|
'abortable',
|
6249
|
-
'
|
6588
|
+
'lateDelay',
|
6589
|
+
'previews',
|
6250
6590
|
];
|
6251
6591
|
}
|
6252
6592
|
defaults() {
|
@@ -6256,10 +6596,11 @@ up.Request = (_a = class Request extends up.Record {
|
|
6256
6596
|
headers: {},
|
6257
6597
|
timeout: up.network.config.timeout,
|
6258
6598
|
builtAt: new Date(),
|
6599
|
+
previews: [],
|
6259
6600
|
};
|
6260
6601
|
}
|
6261
6602
|
constructor(options) {
|
6262
|
-
var _b, _c
|
6603
|
+
var _b, _c;
|
6263
6604
|
super(options);
|
6264
6605
|
this.params = new up.Params(this.params);
|
6265
6606
|
if (this.wrapMethod == null) {
|
@@ -6275,27 +6616,39 @@ up.Request = (_a = class Request extends up.Record {
|
|
6275
6616
|
this.mode || (this.mode = this.layer.mode);
|
6276
6617
|
this.failMode || (this.failMode = (_c = this.failLayer) === null || _c === void 0 ? void 0 : _c.mode);
|
6277
6618
|
}
|
6278
|
-
this.
|
6279
|
-
|
6619
|
+
this.bindLayer = options.bindLayer || this.layer;
|
6620
|
+
this._fragments = options.fragments;
|
6621
|
+
this._bindFragments = options.bindFragments;
|
6622
|
+
this._deferred = u.newDeferred();
|
6280
6623
|
this._setAutoHeaders();
|
6281
6624
|
}
|
6625
|
+
get effectiveLateTime() {
|
6626
|
+
var _b;
|
6627
|
+
if (this.background) {
|
6628
|
+
return false;
|
6629
|
+
}
|
6630
|
+
else {
|
6631
|
+
return (_b = this.lateDelay) !== null && _b !== void 0 ? _b : u.evalOption(up.network.config.lateDelay, this);
|
6632
|
+
}
|
6633
|
+
}
|
6634
|
+
isTimed() {
|
6635
|
+
return u.isNumber(this.effectiveLateTime);
|
6636
|
+
}
|
6282
6637
|
get xhr() {
|
6283
6638
|
var _b;
|
6284
6639
|
return (_b = this._xhr) !== null && _b !== void 0 ? _b : (this._xhr = new XMLHttpRequest());
|
6285
6640
|
}
|
6286
6641
|
get fragments() {
|
6287
|
-
|
6288
|
-
|
6289
|
-
|
6290
|
-
|
6291
|
-
|
6292
|
-
|
6293
|
-
|
6294
|
-
return u.compact(u.map(selectors, (selector) => up.fragment.get(selector, lookupOpts)));
|
6295
|
-
}
|
6642
|
+
return (this._fragments || (this._fragments = this._findFragments()));
|
6643
|
+
}
|
6644
|
+
_findFragments() {
|
6645
|
+
let steps = up.fragment.parseTargetSteps(this.target);
|
6646
|
+
let lookupOpts = { origin: this.origin, layer: this.layer };
|
6647
|
+
let matches = u.map(steps, (step) => up.fragment.get(step.selector, lookupOpts));
|
6648
|
+
return u.compact(matches);
|
6296
6649
|
}
|
6297
|
-
|
6298
|
-
this.
|
6650
|
+
get bindFragments() {
|
6651
|
+
return this._bindFragments || this.fragments;
|
6299
6652
|
}
|
6300
6653
|
get fragment() {
|
6301
6654
|
var _b;
|
@@ -6311,8 +6664,10 @@ up.Request = (_a = class Request extends up.Record {
|
|
6311
6664
|
u.task(() => {
|
6312
6665
|
this.layer = undefined;
|
6313
6666
|
this.failLayer = undefined;
|
6667
|
+
this._bindLayer = undefined;
|
6314
6668
|
this.origin = undefined;
|
6315
|
-
this.
|
6669
|
+
this._fragments = undefined;
|
6670
|
+
this._bindFragments = undefined;
|
6316
6671
|
});
|
6317
6672
|
}
|
6318
6673
|
_extractHashFromURL() {
|
@@ -6366,6 +6721,11 @@ up.Request = (_a = class Request extends up.Record {
|
|
6366
6721
|
this.abort({ reason: 'Prevented by event listener' });
|
6367
6722
|
}
|
6368
6723
|
}
|
6724
|
+
runPreviews(renderOptions) {
|
6725
|
+
if (!this.ended && !this.fromCache) {
|
6726
|
+
this._revertPreviews = up.status.runPreviews(this, renderOptions);
|
6727
|
+
}
|
6728
|
+
}
|
6369
6729
|
_emitLoad() {
|
6370
6730
|
let event = this.emit('up:request:load', { log: ['Loading %s', this.description] });
|
6371
6731
|
return !event.defaultPrevented;
|
@@ -6395,35 +6755,47 @@ up.Request = (_a = class Request extends up.Record {
|
|
6395
6755
|
}
|
6396
6756
|
}
|
6397
6757
|
_setAbortedState(reason) {
|
6398
|
-
if (this.
|
6758
|
+
if (this.ended)
|
6399
6759
|
return;
|
6400
6760
|
let message = 'Aborted request to ' + this.description + (reason ? ': ' + reason : '');
|
6401
6761
|
this.state = 'aborted';
|
6402
|
-
this.
|
6762
|
+
this._reject(new up.Aborted(message));
|
6403
6763
|
this.emit('up:request:aborted', { log: message });
|
6404
6764
|
return true;
|
6405
6765
|
}
|
6406
6766
|
_setOfflineState(reason) {
|
6407
|
-
if (this.
|
6767
|
+
if (this.ended)
|
6408
6768
|
return;
|
6409
6769
|
let message = 'Cannot load request to ' + this.description + (reason ? ': ' + reason : '');
|
6410
6770
|
this.state = 'offline';
|
6411
6771
|
this.emit('up:request:offline', { log: message });
|
6412
|
-
this.
|
6772
|
+
this._reject(new up.Offline(message));
|
6413
6773
|
}
|
6414
6774
|
respondWith(response) {
|
6415
6775
|
this.response = response;
|
6416
|
-
if (this.
|
6776
|
+
if (this.ended)
|
6417
6777
|
return;
|
6418
6778
|
this.state = 'loaded';
|
6419
6779
|
if (response.ok) {
|
6420
|
-
this.
|
6780
|
+
this._resolve(response);
|
6421
6781
|
}
|
6422
6782
|
else {
|
6423
|
-
this.
|
6783
|
+
this._reject(response);
|
6424
6784
|
}
|
6425
6785
|
}
|
6426
|
-
|
6786
|
+
_resolve(response) {
|
6787
|
+
this._onSettle();
|
6788
|
+
this._deferred.resolve(response);
|
6789
|
+
}
|
6790
|
+
_reject(responseOrError) {
|
6791
|
+
this._onSettle();
|
6792
|
+
this._deferred.reject(responseOrError);
|
6793
|
+
}
|
6794
|
+
_onSettle() {
|
6795
|
+
var _b;
|
6796
|
+
(_b = this._revertPreviews) === null || _b === void 0 ? void 0 : _b.call(this);
|
6797
|
+
}
|
6798
|
+
get ended() {
|
6427
6799
|
return (this.state !== 'new') && (this.state !== 'loading') && (this.state !== 'tracking');
|
6428
6800
|
}
|
6429
6801
|
csrfHeader() {
|
@@ -6473,7 +6845,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6473
6845
|
}
|
6474
6846
|
_buildEventEmitter(args) {
|
6475
6847
|
return up.EventEmitter.fromEmitArgs(args, {
|
6476
|
-
layer: this.
|
6848
|
+
layer: this.bindLayer,
|
6477
6849
|
request: this,
|
6478
6850
|
origin: this.origin
|
6479
6851
|
});
|
@@ -6487,12 +6859,15 @@ up.Request = (_a = class Request extends up.Record {
|
|
6487
6859
|
get description() {
|
6488
6860
|
return this.method + ' ' + this.url;
|
6489
6861
|
}
|
6490
|
-
|
6491
|
-
|
6492
|
-
return u.some(this.
|
6493
|
-
return u.some(
|
6862
|
+
isBoundToSubtrees(subtreeRoots) {
|
6863
|
+
subtreeRoots = u.wrapList(subtreeRoots);
|
6864
|
+
return u.some(this.bindFragments, function (fragment) {
|
6865
|
+
return u.some(subtreeRoots, (subtreeElement) => subtreeElement.contains(fragment));
|
6494
6866
|
});
|
6495
6867
|
}
|
6868
|
+
isBoundToLayers(layers) {
|
6869
|
+
return u.contains(layers, this.bindLayer);
|
6870
|
+
}
|
6496
6871
|
get age() {
|
6497
6872
|
return new Date() - this.builtAt;
|
6498
6873
|
}
|
@@ -6555,7 +6930,7 @@ up.Request = (_a = class Request extends up.Record {
|
|
6555
6930
|
}
|
6556
6931
|
},
|
6557
6932
|
(() => {
|
6558
|
-
u.
|
6933
|
+
u.delegatePromise(_a.prototype, '_deferred');
|
6559
6934
|
})(),
|
6560
6935
|
_a);
|
6561
6936
|
|
@@ -6605,8 +6980,8 @@ class Route {
|
|
6605
6980
|
return true;
|
6606
6981
|
if (!newValue)
|
6607
6982
|
return false;
|
6608
|
-
let cachedTokens =
|
6609
|
-
let newTokens =
|
6983
|
+
let cachedTokens = up.fragment.splitTarget(cachedValue);
|
6984
|
+
let newTokens = up.fragment.splitTarget(newValue);
|
6610
6985
|
return u.containsAll(cachedTokens, newTokens);
|
6611
6986
|
}
|
6612
6987
|
else {
|
@@ -6667,7 +7042,13 @@ up.Request.Cache = class Cache {
|
|
6667
7042
|
return __awaiter(this, void 0, void 0, function* () {
|
6668
7043
|
newRequest.trackedRequest = existingRequest;
|
6669
7044
|
newRequest.state = 'tracking';
|
6670
|
-
let value
|
7045
|
+
let value;
|
7046
|
+
if (existingRequest.ended && existingRequest.response) {
|
7047
|
+
value = existingRequest.response;
|
7048
|
+
}
|
7049
|
+
else {
|
7050
|
+
value = yield u.always(existingRequest);
|
7051
|
+
}
|
6671
7052
|
if (value instanceof up.Response) {
|
6672
7053
|
if (options.force || existingRequest.cacheRoute.satisfies(existingRequest, newRequest)) {
|
6673
7054
|
newRequest.fromCache = true;
|
@@ -6683,7 +7064,7 @@ up.Request.Cache = class Cache {
|
|
6683
7064
|
}
|
6684
7065
|
else {
|
6685
7066
|
newRequest.state = existingRequest.state;
|
6686
|
-
newRequest.
|
7067
|
+
newRequest._reject(value);
|
6687
7068
|
}
|
6688
7069
|
});
|
6689
7070
|
}
|
@@ -6766,8 +7147,10 @@ up.Request.Queue = class Queue {
|
|
6766
7147
|
}
|
6767
7148
|
}
|
6768
7149
|
_scheduleSlowTimer(request) {
|
6769
|
-
|
6770
|
-
|
7150
|
+
if (!request.isTimed())
|
7151
|
+
return;
|
7152
|
+
let timeUntilLate = Math.max(request.effectiveLateTime - request.age);
|
7153
|
+
u.timer(timeUntilLate, () => this._checkForLate());
|
6771
7154
|
}
|
6772
7155
|
_getMaxConcurrency() {
|
6773
7156
|
return u.evalOption(up.network.config.concurrency);
|
@@ -6797,8 +7180,8 @@ up.Request.Queue = class Queue {
|
|
6797
7180
|
if ((responseOrError instanceof up.Response) && responseOrError.ok) {
|
6798
7181
|
up.network.registerAliasForRedirect(request, responseOrError);
|
6799
7182
|
}
|
6800
|
-
this._checkLate();
|
6801
7183
|
queueMicrotask(() => this._poke());
|
7184
|
+
u.task(() => this._checkForRecover());
|
6802
7185
|
}
|
6803
7186
|
_poke() {
|
6804
7187
|
let request;
|
@@ -6807,10 +7190,7 @@ up.Request.Queue = class Queue {
|
|
6807
7190
|
}
|
6808
7191
|
}
|
6809
7192
|
abort(...args) {
|
6810
|
-
|
6811
|
-
let options = u.extractOptions(args);
|
6812
|
-
let { except, reason, logOnce } = options;
|
6813
|
-
let conditions = (_a = args[0]) !== null && _a !== void 0 ? _a : true;
|
7193
|
+
let [conditions = true, { except, reason, logOnce }] = u.args(args, 'val', 'options');
|
6814
7194
|
let tester = up.Request.tester(conditions, { except });
|
6815
7195
|
for (let list of [this._currentRequests, this._queuedRequests]) {
|
6816
7196
|
const abortableRequests = u.filter(list, tester);
|
@@ -6824,22 +7204,25 @@ up.Request.Queue = class Queue {
|
|
6824
7204
|
}
|
6825
7205
|
}
|
6826
7206
|
}
|
6827
|
-
|
6828
|
-
|
6829
|
-
|
6830
|
-
|
6831
|
-
|
6832
|
-
|
6833
|
-
|
6834
|
-
|
6835
|
-
|
6836
|
-
}
|
7207
|
+
_checkForLate() {
|
7208
|
+
if (!this._emittedLate && this._hasLateTimedRequests()) {
|
7209
|
+
this._emittedLate = true;
|
7210
|
+
up.emit('up:network:late', { log: 'Server is slow to respond' });
|
7211
|
+
}
|
7212
|
+
}
|
7213
|
+
_checkForRecover() {
|
7214
|
+
if (this._emittedLate && !this._timedRequests.length) {
|
7215
|
+
this._emittedLate = false;
|
7216
|
+
up.emit('up:network:recover', { log: 'Slow requests were loaded' });
|
6837
7217
|
}
|
6838
7218
|
}
|
6839
|
-
|
6840
|
-
|
7219
|
+
get _timedRequests() {
|
7220
|
+
return this.allRequests.filter((request) => request.isTimed());
|
7221
|
+
}
|
7222
|
+
_hasLateTimedRequests() {
|
6841
7223
|
const timerTolerance = 1;
|
6842
|
-
|
7224
|
+
const isLate = (request) => request.age >= (request.effectiveLateTime - timerTolerance);
|
7225
|
+
return u.some(this._timedRequests, isLate);
|
6843
7226
|
}
|
6844
7227
|
};
|
6845
7228
|
|
@@ -7000,7 +7383,7 @@ up.Response = class Response extends up.Record {
|
|
7000
7383
|
}
|
7001
7384
|
get varyHeaderNames() {
|
7002
7385
|
let varyHeaderValue = this.header('Vary');
|
7003
|
-
return u.
|
7386
|
+
return u.getSimpleTokens(varyHeaderValue, { separator: ',' });
|
7004
7387
|
}
|
7005
7388
|
get contentType() {
|
7006
7389
|
return this.header('Content-Type');
|
@@ -7043,15 +7426,15 @@ const u = up.util;
|
|
7043
7426
|
const e = up.element;
|
7044
7427
|
const FULL_DOCUMENT_PATTERN = /^\s*<(html|!DOCTYPE)\b/i;
|
7045
7428
|
up.ResponseDoc = (_a = class ResponseDoc {
|
7046
|
-
constructor({ document, fragment, content, target, origin, cspNonces, match }) {
|
7429
|
+
constructor({ document, fragment, content, target, origin, data, cspNonces, match }) {
|
7047
7430
|
if (document) {
|
7048
|
-
this._parseDocument(document);
|
7431
|
+
this._parseDocument(document, origin, data);
|
7049
7432
|
}
|
7050
7433
|
else if (fragment) {
|
7051
|
-
this._parseFragment(fragment);
|
7434
|
+
this._parseFragment(fragment, origin, data);
|
7052
7435
|
}
|
7053
7436
|
else {
|
7054
|
-
this._parseContent(content || '', target);
|
7437
|
+
this._parseContent(content || '', origin, target, data);
|
7055
7438
|
}
|
7056
7439
|
this._cspNonces = cspNonces;
|
7057
7440
|
if (origin) {
|
@@ -7062,46 +7445,49 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
7062
7445
|
}
|
7063
7446
|
this._match = match;
|
7064
7447
|
}
|
7065
|
-
_parseDocument(value) {
|
7448
|
+
_parseDocument(value, origin, data) {
|
7066
7449
|
if (value instanceof Document) {
|
7067
7450
|
this._document = value;
|
7068
7451
|
this._isFullDocument = true;
|
7069
7452
|
}
|
7070
7453
|
else if (u.isString(value)) {
|
7071
|
-
this._document = e.createBrokenDocumentFromHTML(value);
|
7072
7454
|
this._isFullDocument = FULL_DOCUMENT_PATTERN.test(value);
|
7073
|
-
|
7455
|
+
let htmlParser = (html) => [e.createBrokenDocumentFromHTML(html)];
|
7456
|
+
let nodes = up.fragment.provideNodes(value, { origin, data, htmlParser });
|
7457
|
+
if (nodes[0] instanceof Document) {
|
7458
|
+
this._document = nodes[0];
|
7459
|
+
}
|
7460
|
+
else {
|
7461
|
+
this._document = this._buildFauxDocument(nodes);
|
7462
|
+
}
|
7074
7463
|
}
|
7075
7464
|
else {
|
7076
7465
|
this._document = this._buildFauxDocument(value);
|
7077
|
-
this._isFullDocument = value.matches('html');
|
7078
7466
|
}
|
7079
7467
|
}
|
7080
|
-
|
7081
|
-
|
7082
|
-
|
7468
|
+
_parseDocumentFromHTML(html) {
|
7469
|
+
return e.createBrokenDocumentFromHTML(html);
|
7470
|
+
}
|
7471
|
+
_parseFragment(value, origin, data) {
|
7472
|
+
let element = e.extractSingular(up.fragment.provideNodes(value, { origin, data }));
|
7473
|
+
this._document = this._buildFauxDocument(element);
|
7083
7474
|
}
|
7084
|
-
_parseContent(value, target) {
|
7475
|
+
_parseContent(value, origin, target, data) {
|
7085
7476
|
if (!target)
|
7086
7477
|
up.fail("must pass a { target } when passing { content }");
|
7087
7478
|
let simplifiedTarget = u.map(up.fragment.parseTargetSteps(target), 'selector').join();
|
7088
|
-
|
7089
|
-
|
7090
|
-
matchingElement.innerHTML = value;
|
7091
|
-
}
|
7092
|
-
else {
|
7093
|
-
matchingElement.appendChild(value);
|
7094
|
-
}
|
7479
|
+
let nodes = up.fragment.provideNodes(value, { origin, data });
|
7480
|
+
let matchingElement = e.createFromSelector(simplifiedTarget, { content: nodes });
|
7095
7481
|
this._document = this._buildFauxDocument(matchingElement);
|
7096
7482
|
}
|
7097
|
-
_buildFauxDocument(
|
7483
|
+
_buildFauxDocument(nodes) {
|
7484
|
+
nodes = u.wrapList(nodes);
|
7098
7485
|
let fauxDocument = document.createElement('up-document');
|
7099
|
-
fauxDocument.append(
|
7100
|
-
fauxDocument.documentElement = node;
|
7486
|
+
fauxDocument.append(...nodes);
|
7101
7487
|
return fauxDocument;
|
7102
7488
|
}
|
7103
7489
|
rootSelector() {
|
7104
|
-
return up.fragment.toTarget(this._document.
|
7490
|
+
return up.fragment.toTarget(this._document.children[0]);
|
7105
7491
|
}
|
7106
7492
|
get title() {
|
7107
7493
|
return this._fromHead(this._getTitleText);
|
@@ -7183,7 +7569,7 @@ up.ResponseDoc = (_a = class ResponseDoc {
|
|
7183
7569
|
}
|
7184
7570
|
finalizeElement(element) {
|
7185
7571
|
up.NonceableCallback.adoptNonces(element, this._cspNonces);
|
7186
|
-
if (this.
|
7572
|
+
if (this._document instanceof Document) {
|
7187
7573
|
let brokenElements = e.subtree(element, ':is(noscript,script,audio,video):not(.up-keeping, .up-keeping *)');
|
7188
7574
|
u.each(brokenElements, e.fixParserDamage);
|
7189
7575
|
}
|
@@ -7293,17 +7679,18 @@ up.RevealMotion = class RevealMotion {
|
|
7293
7679
|
/***/ (() => {
|
7294
7680
|
|
7295
7681
|
const u = up.util;
|
7296
|
-
const
|
7682
|
+
const e = up.element;
|
7297
7683
|
up.Selector = class Selector {
|
7298
7684
|
constructor(selector, elementOrDocument, options = {}) {
|
7299
7685
|
var _a;
|
7300
7686
|
this._filters = [];
|
7301
|
-
|
7687
|
+
let matchingInExternalDocument = elementOrDocument && !document.contains(elementOrDocument);
|
7688
|
+
if (!matchingInExternalDocument && !options.destroying) {
|
7302
7689
|
this._filters.push(up.fragment.isNotDestroying);
|
7303
7690
|
}
|
7304
|
-
|
7691
|
+
this._ignoreLayers = matchingInExternalDocument || options.layer === 'any' || up.layer.count === 1;
|
7305
7692
|
let expandTargetLayer;
|
7306
|
-
if (
|
7693
|
+
if (this._ignoreLayers) {
|
7307
7694
|
expandTargetLayer = up.layer.root;
|
7308
7695
|
}
|
7309
7696
|
else {
|
@@ -7314,44 +7701,45 @@ up.Selector = class Selector {
|
|
7314
7701
|
this._filters.push(match => u.some(this._layers, layer => layer.contains(match)));
|
7315
7702
|
expandTargetLayer = this._layers[0];
|
7316
7703
|
}
|
7317
|
-
|
7318
|
-
this._selectors = expandedTargets.map((target) => {
|
7319
|
-
if (!up.browser.canHasSelector()) {
|
7320
|
-
target = target.replace(CSS_HAS_SUFFIX_PATTERN, (match, descendantSelector) => {
|
7321
|
-
this._filters.push(element => element.querySelector(descendantSelector));
|
7322
|
-
return '';
|
7323
|
-
});
|
7324
|
-
}
|
7325
|
-
return target || '*';
|
7326
|
-
});
|
7704
|
+
this._selectors = up.fragment.expandTargets(selector, Object.assign(Object.assign({}, options), { layer: expandTargetLayer }));
|
7327
7705
|
this._unionSelector = this._selectors.join() || 'match-none';
|
7328
7706
|
}
|
7329
7707
|
matches(element) {
|
7330
|
-
return
|
7708
|
+
return e.elementLikeMatches(element, this._unionSelector) && this._passesFilter(element);
|
7331
7709
|
}
|
7332
7710
|
closest(element) {
|
7333
|
-
|
7334
|
-
|
7335
|
-
|
7711
|
+
return this._filterOne(element.closest(this._unionSelector));
|
7712
|
+
}
|
7713
|
+
descendants(root = document) {
|
7714
|
+
return this._filterMany(root.querySelectorAll(this._unionSelector));
|
7715
|
+
}
|
7716
|
+
firstDescendant(root) {
|
7717
|
+
if (this._ignoreLayers) {
|
7718
|
+
root || (root = document);
|
7719
|
+
return this._firstSelectorMatch((selector) => root.querySelectorAll(selector));
|
7336
7720
|
}
|
7337
|
-
else
|
7338
|
-
return this.
|
7721
|
+
else {
|
7722
|
+
return u.findResult(this._layers, (layer) => {
|
7723
|
+
return this._firstSelectorMatch((selector) => e.subtree(layer.element, selector));
|
7724
|
+
});
|
7339
7725
|
}
|
7340
7726
|
}
|
7727
|
+
subtree(root) {
|
7728
|
+
return this._filterMany(e.subtree(root, this._unionSelector));
|
7729
|
+
}
|
7730
|
+
_firstSelectorMatch(fn) {
|
7731
|
+
return u.findResult(this._selectors, (selector) => {
|
7732
|
+
return this._filterMany(fn(selector))[0];
|
7733
|
+
});
|
7734
|
+
}
|
7341
7735
|
_passesFilter(element) {
|
7342
|
-
return u.every(this._filters, filter => filter(element));
|
7736
|
+
return element && u.every(this._filters, filter => filter(element));
|
7343
7737
|
}
|
7344
|
-
|
7345
|
-
|
7346
|
-
return u.filter(results, element => this._passesFilter(element));
|
7738
|
+
_filterOne(element) {
|
7739
|
+
return u.presence(element, this._passesFilter.bind(this));
|
7347
7740
|
}
|
7348
|
-
|
7349
|
-
|
7350
|
-
if (!(root instanceof Document) && this.matches(root)) {
|
7351
|
-
results.push(root);
|
7352
|
-
}
|
7353
|
-
results.push(...this.descendants(root));
|
7354
|
-
return results;
|
7741
|
+
_filterMany(elements) {
|
7742
|
+
return u.filter(elements, this._passesFilter.bind(this));
|
7355
7743
|
}
|
7356
7744
|
};
|
7357
7745
|
|
@@ -7487,7 +7875,7 @@ up.URLPattern = class URLPattern {
|
|
7487
7875
|
this._groups = [];
|
7488
7876
|
const positiveList = [];
|
7489
7877
|
const negativeList = [];
|
7490
|
-
for (let pattern of u.
|
7878
|
+
for (let pattern of u.getSimpleTokens(fullPattern)) {
|
7491
7879
|
if (pattern[0] === '-') {
|
7492
7880
|
negativeList.push(pattern.substring(1));
|
7493
7881
|
}
|
@@ -7611,7 +7999,7 @@ up.framework = (function () {
|
|
7611
7999
|
return !supportIssue();
|
7612
8000
|
}
|
7613
8001
|
function supportIssue() {
|
7614
|
-
for (let feature of ['
|
8002
|
+
for (let feature of ['Promise', 'DOMParser', 'FormData', 'reportError']) {
|
7615
8003
|
if (!window[feature]) {
|
7616
8004
|
return `Browser doesn't support the ${feature} API`;
|
7617
8005
|
}
|
@@ -7619,6 +8007,11 @@ up.framework = (function () {
|
|
7619
8007
|
if (document.compatMode === 'BackCompat') {
|
7620
8008
|
return 'Browser is in quirks mode (missing DOCTYPE?)';
|
7621
8009
|
}
|
8010
|
+
for (let selector of [':is(*)', ':has(*)']) {
|
8011
|
+
if (!CSS.supports(`selector(${selector})`)) {
|
8012
|
+
return `Browser doesn't support the ${selector} selector`;
|
8013
|
+
}
|
8014
|
+
}
|
7622
8015
|
}
|
7623
8016
|
return {
|
7624
8017
|
onEvaled,
|
@@ -7788,23 +8181,23 @@ up.protocol = (function () {
|
|
7788
8181
|
return extractHeader(xhr, 'expireCache') || ((_b = (_a = up.migrate).clearCacheFromXHR) === null || _b === void 0 ? void 0 : _b.call(_a, xhr));
|
7789
8182
|
}
|
7790
8183
|
function contextFromXHR(xhr) {
|
7791
|
-
return extractHeader(xhr, 'context',
|
8184
|
+
return extractHeader(xhr, 'context', u.parseRelaxedJSON);
|
7792
8185
|
}
|
7793
8186
|
function methodFromXHR(xhr) {
|
7794
8187
|
return extractHeader(xhr, 'method', u.normalizeMethod);
|
7795
8188
|
}
|
7796
8189
|
function titleFromXHR(xhr) {
|
7797
8190
|
var _a, _b, _c;
|
7798
|
-
return (_c = (_b = (_a = up.migrate).titleFromXHR) === null || _b === void 0 ? void 0 : _b.call(_a, xhr)) !== null && _c !== void 0 ? _c : extractHeader(xhr, 'title',
|
8191
|
+
return (_c = (_b = (_a = up.migrate).titleFromXHR) === null || _b === void 0 ? void 0 : _b.call(_a, xhr)) !== null && _c !== void 0 ? _c : extractHeader(xhr, 'title', u.parseRelaxedJSON);
|
7799
8192
|
}
|
7800
8193
|
function eventPlansFromXHR(xhr) {
|
7801
|
-
return extractHeader(xhr, 'events',
|
8194
|
+
return extractHeader(xhr, 'events', u.parseRelaxedJSON);
|
7802
8195
|
}
|
7803
8196
|
function acceptLayerFromXHR(xhr) {
|
7804
|
-
return extractHeader(xhr, 'acceptLayer',
|
8197
|
+
return extractHeader(xhr, 'acceptLayer', u.parseRelaxedJSON);
|
7805
8198
|
}
|
7806
8199
|
function dismissLayerFromXHR(xhr) {
|
7807
|
-
return extractHeader(xhr, 'dismissLayer',
|
8200
|
+
return extractHeader(xhr, 'dismissLayer', u.parseRelaxedJSON);
|
7808
8201
|
}
|
7809
8202
|
const initialRequestMethod = u.memoize(function () {
|
7810
8203
|
return u.normalizeMethod(up.browser.popCookie('_up_method'));
|
@@ -7975,6 +8368,9 @@ up.script = (function () {
|
|
7975
8368
|
],
|
7976
8369
|
nonceableAttributes: [
|
7977
8370
|
'up-watch',
|
8371
|
+
'up-on-keep',
|
8372
|
+
'up-on-hungry',
|
8373
|
+
'up-on-opened',
|
7978
8374
|
'up-on-accepted',
|
7979
8375
|
'up-on-dismissed',
|
7980
8376
|
'up-on-loaded',
|
@@ -7982,9 +8378,13 @@ up.script = (function () {
|
|
7982
8378
|
'up-on-finished',
|
7983
8379
|
'up-on-error',
|
7984
8380
|
'up-on-offline',
|
8381
|
+
'up-placeholder',
|
7985
8382
|
],
|
7986
8383
|
scriptSelectors: [
|
7987
|
-
'script'
|
8384
|
+
'script:not([type])',
|
8385
|
+
'script[type="text/javascript"]',
|
8386
|
+
'script[type="module"]',
|
8387
|
+
'script[type="importmap"]',
|
7988
8388
|
],
|
7989
8389
|
noScriptSelectors: [
|
7990
8390
|
'script[type="application/ld+json"]'
|
@@ -8015,10 +8415,13 @@ up.script = (function () {
|
|
8015
8415
|
function registerAttrCompiler(...args) {
|
8016
8416
|
let [attr, options, valueCallback] = parseProcessorArgs(args);
|
8017
8417
|
let selector = `[${attr}]`;
|
8418
|
+
let { defaultValue } = options;
|
8018
8419
|
let callback = (element) => {
|
8019
|
-
let value = e.booleanOrStringAttr(element, attr
|
8020
|
-
if (
|
8420
|
+
let value = e.booleanOrStringAttr(element, attr);
|
8421
|
+
if (value === false)
|
8021
8422
|
return;
|
8423
|
+
if (u.isDefined(defaultValue) && value === true)
|
8424
|
+
value = defaultValue;
|
8022
8425
|
return valueCallback(element, value);
|
8023
8426
|
};
|
8024
8427
|
registerProcessor([selector, options, callback]);
|
@@ -8045,11 +8448,7 @@ up.script = (function () {
|
|
8045
8448
|
}
|
8046
8449
|
}
|
8047
8450
|
const parseProcessorArgs = function (args) {
|
8048
|
-
|
8049
|
-
const selector = args.shift();
|
8050
|
-
const callback = args.pop();
|
8051
|
-
const options = Object.assign(Object.assign({}, defaults), u.extractOptions(args));
|
8052
|
-
return [selector, options, callback];
|
8451
|
+
return u.args(args, 'val', 'options', 'callback');
|
8053
8452
|
};
|
8054
8453
|
function buildProcessor(args, overrides) {
|
8055
8454
|
let [selector, options, callback] = parseProcessorArgs(args);
|
@@ -8087,18 +8486,16 @@ up.script = (function () {
|
|
8087
8486
|
pass.run();
|
8088
8487
|
}
|
8089
8488
|
function registerDestructor(element, destructor) {
|
8090
|
-
let
|
8091
|
-
if (!
|
8092
|
-
|
8093
|
-
|
8094
|
-
|
8095
|
-
|
8096
|
-
|
8097
|
-
|
8098
|
-
|
8099
|
-
|
8100
|
-
destructors.push(destructor);
|
8101
|
-
}
|
8489
|
+
let fns = u.scanFunctions(destructor);
|
8490
|
+
if (!fns.length)
|
8491
|
+
return;
|
8492
|
+
let registry = (element.upDestructors || (element.upDestructors = buildDestructorRegistry(element)));
|
8493
|
+
registry.guard(fns);
|
8494
|
+
}
|
8495
|
+
function buildDestructorRegistry(element) {
|
8496
|
+
let registry = u.cleaner();
|
8497
|
+
registry(e.addClassTemp(element, 'up-can-clean'));
|
8498
|
+
return registry;
|
8102
8499
|
}
|
8103
8500
|
function hello(element, options = {}) {
|
8104
8501
|
element = up.fragment.get(element, options);
|
@@ -8115,18 +8512,12 @@ up.script = (function () {
|
|
8115
8512
|
return element.upData || (element.upData = buildData(element));
|
8116
8513
|
}
|
8117
8514
|
function buildData(element) {
|
8118
|
-
|
8119
|
-
|
8120
|
-
|
8121
|
-
|
8122
|
-
let parsedJSON;
|
8123
|
-
if (rawJSON) {
|
8124
|
-
parsedJSON = JSON.parse(rawJSON);
|
8125
|
-
if (!u.isOptions(parsedJSON)) {
|
8126
|
-
return parsedJSON;
|
8127
|
-
}
|
8515
|
+
var _a;
|
8516
|
+
let parsedJSON = (_a = e.jsonAttr(element, 'up-data')) !== null && _a !== void 0 ? _a : {};
|
8517
|
+
if (!u.isOptions(parsedJSON)) {
|
8518
|
+
return parsedJSON;
|
8128
8519
|
}
|
8129
|
-
return Object.assign(Object.assign(Object.assign({}, element.dataset), parsedJSON), element.upCompileData);
|
8520
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, element.upTemplateData), element.dataset), parsedJSON), element.upCompileData);
|
8130
8521
|
}
|
8131
8522
|
function findAssets(head = document.head) {
|
8132
8523
|
return head.querySelectorAll(config.selector('assetSelectors'));
|
@@ -8146,6 +8537,9 @@ up.script = (function () {
|
|
8146
8537
|
let selector = config.selector('scriptSelectors');
|
8147
8538
|
u.each(e.subtree(root, selector), disableScript);
|
8148
8539
|
}
|
8540
|
+
function isScript(value) {
|
8541
|
+
return config.matches(value, 'scriptSelectors');
|
8542
|
+
}
|
8149
8543
|
function reset() {
|
8150
8544
|
registeredCompilers = u.filter(registeredCompilers, 'isDefault');
|
8151
8545
|
registeredMacros = u.filter(registeredMacros, 'isDefault');
|
@@ -8163,6 +8557,7 @@ up.script = (function () {
|
|
8163
8557
|
findAssets,
|
8164
8558
|
assertAssetsOK,
|
8165
8559
|
disableSubtree: disableScriptsInSubtree,
|
8560
|
+
isScript,
|
8166
8561
|
};
|
8167
8562
|
})();
|
8168
8563
|
up.compiler = up.script.compiler;
|
@@ -8312,7 +8707,7 @@ up.history = (function () {
|
|
8312
8707
|
}
|
8313
8708
|
}
|
8314
8709
|
function updateLang(newLang) {
|
8315
|
-
e.
|
8710
|
+
e.setAttrPresence(e.root, 'lang', newLang, !!newLang);
|
8316
8711
|
}
|
8317
8712
|
up.macro('[up-back]', function (link) {
|
8318
8713
|
if (previousLocation) {
|
@@ -8354,14 +8749,18 @@ up.fragment = (function () {
|
|
8354
8749
|
return tagName;
|
8355
8750
|
}
|
8356
8751
|
}
|
8752
|
+
const STRONG_TARGET_DERIVERS = [
|
8753
|
+
'[up-id]',
|
8754
|
+
'[id]',
|
8755
|
+
'html',
|
8756
|
+
'head',
|
8757
|
+
'body',
|
8758
|
+
];
|
8357
8759
|
const config = new up.Config(() => ({
|
8358
8760
|
badTargetClasses: [/^up-/],
|
8761
|
+
strongTargetDerivers: STRONG_TARGET_DERIVERS,
|
8359
8762
|
targetDerivers: [
|
8360
|
-
|
8361
|
-
'[id]',
|
8362
|
-
'html',
|
8363
|
-
'head',
|
8364
|
-
'body',
|
8763
|
+
...STRONG_TARGET_DERIVERS,
|
8365
8764
|
'main',
|
8366
8765
|
'[up-main]',
|
8367
8766
|
upTagName,
|
@@ -8379,10 +8778,19 @@ up.fragment = (function () {
|
|
8379
8778
|
'form',
|
8380
8779
|
],
|
8381
8780
|
verifyDerivedTarget: true,
|
8781
|
+
renderOptions: {
|
8782
|
+
hungry: true,
|
8783
|
+
keep: true,
|
8784
|
+
saveScroll: true,
|
8785
|
+
saveFocus: true,
|
8786
|
+
focus: 'keep',
|
8787
|
+
abort: 'target',
|
8788
|
+
failOptions: true,
|
8789
|
+
feedback: true,
|
8790
|
+
},
|
8382
8791
|
navigateOptions: {
|
8383
8792
|
cache: 'auto',
|
8384
8793
|
revalidate: 'auto',
|
8385
|
-
feedback: true,
|
8386
8794
|
fallback: true,
|
8387
8795
|
focus: 'auto',
|
8388
8796
|
scroll: 'auto',
|
@@ -8395,7 +8803,7 @@ up.fragment = (function () {
|
|
8395
8803
|
autoFocus: ['hash', 'autofocus', 'main-if-main', 'keep', 'target-if-lost'],
|
8396
8804
|
autoScroll: ['hash', 'layer-if-main'],
|
8397
8805
|
autoRevalidate: (response) => response.expired,
|
8398
|
-
skipResponse: defaultSkipResponse
|
8806
|
+
skipResponse: defaultSkipResponse,
|
8399
8807
|
}));
|
8400
8808
|
u.delegate(config, ['mainTargets'], () => up.layer.config.any);
|
8401
8809
|
function defaultSkipResponse({ response, expiredResponse }) {
|
@@ -8455,14 +8863,12 @@ up.fragment = (function () {
|
|
8455
8863
|
return fragment.isConnected && isNotDestroying(fragment);
|
8456
8864
|
}
|
8457
8865
|
function getSmart(...args) {
|
8458
|
-
|
8459
|
-
|
8460
|
-
const root = args[0];
|
8461
|
-
if (u.isElementish(selector)) {
|
8866
|
+
let [root, selector, options] = parseGetArgs(args);
|
8867
|
+
if (u.isElementLike(selector)) {
|
8462
8868
|
return e.get(selector);
|
8463
8869
|
}
|
8464
8870
|
if (root) {
|
8465
|
-
return
|
8871
|
+
return getFirstDescendant(root, selector, options);
|
8466
8872
|
}
|
8467
8873
|
return new up.FragmentFinder({
|
8468
8874
|
selector,
|
@@ -8471,13 +8877,16 @@ up.fragment = (function () {
|
|
8471
8877
|
match: options.match,
|
8472
8878
|
}).find();
|
8473
8879
|
}
|
8474
|
-
function
|
8475
|
-
|
8880
|
+
function getFirstDescendant(...args) {
|
8881
|
+
let [root, selectorString, options] = parseGetArgs(args);
|
8882
|
+
let selector = new up.Selector(selectorString, root, options);
|
8883
|
+
return selector.firstDescendant(root);
|
8884
|
+
}
|
8885
|
+
function parseGetArgs(args) {
|
8886
|
+
return u.args(args, 'val', 'val', 'options');
|
8476
8887
|
}
|
8477
8888
|
function getAll(...args) {
|
8478
|
-
|
8479
|
-
let selectorString = args.pop();
|
8480
|
-
const root = args[0];
|
8889
|
+
let [root, selectorString, options] = parseGetArgs(args);
|
8481
8890
|
if (u.isElement(selectorString)) {
|
8482
8891
|
return [selectorString];
|
8483
8892
|
}
|
@@ -8585,8 +8994,9 @@ up.fragment = (function () {
|
|
8585
8994
|
function cannotTarget(element) {
|
8586
8995
|
throw new up.CannotTarget(untargetableMessage(element));
|
8587
8996
|
}
|
8588
|
-
function tryToTarget(element, options) {
|
8589
|
-
|
8997
|
+
function tryToTarget(element, options = {}) {
|
8998
|
+
let derivers = options.strong ? config.strongTargetDerivers : config.targetDerivers;
|
8999
|
+
return u.findResult(derivers, function (deriver) {
|
8590
9000
|
let target = deriveTarget(element, deriver);
|
8591
9001
|
if (target && isGoodTarget(target, element, options)) {
|
8592
9002
|
return target;
|
@@ -8612,7 +9022,7 @@ up.fragment = (function () {
|
|
8612
9022
|
}
|
8613
9023
|
}
|
8614
9024
|
function deriveTargetFromPattern(element, deriver) {
|
8615
|
-
let { includePath, excludeRaw } =
|
9025
|
+
let { includePath, excludeRaw } = e.parseSelector(deriver);
|
8616
9026
|
if (includePath.length !== 1) {
|
8617
9027
|
throw new up.CannotParse(deriver);
|
8618
9028
|
}
|
@@ -8650,7 +9060,9 @@ up.fragment = (function () {
|
|
8650
9060
|
return result;
|
8651
9061
|
}
|
8652
9062
|
function isGoodTarget(target, element, options = {}) {
|
8653
|
-
|
9063
|
+
var _a;
|
9064
|
+
let verify = (_a = options.verify) !== null && _a !== void 0 ? _a : config.verifyDerivedTarget;
|
9065
|
+
return !isAlive(element) || !verify || up.fragment.get(target, Object.assign({ layer: element }, options)) === element;
|
8654
9066
|
}
|
8655
9067
|
function matchesPattern(pattern, str) {
|
8656
9068
|
if (u.isRegExp(pattern)) {
|
@@ -8692,7 +9104,7 @@ up.fragment = (function () {
|
|
8692
9104
|
let firstSwappableTarget = toTarget(layer.getFirstSwappableElement(), options);
|
8693
9105
|
targets.unshift(target.replace(LAYER_PSEUDO, firstSwappableTarget));
|
8694
9106
|
}
|
8695
|
-
else if (u.
|
9107
|
+
else if (u.isElementLike(target)) {
|
8696
9108
|
expanded.push(toTarget(target, options));
|
8697
9109
|
}
|
8698
9110
|
else if (u.isString(target)) {
|
@@ -8719,11 +9131,13 @@ up.fragment = (function () {
|
|
8719
9131
|
}
|
8720
9132
|
});
|
8721
9133
|
}
|
8722
|
-
function resolveOrigin(
|
8723
|
-
|
9134
|
+
function resolveOrigin(target, options) {
|
9135
|
+
if (!u.isString(target))
|
9136
|
+
return target;
|
9137
|
+
return (up.migrate.resolveOrigin || modernResolveOrigin)(target, options);
|
8724
9138
|
}
|
8725
9139
|
function splitTarget(target) {
|
8726
|
-
return u.
|
9140
|
+
return u.getComplexTokens(target);
|
8727
9141
|
}
|
8728
9142
|
function parseTargetSteps(target, options = {}) {
|
8729
9143
|
var _a;
|
@@ -8800,13 +9214,13 @@ up.fragment = (function () {
|
|
8800
9214
|
let elements;
|
8801
9215
|
if (options.target) {
|
8802
9216
|
elements = getAll(options.target, options);
|
8803
|
-
testFn = (request) => request.
|
9217
|
+
testFn = (request) => request.isBoundToSubtrees(elements);
|
8804
9218
|
reason || (reason = 'Aborting requests within fragment');
|
8805
9219
|
}
|
8806
9220
|
else {
|
8807
9221
|
let layers = up.layer.getAll(options);
|
8808
9222
|
elements = u.map(layers, 'element');
|
8809
|
-
testFn = (request) =>
|
9223
|
+
testFn = (request) => request.isBoundToLayers(layers);
|
8810
9224
|
reason || (reason = 'Aborting requests within ' + layers.join(', '));
|
8811
9225
|
}
|
8812
9226
|
let testFnWithAbortable = (request) => request.abortable && testFn(request);
|
@@ -8821,8 +9235,8 @@ up.fragment = (function () {
|
|
8821
9235
|
up.destructor(fragment, unsubscribe);
|
8822
9236
|
return unsubscribe;
|
8823
9237
|
}
|
8824
|
-
function onFirstIntersect(
|
8825
|
-
if (e.isIntersectingWindow(
|
9238
|
+
function onFirstIntersect(element, callback, { margin = 0 } = {}) {
|
9239
|
+
if (e.isIntersectingWindow(element, { margin })) {
|
8826
9240
|
callback();
|
8827
9241
|
return;
|
8828
9242
|
}
|
@@ -8837,15 +9251,63 @@ up.fragment = (function () {
|
|
8837
9251
|
}
|
8838
9252
|
let observer = new IntersectionObserver(processIntersectEntries, { rootMargin: `${margin}px` });
|
8839
9253
|
let disconnect = () => observer.disconnect();
|
8840
|
-
observer.observe(
|
8841
|
-
|
9254
|
+
observer.observe(element);
|
9255
|
+
up.destructor(element, disconnect);
|
9256
|
+
}
|
9257
|
+
const STARTS_WITH_SELECTOR = /^([\w-]+|\*)?(#|\.|[:[][a-z-]{3,})/;
|
9258
|
+
function provideNodes(value, { origin, originLayer, data, htmlParser = e.createNodesFromHTML } = {}) {
|
9259
|
+
if (u.isString(value) && STARTS_WITH_SELECTOR.test(value)) {
|
9260
|
+
let [parsedValue, parsedData] = u.parseScalarJSONPairs(value)[0];
|
9261
|
+
data = Object.assign(Object.assign({}, data), parsedData);
|
9262
|
+
value = up.fragment.get(parsedValue, { layer: 'closest', origin, originLayer }) || up.fail(`Cannot find template "%s"`, value);
|
9263
|
+
}
|
9264
|
+
if (u.isString(value)) {
|
9265
|
+
value = htmlParser(value);
|
9266
|
+
}
|
9267
|
+
if (isTemplate(value)) {
|
9268
|
+
value = cloneTemplate(value, data, { htmlParser });
|
9269
|
+
}
|
9270
|
+
return u.wrapList(value);
|
9271
|
+
}
|
9272
|
+
function isTemplate(value) {
|
9273
|
+
return u.isElement(value) && value.matches('template, script[type]') && !up.script.isScript(value);
|
9274
|
+
}
|
9275
|
+
function cloneTemplate(templateOrSelector, data = {}, { origin, htmlParser } = {}) {
|
9276
|
+
var _a;
|
9277
|
+
let template = getSmart(templateOrSelector, { origin }) || up.fail('Template not found: %o', templateOrSelector);
|
9278
|
+
let event = up.emit(template, 'up:template:clone', { data, nodes: null, log: ["Using template %o", templateOrSelector] });
|
9279
|
+
let nodes = (_a = event.nodes) !== null && _a !== void 0 ? _a : defaultTemplateNodes(template, htmlParser);
|
9280
|
+
for (let node of nodes) {
|
9281
|
+
node.upTemplateData = data;
|
9282
|
+
}
|
9283
|
+
return nodes;
|
9284
|
+
}
|
9285
|
+
function defaultTemplateNodes(template, htmlParser = e.createNodesFromHTML) {
|
9286
|
+
let templateText = template.innerHTML;
|
9287
|
+
return htmlParser(templateText);
|
9288
|
+
}
|
9289
|
+
function insertTemp(...args) {
|
9290
|
+
let [reference, position = 'beforeend', tempValue] = u.args(args, 'val', u.isAdjacentPosition, 'val');
|
9291
|
+
let tempNodes = provideNodes(tempValue, { origin: reference });
|
9292
|
+
let tempElement = e.wrapIfRequired(tempNodes);
|
9293
|
+
let oldPosition = document.contains(tempElement) && e.documentPosition(tempElement);
|
9294
|
+
reference.insertAdjacentElement(position, tempElement);
|
9295
|
+
if (oldPosition) {
|
9296
|
+
return () => {
|
9297
|
+
oldPosition[0].insertAdjacentElement(oldPosition[1], tempElement);
|
9298
|
+
};
|
9299
|
+
}
|
9300
|
+
else {
|
9301
|
+
up.hello(tempElement);
|
9302
|
+
return () => up.destroy(tempElement);
|
9303
|
+
}
|
8842
9304
|
}
|
8843
9305
|
up.on('up:framework:boot', function () {
|
8844
9306
|
const { documentElement } = document;
|
8845
9307
|
documentElement.setAttribute('up-source', normalizeSource(location.href));
|
8846
9308
|
up.hello(documentElement);
|
8847
9309
|
if (!up.browser.canPushState()) {
|
8848
|
-
return up.warn('Cannot push history changes. Next
|
9310
|
+
return up.warn('Cannot push history changes. Next render pass with history will load a full page.');
|
8849
9311
|
}
|
8850
9312
|
});
|
8851
9313
|
return {
|
@@ -8855,7 +9317,7 @@ up.fragment = (function () {
|
|
8855
9317
|
render,
|
8856
9318
|
navigate,
|
8857
9319
|
get: getSmart,
|
8858
|
-
|
9320
|
+
getFirstDescendant,
|
8859
9321
|
all: getAll,
|
8860
9322
|
subtree: getSubtree,
|
8861
9323
|
contains,
|
@@ -8889,6 +9351,9 @@ up.fragment = (function () {
|
|
8889
9351
|
targetForSteps,
|
8890
9352
|
compressNestedSteps,
|
8891
9353
|
containsMainPseudo,
|
9354
|
+
insertTemp,
|
9355
|
+
provideNodes,
|
9356
|
+
cloneTemplate,
|
8892
9357
|
};
|
8893
9358
|
})();
|
8894
9359
|
up.reload = up.fragment.reload;
|
@@ -8896,6 +9361,7 @@ up.destroy = up.fragment.destroy;
|
|
8896
9361
|
up.render = up.fragment.render;
|
8897
9362
|
up.navigate = up.fragment.navigate;
|
8898
9363
|
up.visit = up.fragment.visit;
|
9364
|
+
up.template = { clone: up.fragment.cloneTemplate };
|
8899
9365
|
u.delegate(up, ['context'], () => up.layer.current);
|
8900
9366
|
|
8901
9367
|
|
@@ -8929,7 +9395,7 @@ up.viewport = (function () {
|
|
8929
9395
|
up.compiler(config.selectorFn('anchoredRightSelectors'), function (element) {
|
8930
9396
|
return bodyShifter.onAnchoredElementInserted(element);
|
8931
9397
|
});
|
8932
|
-
|
9398
|
+
const reveal = up.mockable(function (element, options) {
|
8933
9399
|
var _a, _b;
|
8934
9400
|
options = u.options(options);
|
8935
9401
|
element = f.get(element, options);
|
@@ -8942,7 +9408,7 @@ up.viewport = (function () {
|
|
8942
9408
|
const motion = new up.RevealMotion(element, options);
|
8943
9409
|
motion.start();
|
8944
9410
|
return ((_b = (_a = up.migrate).formerlyAsync) === null || _b === void 0 ? void 0 : _b.call(_a, 'up.reveal()')) || true;
|
8945
|
-
}
|
9411
|
+
});
|
8946
9412
|
function doFocus(element, { preventScroll, force, inputDevice, focusVisible } = {}) {
|
8947
9413
|
if (force) {
|
8948
9414
|
if (!element.hasAttribute('tabindex') && element.tabIndex === -1) {
|
@@ -8975,7 +9441,7 @@ up.viewport = (function () {
|
|
8975
9441
|
function revealHash(hash = location.hash, options) {
|
8976
9442
|
let match = firstHashTarget(hash, options);
|
8977
9443
|
if (match) {
|
8978
|
-
return
|
9444
|
+
return reveal(match, { top: true });
|
8979
9445
|
}
|
8980
9446
|
}
|
8981
9447
|
function allSelector() {
|
@@ -9079,11 +9545,11 @@ up.viewport = (function () {
|
|
9079
9545
|
return new up.FIFOCache({ capacity: 30, normalizeKey: u.matchableURL });
|
9080
9546
|
}
|
9081
9547
|
function parseOptions(args) {
|
9082
|
-
const options = u.
|
9548
|
+
const [reference, options] = u.args(args, 'val', 'options');
|
9083
9549
|
options.layer = up.layer.get(options);
|
9084
9550
|
let viewports;
|
9085
|
-
if (
|
9086
|
-
viewports = [closest(
|
9551
|
+
if (reference) {
|
9552
|
+
viewports = [closest(reference, options)];
|
9087
9553
|
}
|
9088
9554
|
else if (options.around) {
|
9089
9555
|
viewports = getAround(options.around, options);
|
@@ -9170,16 +9636,19 @@ up.viewport = (function () {
|
|
9170
9636
|
}
|
9171
9637
|
return to;
|
9172
9638
|
}
|
9173
|
-
|
9174
|
-
|
9175
|
-
|
9176
|
-
u.task(function () {
|
9177
|
-
if (!userScrolled) {
|
9178
|
-
return revealHash();
|
9179
|
-
}
|
9180
|
-
});
|
9639
|
+
document.addEventListener('DOMContentLoaded', function () {
|
9640
|
+
revealHash();
|
9641
|
+
u.task(revealHash);
|
9181
9642
|
});
|
9182
9643
|
up.on(window, 'hashchange', () => revealHash());
|
9644
|
+
up.on('up:click', 'a[href^="#"]', function (event, link) {
|
9645
|
+
if (link.hash !== location.hash)
|
9646
|
+
return;
|
9647
|
+
if (up.link.isFollowable(link))
|
9648
|
+
return;
|
9649
|
+
if (revealHash(link.hash))
|
9650
|
+
up.event.halt(event);
|
9651
|
+
});
|
9183
9652
|
return {
|
9184
9653
|
reveal,
|
9185
9654
|
revealHash,
|
@@ -9513,7 +9982,7 @@ up.network = (function () {
|
|
9513
9982
|
cacheSize: 70,
|
9514
9983
|
cacheExpireAge: 15 * 1000,
|
9515
9984
|
cacheEvictAge: 90 * 60 * 1000,
|
9516
|
-
|
9985
|
+
lateDelay: 400,
|
9517
9986
|
fail(response) { return (response.status < 200 || response.status > 299) && response.status !== 304; },
|
9518
9987
|
autoCache(request) { return request.isSafe(); },
|
9519
9988
|
expireCache(request, _response) { return !request.isSafe(); },
|
@@ -9539,10 +10008,7 @@ up.network = (function () {
|
|
9539
10008
|
}
|
9540
10009
|
function parseRequestOptions(args) {
|
9541
10010
|
var _a, _b;
|
9542
|
-
|
9543
|
-
if (!options.url) {
|
9544
|
-
options.url = args[0];
|
9545
|
-
}
|
10011
|
+
let options = u.parseArgIntoOptions(args, 'url');
|
9546
10012
|
(_b = (_a = up.migrate).handleRequestOptions) === null || _b === void 0 ? void 0 : _b.call(_a, options);
|
9547
10013
|
return options;
|
9548
10014
|
}
|
@@ -9698,7 +10164,7 @@ up.layer = (function () {
|
|
9698
10164
|
openAnimation: 'fade-in',
|
9699
10165
|
closeAnimation: 'fade-out',
|
9700
10166
|
dismissLabel: '×',
|
9701
|
-
|
10167
|
+
dismissARIALabel: 'Dismiss dialog',
|
9702
10168
|
dismissable: true,
|
9703
10169
|
history: 'auto',
|
9704
10170
|
trapFocus: true,
|
@@ -9779,10 +10245,7 @@ up.layer = (function () {
|
|
9779
10245
|
}
|
9780
10246
|
}
|
9781
10247
|
}
|
9782
|
-
else if (options.
|
9783
|
-
options.layer = 'new';
|
9784
|
-
}
|
9785
|
-
else if (u.isElementish(options.target)) {
|
10248
|
+
else if (u.isElementLike(options.target)) {
|
9786
10249
|
options.layer = stack.get(options.target, { normalizeLayerOptions: false });
|
9787
10250
|
}
|
9788
10251
|
else if (options.origin) {
|
@@ -9980,7 +10443,7 @@ up.link = (function () {
|
|
9980
10443
|
parser.boolean('abortable');
|
9981
10444
|
parser.boolean('background');
|
9982
10445
|
parser.string('contentType');
|
9983
|
-
parser.
|
10446
|
+
parser.booleanOrNumber('lateDelay');
|
9984
10447
|
parser.number('timeout');
|
9985
10448
|
return options;
|
9986
10449
|
}
|
@@ -9990,7 +10453,6 @@ up.link = (function () {
|
|
9990
10453
|
options = u.options(options);
|
9991
10454
|
const parser = new up.OptionsParser(link, options, Object.assign({ fail: true }, parserOptions));
|
9992
10455
|
parser.include(parseRequestOptions);
|
9993
|
-
parser.boolean('feedback');
|
9994
10456
|
options.origin || (options.origin = link);
|
9995
10457
|
parser.boolean('fail');
|
9996
10458
|
parser.boolean('navigate', { default: true });
|
@@ -9998,11 +10460,12 @@ up.link = (function () {
|
|
9998
10460
|
parser.string('target');
|
9999
10461
|
parser.booleanOrString('fallback');
|
10000
10462
|
parser.string('match');
|
10001
|
-
parser.string('content');
|
10002
|
-
parser.string('fragment');
|
10003
10463
|
parser.string('document');
|
10004
|
-
parser.
|
10005
|
-
parser.
|
10464
|
+
parser.string('fragment');
|
10465
|
+
parser.string('content');
|
10466
|
+
parser.boolean('keep', { attr: 'up-use-keep' });
|
10467
|
+
parser.boolean('hungry', { attr: 'up-use-hungry' });
|
10468
|
+
parser.json('data', { attr: 'up-use-data' });
|
10006
10469
|
parser.callback('onLoaded');
|
10007
10470
|
parser.callback('onRendered', { mainKey: 'result' });
|
10008
10471
|
parser.callback('onFinished', { mainKey: 'result' });
|
@@ -10026,6 +10489,7 @@ up.link = (function () {
|
|
10026
10489
|
parser.string('acceptLocation');
|
10027
10490
|
parser.string('dismissLocation');
|
10028
10491
|
parser.booleanOrString('history');
|
10492
|
+
parser.include(up.status.statusOptions);
|
10029
10493
|
parser.booleanOrString('focus');
|
10030
10494
|
parser.boolean('saveScroll');
|
10031
10495
|
parser.boolean('saveFocus');
|
@@ -10051,7 +10515,7 @@ up.link = (function () {
|
|
10051
10515
|
return Promise.reject(new up.Error(issue));
|
10052
10516
|
}
|
10053
10517
|
const guardEvent = up.event.build('up:link:preload', { log: ['Preloading link %o', link] });
|
10054
|
-
return follow(link, Object.assign(Object.assign({ abortable: false }, options), { guardEvent, preload: true }));
|
10518
|
+
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 }));
|
10055
10519
|
}
|
10056
10520
|
function preloadIssue(link) {
|
10057
10521
|
if (!isSafe(link)) {
|
@@ -10183,15 +10647,16 @@ up.link = (function () {
|
|
10183
10647
|
let childLink = e.get(area, childLinkSelector);
|
10184
10648
|
if (childLink) {
|
10185
10649
|
e.setMissingAttrs(area, Object.assign({ 'up-href': e.attr(childLink, 'href') }, e.upAttrs(childLink)));
|
10186
|
-
|
10650
|
+
e.addClasses(area, e.upClasses(childLink));
|
10187
10651
|
makeFollowable(area);
|
10188
10652
|
}
|
10189
10653
|
});
|
10190
10654
|
up.compiler(config.selectorFn('preloadSelectors'), function (link) {
|
10191
|
-
var _a;
|
10192
10655
|
if (!isPreloadDisabled(link)) {
|
10193
10656
|
let doPreload = () => up.error.muteUncriticalRejection(preload(link));
|
10194
|
-
let condition =
|
10657
|
+
let condition = e.booleanOrStringAttr(link, 'up-preload');
|
10658
|
+
if (condition === true || u.isUndefined(condition))
|
10659
|
+
condition = 'hover';
|
10195
10660
|
onLoadCondition(condition, link, doPreload);
|
10196
10661
|
}
|
10197
10662
|
});
|
@@ -10229,10 +10694,11 @@ up.form = (function () {
|
|
10229
10694
|
const e = up.element;
|
10230
10695
|
const config = new up.Config(() => ({
|
10231
10696
|
groupSelectors: ['[up-form-group]', 'fieldset', 'label', 'form'],
|
10232
|
-
fieldSelectors: ['select', 'input:not([type=submit]
|
10697
|
+
fieldSelectors: ['select', 'input:not([type=submit], [type=image], [type=button])', 'button[type]:not([type=submit], [type=button])', 'textarea'],
|
10233
10698
|
submitSelectors: ['form:is([up-submit], [up-target], [up-layer], [up-transition])'],
|
10234
10699
|
noSubmitSelectors: ['[up-submit=false]', '[target]', e.crossOriginSelector('action')],
|
10235
10700
|
submitButtonSelectors: ['input[type=submit]', 'input[type=image]', 'button[type=submit]', 'button:not([type])'],
|
10701
|
+
genericButtonSelectors: ['input[type=button]', 'button[type=button]'],
|
10236
10702
|
watchInputEvents: ['input', 'change'],
|
10237
10703
|
watchInputDelay: 0,
|
10238
10704
|
watchChangeEvents: ['change'],
|
@@ -10257,6 +10723,9 @@ up.form = (function () {
|
|
10257
10723
|
function findSubmitButtons(root) {
|
10258
10724
|
return e.subtree(root, submitButtonSelector());
|
10259
10725
|
}
|
10726
|
+
function findGenericButtons(root) {
|
10727
|
+
return e.subtree(root, config.selector('genericButtonSelectors'));
|
10728
|
+
}
|
10260
10729
|
function isSubmitButton(element) {
|
10261
10730
|
return element === null || element === void 0 ? void 0 : element.matches(submitButtonSelector());
|
10262
10731
|
}
|
@@ -10272,7 +10741,6 @@ up.form = (function () {
|
|
10272
10741
|
let parser = new up.OptionsParser(form, options, parserOptions);
|
10273
10742
|
parser.include(destinationOptions);
|
10274
10743
|
parser.string('failTarget', { default: up.fragment.tryToTarget(form) });
|
10275
|
-
parser.booleanOrString('disable');
|
10276
10744
|
options.guardEvent || (options.guardEvent = up.event.build('up:form:submit', {
|
10277
10745
|
submitButton: options.submitButton,
|
10278
10746
|
log: 'Submitting form',
|
@@ -10280,6 +10748,7 @@ up.form = (function () {
|
|
10280
10748
|
form,
|
10281
10749
|
}));
|
10282
10750
|
options.origin || (options.origin = up.viewport.focusedElementWithin(form) || options.submitButton || form);
|
10751
|
+
options.activeElements = u.uniq([options.origin, options.submitButton, form].filter(u.isElement));
|
10283
10752
|
parser.include(up.link.followOptions);
|
10284
10753
|
return options;
|
10285
10754
|
}
|
@@ -10287,8 +10756,7 @@ up.form = (function () {
|
|
10287
10756
|
var _a;
|
10288
10757
|
options = u.options(options);
|
10289
10758
|
let parser = new up.OptionsParser(field, options, Object.assign(Object.assign({}, parserOptions), { closest: true, attrPrefix: 'up-watch-' }));
|
10290
|
-
parser.
|
10291
|
-
parser.booleanOrString('disable');
|
10759
|
+
parser.include(up.status.statusOptions);
|
10292
10760
|
parser.string('event');
|
10293
10761
|
parser.number('delay');
|
10294
10762
|
let config = up.form.config;
|
@@ -10303,61 +10771,58 @@ up.form = (function () {
|
|
10303
10771
|
return options;
|
10304
10772
|
}
|
10305
10773
|
function disableContainer(container) {
|
10306
|
-
let
|
10774
|
+
let controls = [
|
10775
|
+
...findFields(container),
|
10776
|
+
...findSubmitButtons(container),
|
10777
|
+
...findGenericButtons(container),
|
10778
|
+
];
|
10779
|
+
return u.sequence(u.map(controls, disableControl));
|
10780
|
+
}
|
10781
|
+
function disableControl(control) {
|
10782
|
+
if (control.disabled)
|
10783
|
+
return;
|
10307
10784
|
let focusFallback;
|
10308
|
-
|
10309
|
-
|
10310
|
-
|
10311
|
-
focusFallback = findGroup(focusedElement);
|
10312
|
-
}
|
10313
|
-
raiseDisableStack(control);
|
10314
|
-
}
|
10315
|
-
if (focusFallback) {
|
10785
|
+
if (document.activeElement === control) {
|
10786
|
+
focusFallback = findGroup(control);
|
10787
|
+
control.disabled = true;
|
10316
10788
|
up.focus(focusFallback, { force: true, preventScroll: true });
|
10317
10789
|
}
|
10318
|
-
|
10319
|
-
|
10320
|
-
};
|
10321
|
-
}
|
10322
|
-
function raiseDisableStack(control) {
|
10323
|
-
if (!control.upDisableCount) {
|
10324
|
-
control.upDisableCount || (control.upDisableCount = 0);
|
10325
|
-
control.upOriginalDisabled = control.disabled;
|
10790
|
+
else {
|
10791
|
+
control.disabled = true;
|
10326
10792
|
}
|
10327
|
-
|
10328
|
-
|
10329
|
-
|
10330
|
-
|
10331
|
-
if (control.upDisableCount) {
|
10332
|
-
if (!control.disabled) {
|
10333
|
-
control.upDisableCount = 0;
|
10334
|
-
}
|
10335
|
-
else {
|
10336
|
-
control.upDisableCount--;
|
10337
|
-
if (!control.upDisableCount) {
|
10338
|
-
control.disabled = control.upOriginalDisabled;
|
10339
|
-
}
|
10793
|
+
return () => {
|
10794
|
+
control.disabled = false;
|
10795
|
+
if (focusFallback && document.activeElement === focusFallback && control.isConnected) {
|
10796
|
+
up.focus(control, { preventScroll: true });
|
10340
10797
|
}
|
10341
|
-
}
|
10342
|
-
}
|
10343
|
-
function disableWhile(promise, options) {
|
10344
|
-
let undoDisable = handleDisableOption(options);
|
10345
|
-
u.always(promise, undoDisable);
|
10798
|
+
};
|
10346
10799
|
}
|
10347
|
-
function
|
10348
|
-
|
10349
|
-
|
10350
|
-
let missingOption = (key) => { up.fail("Cannot process { disable: '%s' } option without { %s }", disable, key); };
|
10351
|
-
let getOrigin = () => origin || missingOption('origin');
|
10352
|
-
let getOriginForm = () => getScope(getOrigin());
|
10353
|
-
let containers;
|
10800
|
+
function getDisableContainers(disable, origin) {
|
10801
|
+
let givenOrigin = () => origin || up.fail('Missing { origin }');
|
10802
|
+
let originScope = () => getScope(givenOrigin());
|
10354
10803
|
if (disable === true) {
|
10355
|
-
|
10804
|
+
return [originScope()];
|
10805
|
+
}
|
10806
|
+
else if (u.isElement(disable)) {
|
10807
|
+
return [disable];
|
10356
10808
|
}
|
10357
10809
|
else if (u.isString(disable)) {
|
10358
|
-
|
10810
|
+
return up.fragment.subtree(originScope(), disable, { origin });
|
10811
|
+
}
|
10812
|
+
else if (u.isArray(disable)) {
|
10813
|
+
return u.flatMap(disable, (d) => getDisableContainers(d, origin));
|
10814
|
+
}
|
10815
|
+
else {
|
10816
|
+
return [];
|
10359
10817
|
}
|
10360
|
-
|
10818
|
+
}
|
10819
|
+
function getDisablePreviewFn(disable, origin) {
|
10820
|
+
return function (preview) {
|
10821
|
+
let containers = getDisableContainers(disable, origin);
|
10822
|
+
for (let container of containers) {
|
10823
|
+
preview.disable(container);
|
10824
|
+
}
|
10825
|
+
};
|
10361
10826
|
}
|
10362
10827
|
function destinationOptions(form, options, parserOptions) {
|
10363
10828
|
var _a;
|
@@ -10386,10 +10851,10 @@ up.form = (function () {
|
|
10386
10851
|
}
|
10387
10852
|
return options;
|
10388
10853
|
}
|
10389
|
-
function watch(
|
10854
|
+
function watch(...args) {
|
10855
|
+
let [root, options, callback] = u.args(args, 'val', 'options', 'callback');
|
10390
10856
|
root = up.element.get(root);
|
10391
|
-
|
10392
|
-
let options = u.extractOptions(args);
|
10857
|
+
callback || (callback = watchCallbackFromElement(root) || up.fail('No callback given for up.watch()'));
|
10393
10858
|
const watcher = new up.FieldWatcher(root, options, callback);
|
10394
10859
|
watcher.start();
|
10395
10860
|
return () => watcher.stop();
|
@@ -10397,12 +10862,12 @@ up.form = (function () {
|
|
10397
10862
|
function watchCallbackFromElement(element) {
|
10398
10863
|
let rawCallback = element.getAttribute('up-watch');
|
10399
10864
|
if (rawCallback) {
|
10400
|
-
return up.NonceableCallback.fromString(rawCallback).toFunction('value', 'name').bind(element);
|
10865
|
+
return up.NonceableCallback.fromString(rawCallback).toFunction('value', 'name', 'options').bind(element);
|
10401
10866
|
}
|
10402
10867
|
}
|
10403
10868
|
function autosubmit(target, options = {}) {
|
10404
10869
|
const onChange = (_diff, renderOptions) => submit(target, renderOptions);
|
10405
|
-
return watch(target, { options, batch: true }, onChange);
|
10870
|
+
return watch(target, Object.assign(Object.assign({}, options), { batch: true }), onChange);
|
10406
10871
|
}
|
10407
10872
|
function getGroupSelectors() {
|
10408
10873
|
var _a, _b;
|
@@ -10415,10 +10880,10 @@ up.form = (function () {
|
|
10415
10880
|
return u.findResult(getGroupSelectors(), function (groupSelector) {
|
10416
10881
|
let group = field.closest(groupSelector);
|
10417
10882
|
if (group) {
|
10418
|
-
let
|
10883
|
+
let strongDerivedGroupTarget = up.fragment.tryToTarget(group, { strong: true });
|
10419
10884
|
let goodDerivedFieldTarget = up.fragment.tryToTarget(field);
|
10420
10885
|
let groupHasFieldTarget = goodDerivedFieldTarget && (group !== field) && `${groupSelector}:has(${goodDerivedFieldTarget})`;
|
10421
|
-
let target =
|
10886
|
+
let target = strongDerivedGroupTarget || groupHasFieldTarget;
|
10422
10887
|
if (target) {
|
10423
10888
|
return {
|
10424
10889
|
target,
|
@@ -10510,7 +10975,7 @@ up.form = (function () {
|
|
10510
10975
|
target.classList.add('up-switched');
|
10511
10976
|
});
|
10512
10977
|
function parseSwitchTokens(str) {
|
10513
|
-
return u.
|
10978
|
+
return u.getSimpleTokens(str, { json: true });
|
10514
10979
|
}
|
10515
10980
|
function findSwitcherForTarget(target) {
|
10516
10981
|
const form = getScope(target);
|
@@ -10578,8 +11043,8 @@ up.form = (function () {
|
|
10578
11043
|
submitButtons: findSubmitButtons,
|
10579
11044
|
focusedField,
|
10580
11045
|
switchTarget,
|
10581
|
-
disableWhile,
|
10582
11046
|
disable: disableContainer,
|
11047
|
+
getDisablePreviewFn,
|
10583
11048
|
group: findGroup,
|
10584
11049
|
groupSolution: findGroupSolution,
|
10585
11050
|
groupSelectors: getGroupSelectors,
|
@@ -10597,22 +11062,24 @@ up.validate = up.form.validate;
|
|
10597
11062
|
/* 98 */
|
10598
11063
|
/***/ (() => {
|
10599
11064
|
|
10600
|
-
up.
|
11065
|
+
up.status = (function () {
|
10601
11066
|
const u = up.util;
|
10602
11067
|
const e = up.element;
|
11068
|
+
let namedPreviewFns = {};
|
10603
11069
|
const config = new up.Config(() => ({
|
10604
11070
|
currentClasses: ['up-current'],
|
11071
|
+
activeClasses: ['up-active'],
|
11072
|
+
loadingClasses: ['up-loading'],
|
10605
11073
|
navSelectors: ['[up-nav]', 'nav'],
|
10606
11074
|
noNavSelectors: ['[up-nav=false]'],
|
10607
11075
|
}));
|
10608
11076
|
function reset() {
|
10609
11077
|
up.layer.root.feedbackLocation = null;
|
11078
|
+
namedPreviewFns = u.pickBy(namedPreviewFns, 'isDefault');
|
10610
11079
|
}
|
10611
|
-
const CLASS_ACTIVE = 'up-active';
|
10612
|
-
const CLASS_LOADING = 'up-loading';
|
10613
11080
|
const SELECTOR_LINK = 'a, [up-href]';
|
10614
|
-
function
|
10615
|
-
return link.
|
11081
|
+
function linkCurrentURLs(link) {
|
11082
|
+
return link.upCurrentURLs || (link.upCurrentURLs = new up.LinkCurrentURLs(link));
|
10616
11083
|
}
|
10617
11084
|
function updateFragment(fragment, { layer } = {}) {
|
10618
11085
|
layer || (layer = up.layer.get(fragment));
|
@@ -10621,11 +11088,11 @@ up.feedback = (function () {
|
|
10621
11088
|
const navLinkSelector = `${navSelector} :is(${SELECTOR_LINK}), ${navSelector}:is(${SELECTOR_LINK})`;
|
10622
11089
|
const links = up.fragment.all(navLinkSelector, { layer });
|
10623
11090
|
for (let link of links) {
|
10624
|
-
const isCurrent =
|
11091
|
+
const isCurrent = linkCurrentURLs(link).isCurrent(layerLocation);
|
10625
11092
|
for (let currentClass of config.currentClasses) {
|
10626
11093
|
link.classList.toggle(currentClass, isCurrent);
|
10627
11094
|
}
|
10628
|
-
e.
|
11095
|
+
e.setAttrPresence(link, 'aria-current', 'page', isCurrent);
|
10629
11096
|
}
|
10630
11097
|
}
|
10631
11098
|
function getMatchableLayerLocation(layer) {
|
@@ -10634,24 +11101,88 @@ up.feedback = (function () {
|
|
10634
11101
|
function findActivatableArea(element) {
|
10635
11102
|
return e.ancestor(element, SELECTOR_LINK) || element;
|
10636
11103
|
}
|
10637
|
-
function
|
10638
|
-
|
11104
|
+
function runPreviews(request, renderOptions) {
|
11105
|
+
let { bindLayer } = request;
|
11106
|
+
let focusCapsule = up.FocusCapsule.preserve(bindLayer);
|
11107
|
+
let applyPreviews = () => doRunPreviews(request, renderOptions);
|
11108
|
+
let revertPreviews = bindLayer.asCurrent(applyPreviews);
|
11109
|
+
up.on('focusin', { once: true }, () => focusCapsule = null);
|
11110
|
+
return () => {
|
11111
|
+
bindLayer.asCurrent(revertPreviews);
|
11112
|
+
focusCapsule === null || focusCapsule === void 0 ? void 0 : focusCapsule.restore(bindLayer, { preventScroll: true });
|
11113
|
+
};
|
11114
|
+
}
|
11115
|
+
function doRunPreviews(request, renderOptions) {
|
11116
|
+
let { fragment, fragments, origin } = request;
|
11117
|
+
let cleaner = u.cleaner();
|
11118
|
+
let previewForFragment = (fragment) => new up.Preview({ fragment, request, renderOptions, cleaner });
|
11119
|
+
let singlePreview = previewForFragment(fragment);
|
11120
|
+
singlePreview.run(resolvePreviewFns(renderOptions.preview));
|
11121
|
+
singlePreview.run(getPlaceholderPreviewFn(renderOptions.placeholder));
|
11122
|
+
singlePreview.run(getFeedbackClassesPreviewFn(renderOptions.feedback, fragments));
|
11123
|
+
singlePreview.run(up.form.getDisablePreviewFn(renderOptions.disable, origin));
|
11124
|
+
for (let fragment of fragments) {
|
11125
|
+
let eachPreview = previewForFragment(fragment);
|
11126
|
+
eachPreview.run(e.matchSelectorMap(renderOptions.previewMap, fragment));
|
11127
|
+
eachPreview.run(e.matchSelectorMap(renderOptions.placeholderMap, fragment).flatMap(getPlaceholderPreviewFn));
|
11128
|
+
}
|
11129
|
+
return cleaner.clean;
|
11130
|
+
}
|
11131
|
+
function getPlaceholderPreviewFn(placeholder) {
|
11132
|
+
if (!placeholder)
|
10639
11133
|
return;
|
11134
|
+
return function (preview) {
|
11135
|
+
preview.showPlaceholder(placeholder);
|
11136
|
+
};
|
11137
|
+
}
|
11138
|
+
function resolvePreviewFns(value) {
|
11139
|
+
if (u.isFunction(value)) {
|
11140
|
+
return [value];
|
11141
|
+
}
|
11142
|
+
else if (u.isString(value)) {
|
11143
|
+
return resolvePreviewString(value);
|
10640
11144
|
}
|
10641
|
-
|
10642
|
-
|
10643
|
-
if (activeElement) {
|
10644
|
-
clean(e.addTemporaryClass(activeElement, CLASS_ACTIVE));
|
11145
|
+
else if (u.isArray(value)) {
|
11146
|
+
return value.flatMap(resolvePreviewFns);
|
10645
11147
|
}
|
10646
|
-
|
10647
|
-
|
11148
|
+
else {
|
11149
|
+
return [];
|
10648
11150
|
}
|
10649
11151
|
}
|
10650
|
-
function
|
10651
|
-
|
10652
|
-
|
10653
|
-
return
|
10654
|
-
|
11152
|
+
function resolvePreviewString(str) {
|
11153
|
+
return u.map(u.parseScalarJSONPairs(str), ([name, parsedOptions]) => {
|
11154
|
+
let previewFn = namedPreviewFns[name] || up.fail('Unknown preview "%s"', name);
|
11155
|
+
return function (preview, runOptions) {
|
11156
|
+
up.puts('[up-preview]', 'Showing preview %o', name);
|
11157
|
+
return previewFn(preview, parsedOptions || runOptions);
|
11158
|
+
};
|
11159
|
+
});
|
11160
|
+
}
|
11161
|
+
function getActiveElements({ origin, activeElements }) {
|
11162
|
+
activeElements || (activeElements = u.wrapList(origin));
|
11163
|
+
return activeElements.map(findActivatableArea);
|
11164
|
+
}
|
11165
|
+
function registerPreview(name, previewFn) {
|
11166
|
+
previewFn.isDefault = up.framework.evaling;
|
11167
|
+
namedPreviewFns[name] = previewFn;
|
11168
|
+
}
|
11169
|
+
function getFeedbackClassesPreviewFn(feedbackOption, fragments) {
|
11170
|
+
if (!feedbackOption)
|
11171
|
+
return;
|
11172
|
+
return function (preview) {
|
11173
|
+
preview.addClassBatch(getActiveElements(preview.renderOptions), config.activeClasses);
|
11174
|
+
preview.addClassBatch(fragments, config.loadingClasses);
|
11175
|
+
};
|
11176
|
+
}
|
11177
|
+
function statusOptions(element, options, parserOptions) {
|
11178
|
+
options = u.options(options);
|
11179
|
+
const parser = new up.OptionsParser(element, options, parserOptions);
|
11180
|
+
parser.booleanOrString('disable');
|
11181
|
+
parser.boolean('feedback');
|
11182
|
+
parser.string('preview');
|
11183
|
+
parser.booleanOrString('revalidatePreview');
|
11184
|
+
parser.string('placeholder');
|
11185
|
+
return options;
|
10655
11186
|
}
|
10656
11187
|
function updateLayerIfLocationChanged(layer) {
|
10657
11188
|
const processedLocation = layer.feedbackLocation;
|
@@ -10679,9 +11210,13 @@ up.feedback = (function () {
|
|
10679
11210
|
up.on('up:framework:reset', reset);
|
10680
11211
|
return {
|
10681
11212
|
config,
|
10682
|
-
|
11213
|
+
preview: registerPreview,
|
11214
|
+
resolvePreviewFns,
|
11215
|
+
runPreviews,
|
11216
|
+
statusOptions,
|
10683
11217
|
};
|
10684
11218
|
})();
|
11219
|
+
up.preview = up.status.preview;
|
10685
11220
|
|
10686
11221
|
|
10687
11222
|
/***/ }),
|
@@ -10696,9 +11231,9 @@ up.radio = (function () {
|
|
10696
11231
|
pollInterval: 30000,
|
10697
11232
|
}));
|
10698
11233
|
function hungrySteps(renderOptions) {
|
10699
|
-
let {
|
11234
|
+
let { hungry, origin, layer: renderLayer, meta } = renderOptions;
|
10700
11235
|
let steps = { current: [], other: [] };
|
10701
|
-
if (!
|
11236
|
+
if (!hungry)
|
10702
11237
|
return steps;
|
10703
11238
|
let hungrySelector = config.selector('hungrySelectors');
|
10704
11239
|
const layerPreference = [renderLayer, ...renderLayer.ancestors, ...renderLayer.descendants];
|
@@ -10715,7 +11250,8 @@ up.radio = (function () {
|
|
10715
11250
|
let motionOptions = up.motion.motionOptions(element);
|
10716
11251
|
let selectEvent = up.event.build('up:fragment:hungry', { log: false });
|
10717
11252
|
let selectCallback = e.callbackAttr(element, 'up-on-hungry', { exposedKeys: ['newFragment', 'renderOptions'] });
|
10718
|
-
let step = Object.assign(Object.assign({ selector, oldElement: element, layer: elementLayer, origin }, motionOptions), { placement: 'swap',
|
11253
|
+
let step = Object.assign(Object.assign({ selector, oldElement: element, layer: elementLayer, origin }, motionOptions), { placement: 'swap', keep: true, maybe: true, meta,
|
11254
|
+
selectEvent,
|
10719
11255
|
selectCallback, originalRenderOptions: renderOptions });
|
10720
11256
|
if (applicableLayers.includes(renderLayer)) {
|
10721
11257
|
let list = renderLayer === elementLayer ? steps.current : steps.other;
|
@@ -10738,6 +11274,7 @@ up.radio = (function () {
|
|
10738
11274
|
parser.number('interval', { default: config.pollInterval });
|
10739
11275
|
parser.string('ifLayer', { default: 'front' });
|
10740
11276
|
parser.include(up.link.requestOptions);
|
11277
|
+
parser.include(up.status.statusOptions);
|
10741
11278
|
return options;
|
10742
11279
|
}
|
10743
11280
|
up.attribute('up-poll', function (fragment) {
|