locize 4.0.11 → 4.0.13
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.
- package/CHANGELOG.md +9 -1
- package/dist/cjs/api/handleEditKey.js +3 -1
- package/dist/cjs/api/handleRequestPopupChanges.js +8 -4
- package/dist/cjs/api/handleSendMatchedUninstrumented.js +3 -1
- package/dist/cjs/implementations/dummyImplementation.js +4 -12
- package/dist/cjs/implementations/i18nextImplementation.js +3 -1
- package/dist/cjs/locizePlugin.js +3 -3
- package/dist/cjs/parser.js +3 -3
- package/dist/cjs/process.js +3 -7
- package/dist/cjs/startStandalone.js +3 -1
- package/dist/cjs/ui/highlightNode.js +0 -1
- package/dist/cjs/ui/popup.js +8 -4
- package/dist/cjs/utils.js +9 -3
- package/dist/esm/api/handleEditKey.js +3 -1
- package/dist/esm/api/handleRequestPopupChanges.js +8 -4
- package/dist/esm/api/handleSendMatchedUninstrumented.js +3 -1
- package/dist/esm/implementations/dummyImplementation.js +4 -12
- package/dist/esm/implementations/i18nextImplementation.js +3 -1
- package/dist/esm/locizePlugin.js +3 -3
- package/dist/esm/parser.js +3 -3
- package/dist/esm/process.js +2 -6
- package/dist/esm/startStandalone.js +3 -1
- package/dist/esm/ui/highlightNode.js +0 -1
- package/dist/esm/ui/popup.js +8 -4
- package/dist/esm/utils.js +9 -4
- package/dist/umd/locize.js +836 -191
- package/dist/umd/locize.min.js +1 -1
- package/locize.js +836 -191
- package/locize.min.js +1 -1
- package/package.json +2 -2
- package/src/_startStandalone.js +1 -2
- package/src/api/handleEditKey.js +1 -2
- package/src/api/handleRequestPopupChanges.js +4 -6
- package/src/api/handleSendMatchedUninstrumented.js +1 -2
- package/src/clickHandler.js +3 -6
- package/src/implementations/dummyImplementation.js +5 -4
- package/src/implementations/i18nextImplementation.js +1 -2
- package/src/locizePlugin.js +120 -116
- package/src/parser.js +11 -11
- package/src/process.js +2 -9
- package/src/startStandalone.js +1 -2
- package/src/ui/highlightNode.js +26 -26
- package/src/ui/popup.js +4 -6
- package/src/utils.js +18 -12
- package/src/vars.js +2 -2
package/dist/umd/locize.js
CHANGED
|
@@ -14,69 +14,33 @@
|
|
|
14
14
|
}, _typeof(o);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function
|
|
18
|
-
if (
|
|
19
|
-
var
|
|
20
|
-
if (
|
|
21
|
-
var
|
|
22
|
-
if (
|
|
17
|
+
function toPrimitive(t, r) {
|
|
18
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
19
|
+
var e = t[Symbol.toPrimitive];
|
|
20
|
+
if (void 0 !== e) {
|
|
21
|
+
var i = e.call(t, r || "default");
|
|
22
|
+
if ("object" != _typeof(i)) return i;
|
|
23
23
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
24
24
|
}
|
|
25
|
-
return (
|
|
25
|
+
return ("string" === r ? String : Number)(t);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function
|
|
29
|
-
var
|
|
30
|
-
return _typeof(
|
|
28
|
+
function toPropertyKey(t) {
|
|
29
|
+
var i = toPrimitive(t, "string");
|
|
30
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function _defineProperty(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
writable: true
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
obj[key] = value;
|
|
44
|
-
}
|
|
45
|
-
return obj;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function _arrayLikeToArray(arr, len) {
|
|
49
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
50
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
51
|
-
return arr2;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function _arrayWithoutHoles(arr) {
|
|
55
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function _iterableToArray(iter) {
|
|
59
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
33
|
+
function _defineProperty(e, r, t) {
|
|
34
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
35
|
+
value: t,
|
|
36
|
+
enumerable: !0,
|
|
37
|
+
configurable: !0,
|
|
38
|
+
writable: !0
|
|
39
|
+
}) : e[r] = t, e;
|
|
60
40
|
}
|
|
61
41
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
65
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
66
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
67
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
68
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function _nonIterableSpread() {
|
|
72
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function _toConsumableArray(arr) {
|
|
76
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
var INVISIBLE_CHARACTERS = ["\u200B", "\u200C"];
|
|
42
|
+
var isBrowser = typeof window !== 'undefined';
|
|
43
|
+
var INVISIBLE_CHARACTERS = isBrowser ? ["\u200C", "\u200D"] : ["\u200B", "\u200C"];
|
|
80
44
|
var INVISIBLE_REGEX = RegExp("([".concat(INVISIBLE_CHARACTERS.join(''), "]{9})+"), 'gu');
|
|
81
45
|
var TEMPLATE_MINIMUM_LENGTH = '{"k":"a"}'.length;
|
|
82
46
|
var invisibleStartMarker = 'subliminal:start';
|
|
@@ -173,7 +137,7 @@
|
|
|
173
137
|
}
|
|
174
138
|
|
|
175
139
|
function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
176
|
-
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t),
|
|
140
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
177
141
|
var postProcessorName = 'subliminal';
|
|
178
142
|
var SubliminalPostProcessor = {
|
|
179
143
|
name: postProcessorName,
|
|
@@ -299,8 +263,8 @@
|
|
|
299
263
|
data: data$1
|
|
300
264
|
};
|
|
301
265
|
|
|
302
|
-
function _arrayWithHoles(
|
|
303
|
-
if (Array.isArray(
|
|
266
|
+
function _arrayWithHoles(r) {
|
|
267
|
+
if (Array.isArray(r)) return r;
|
|
304
268
|
}
|
|
305
269
|
|
|
306
270
|
function _iterableToArrayLimit(r, l) {
|
|
@@ -331,12 +295,26 @@
|
|
|
331
295
|
}
|
|
332
296
|
}
|
|
333
297
|
|
|
298
|
+
function _arrayLikeToArray(r, a) {
|
|
299
|
+
(null == a || a > r.length) && (a = r.length);
|
|
300
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
301
|
+
return n;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function _unsupportedIterableToArray(r, a) {
|
|
305
|
+
if (r) {
|
|
306
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
307
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
308
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
334
312
|
function _nonIterableRest() {
|
|
335
313
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
336
314
|
}
|
|
337
315
|
|
|
338
|
-
function _slicedToArray(
|
|
339
|
-
return _arrayWithHoles(
|
|
316
|
+
function _slicedToArray(r, e) {
|
|
317
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
340
318
|
}
|
|
341
319
|
|
|
342
320
|
function debounce(func, wait, immediate) {
|
|
@@ -367,12 +345,12 @@
|
|
|
367
345
|
}
|
|
368
346
|
function parseAttrFromKey(key) {
|
|
369
347
|
var attr = 'text';
|
|
370
|
-
if (key.indexOf('[')
|
|
348
|
+
if (key.indexOf('[') === 0) {
|
|
371
349
|
var parts = key.split(']');
|
|
372
350
|
key = parts[1];
|
|
373
351
|
attr = parts[0].substr(1, parts[0].length - 1);
|
|
374
352
|
}
|
|
375
|
-
var newKey = key.indexOf(';')
|
|
353
|
+
var newKey = key.indexOf(';') === key.length - 1 ? key.substr(0, key.length - 2) : key;
|
|
376
354
|
return [newKey, attr];
|
|
377
355
|
}
|
|
378
356
|
function getI18nMetaFromNode(el) {
|
|
@@ -382,7 +360,7 @@
|
|
|
382
360
|
var allKeys = {};
|
|
383
361
|
if (key && key.indexOf(';') >= 0) {
|
|
384
362
|
var keys = key.split(';');
|
|
385
|
-
for (var ix = 0,
|
|
363
|
+
for (var ix = 0, lix = keys.length; ix < lix; ix++) {
|
|
386
364
|
if (keys[ix] != '') {
|
|
387
365
|
var _parseAttrFromKey = parseAttrFromKey(keys[ix]),
|
|
388
366
|
_parseAttrFromKey2 = _slicedToArray(_parseAttrFromKey, 2),
|
|
@@ -449,6 +427,11 @@
|
|
|
449
427
|
if (!results[2]) return '';
|
|
450
428
|
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
451
429
|
}
|
|
430
|
+
var _isInIframe = typeof window !== 'undefined';
|
|
431
|
+
try {
|
|
432
|
+
_isInIframe = self !== top;
|
|
433
|
+
} catch (e) {}
|
|
434
|
+
var isInIframe = _isInIframe;
|
|
452
435
|
|
|
453
436
|
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
454
437
|
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -631,7 +614,9 @@
|
|
|
631
614
|
}
|
|
632
615
|
});
|
|
633
616
|
children.forEach(function (replaceable) {
|
|
634
|
-
if (item.node.contains(replaceable.child))
|
|
617
|
+
if (item.node.contains(replaceable.child)) {
|
|
618
|
+
item.node.removeChild(replaceable.child);
|
|
619
|
+
}
|
|
635
620
|
});
|
|
636
621
|
}
|
|
637
622
|
}
|
|
@@ -658,6 +643,22 @@
|
|
|
658
643
|
}
|
|
659
644
|
api.addHandler('commitKey', handler$7);
|
|
660
645
|
|
|
646
|
+
function _arrayWithoutHoles(r) {
|
|
647
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function _iterableToArray(r) {
|
|
651
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
function _nonIterableSpread() {
|
|
655
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function _toConsumableArray(r) {
|
|
659
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
660
|
+
}
|
|
661
|
+
|
|
661
662
|
function handler$6(payload) {
|
|
662
663
|
var updated = payload.updated;
|
|
663
664
|
updated.forEach(function (item) {
|
|
@@ -889,9 +890,9 @@
|
|
|
889
890
|
if (containerStyle) {
|
|
890
891
|
var popup = document.getElementById(popupId);
|
|
891
892
|
if (!popup) return;
|
|
892
|
-
var storedPos = localStorage.getItem('locize_popup_pos');
|
|
893
|
+
var storedPos = window.localStorage.getItem('locize_popup_pos');
|
|
893
894
|
if (storedPos) storedPos = JSON.parse(storedPos);
|
|
894
|
-
var storedSize = localStorage.getItem('locize_popup_size');
|
|
895
|
+
var storedSize = window.localStorage.getItem('locize_popup_size');
|
|
895
896
|
if (storedSize) storedSize = JSON.parse(storedSize);
|
|
896
897
|
if (storedSize && storedSize.height && storedSize.width) {
|
|
897
898
|
containerStyle.height = storedSize.height + 'px';
|
|
@@ -907,39 +908,36 @@
|
|
|
907
908
|
popup.style.setProperty('left', "calc(".concat(popup.style.left, " - ").concat(_diff, ")"));
|
|
908
909
|
popup.style.setProperty('width', containerStyle.width);
|
|
909
910
|
}
|
|
910
|
-
if (storedPos && storedPos.top && storedPos.top < window.innerHeight - containerStyle.height.replace('px', ''))
|
|
911
|
-
|
|
911
|
+
if (storedPos && storedPos.top && storedPos.top < window.innerHeight - containerStyle.height.replace('px', '')) {
|
|
912
|
+
popup.style.setProperty('top', storedPos.top + 'px');
|
|
913
|
+
}
|
|
914
|
+
if (storedPos && storedPos.left && storedPos.left < window.innerWidth - containerStyle.width.replace('px', '')) {
|
|
915
|
+
popup.style.setProperty('left', storedPos.left + 'px');
|
|
916
|
+
}
|
|
912
917
|
}
|
|
913
918
|
}
|
|
914
919
|
api.addHandler('requestPopupChanges', handler$4);
|
|
915
920
|
|
|
916
|
-
function _objectWithoutPropertiesLoose(
|
|
917
|
-
if (
|
|
918
|
-
var
|
|
919
|
-
var
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
key = sourceKeys[i];
|
|
923
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
924
|
-
target[key] = source[key];
|
|
921
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
922
|
+
if (null == r) return {};
|
|
923
|
+
var t = {};
|
|
924
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
925
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
926
|
+
t[n] = r[n];
|
|
925
927
|
}
|
|
926
|
-
return
|
|
928
|
+
return t;
|
|
927
929
|
}
|
|
928
930
|
|
|
929
|
-
function _objectWithoutProperties(
|
|
930
|
-
if (
|
|
931
|
-
var
|
|
932
|
-
|
|
931
|
+
function _objectWithoutProperties(e, t) {
|
|
932
|
+
if (null == e) return {};
|
|
933
|
+
var o,
|
|
934
|
+
r,
|
|
935
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
933
936
|
if (Object.getOwnPropertySymbols) {
|
|
934
|
-
var
|
|
935
|
-
for (
|
|
936
|
-
key = sourceSymbolKeys[i];
|
|
937
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
938
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
939
|
-
target[key] = source[key];
|
|
940
|
-
}
|
|
937
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
938
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
941
939
|
}
|
|
942
|
-
return
|
|
940
|
+
return i;
|
|
943
941
|
}
|
|
944
942
|
|
|
945
943
|
var _excluded$1 = ["lng", "ns"];
|
|
@@ -998,7 +996,9 @@
|
|
|
998
996
|
key: item.key
|
|
999
997
|
}), item.value), uni === null || uni === void 0 ? void 0 : uni.node);
|
|
1000
998
|
if (uni && uni.keys) delete uni.keys["".concat(item.textType)];
|
|
1001
|
-
if (uni && uni.keys && !Object.keys(uni.keys).length)
|
|
999
|
+
if (uni && uni.keys && !Object.keys(uni.keys).length) {
|
|
1000
|
+
uninstrumentedStore.remove(item.eleUniqueID, uni.node);
|
|
1001
|
+
}
|
|
1002
1002
|
});
|
|
1003
1003
|
api.sendCurrentParsedContent();
|
|
1004
1004
|
}
|
|
@@ -1058,6 +1058,14 @@
|
|
|
1058
1058
|
return box;
|
|
1059
1059
|
}
|
|
1060
1060
|
|
|
1061
|
+
/**
|
|
1062
|
+
* Custom positioning reference element.
|
|
1063
|
+
* @see https://floating-ui.com/docs/virtual-elements
|
|
1064
|
+
*/
|
|
1065
|
+
|
|
1066
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
|
1067
|
+
const alignments = ['start', 'end'];
|
|
1068
|
+
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
1061
1069
|
const min = Math.min;
|
|
1062
1070
|
const max = Math.max;
|
|
1063
1071
|
const round = Math.round;
|
|
@@ -1168,12 +1176,21 @@
|
|
|
1168
1176
|
};
|
|
1169
1177
|
}
|
|
1170
1178
|
function rectToClientRect(rect) {
|
|
1179
|
+
const {
|
|
1180
|
+
x,
|
|
1181
|
+
y,
|
|
1182
|
+
width,
|
|
1183
|
+
height
|
|
1184
|
+
} = rect;
|
|
1171
1185
|
return {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1186
|
+
width,
|
|
1187
|
+
height,
|
|
1188
|
+
top: y,
|
|
1189
|
+
left: x,
|
|
1190
|
+
right: x + width,
|
|
1191
|
+
bottom: y + height,
|
|
1192
|
+
x,
|
|
1193
|
+
y
|
|
1177
1194
|
};
|
|
1178
1195
|
}
|
|
1179
1196
|
|
|
@@ -1235,7 +1252,7 @@
|
|
|
1235
1252
|
|
|
1236
1253
|
/**
|
|
1237
1254
|
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1238
|
-
* next to a reference element
|
|
1255
|
+
* next to a given reference element.
|
|
1239
1256
|
*
|
|
1240
1257
|
* This export does not have any `platform` interface logic. You will need to
|
|
1241
1258
|
* write one for the platform you are using Floating UI with.
|
|
@@ -1313,7 +1330,6 @@
|
|
|
1313
1330
|
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
1314
1331
|
}
|
|
1315
1332
|
i = -1;
|
|
1316
|
-
continue;
|
|
1317
1333
|
}
|
|
1318
1334
|
}
|
|
1319
1335
|
return {
|
|
@@ -1363,9 +1379,10 @@
|
|
|
1363
1379
|
strategy
|
|
1364
1380
|
}));
|
|
1365
1381
|
const rect = elementContext === 'floating' ? {
|
|
1366
|
-
...rects.floating,
|
|
1367
1382
|
x,
|
|
1368
|
-
y
|
|
1383
|
+
y,
|
|
1384
|
+
width: rects.floating.width,
|
|
1385
|
+
height: rects.floating.height
|
|
1369
1386
|
} : rects.reference;
|
|
1370
1387
|
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
1371
1388
|
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
@@ -1376,6 +1393,7 @@
|
|
|
1376
1393
|
y: 1
|
|
1377
1394
|
};
|
|
1378
1395
|
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
1396
|
+
elements,
|
|
1379
1397
|
rect,
|
|
1380
1398
|
offsetParent,
|
|
1381
1399
|
strategy
|
|
@@ -1393,7 +1411,7 @@
|
|
|
1393
1411
|
* appears centered to the reference element.
|
|
1394
1412
|
* @see https://floating-ui.com/docs/arrow
|
|
1395
1413
|
*/
|
|
1396
|
-
const arrow = options => ({
|
|
1414
|
+
const arrow$1 = options => ({
|
|
1397
1415
|
name: 'arrow',
|
|
1398
1416
|
options,
|
|
1399
1417
|
async fn(state) {
|
|
@@ -1454,7 +1472,7 @@
|
|
|
1454
1472
|
// to point to nothing for an aligned placement, adjust the offset of the
|
|
1455
1473
|
// floating element itself. To ensure `shift()` continues to take action,
|
|
1456
1474
|
// a single reset is performed when this is true.
|
|
1457
|
-
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center
|
|
1475
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
1458
1476
|
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
1459
1477
|
return {
|
|
1460
1478
|
[axis]: coords[axis] + alignmentOffset,
|
|
@@ -1470,13 +1488,116 @@
|
|
|
1470
1488
|
}
|
|
1471
1489
|
});
|
|
1472
1490
|
|
|
1491
|
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
1492
|
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
|
1493
|
+
return allowedPlacementsSortedByAlignment.filter(placement => {
|
|
1494
|
+
if (alignment) {
|
|
1495
|
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
1496
|
+
}
|
|
1497
|
+
return true;
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Optimizes the visibility of the floating element by choosing the placement
|
|
1502
|
+
* that has the most space available automatically, without needing to specify a
|
|
1503
|
+
* preferred placement. Alternative to `flip`.
|
|
1504
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
1505
|
+
*/
|
|
1506
|
+
const autoPlacement = function (options) {
|
|
1507
|
+
if (options === void 0) {
|
|
1508
|
+
options = {};
|
|
1509
|
+
}
|
|
1510
|
+
return {
|
|
1511
|
+
name: 'autoPlacement',
|
|
1512
|
+
options,
|
|
1513
|
+
async fn(state) {
|
|
1514
|
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
|
1515
|
+
const {
|
|
1516
|
+
rects,
|
|
1517
|
+
middlewareData,
|
|
1518
|
+
placement,
|
|
1519
|
+
platform,
|
|
1520
|
+
elements
|
|
1521
|
+
} = state;
|
|
1522
|
+
const {
|
|
1523
|
+
crossAxis = false,
|
|
1524
|
+
alignment,
|
|
1525
|
+
allowedPlacements = placements,
|
|
1526
|
+
autoAlignment = true,
|
|
1527
|
+
...detectOverflowOptions
|
|
1528
|
+
} = evaluate(options, state);
|
|
1529
|
+
const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
1530
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1531
|
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
1532
|
+
const currentPlacement = placements$1[currentIndex];
|
|
1533
|
+
if (currentPlacement == null) {
|
|
1534
|
+
return {};
|
|
1535
|
+
}
|
|
1536
|
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
1537
|
+
|
|
1538
|
+
// Make `computeCoords` start from the right place.
|
|
1539
|
+
if (placement !== currentPlacement) {
|
|
1540
|
+
return {
|
|
1541
|
+
reset: {
|
|
1542
|
+
placement: placements$1[0]
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
|
1547
|
+
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
|
|
1548
|
+
placement: currentPlacement,
|
|
1549
|
+
overflows: currentOverflows
|
|
1550
|
+
}];
|
|
1551
|
+
const nextPlacement = placements$1[currentIndex + 1];
|
|
1552
|
+
|
|
1553
|
+
// There are more placements to check.
|
|
1554
|
+
if (nextPlacement) {
|
|
1555
|
+
return {
|
|
1556
|
+
data: {
|
|
1557
|
+
index: currentIndex + 1,
|
|
1558
|
+
overflows: allOverflows
|
|
1559
|
+
},
|
|
1560
|
+
reset: {
|
|
1561
|
+
placement: nextPlacement
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
const placementsSortedByMostSpace = allOverflows.map(d => {
|
|
1566
|
+
const alignment = getAlignment(d.placement);
|
|
1567
|
+
return [d.placement, alignment && crossAxis ?
|
|
1568
|
+
// Check along the mainAxis and main crossAxis side.
|
|
1569
|
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
|
|
1570
|
+
// Check only the mainAxis.
|
|
1571
|
+
d.overflows[0], d.overflows];
|
|
1572
|
+
}).sort((a, b) => a[1] - b[1]);
|
|
1573
|
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
|
|
1574
|
+
// Aligned placements should not check their opposite crossAxis
|
|
1575
|
+
// side.
|
|
1576
|
+
getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
|
|
1577
|
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
|
1578
|
+
if (resetPlacement !== placement) {
|
|
1579
|
+
return {
|
|
1580
|
+
data: {
|
|
1581
|
+
index: currentIndex + 1,
|
|
1582
|
+
overflows: allOverflows
|
|
1583
|
+
},
|
|
1584
|
+
reset: {
|
|
1585
|
+
placement: resetPlacement
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1589
|
+
return {};
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
};
|
|
1593
|
+
|
|
1473
1594
|
/**
|
|
1474
1595
|
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1475
1596
|
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1476
1597
|
* clipping boundary. Alternative to `autoPlacement`.
|
|
1477
1598
|
* @see https://floating-ui.com/docs/flip
|
|
1478
1599
|
*/
|
|
1479
|
-
const flip = function (options) {
|
|
1600
|
+
const flip$1 = function (options) {
|
|
1480
1601
|
if (options === void 0) {
|
|
1481
1602
|
options = {};
|
|
1482
1603
|
}
|
|
@@ -1511,10 +1632,12 @@
|
|
|
1511
1632
|
return {};
|
|
1512
1633
|
}
|
|
1513
1634
|
const side = getSide(placement);
|
|
1635
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
1514
1636
|
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
1515
1637
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1516
1638
|
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1517
|
-
|
|
1639
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
|
1640
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
1518
1641
|
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
1519
1642
|
}
|
|
1520
1643
|
const placements = [initialPlacement, ...fallbackPlacements];
|
|
@@ -1560,8 +1683,17 @@
|
|
|
1560
1683
|
switch (fallbackStrategy) {
|
|
1561
1684
|
case 'bestFit':
|
|
1562
1685
|
{
|
|
1563
|
-
var _overflowsData$
|
|
1564
|
-
const placement = (_overflowsData$
|
|
1686
|
+
var _overflowsData$filter2;
|
|
1687
|
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
|
1688
|
+
if (hasFallbackAxisSideDirection) {
|
|
1689
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
1690
|
+
return currentSideAxis === initialSideAxis ||
|
|
1691
|
+
// Create a bias to the `y` side axis due to horizontal
|
|
1692
|
+
// reading directions favoring greater width.
|
|
1693
|
+
currentSideAxis === 'y';
|
|
1694
|
+
}
|
|
1695
|
+
return true;
|
|
1696
|
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
1565
1697
|
if (placement) {
|
|
1566
1698
|
resetPlacement = placement;
|
|
1567
1699
|
}
|
|
@@ -1585,8 +1717,209 @@
|
|
|
1585
1717
|
};
|
|
1586
1718
|
};
|
|
1587
1719
|
|
|
1720
|
+
function getSideOffsets(overflow, rect) {
|
|
1721
|
+
return {
|
|
1722
|
+
top: overflow.top - rect.height,
|
|
1723
|
+
right: overflow.right - rect.width,
|
|
1724
|
+
bottom: overflow.bottom - rect.height,
|
|
1725
|
+
left: overflow.left - rect.width
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1728
|
+
function isAnySideFullyClipped(overflow) {
|
|
1729
|
+
return sides.some(side => overflow[side] >= 0);
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
1733
|
+
* when it is not in the same clipping context as the reference element.
|
|
1734
|
+
* @see https://floating-ui.com/docs/hide
|
|
1735
|
+
*/
|
|
1736
|
+
const hide = function (options) {
|
|
1737
|
+
if (options === void 0) {
|
|
1738
|
+
options = {};
|
|
1739
|
+
}
|
|
1740
|
+
return {
|
|
1741
|
+
name: 'hide',
|
|
1742
|
+
options,
|
|
1743
|
+
async fn(state) {
|
|
1744
|
+
const {
|
|
1745
|
+
rects
|
|
1746
|
+
} = state;
|
|
1747
|
+
const {
|
|
1748
|
+
strategy = 'referenceHidden',
|
|
1749
|
+
...detectOverflowOptions
|
|
1750
|
+
} = evaluate(options, state);
|
|
1751
|
+
switch (strategy) {
|
|
1752
|
+
case 'referenceHidden':
|
|
1753
|
+
{
|
|
1754
|
+
const overflow = await detectOverflow(state, {
|
|
1755
|
+
...detectOverflowOptions,
|
|
1756
|
+
elementContext: 'reference'
|
|
1757
|
+
});
|
|
1758
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
1759
|
+
return {
|
|
1760
|
+
data: {
|
|
1761
|
+
referenceHiddenOffsets: offsets,
|
|
1762
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
case 'escaped':
|
|
1767
|
+
{
|
|
1768
|
+
const overflow = await detectOverflow(state, {
|
|
1769
|
+
...detectOverflowOptions,
|
|
1770
|
+
altBoundary: true
|
|
1771
|
+
});
|
|
1772
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
1773
|
+
return {
|
|
1774
|
+
data: {
|
|
1775
|
+
escapedOffsets: offsets,
|
|
1776
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
1777
|
+
}
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1780
|
+
default:
|
|
1781
|
+
{
|
|
1782
|
+
return {};
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1787
|
+
};
|
|
1788
|
+
|
|
1789
|
+
function getBoundingRect(rects) {
|
|
1790
|
+
const minX = min(...rects.map(rect => rect.left));
|
|
1791
|
+
const minY = min(...rects.map(rect => rect.top));
|
|
1792
|
+
const maxX = max(...rects.map(rect => rect.right));
|
|
1793
|
+
const maxY = max(...rects.map(rect => rect.bottom));
|
|
1794
|
+
return {
|
|
1795
|
+
x: minX,
|
|
1796
|
+
y: minY,
|
|
1797
|
+
width: maxX - minX,
|
|
1798
|
+
height: maxY - minY
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
function getRectsByLine(rects) {
|
|
1802
|
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
|
1803
|
+
const groups = [];
|
|
1804
|
+
let prevRect = null;
|
|
1805
|
+
for (let i = 0; i < sortedRects.length; i++) {
|
|
1806
|
+
const rect = sortedRects[i];
|
|
1807
|
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
|
1808
|
+
groups.push([rect]);
|
|
1809
|
+
} else {
|
|
1810
|
+
groups[groups.length - 1].push(rect);
|
|
1811
|
+
}
|
|
1812
|
+
prevRect = rect;
|
|
1813
|
+
}
|
|
1814
|
+
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Provides improved positioning for inline reference elements that can span
|
|
1818
|
+
* over multiple lines, such as hyperlinks or range selections.
|
|
1819
|
+
* @see https://floating-ui.com/docs/inline
|
|
1820
|
+
*/
|
|
1821
|
+
const inline = function (options) {
|
|
1822
|
+
if (options === void 0) {
|
|
1823
|
+
options = {};
|
|
1824
|
+
}
|
|
1825
|
+
return {
|
|
1826
|
+
name: 'inline',
|
|
1827
|
+
options,
|
|
1828
|
+
async fn(state) {
|
|
1829
|
+
const {
|
|
1830
|
+
placement,
|
|
1831
|
+
elements,
|
|
1832
|
+
rects,
|
|
1833
|
+
platform,
|
|
1834
|
+
strategy
|
|
1835
|
+
} = state;
|
|
1836
|
+
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
|
1837
|
+
// ClientRect's bounds, despite the event listener being triggered. A
|
|
1838
|
+
// padding of 2 seems to handle this issue.
|
|
1839
|
+
const {
|
|
1840
|
+
padding = 2,
|
|
1841
|
+
x,
|
|
1842
|
+
y
|
|
1843
|
+
} = evaluate(options, state);
|
|
1844
|
+
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
|
|
1845
|
+
const clientRects = getRectsByLine(nativeClientRects);
|
|
1846
|
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
1847
|
+
const paddingObject = getPaddingObject(padding);
|
|
1848
|
+
function getBoundingClientRect() {
|
|
1849
|
+
// There are two rects and they are disjoined.
|
|
1850
|
+
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
1851
|
+
// Find the first rect in which the point is fully inside.
|
|
1852
|
+
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
// There are 2 or more connected rects.
|
|
1856
|
+
if (clientRects.length >= 2) {
|
|
1857
|
+
if (getSideAxis(placement) === 'y') {
|
|
1858
|
+
const firstRect = clientRects[0];
|
|
1859
|
+
const lastRect = clientRects[clientRects.length - 1];
|
|
1860
|
+
const isTop = getSide(placement) === 'top';
|
|
1861
|
+
const top = firstRect.top;
|
|
1862
|
+
const bottom = lastRect.bottom;
|
|
1863
|
+
const left = isTop ? firstRect.left : lastRect.left;
|
|
1864
|
+
const right = isTop ? firstRect.right : lastRect.right;
|
|
1865
|
+
const width = right - left;
|
|
1866
|
+
const height = bottom - top;
|
|
1867
|
+
return {
|
|
1868
|
+
top,
|
|
1869
|
+
bottom,
|
|
1870
|
+
left,
|
|
1871
|
+
right,
|
|
1872
|
+
width,
|
|
1873
|
+
height,
|
|
1874
|
+
x: left,
|
|
1875
|
+
y: top
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
const isLeftSide = getSide(placement) === 'left';
|
|
1879
|
+
const maxRight = max(...clientRects.map(rect => rect.right));
|
|
1880
|
+
const minLeft = min(...clientRects.map(rect => rect.left));
|
|
1881
|
+
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
1882
|
+
const top = measureRects[0].top;
|
|
1883
|
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
1884
|
+
const left = minLeft;
|
|
1885
|
+
const right = maxRight;
|
|
1886
|
+
const width = right - left;
|
|
1887
|
+
const height = bottom - top;
|
|
1888
|
+
return {
|
|
1889
|
+
top,
|
|
1890
|
+
bottom,
|
|
1891
|
+
left,
|
|
1892
|
+
right,
|
|
1893
|
+
width,
|
|
1894
|
+
height,
|
|
1895
|
+
x: left,
|
|
1896
|
+
y: top
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
return fallback;
|
|
1900
|
+
}
|
|
1901
|
+
const resetRects = await platform.getElementRects({
|
|
1902
|
+
reference: {
|
|
1903
|
+
getBoundingClientRect
|
|
1904
|
+
},
|
|
1905
|
+
floating: elements.floating,
|
|
1906
|
+
strategy
|
|
1907
|
+
});
|
|
1908
|
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
1909
|
+
return {
|
|
1910
|
+
reset: {
|
|
1911
|
+
rects: resetRects
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
return {};
|
|
1916
|
+
}
|
|
1917
|
+
};
|
|
1918
|
+
};
|
|
1919
|
+
|
|
1588
1920
|
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
1589
1921
|
// Derivable.
|
|
1922
|
+
|
|
1590
1923
|
async function convertValueToCoords(state, options) {
|
|
1591
1924
|
const {
|
|
1592
1925
|
placement,
|
|
@@ -1611,10 +1944,9 @@
|
|
|
1611
1944
|
crossAxis: 0,
|
|
1612
1945
|
alignmentAxis: null
|
|
1613
1946
|
} : {
|
|
1614
|
-
mainAxis: 0,
|
|
1615
|
-
crossAxis: 0,
|
|
1616
|
-
alignmentAxis:
|
|
1617
|
-
...rawValue
|
|
1947
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
1948
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
1949
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
1618
1950
|
};
|
|
1619
1951
|
if (alignment && typeof alignmentAxis === 'number') {
|
|
1620
1952
|
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
@@ -1635,7 +1967,7 @@
|
|
|
1635
1967
|
* object may be passed.
|
|
1636
1968
|
* @see https://floating-ui.com/docs/offset
|
|
1637
1969
|
*/
|
|
1638
|
-
const offset = function (options) {
|
|
1970
|
+
const offset$1 = function (options) {
|
|
1639
1971
|
if (options === void 0) {
|
|
1640
1972
|
options = 0;
|
|
1641
1973
|
}
|
|
@@ -1643,15 +1975,27 @@
|
|
|
1643
1975
|
name: 'offset',
|
|
1644
1976
|
options,
|
|
1645
1977
|
async fn(state) {
|
|
1978
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
1646
1979
|
const {
|
|
1647
1980
|
x,
|
|
1648
|
-
y
|
|
1981
|
+
y,
|
|
1982
|
+
placement,
|
|
1983
|
+
middlewareData
|
|
1649
1984
|
} = state;
|
|
1650
1985
|
const diffCoords = await convertValueToCoords(state, options);
|
|
1986
|
+
|
|
1987
|
+
// If the placement is the same and the arrow caused an alignment offset
|
|
1988
|
+
// then we don't need to change the positioning coordinates.
|
|
1989
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1990
|
+
return {};
|
|
1991
|
+
}
|
|
1651
1992
|
return {
|
|
1652
1993
|
x: x + diffCoords.x,
|
|
1653
1994
|
y: y + diffCoords.y,
|
|
1654
|
-
data:
|
|
1995
|
+
data: {
|
|
1996
|
+
...diffCoords,
|
|
1997
|
+
placement
|
|
1998
|
+
}
|
|
1655
1999
|
};
|
|
1656
2000
|
}
|
|
1657
2001
|
};
|
|
@@ -1662,7 +2006,7 @@
|
|
|
1662
2006
|
* keep it in view when it will overflow the clipping boundary.
|
|
1663
2007
|
* @see https://floating-ui.com/docs/shift
|
|
1664
2008
|
*/
|
|
1665
|
-
const shift = function (options) {
|
|
2009
|
+
const shift$1 = function (options) {
|
|
1666
2010
|
if (options === void 0) {
|
|
1667
2011
|
options = {};
|
|
1668
2012
|
}
|
|
@@ -1724,13 +2068,172 @@
|
|
|
1724
2068
|
...limitedCoords,
|
|
1725
2069
|
data: {
|
|
1726
2070
|
x: limitedCoords.x - x,
|
|
1727
|
-
y: limitedCoords.y - y
|
|
2071
|
+
y: limitedCoords.y - y,
|
|
2072
|
+
enabled: {
|
|
2073
|
+
[mainAxis]: checkMainAxis,
|
|
2074
|
+
[crossAxis]: checkCrossAxis
|
|
2075
|
+
}
|
|
1728
2076
|
}
|
|
1729
2077
|
};
|
|
1730
2078
|
}
|
|
1731
2079
|
};
|
|
1732
2080
|
};
|
|
2081
|
+
/**
|
|
2082
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
2083
|
+
*/
|
|
2084
|
+
const limitShift = function (options) {
|
|
2085
|
+
if (options === void 0) {
|
|
2086
|
+
options = {};
|
|
2087
|
+
}
|
|
2088
|
+
return {
|
|
2089
|
+
options,
|
|
2090
|
+
fn(state) {
|
|
2091
|
+
const {
|
|
2092
|
+
x,
|
|
2093
|
+
y,
|
|
2094
|
+
placement,
|
|
2095
|
+
rects,
|
|
2096
|
+
middlewareData
|
|
2097
|
+
} = state;
|
|
2098
|
+
const {
|
|
2099
|
+
offset = 0,
|
|
2100
|
+
mainAxis: checkMainAxis = true,
|
|
2101
|
+
crossAxis: checkCrossAxis = true
|
|
2102
|
+
} = evaluate(options, state);
|
|
2103
|
+
const coords = {
|
|
2104
|
+
x,
|
|
2105
|
+
y
|
|
2106
|
+
};
|
|
2107
|
+
const crossAxis = getSideAxis(placement);
|
|
2108
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
2109
|
+
let mainAxisCoord = coords[mainAxis];
|
|
2110
|
+
let crossAxisCoord = coords[crossAxis];
|
|
2111
|
+
const rawOffset = evaluate(offset, state);
|
|
2112
|
+
const computedOffset = typeof rawOffset === 'number' ? {
|
|
2113
|
+
mainAxis: rawOffset,
|
|
2114
|
+
crossAxis: 0
|
|
2115
|
+
} : {
|
|
2116
|
+
mainAxis: 0,
|
|
2117
|
+
crossAxis: 0,
|
|
2118
|
+
...rawOffset
|
|
2119
|
+
};
|
|
2120
|
+
if (checkMainAxis) {
|
|
2121
|
+
const len = mainAxis === 'y' ? 'height' : 'width';
|
|
2122
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
|
2123
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
|
2124
|
+
if (mainAxisCoord < limitMin) {
|
|
2125
|
+
mainAxisCoord = limitMin;
|
|
2126
|
+
} else if (mainAxisCoord > limitMax) {
|
|
2127
|
+
mainAxisCoord = limitMax;
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
if (checkCrossAxis) {
|
|
2131
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
|
2132
|
+
const len = mainAxis === 'y' ? 'width' : 'height';
|
|
2133
|
+
const isOriginSide = ['top', 'left'].includes(getSide(placement));
|
|
2134
|
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
|
2135
|
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
|
2136
|
+
if (crossAxisCoord < limitMin) {
|
|
2137
|
+
crossAxisCoord = limitMin;
|
|
2138
|
+
} else if (crossAxisCoord > limitMax) {
|
|
2139
|
+
crossAxisCoord = limitMax;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
return {
|
|
2143
|
+
[mainAxis]: mainAxisCoord,
|
|
2144
|
+
[crossAxis]: crossAxisCoord
|
|
2145
|
+
};
|
|
2146
|
+
}
|
|
2147
|
+
};
|
|
2148
|
+
};
|
|
1733
2149
|
|
|
2150
|
+
/**
|
|
2151
|
+
* Provides data that allows you to change the size of the floating element —
|
|
2152
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
2153
|
+
* width of the reference element.
|
|
2154
|
+
* @see https://floating-ui.com/docs/size
|
|
2155
|
+
*/
|
|
2156
|
+
const size = function (options) {
|
|
2157
|
+
if (options === void 0) {
|
|
2158
|
+
options = {};
|
|
2159
|
+
}
|
|
2160
|
+
return {
|
|
2161
|
+
name: 'size',
|
|
2162
|
+
options,
|
|
2163
|
+
async fn(state) {
|
|
2164
|
+
var _state$middlewareData, _state$middlewareData2;
|
|
2165
|
+
const {
|
|
2166
|
+
placement,
|
|
2167
|
+
rects,
|
|
2168
|
+
platform,
|
|
2169
|
+
elements
|
|
2170
|
+
} = state;
|
|
2171
|
+
const {
|
|
2172
|
+
apply = () => {},
|
|
2173
|
+
...detectOverflowOptions
|
|
2174
|
+
} = evaluate(options, state);
|
|
2175
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
2176
|
+
const side = getSide(placement);
|
|
2177
|
+
const alignment = getAlignment(placement);
|
|
2178
|
+
const isYAxis = getSideAxis(placement) === 'y';
|
|
2179
|
+
const {
|
|
2180
|
+
width,
|
|
2181
|
+
height
|
|
2182
|
+
} = rects.floating;
|
|
2183
|
+
let heightSide;
|
|
2184
|
+
let widthSide;
|
|
2185
|
+
if (side === 'top' || side === 'bottom') {
|
|
2186
|
+
heightSide = side;
|
|
2187
|
+
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
|
2188
|
+
} else {
|
|
2189
|
+
widthSide = side;
|
|
2190
|
+
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
|
2191
|
+
}
|
|
2192
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
2193
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
2194
|
+
const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
|
|
2195
|
+
const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
|
|
2196
|
+
const noShift = !state.middlewareData.shift;
|
|
2197
|
+
let availableHeight = overflowAvailableHeight;
|
|
2198
|
+
let availableWidth = overflowAvailableWidth;
|
|
2199
|
+
if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
|
|
2200
|
+
availableWidth = maximumClippingWidth;
|
|
2201
|
+
}
|
|
2202
|
+
if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
|
|
2203
|
+
availableHeight = maximumClippingHeight;
|
|
2204
|
+
}
|
|
2205
|
+
if (noShift && !alignment) {
|
|
2206
|
+
const xMin = max(overflow.left, 0);
|
|
2207
|
+
const xMax = max(overflow.right, 0);
|
|
2208
|
+
const yMin = max(overflow.top, 0);
|
|
2209
|
+
const yMax = max(overflow.bottom, 0);
|
|
2210
|
+
if (isYAxis) {
|
|
2211
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
2212
|
+
} else {
|
|
2213
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
await apply({
|
|
2217
|
+
...state,
|
|
2218
|
+
availableWidth,
|
|
2219
|
+
availableHeight
|
|
2220
|
+
});
|
|
2221
|
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
2222
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
2223
|
+
return {
|
|
2224
|
+
reset: {
|
|
2225
|
+
rects: true
|
|
2226
|
+
}
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
return {};
|
|
2230
|
+
}
|
|
2231
|
+
};
|
|
2232
|
+
};
|
|
2233
|
+
|
|
2234
|
+
function hasWindow() {
|
|
2235
|
+
return typeof window !== 'undefined';
|
|
2236
|
+
}
|
|
1734
2237
|
function getNodeName(node) {
|
|
1735
2238
|
if (isNode(node)) {
|
|
1736
2239
|
return (node.nodeName || '').toLowerCase();
|
|
@@ -1742,24 +2245,32 @@
|
|
|
1742
2245
|
}
|
|
1743
2246
|
function getWindow(node) {
|
|
1744
2247
|
var _node$ownerDocument;
|
|
1745
|
-
return (node == null
|
|
2248
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
1746
2249
|
}
|
|
1747
2250
|
function getDocumentElement(node) {
|
|
1748
2251
|
var _ref;
|
|
1749
2252
|
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
1750
2253
|
}
|
|
1751
2254
|
function isNode(value) {
|
|
2255
|
+
if (!hasWindow()) {
|
|
2256
|
+
return false;
|
|
2257
|
+
}
|
|
1752
2258
|
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
1753
2259
|
}
|
|
1754
2260
|
function isElement(value) {
|
|
2261
|
+
if (!hasWindow()) {
|
|
2262
|
+
return false;
|
|
2263
|
+
}
|
|
1755
2264
|
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
1756
2265
|
}
|
|
1757
2266
|
function isHTMLElement(value) {
|
|
2267
|
+
if (!hasWindow()) {
|
|
2268
|
+
return false;
|
|
2269
|
+
}
|
|
1758
2270
|
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
1759
2271
|
}
|
|
1760
2272
|
function isShadowRoot(value) {
|
|
1761
|
-
|
|
1762
|
-
if (typeof ShadowRoot === 'undefined') {
|
|
2273
|
+
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
|
1763
2274
|
return false;
|
|
1764
2275
|
}
|
|
1765
2276
|
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
@@ -1776,21 +2287,32 @@
|
|
|
1776
2287
|
function isTableElement(element) {
|
|
1777
2288
|
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
1778
2289
|
}
|
|
1779
|
-
function
|
|
2290
|
+
function isTopLayer(element) {
|
|
2291
|
+
return [':popover-open', ':modal'].some(selector => {
|
|
2292
|
+
try {
|
|
2293
|
+
return element.matches(selector);
|
|
2294
|
+
} catch (e) {
|
|
2295
|
+
return false;
|
|
2296
|
+
}
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
function isContainingBlock(elementOrCss) {
|
|
1780
2300
|
const webkit = isWebKit();
|
|
1781
|
-
const css = getComputedStyle(
|
|
2301
|
+
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
|
1782
2302
|
|
|
1783
2303
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1784
|
-
|
|
2304
|
+
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
|
2305
|
+
return ['transform', 'translate', 'scale', 'rotate', 'perspective'].some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
|
|
1785
2306
|
}
|
|
1786
2307
|
function getContainingBlock(element) {
|
|
1787
2308
|
let currentNode = getParentNode(element);
|
|
1788
2309
|
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1789
2310
|
if (isContainingBlock(currentNode)) {
|
|
1790
2311
|
return currentNode;
|
|
1791
|
-
} else {
|
|
1792
|
-
|
|
2312
|
+
} else if (isTopLayer(currentNode)) {
|
|
2313
|
+
return null;
|
|
1793
2314
|
}
|
|
2315
|
+
currentNode = getParentNode(currentNode);
|
|
1794
2316
|
}
|
|
1795
2317
|
return null;
|
|
1796
2318
|
}
|
|
@@ -1812,8 +2334,8 @@
|
|
|
1812
2334
|
};
|
|
1813
2335
|
}
|
|
1814
2336
|
return {
|
|
1815
|
-
scrollLeft: element.
|
|
1816
|
-
scrollTop: element.
|
|
2337
|
+
scrollLeft: element.scrollX,
|
|
2338
|
+
scrollTop: element.scrollY
|
|
1817
2339
|
};
|
|
1818
2340
|
}
|
|
1819
2341
|
function getParentNode(node) {
|
|
@@ -1853,10 +2375,14 @@
|
|
|
1853
2375
|
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
1854
2376
|
const win = getWindow(scrollableAncestor);
|
|
1855
2377
|
if (isBody) {
|
|
1856
|
-
|
|
2378
|
+
const frameElement = getFrameElement(win);
|
|
2379
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1857
2380
|
}
|
|
1858
2381
|
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
1859
2382
|
}
|
|
2383
|
+
function getFrameElement(win) {
|
|
2384
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
2385
|
+
}
|
|
1860
2386
|
|
|
1861
2387
|
function getCssDimensions(element) {
|
|
1862
2388
|
const css = getComputedStyle(element);
|
|
@@ -1959,8 +2485,9 @@
|
|
|
1959
2485
|
if (domElement) {
|
|
1960
2486
|
const win = getWindow(domElement);
|
|
1961
2487
|
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1962
|
-
let
|
|
1963
|
-
|
|
2488
|
+
let currentWin = win;
|
|
2489
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
2490
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1964
2491
|
const iframeScale = getScale(currentIFrame);
|
|
1965
2492
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1966
2493
|
const css = getComputedStyle(currentIFrame);
|
|
@@ -1972,7 +2499,8 @@
|
|
|
1972
2499
|
height *= iframeScale.y;
|
|
1973
2500
|
x += left;
|
|
1974
2501
|
y += top;
|
|
1975
|
-
|
|
2502
|
+
currentWin = getWindow(currentIFrame);
|
|
2503
|
+
currentIFrame = getFrameElement(currentWin);
|
|
1976
2504
|
}
|
|
1977
2505
|
}
|
|
1978
2506
|
return rectToClientRect({
|
|
@@ -1983,15 +2511,42 @@
|
|
|
1983
2511
|
});
|
|
1984
2512
|
}
|
|
1985
2513
|
|
|
2514
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
2515
|
+
// incorrect for RTL.
|
|
2516
|
+
function getWindowScrollBarX(element, rect) {
|
|
2517
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
2518
|
+
if (!rect) {
|
|
2519
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
2520
|
+
}
|
|
2521
|
+
return rect.left + leftScroll;
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
|
|
2525
|
+
if (ignoreScrollbarX === void 0) {
|
|
2526
|
+
ignoreScrollbarX = false;
|
|
2527
|
+
}
|
|
2528
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
2529
|
+
const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
|
|
2530
|
+
// RTL <body> scrollbar.
|
|
2531
|
+
getWindowScrollBarX(documentElement, htmlRect));
|
|
2532
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
2533
|
+
return {
|
|
2534
|
+
x,
|
|
2535
|
+
y
|
|
2536
|
+
};
|
|
2537
|
+
}
|
|
2538
|
+
|
|
1986
2539
|
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1987
2540
|
let {
|
|
2541
|
+
elements,
|
|
1988
2542
|
rect,
|
|
1989
2543
|
offsetParent,
|
|
1990
2544
|
strategy
|
|
1991
2545
|
} = _ref;
|
|
1992
|
-
const
|
|
2546
|
+
const isFixed = strategy === 'fixed';
|
|
1993
2547
|
const documentElement = getDocumentElement(offsetParent);
|
|
1994
|
-
|
|
2548
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
2549
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1995
2550
|
return rect;
|
|
1996
2551
|
}
|
|
1997
2552
|
let scroll = {
|
|
@@ -2000,7 +2555,8 @@
|
|
|
2000
2555
|
};
|
|
2001
2556
|
let scale = createCoords(1);
|
|
2002
2557
|
const offsets = createCoords(0);
|
|
2003
|
-
|
|
2558
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2559
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
2004
2560
|
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2005
2561
|
scroll = getNodeScroll(offsetParent);
|
|
2006
2562
|
}
|
|
@@ -2011,11 +2567,12 @@
|
|
|
2011
2567
|
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2012
2568
|
}
|
|
2013
2569
|
}
|
|
2570
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
|
|
2014
2571
|
return {
|
|
2015
2572
|
width: rect.width * scale.x,
|
|
2016
2573
|
height: rect.height * scale.y,
|
|
2017
|
-
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
|
|
2018
|
-
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
2574
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
2575
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
2019
2576
|
};
|
|
2020
2577
|
}
|
|
2021
2578
|
|
|
@@ -2023,12 +2580,6 @@
|
|
|
2023
2580
|
return Array.from(element.getClientRects());
|
|
2024
2581
|
}
|
|
2025
2582
|
|
|
2026
|
-
function getWindowScrollBarX(element) {
|
|
2027
|
-
// If <html> has a CSS width greater than the viewport, then this will be
|
|
2028
|
-
// incorrect for RTL.
|
|
2029
|
-
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
2030
|
-
}
|
|
2031
|
-
|
|
2032
2583
|
// Gets the entire size of the scrollable document area, even extending outside
|
|
2033
2584
|
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
2034
2585
|
function getDocumentRect(element) {
|
|
@@ -2103,9 +2654,10 @@
|
|
|
2103
2654
|
} else {
|
|
2104
2655
|
const visualOffsets = getVisualOffsets(element);
|
|
2105
2656
|
rect = {
|
|
2106
|
-
...clippingAncestor,
|
|
2107
2657
|
x: clippingAncestor.x - visualOffsets.x,
|
|
2108
|
-
y: clippingAncestor.y - visualOffsets.y
|
|
2658
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
2659
|
+
width: clippingAncestor.width,
|
|
2660
|
+
height: clippingAncestor.height
|
|
2109
2661
|
};
|
|
2110
2662
|
}
|
|
2111
2663
|
return rectToClientRect(rect);
|
|
@@ -2161,7 +2713,7 @@
|
|
|
2161
2713
|
rootBoundary,
|
|
2162
2714
|
strategy
|
|
2163
2715
|
} = _ref;
|
|
2164
|
-
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
2716
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
2165
2717
|
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
2166
2718
|
const firstClippingAncestor = clippingAncestors[0];
|
|
2167
2719
|
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
@@ -2181,7 +2733,14 @@
|
|
|
2181
2733
|
}
|
|
2182
2734
|
|
|
2183
2735
|
function getDimensions(element) {
|
|
2184
|
-
|
|
2736
|
+
const {
|
|
2737
|
+
width,
|
|
2738
|
+
height
|
|
2739
|
+
} = getCssDimensions(element);
|
|
2740
|
+
return {
|
|
2741
|
+
width,
|
|
2742
|
+
height
|
|
2743
|
+
};
|
|
2185
2744
|
}
|
|
2186
2745
|
|
|
2187
2746
|
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
@@ -2203,17 +2762,26 @@
|
|
|
2203
2762
|
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2204
2763
|
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2205
2764
|
} else if (documentElement) {
|
|
2765
|
+
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
|
2766
|
+
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
|
2206
2767
|
offsets.x = getWindowScrollBarX(documentElement);
|
|
2207
2768
|
}
|
|
2208
2769
|
}
|
|
2770
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
2771
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
2772
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
2209
2773
|
return {
|
|
2210
|
-
x
|
|
2211
|
-
y
|
|
2774
|
+
x,
|
|
2775
|
+
y,
|
|
2212
2776
|
width: rect.width,
|
|
2213
2777
|
height: rect.height
|
|
2214
2778
|
};
|
|
2215
2779
|
}
|
|
2216
2780
|
|
|
2781
|
+
function isStaticPositioned(element) {
|
|
2782
|
+
return getComputedStyle(element).position === 'static';
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2217
2785
|
function getTrueOffsetParent(element, polyfill) {
|
|
2218
2786
|
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
2219
2787
|
return null;
|
|
@@ -2221,40 +2789,56 @@
|
|
|
2221
2789
|
if (polyfill) {
|
|
2222
2790
|
return polyfill(element);
|
|
2223
2791
|
}
|
|
2224
|
-
|
|
2792
|
+
let rawOffsetParent = element.offsetParent;
|
|
2793
|
+
|
|
2794
|
+
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
|
2795
|
+
// while Chrome and Safari return the <body> element. The <body> element must
|
|
2796
|
+
// be used to perform the correct calculations even if the <html> element is
|
|
2797
|
+
// non-static.
|
|
2798
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
2799
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
2800
|
+
}
|
|
2801
|
+
return rawOffsetParent;
|
|
2225
2802
|
}
|
|
2226
2803
|
|
|
2227
2804
|
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
2228
2805
|
// such as table ancestors and cross browser bugs.
|
|
2229
2806
|
function getOffsetParent(element, polyfill) {
|
|
2230
|
-
const
|
|
2807
|
+
const win = getWindow(element);
|
|
2808
|
+
if (isTopLayer(element)) {
|
|
2809
|
+
return win;
|
|
2810
|
+
}
|
|
2231
2811
|
if (!isHTMLElement(element)) {
|
|
2232
|
-
|
|
2812
|
+
let svgOffsetParent = getParentNode(element);
|
|
2813
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
2814
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
2815
|
+
return svgOffsetParent;
|
|
2816
|
+
}
|
|
2817
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
2818
|
+
}
|
|
2819
|
+
return win;
|
|
2233
2820
|
}
|
|
2234
2821
|
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
2235
|
-
while (offsetParent && isTableElement(offsetParent) &&
|
|
2822
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
2236
2823
|
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
2237
2824
|
}
|
|
2238
|
-
if (offsetParent && (
|
|
2239
|
-
return
|
|
2825
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
2826
|
+
return win;
|
|
2240
2827
|
}
|
|
2241
|
-
return offsetParent || getContainingBlock(element) ||
|
|
2828
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
2242
2829
|
}
|
|
2243
2830
|
|
|
2244
|
-
const getElementRects = async function (
|
|
2245
|
-
let {
|
|
2246
|
-
reference,
|
|
2247
|
-
floating,
|
|
2248
|
-
strategy
|
|
2249
|
-
} = _ref;
|
|
2831
|
+
const getElementRects = async function (data) {
|
|
2250
2832
|
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
2251
2833
|
const getDimensionsFn = this.getDimensions;
|
|
2834
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
2252
2835
|
return {
|
|
2253
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
2836
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
2254
2837
|
floating: {
|
|
2255
2838
|
x: 0,
|
|
2256
2839
|
y: 0,
|
|
2257
|
-
|
|
2840
|
+
width: floatingDimensions.width,
|
|
2841
|
+
height: floatingDimensions.height
|
|
2258
2842
|
}
|
|
2259
2843
|
};
|
|
2260
2844
|
};
|
|
@@ -2276,10 +2860,75 @@
|
|
|
2276
2860
|
isRTL
|
|
2277
2861
|
};
|
|
2278
2862
|
|
|
2863
|
+
/**
|
|
2864
|
+
* Modifies the placement by translating the floating element along the
|
|
2865
|
+
* specified axes.
|
|
2866
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
2867
|
+
* object may be passed.
|
|
2868
|
+
* @see https://floating-ui.com/docs/offset
|
|
2869
|
+
*/
|
|
2870
|
+
const offset = offset$1;
|
|
2871
|
+
|
|
2872
|
+
/**
|
|
2873
|
+
* Optimizes the visibility of the floating element by choosing the placement
|
|
2874
|
+
* that has the most space available automatically, without needing to specify a
|
|
2875
|
+
* preferred placement. Alternative to `flip`.
|
|
2876
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
2877
|
+
*/
|
|
2878
|
+
autoPlacement;
|
|
2879
|
+
|
|
2880
|
+
/**
|
|
2881
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
2882
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
2883
|
+
* @see https://floating-ui.com/docs/shift
|
|
2884
|
+
*/
|
|
2885
|
+
const shift = shift$1;
|
|
2886
|
+
|
|
2887
|
+
/**
|
|
2888
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
2889
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
2890
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
2891
|
+
* @see https://floating-ui.com/docs/flip
|
|
2892
|
+
*/
|
|
2893
|
+
const flip = flip$1;
|
|
2894
|
+
|
|
2895
|
+
/**
|
|
2896
|
+
* Provides data that allows you to change the size of the floating element —
|
|
2897
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
2898
|
+
* width of the reference element.
|
|
2899
|
+
* @see https://floating-ui.com/docs/size
|
|
2900
|
+
*/
|
|
2901
|
+
size;
|
|
2902
|
+
|
|
2903
|
+
/**
|
|
2904
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
2905
|
+
* when it is not in the same clipping context as the reference element.
|
|
2906
|
+
* @see https://floating-ui.com/docs/hide
|
|
2907
|
+
*/
|
|
2908
|
+
hide;
|
|
2909
|
+
|
|
2910
|
+
/**
|
|
2911
|
+
* Provides data to position an inner element of the floating element so that it
|
|
2912
|
+
* appears centered to the reference element.
|
|
2913
|
+
* @see https://floating-ui.com/docs/arrow
|
|
2914
|
+
*/
|
|
2915
|
+
const arrow = arrow$1;
|
|
2916
|
+
|
|
2917
|
+
/**
|
|
2918
|
+
* Provides improved positioning for inline reference elements that can span
|
|
2919
|
+
* over multiple lines, such as hyperlinks or range selections.
|
|
2920
|
+
* @see https://floating-ui.com/docs/inline
|
|
2921
|
+
*/
|
|
2922
|
+
inline;
|
|
2923
|
+
|
|
2924
|
+
/**
|
|
2925
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
2926
|
+
*/
|
|
2927
|
+
limitShift;
|
|
2928
|
+
|
|
2279
2929
|
/**
|
|
2280
2930
|
* Computes the `x` and `y` coordinates that will place the floating element
|
|
2281
|
-
* next to a reference element
|
|
2282
|
-
* strategy.
|
|
2931
|
+
* next to a given reference element.
|
|
2283
2932
|
*/
|
|
2284
2933
|
const computePosition = (reference, floating, options) => {
|
|
2285
2934
|
// This caches the expensive `getClippingElementAncestors` function so that
|
|
@@ -2302,7 +2951,6 @@
|
|
|
2302
2951
|
|
|
2303
2952
|
var selected = {};
|
|
2304
2953
|
function highlight(item, node, keys) {
|
|
2305
|
-
item.id;
|
|
2306
2954
|
var rectEle = getOptimizedBoundingRectEle(node);
|
|
2307
2955
|
if (!item.highlightBox) {
|
|
2308
2956
|
var box = HighlightBox(rectEle, colors.highlight);
|
|
@@ -2607,13 +3255,13 @@
|
|
|
2607
3255
|
ignoreMergedEleUniqueIds.push(child.uniqueID);
|
|
2608
3256
|
}
|
|
2609
3257
|
var txt = child.textContent;
|
|
2610
|
-
if (nodeI18nMeta && nodeI18nMeta
|
|
3258
|
+
if (nodeI18nMeta && nodeI18nMeta.html && i < node.childNodes.length - 1) {
|
|
2611
3259
|
merge.push({
|
|
2612
3260
|
childIndex: i,
|
|
2613
3261
|
child: child,
|
|
2614
3262
|
text: txt
|
|
2615
3263
|
});
|
|
2616
|
-
} else if (nodeI18nMeta && nodeI18nMeta
|
|
3264
|
+
} else if (nodeI18nMeta && nodeI18nMeta.html && i === node.childNodes.length - 1) {
|
|
2617
3265
|
merge.push({
|
|
2618
3266
|
childIndex: i,
|
|
2619
3267
|
child: child,
|
|
@@ -2622,7 +3270,7 @@
|
|
|
2622
3270
|
storeIfQualifiedKey(node.uniqueID, null, 'html', nodeI18nMeta, node, merge, node.innerHTML);
|
|
2623
3271
|
merge = [];
|
|
2624
3272
|
} else if (txt) {
|
|
2625
|
-
if (nodeI18nMeta && nodeI18nMeta
|
|
3273
|
+
if (nodeI18nMeta && nodeI18nMeta.text) {
|
|
2626
3274
|
storeIfQualifiedKey(node.uniqueID, null, 'text', nodeI18nMeta, node, undefined, txt);
|
|
2627
3275
|
} else if (child.nodeName === '#text' && !containsOnlySpaces(txt)) {
|
|
2628
3276
|
uninstrumentedStore.save(node.uniqueID, 'text', node, txt);
|
|
@@ -2777,7 +3425,9 @@
|
|
|
2777
3425
|
}
|
|
2778
3426
|
}
|
|
2779
3427
|
function dragMouseDown(e) {
|
|
2780
|
-
if (!overlay)
|
|
3428
|
+
if (!overlay) {
|
|
3429
|
+
overlay = document.getElementById('i18next-editor-popup-overlay');
|
|
3430
|
+
}
|
|
2781
3431
|
if (overlay) overlay.style.display = 'block';
|
|
2782
3432
|
stopMouseTracking();
|
|
2783
3433
|
elmnt = this.parentPopup;
|
|
@@ -2804,7 +3454,7 @@
|
|
|
2804
3454
|
startMouseTracking();
|
|
2805
3455
|
if (overlay) overlay.style.display = 'none';
|
|
2806
3456
|
var ele = document.getElementById('i18next-editor-popup');
|
|
2807
|
-
localStorage.setItem('locize_popup_pos', JSON.stringify({
|
|
3457
|
+
window.localStorage.setItem('locize_popup_pos', JSON.stringify({
|
|
2808
3458
|
top: parseInt(document.defaultView.getComputedStyle(ele).top, 10),
|
|
2809
3459
|
left: parseInt(document.defaultView.getComputedStyle(ele).left, 10)
|
|
2810
3460
|
}));
|
|
@@ -2844,7 +3494,9 @@
|
|
|
2844
3494
|
}
|
|
2845
3495
|
function initDrag(e) {
|
|
2846
3496
|
stopMouseTracking();
|
|
2847
|
-
if (!overlay)
|
|
3497
|
+
if (!overlay) {
|
|
3498
|
+
overlay = document.getElementById('i18next-editor-popup-overlay');
|
|
3499
|
+
}
|
|
2848
3500
|
if (overlay) overlay.style.display = 'block';
|
|
2849
3501
|
element = this.parentPopup;
|
|
2850
3502
|
startX = e.clientX;
|
|
@@ -2862,7 +3514,7 @@
|
|
|
2862
3514
|
startMouseTracking();
|
|
2863
3515
|
if (overlay) overlay.style.display = 'none';
|
|
2864
3516
|
var ele = document.getElementById('i18next-editor-popup');
|
|
2865
|
-
localStorage.setItem('locize_popup_size', JSON.stringify({
|
|
3517
|
+
window.localStorage.setItem('locize_popup_size', JSON.stringify({
|
|
2866
3518
|
width: parseInt(document.defaultView.getComputedStyle(ele).width, 10),
|
|
2867
3519
|
height: parseInt(document.defaultView.getComputedStyle(ele).height, 10)
|
|
2868
3520
|
}));
|
|
@@ -2900,7 +3552,9 @@
|
|
|
2900
3552
|
if (Array.isArray(fallback)) return fallback[fallback.length - 1];
|
|
2901
3553
|
if (fallback && fallback["default"]) {
|
|
2902
3554
|
if (typeof fallback["default"] === 'string') return fallback;
|
|
2903
|
-
if (Array.isArray(fallback["default"]))
|
|
3555
|
+
if (Array.isArray(fallback["default"])) {
|
|
3556
|
+
return fallback["default"][fallback["default"].length - 1];
|
|
3557
|
+
}
|
|
2904
3558
|
}
|
|
2905
3559
|
if (typeof fallback === 'function') {
|
|
2906
3560
|
var res = fallback(i18n.resolvedLanguage);
|
|
@@ -2957,21 +3611,13 @@
|
|
|
2957
3611
|
getResource: function getResource(lng, ns, key) {
|
|
2958
3612
|
return {};
|
|
2959
3613
|
},
|
|
2960
|
-
setResource: function setResource(lng, ns, key, value) {
|
|
2961
|
-
return;
|
|
2962
|
-
},
|
|
3614
|
+
setResource: function setResource(lng, ns, key, value) {},
|
|
2963
3615
|
getResourceBundle: function getResourceBundle(lng, ns, cb) {
|
|
2964
3616
|
cb({});
|
|
2965
3617
|
},
|
|
2966
|
-
getDefaultNS: function getDefaultNS() {
|
|
2967
|
-
|
|
2968
|
-
},
|
|
2969
|
-
getLng: function getLng() {
|
|
2970
|
-
return;
|
|
2971
|
-
},
|
|
2972
|
-
getSourceLng: function getSourceLng() {
|
|
2973
|
-
return;
|
|
2974
|
-
},
|
|
3618
|
+
getDefaultNS: function getDefaultNS() {},
|
|
3619
|
+
getLng: function getLng() {},
|
|
3620
|
+
getSourceLng: function getSourceLng() {},
|
|
2975
3621
|
getLocizeDetails: function getLocizeDetails() {
|
|
2976
3622
|
return {};
|
|
2977
3623
|
},
|
|
@@ -2985,10 +3631,6 @@
|
|
|
2985
3631
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2986
3632
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2987
3633
|
var dummyImplementation = getImplementation();
|
|
2988
|
-
var isInIframe = typeof window !== 'undefined';
|
|
2989
|
-
try {
|
|
2990
|
-
isInIframe = self !== top;
|
|
2991
|
-
} catch (e) {}
|
|
2992
3634
|
function start() {
|
|
2993
3635
|
var implementation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dummyImplementation;
|
|
2994
3636
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
@@ -3050,7 +3692,7 @@
|
|
|
3050
3692
|
}
|
|
3051
3693
|
}
|
|
3052
3694
|
if (document.body) return continueToStart();
|
|
3053
|
-
window.addEventListener('load', function () {
|
|
3695
|
+
if (typeof window !== 'undefined') window.addEventListener('load', function () {
|
|
3054
3696
|
return continueToStart();
|
|
3055
3697
|
});
|
|
3056
3698
|
}
|
|
@@ -3076,7 +3718,8 @@
|
|
|
3076
3718
|
var options = i18n.options;
|
|
3077
3719
|
i18next = i18n;
|
|
3078
3720
|
var impl = getImplementation$1(i18n);
|
|
3079
|
-
|
|
3721
|
+
var showInContext = opt.show || getQsParameterByName(opt.qsProp) === 'true';
|
|
3722
|
+
if (isInIframe || showInContext) configurePostProcessor(i18next, options);
|
|
3080
3723
|
start(impl, opt);
|
|
3081
3724
|
}
|
|
3082
3725
|
};
|
|
@@ -3090,7 +3733,9 @@
|
|
|
3090
3733
|
rest = _objectWithoutProperties(options, _excluded);
|
|
3091
3734
|
start(implementation, Object.keys(rest).length > 0 ? rest : undefined);
|
|
3092
3735
|
}
|
|
3093
|
-
if (typeof window !== 'undefined')
|
|
3736
|
+
if (typeof window !== 'undefined') {
|
|
3737
|
+
window.locizeStartStandalone = startStandalone;
|
|
3738
|
+
}
|
|
3094
3739
|
|
|
3095
3740
|
var index = {
|
|
3096
3741
|
wrap: wrap,
|