@moda/om 19.2.0 → 19.3.0
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/README.md +6 -6
- package/dist/index.cjs.js +255 -148
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +255 -148
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Select/Select.d.ts +1 -0
- package/dist/styles.css +1 -1
- package/package.json +88 -86
- package/src/components/Select/Select.tsx +1 -0
- package/CHANGELOG.md +0 -764
package/dist/index.esm.js
CHANGED
|
@@ -1047,7 +1047,7 @@ function _objectSpread2(e) {
|
|
|
1047
1047
|
}
|
|
1048
1048
|
return e;
|
|
1049
1049
|
}
|
|
1050
|
-
function _toPrimitive
|
|
1050
|
+
function _toPrimitive(t, r) {
|
|
1051
1051
|
if ("object" != typeof t || !t) return t;
|
|
1052
1052
|
var e = t[Symbol.toPrimitive];
|
|
1053
1053
|
if (void 0 !== e) {
|
|
@@ -1057,8 +1057,8 @@ function _toPrimitive$1(t, r) {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
return ("string" === r ? String : Number)(t);
|
|
1059
1059
|
}
|
|
1060
|
-
function _toPropertyKey
|
|
1061
|
-
var i = _toPrimitive
|
|
1060
|
+
function _toPropertyKey(t) {
|
|
1061
|
+
var i = _toPrimitive(t, "string");
|
|
1062
1062
|
return "symbol" == typeof i ? i : String(i);
|
|
1063
1063
|
}
|
|
1064
1064
|
function _typeof$1(o) {
|
|
@@ -1071,7 +1071,7 @@ function _typeof$1(o) {
|
|
|
1071
1071
|
}, _typeof$1(o);
|
|
1072
1072
|
}
|
|
1073
1073
|
function _defineProperty$1(obj, key, value) {
|
|
1074
|
-
key = _toPropertyKey
|
|
1074
|
+
key = _toPropertyKey(key);
|
|
1075
1075
|
if (key in obj) {
|
|
1076
1076
|
Object.defineProperty(obj, key, {
|
|
1077
1077
|
value: value,
|
|
@@ -1388,41 +1388,70 @@ var States = function States(_ref) {
|
|
|
1388
1388
|
}));
|
|
1389
1389
|
};
|
|
1390
1390
|
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1391
|
+
/******************************************************************************
|
|
1392
|
+
Copyright (c) Microsoft Corporation.
|
|
1393
|
+
|
|
1394
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1395
|
+
purpose with or without fee is hereby granted.
|
|
1396
|
+
|
|
1397
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1398
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1399
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1400
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1401
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1402
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1403
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1404
|
+
***************************************************************************** */
|
|
1405
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
var __assign$b = function() {
|
|
1409
|
+
__assign$b = Object.assign || function __assign(t) {
|
|
1410
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1411
|
+
s = arguments[i];
|
|
1412
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1413
|
+
}
|
|
1414
|
+
return t;
|
|
1398
1415
|
};
|
|
1399
|
-
return
|
|
1416
|
+
return __assign$b.apply(this, arguments);
|
|
1400
1417
|
};
|
|
1418
|
+
|
|
1401
1419
|
function __rest$a(s, e) {
|
|
1402
1420
|
var t = {};
|
|
1403
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1421
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1422
|
+
t[p] = s[p];
|
|
1423
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1424
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1425
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1426
|
+
t[p[i]] = s[p[i]];
|
|
1427
|
+
}
|
|
1407
1428
|
return t;
|
|
1408
1429
|
}
|
|
1409
1430
|
|
|
1410
1431
|
/** @deprecated */
|
|
1411
1432
|
function __spreadArrays() {
|
|
1412
1433
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
1413
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
1434
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
1435
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
1436
|
+
r[k] = a[j];
|
|
1414
1437
|
return r;
|
|
1415
1438
|
}
|
|
1439
|
+
|
|
1416
1440
|
function __spreadArray(to, from, pack) {
|
|
1417
1441
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1442
|
+
if (ar || !(i in from)) {
|
|
1443
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1444
|
+
ar[i] = from[i];
|
|
1445
|
+
}
|
|
1422
1446
|
}
|
|
1423
1447
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1424
1448
|
}
|
|
1425
1449
|
|
|
1450
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1451
|
+
var e = new Error(message);
|
|
1452
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1453
|
+
};
|
|
1454
|
+
|
|
1426
1455
|
var zeroRightClassName = 'right-scroll-bar-position';
|
|
1427
1456
|
var fullWidthClassName = 'width-before-scroll-bar';
|
|
1428
1457
|
var noScrollbarsClassName = 'with-scroll-bars-hidden';
|
|
@@ -1495,6 +1524,7 @@ function useCallbackRef(initialValue, callback) {
|
|
|
1495
1524
|
return ref.facade;
|
|
1496
1525
|
}
|
|
1497
1526
|
|
|
1527
|
+
var currentValues = new WeakMap();
|
|
1498
1528
|
/**
|
|
1499
1529
|
* Merges two or more refs together providing a single interface to set their value
|
|
1500
1530
|
* @param {RefObject|Ref} refs
|
|
@@ -1510,11 +1540,32 @@ function useCallbackRef(initialValue, callback) {
|
|
|
1510
1540
|
* }
|
|
1511
1541
|
*/
|
|
1512
1542
|
function useMergeRefs(refs, defaultValue) {
|
|
1513
|
-
|
|
1543
|
+
var callbackRef = useCallbackRef(defaultValue || null, function (newValue) {
|
|
1514
1544
|
return refs.forEach(function (ref) {
|
|
1515
1545
|
return assignRef(ref, newValue);
|
|
1516
1546
|
});
|
|
1517
1547
|
});
|
|
1548
|
+
// handle refs changes - added or removed
|
|
1549
|
+
React.useLayoutEffect(function () {
|
|
1550
|
+
var oldValue = currentValues.get(callbackRef);
|
|
1551
|
+
if (oldValue) {
|
|
1552
|
+
var prevRefs_1 = new Set(oldValue);
|
|
1553
|
+
var nextRefs_1 = new Set(refs);
|
|
1554
|
+
var current_1 = callbackRef.current;
|
|
1555
|
+
prevRefs_1.forEach(function (ref) {
|
|
1556
|
+
if (!nextRefs_1.has(ref)) {
|
|
1557
|
+
assignRef(ref, null);
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
nextRefs_1.forEach(function (ref) {
|
|
1561
|
+
if (!prevRefs_1.has(ref)) {
|
|
1562
|
+
assignRef(ref, current_1);
|
|
1563
|
+
}
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
currentValues.set(callbackRef, refs);
|
|
1567
|
+
}, [refs]);
|
|
1568
|
+
return callbackRef;
|
|
1518
1569
|
}
|
|
1519
1570
|
|
|
1520
1571
|
function ItoI(a) {
|
|
@@ -1605,7 +1656,7 @@ function createSidecarMedium(options) {
|
|
|
1605
1656
|
options = {};
|
|
1606
1657
|
}
|
|
1607
1658
|
var medium = innerCreateMedium(null);
|
|
1608
|
-
medium.options =
|
|
1659
|
+
medium.options = __assign$b({
|
|
1609
1660
|
async: true,
|
|
1610
1661
|
ssr: false
|
|
1611
1662
|
}, options);
|
|
@@ -1622,7 +1673,7 @@ var SideCar$1 = function SideCar(_a) {
|
|
|
1622
1673
|
if (!Target) {
|
|
1623
1674
|
throw new Error('Sidecar medium not found');
|
|
1624
1675
|
}
|
|
1625
|
-
return /*#__PURE__*/React.createElement(Target,
|
|
1676
|
+
return /*#__PURE__*/React.createElement(Target, __assign$b({}, rest));
|
|
1626
1677
|
};
|
|
1627
1678
|
SideCar$1.isSideCarExport = true;
|
|
1628
1679
|
function exportSidecar(medium, exported) {
|
|
@@ -1663,7 +1714,7 @@ var RemoveScroll = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
|
|
|
1663
1714
|
rest = __rest$a(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
|
|
1664
1715
|
var SideCar = sideCar;
|
|
1665
1716
|
var containerRef = useMergeRefs([ref, parentRef]);
|
|
1666
|
-
var containerProps =
|
|
1717
|
+
var containerProps = __assign$b(__assign$b({}, rest), callbacks);
|
|
1667
1718
|
return /*#__PURE__*/React.createElement(React.Fragment, null, enabled && ( /*#__PURE__*/React.createElement(SideCar, {
|
|
1668
1719
|
sideCar: effectCar$1,
|
|
1669
1720
|
removeScrollBar: removeScrollBar,
|
|
@@ -1674,9 +1725,9 @@ var RemoveScroll = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
|
|
|
1674
1725
|
allowPinchZoom: !!allowPinchZoom,
|
|
1675
1726
|
lockRef: ref,
|
|
1676
1727
|
gapMode: gapMode
|
|
1677
|
-
})), forwardProps ? ( /*#__PURE__*/React.cloneElement(React.Children.only(children),
|
|
1728
|
+
})), forwardProps ? ( /*#__PURE__*/React.cloneElement(React.Children.only(children), __assign$b(__assign$b({}, containerProps), {
|
|
1678
1729
|
ref: containerRef
|
|
1679
|
-
}))) : ( /*#__PURE__*/React.createElement(Container,
|
|
1730
|
+
}))) : ( /*#__PURE__*/React.createElement(Container, __assign$b({}, containerProps, {
|
|
1680
1731
|
className: className,
|
|
1681
1732
|
ref: containerRef
|
|
1682
1733
|
}), children)));
|
|
@@ -2982,7 +3033,7 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
2982
3033
|
var hasLeadingGuards = noFocusGuards !== true;
|
|
2983
3034
|
var hasTailingGuards = hasLeadingGuards && noFocusGuards !== 'tail';
|
|
2984
3035
|
var mergedRef = useMergeRefs([parentRef, setObserveNode]);
|
|
2985
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, hasLeadingGuards && [
|
|
3036
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, hasLeadingGuards && [/*#__PURE__*/
|
|
2986
3037
|
// nearest focus guard
|
|
2987
3038
|
React.createElement("div", {
|
|
2988
3039
|
key: "guard-first",
|
|
@@ -3066,14 +3117,7 @@ FocusLock.defaultProps = {
|
|
|
3066
3117
|
var FocusLockUI = FocusLock;
|
|
3067
3118
|
|
|
3068
3119
|
function deferAction(action) {
|
|
3069
|
-
|
|
3070
|
-
var _window = window,
|
|
3071
|
-
setImmediate = _window.setImmediate;
|
|
3072
|
-
if (typeof setImmediate !== 'undefined') {
|
|
3073
|
-
setImmediate(action);
|
|
3074
|
-
} else {
|
|
3075
|
-
setTimeout(action, 1);
|
|
3076
|
-
}
|
|
3120
|
+
setTimeout(action, 1);
|
|
3077
3121
|
}
|
|
3078
3122
|
|
|
3079
3123
|
var effectCar = createSidecarMedium();
|
|
@@ -3112,7 +3156,7 @@ var FocusOn$1 = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
|
|
|
3112
3156
|
var onActivation = lockProps.onActivation,
|
|
3113
3157
|
onDeactivation = lockProps.onDeactivation,
|
|
3114
3158
|
restProps = __rest$a(lockProps, ["onActivation", "onDeactivation"]);
|
|
3115
|
-
var appliedLockProps =
|
|
3159
|
+
var appliedLockProps = __assign$b(__assign$b({}, restProps), {
|
|
3116
3160
|
as: as,
|
|
3117
3161
|
style: style,
|
|
3118
3162
|
sideCar: sideCar,
|
|
@@ -3137,7 +3181,7 @@ var FocusOn$1 = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
|
|
|
3137
3181
|
lockProps: appliedLockProps,
|
|
3138
3182
|
focusOptions: preventScrollOnFocus ? PREVENT_SCROLL : undefined,
|
|
3139
3183
|
as: RemoveScroll
|
|
3140
|
-
}, children), enabled && ( /*#__PURE__*/React.createElement(SideCar,
|
|
3184
|
+
}, children), enabled && ( /*#__PURE__*/React.createElement(SideCar, __assign$b({}, rest, {
|
|
3141
3185
|
sideCar: effectCar,
|
|
3142
3186
|
setLockProps: setLockProps,
|
|
3143
3187
|
shards: shards
|
|
@@ -3158,34 +3202,34 @@ function _inheritsLoose(subClass, superClass) {
|
|
|
3158
3202
|
_setPrototypeOf(subClass, superClass);
|
|
3159
3203
|
}
|
|
3160
3204
|
|
|
3161
|
-
function _typeof(
|
|
3205
|
+
function _typeof(o) {
|
|
3162
3206
|
"@babel/helpers - typeof";
|
|
3163
3207
|
|
|
3164
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (
|
|
3165
|
-
return typeof
|
|
3166
|
-
} : function (
|
|
3167
|
-
return
|
|
3168
|
-
}, _typeof(
|
|
3208
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
3209
|
+
return typeof o;
|
|
3210
|
+
} : function (o) {
|
|
3211
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
3212
|
+
}, _typeof(o);
|
|
3169
3213
|
}
|
|
3170
3214
|
|
|
3171
|
-
function
|
|
3172
|
-
if (
|
|
3173
|
-
var
|
|
3174
|
-
if (
|
|
3175
|
-
var
|
|
3176
|
-
if (
|
|
3215
|
+
function toPrimitive(t, r) {
|
|
3216
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
3217
|
+
var e = t[Symbol.toPrimitive];
|
|
3218
|
+
if (void 0 !== e) {
|
|
3219
|
+
var i = e.call(t, r || "default");
|
|
3220
|
+
if ("object" != _typeof(i)) return i;
|
|
3177
3221
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3178
3222
|
}
|
|
3179
|
-
return (
|
|
3223
|
+
return ("string" === r ? String : Number)(t);
|
|
3180
3224
|
}
|
|
3181
3225
|
|
|
3182
|
-
function
|
|
3183
|
-
var
|
|
3184
|
-
return _typeof(
|
|
3226
|
+
function toPropertyKey(t) {
|
|
3227
|
+
var i = toPrimitive(t, "string");
|
|
3228
|
+
return "symbol" == _typeof(i) ? i : String(i);
|
|
3185
3229
|
}
|
|
3186
3230
|
|
|
3187
3231
|
function _defineProperty(obj, key, value) {
|
|
3188
|
-
key =
|
|
3232
|
+
key = toPropertyKey(key);
|
|
3189
3233
|
if (key in obj) {
|
|
3190
3234
|
Object.defineProperty(obj, key, {
|
|
3191
3235
|
value: value,
|
|
@@ -3450,17 +3494,29 @@ var filterAutoFocusable = function filterAutoFocusable(nodes, cache) {
|
|
|
3450
3494
|
});
|
|
3451
3495
|
};
|
|
3452
3496
|
/**
|
|
3453
|
-
*
|
|
3454
|
-
*
|
|
3497
|
+
* !__WARNING__! Low level API.
|
|
3498
|
+
* @returns all tabbable nodes
|
|
3499
|
+
*
|
|
3500
|
+
* @see {@link getFocusableNodes} to get any focusable element
|
|
3501
|
+
*
|
|
3502
|
+
* @param topNodes - array of top level HTMLElements to search inside
|
|
3503
|
+
* @param visibilityCache - an cache to store intermediate measurements. Expected to be a fresh `new Map` on every call
|
|
3455
3504
|
*/
|
|
3456
3505
|
var getTabbableNodes = function getTabbableNodes(topNodes, visibilityCache, withGuards) {
|
|
3457
3506
|
return orderByTabIndex(filterFocusable(getFocusables(topNodes, withGuards), visibilityCache), true, withGuards);
|
|
3458
3507
|
};
|
|
3459
3508
|
/**
|
|
3460
|
-
*
|
|
3461
|
-
*
|
|
3509
|
+
* !__WARNING__! Low level API.
|
|
3510
|
+
*
|
|
3511
|
+
* @returns anything "focusable", not only tabbable. The difference is in `tabIndex=-1`
|
|
3512
|
+
* (without guards, as long as they are not expected to be ever focused)
|
|
3513
|
+
*
|
|
3514
|
+
* @see {@link getTabbableNodes} to get only tabble nodes element
|
|
3515
|
+
*
|
|
3516
|
+
* @param topNodes - array of top level HTMLElements to search inside
|
|
3517
|
+
* @param visibilityCache - an cache to store intermediate measurements. Expected to be a fresh `new Map` on every call
|
|
3462
3518
|
*/
|
|
3463
|
-
var
|
|
3519
|
+
var getFocusableNodes = function getFocusableNodes(topNodes, visibilityCache) {
|
|
3464
3520
|
return orderByTabIndex(filterFocusable(getFocusables(topNodes), visibilityCache), false);
|
|
3465
3521
|
};
|
|
3466
3522
|
/**
|
|
@@ -3532,8 +3588,8 @@ var getTopParent = function getTopParent(node) {
|
|
|
3532
3588
|
};
|
|
3533
3589
|
/**
|
|
3534
3590
|
* returns all "focus containers" inside a given node
|
|
3535
|
-
* @param node
|
|
3536
|
-
* @returns
|
|
3591
|
+
* @param node - node or nodes to look inside
|
|
3592
|
+
* @returns Element[]
|
|
3537
3593
|
*/
|
|
3538
3594
|
var getAllAffectedNodes = function getAllAffectedNodes(node) {
|
|
3539
3595
|
var nodes = asArray(node);
|
|
@@ -3555,6 +3611,10 @@ var safeProbe = function safeProbe(cb) {
|
|
|
3555
3611
|
/**
|
|
3556
3612
|
* returns active element from document or from nested shadowdoms
|
|
3557
3613
|
*/
|
|
3614
|
+
/**
|
|
3615
|
+
* returns current active element. If the active element is a "container" itself(shadowRoot or iframe) returns active element inside it
|
|
3616
|
+
* @param [inDocument]
|
|
3617
|
+
*/
|
|
3558
3618
|
var getActiveElement = function getActiveElement(inDocument) {
|
|
3559
3619
|
if (inDocument === void 0) {
|
|
3560
3620
|
inDocument = document;
|
|
@@ -3577,7 +3637,8 @@ var focusInsideIframe = function focusInsideIframe(topNode, activeElement) {
|
|
|
3577
3637
|
}));
|
|
3578
3638
|
};
|
|
3579
3639
|
/**
|
|
3580
|
-
* @returns {Boolean} true, if the current focus is inside given node or nodes
|
|
3640
|
+
* @returns {Boolean} true, if the current focus is inside given node or nodes.
|
|
3641
|
+
* Supports nodes hidden inside shadowDom
|
|
3581
3642
|
*/
|
|
3582
3643
|
var focusInside = function focusInside(topNode, activeElement) {
|
|
3583
3644
|
// const activeElement = document && getActiveElement();
|
|
@@ -3593,8 +3654,11 @@ var focusInside = function focusInside(topNode, activeElement) {
|
|
|
3593
3654
|
};
|
|
3594
3655
|
|
|
3595
3656
|
/**
|
|
3596
|
-
* focus is hidden FROM the focus-lock
|
|
3657
|
+
* checks if focus is hidden FROM the focus-lock
|
|
3597
3658
|
* ie contained inside a node focus-lock shall ignore
|
|
3659
|
+
*
|
|
3660
|
+
* This is a utility function coupled with {@link FOCUS_ALLOW} constant
|
|
3661
|
+
*
|
|
3598
3662
|
* @returns {boolean} focus is currently is in "allow" area
|
|
3599
3663
|
*/
|
|
3600
3664
|
var focusIsHidden = function focusIsHidden(inDocument) {
|
|
@@ -3819,16 +3883,21 @@ var reorderNodes = function reorderNodes(srcNodes, dstNodes) {
|
|
|
3819
3883
|
}).filter(isDefined);
|
|
3820
3884
|
};
|
|
3821
3885
|
/**
|
|
3822
|
-
*
|
|
3886
|
+
* contains the main logic of the `focus-lock` package.
|
|
3887
|
+
*
|
|
3888
|
+
* ! you probably dont need this function !
|
|
3889
|
+
*
|
|
3890
|
+
* given top node(s) and the last active element returns the element to be focused next
|
|
3891
|
+
* @returns element which should be focused to move focus inside
|
|
3823
3892
|
* @param topNode
|
|
3824
3893
|
* @param lastNode
|
|
3825
3894
|
*/
|
|
3826
|
-
var
|
|
3895
|
+
var focusSolver = function focusSolver(topNode, lastNode) {
|
|
3827
3896
|
var activeElement = getActiveElement(asArray(topNode).length > 0 ? document : getFirst(topNode).ownerDocument);
|
|
3828
3897
|
var entries = getAllAffectedNodes(topNode).filter(isNotAGuard);
|
|
3829
3898
|
var commonParent = getTopCommonParent(activeElement || topNode, topNode, entries);
|
|
3830
3899
|
var visibilityCache = new Map();
|
|
3831
|
-
var anyFocusable =
|
|
3900
|
+
var anyFocusable = getFocusableNodes(entries, visibilityCache);
|
|
3832
3901
|
var innerElements = getTabbableNodes(entries, visibilityCache).filter(function (_a) {
|
|
3833
3902
|
var node = _a.node;
|
|
3834
3903
|
return isNotAGuard(node);
|
|
@@ -3839,7 +3908,7 @@ var getFocusMerge = function getFocusMerge(topNode, lastNode) {
|
|
|
3839
3908
|
return undefined;
|
|
3840
3909
|
}
|
|
3841
3910
|
}
|
|
3842
|
-
var outerNodes =
|
|
3911
|
+
var outerNodes = getFocusableNodes([commonParent], visibilityCache).map(function (_a) {
|
|
3843
3912
|
var node = _a.node;
|
|
3844
3913
|
return node;
|
|
3845
3914
|
});
|
|
@@ -3867,10 +3936,10 @@ var getFocusMerge = function getFocusMerge(topNode, lastNode) {
|
|
|
3867
3936
|
};
|
|
3868
3937
|
|
|
3869
3938
|
/**
|
|
3870
|
-
*
|
|
3871
|
-
* @
|
|
3939
|
+
* @returns list of focusable elements inside a given top node
|
|
3940
|
+
* @see {@link getFocusableNodes} for lower level access
|
|
3872
3941
|
*/
|
|
3873
|
-
var
|
|
3942
|
+
var expandFocusableNodes = function expandFocusableNodes(topNode) {
|
|
3874
3943
|
var entries = getAllAffectedNodes(topNode).filter(isNotAGuard);
|
|
3875
3944
|
var commonParent = getTopCommonParent(topNode, topNode, entries);
|
|
3876
3945
|
var visibilityCache = new Map();
|
|
@@ -3902,26 +3971,34 @@ var focusOn = function focusOn(target, focusOptions) {
|
|
|
3902
3971
|
target.contentWindow.focus();
|
|
3903
3972
|
}
|
|
3904
3973
|
};
|
|
3974
|
+
|
|
3905
3975
|
var guardCount = 0;
|
|
3906
3976
|
var lockDisabled = false;
|
|
3907
3977
|
/**
|
|
3908
|
-
*
|
|
3978
|
+
* The main functionality of the focus-lock package
|
|
3979
|
+
*
|
|
3980
|
+
* Contains focus at a given node.
|
|
3981
|
+
* The last focused element will help to determine which element(first or last) should be focused.
|
|
3982
|
+
* The found element will be focused.
|
|
3983
|
+
*
|
|
3984
|
+
* This is one time action (move), not a persistent focus-lock
|
|
3985
|
+
*
|
|
3909
3986
|
* HTML markers (see {@link import('./constants').FOCUS_AUTO} constants) can control autofocus
|
|
3910
|
-
* @
|
|
3911
|
-
* @param lastNode
|
|
3912
|
-
* @param options
|
|
3987
|
+
* @see {@link focusSolver} for the same functionality without autofocus
|
|
3913
3988
|
*/
|
|
3914
|
-
var
|
|
3989
|
+
var moveFocusInside = function moveFocusInside(topNode, lastNode, options) {
|
|
3915
3990
|
if (options === void 0) {
|
|
3916
3991
|
options = {};
|
|
3917
3992
|
}
|
|
3918
|
-
var focusable =
|
|
3993
|
+
var focusable = focusSolver(topNode, lastNode);
|
|
3994
|
+
// global local side effect to countain recursive lock activation and resolve focus-fighting
|
|
3919
3995
|
if (lockDisabled) {
|
|
3920
3996
|
return;
|
|
3921
3997
|
}
|
|
3922
3998
|
if (focusable) {
|
|
3999
|
+
/** +FOCUS-FIGHTING prevention **/
|
|
3923
4000
|
if (guardCount > 2) {
|
|
3924
|
-
//
|
|
4001
|
+
// we have recursive entered back the lock activation
|
|
3925
4002
|
console.error('FocusLock: focus-fighting detected. Only one focus management system could be active. ' + 'See https://github.com/theKashey/focus-lock/#focus-fighting');
|
|
3926
4003
|
lockDisabled = true;
|
|
3927
4004
|
setTimeout(function () {
|
|
@@ -4034,7 +4111,7 @@ var activateTrap = function activateTrap() {
|
|
|
4034
4111
|
}
|
|
4035
4112
|
document.body.focus();
|
|
4036
4113
|
} else {
|
|
4037
|
-
result =
|
|
4114
|
+
result = moveFocusInside(workingArea, lastActiveFocus, {
|
|
4038
4115
|
focusOptions: focusOptions
|
|
4039
4116
|
});
|
|
4040
4117
|
lastPortaledElement = {};
|
|
@@ -4046,7 +4123,7 @@ var activateTrap = function activateTrap() {
|
|
|
4046
4123
|
}
|
|
4047
4124
|
if (document) {
|
|
4048
4125
|
var newActiveElement = document && document.activeElement;
|
|
4049
|
-
var allNodes =
|
|
4126
|
+
var allNodes = expandFocusableNodes(workingArea);
|
|
4050
4127
|
var focusedIndex = allNodes.map(function (_ref) {
|
|
4051
4128
|
var node = _ref.node;
|
|
4052
4129
|
return node;
|
|
@@ -4096,9 +4173,9 @@ process.env.NODE_ENV !== "production" ? {
|
|
|
4096
4173
|
var onWindowBlur = function onWindowBlur() {
|
|
4097
4174
|
focusWasOutsideWindow = 'just'; // using setTimeout to set this variable after React/sidecar reaction
|
|
4098
4175
|
|
|
4099
|
-
|
|
4176
|
+
deferAction(function () {
|
|
4100
4177
|
focusWasOutsideWindow = 'meanwhile';
|
|
4101
|
-
}
|
|
4178
|
+
});
|
|
4102
4179
|
};
|
|
4103
4180
|
var attachHandler = function attachHandler() {
|
|
4104
4181
|
document.addEventListener('focusin', onTrap);
|
|
@@ -4152,7 +4229,7 @@ mediumFocus.assignSyncMedium(onFocus);
|
|
|
4152
4229
|
mediumBlur.assignMedium(onBlur);
|
|
4153
4230
|
mediumEffect.assignMedium(function (cb) {
|
|
4154
4231
|
return cb({
|
|
4155
|
-
moveFocusInside:
|
|
4232
|
+
moveFocusInside: moveFocusInside,
|
|
4156
4233
|
focusInside: focusInside
|
|
4157
4234
|
});
|
|
4158
4235
|
});
|
|
@@ -4429,15 +4506,20 @@ var handleScroll = function handleScroll(axis, endTarget, event, sourceDelta, no
|
|
|
4429
4506
|
availableScrollTop += position;
|
|
4430
4507
|
}
|
|
4431
4508
|
}
|
|
4432
|
-
target
|
|
4509
|
+
if (target instanceof ShadowRoot) {
|
|
4510
|
+
target = target.host;
|
|
4511
|
+
} else {
|
|
4512
|
+
target = target.parentNode;
|
|
4513
|
+
}
|
|
4433
4514
|
} while (
|
|
4434
4515
|
// portaled content
|
|
4435
4516
|
!targetInLock && target !== document.body ||
|
|
4436
4517
|
// self content
|
|
4437
4518
|
targetInLock && (endTarget.contains(target) || endTarget === target));
|
|
4438
|
-
|
|
4519
|
+
// handle epsilon around 0 (non standard zoom levels)
|
|
4520
|
+
if (isDeltaPositive && (noOverscroll && Math.abs(availableScroll) < 1 || !noOverscroll && delta > availableScroll)) {
|
|
4439
4521
|
shouldCancelScroll = true;
|
|
4440
|
-
} else if (!isDeltaPositive && (noOverscroll && availableScrollTop
|
|
4522
|
+
} else if (!isDeltaPositive && (noOverscroll && Math.abs(availableScrollTop) < 1 || !noOverscroll && -delta > availableScrollTop)) {
|
|
4441
4523
|
shouldCancelScroll = true;
|
|
4442
4524
|
}
|
|
4443
4525
|
return shouldCancelScroll;
|
|
@@ -4532,7 +4614,7 @@ function RemoveScrollSideCar(props) {
|
|
|
4532
4614
|
}
|
|
4533
4615
|
var delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
|
|
4534
4616
|
var sourceEvent = shouldPreventQueue.current.filter(function (e) {
|
|
4535
|
-
return e.name === event.type && e.target === event.target && deltaCompare(e.delta, delta);
|
|
4617
|
+
return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
|
|
4536
4618
|
})[0];
|
|
4537
4619
|
// self event, and should be canceled
|
|
4538
4620
|
if (sourceEvent && sourceEvent.should) {
|
|
@@ -4559,7 +4641,8 @@ function RemoveScrollSideCar(props) {
|
|
|
4559
4641
|
name: name,
|
|
4560
4642
|
delta: delta,
|
|
4561
4643
|
target: target,
|
|
4562
|
-
should: should
|
|
4644
|
+
should: should,
|
|
4645
|
+
shadowParent: getOutermostShadowParent(target)
|
|
4563
4646
|
};
|
|
4564
4647
|
shouldPreventQueue.current.push(event);
|
|
4565
4648
|
setTimeout(function () {
|
|
@@ -4605,6 +4688,17 @@ function RemoveScrollSideCar(props) {
|
|
|
4605
4688
|
gapMode: props.gapMode
|
|
4606
4689
|
}) : null);
|
|
4607
4690
|
}
|
|
4691
|
+
function getOutermostShadowParent(node) {
|
|
4692
|
+
var shadowParent = null;
|
|
4693
|
+
while (node !== null) {
|
|
4694
|
+
if (node instanceof ShadowRoot) {
|
|
4695
|
+
shadowParent = node.host;
|
|
4696
|
+
node = node.host;
|
|
4697
|
+
}
|
|
4698
|
+
node = node.parentNode;
|
|
4699
|
+
}
|
|
4700
|
+
return shadowParent;
|
|
4701
|
+
}
|
|
4608
4702
|
|
|
4609
4703
|
exportSidecar(effectCar$1, RemoveScrollSideCar);
|
|
4610
4704
|
|
|
@@ -4858,10 +4952,10 @@ function Effect(_a) {
|
|
|
4858
4952
|
var SideCar = exportSidecar(effectCar, Effect);
|
|
4859
4953
|
|
|
4860
4954
|
var RequireSideCar = function RequireSideCar(props) {
|
|
4861
|
-
return /*#__PURE__*/React.createElement(SideCar,
|
|
4955
|
+
return /*#__PURE__*/React.createElement(SideCar, __assign$b({}, props));
|
|
4862
4956
|
};
|
|
4863
4957
|
var FocusOn = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
4864
|
-
return /*#__PURE__*/React.createElement(FocusOn$1,
|
|
4958
|
+
return /*#__PURE__*/React.createElement(FocusOn$1, __assign$b({}, props, {
|
|
4865
4959
|
ref: ref,
|
|
4866
4960
|
sideCar: RequireSideCar
|
|
4867
4961
|
}));
|
|
@@ -9736,8 +9830,8 @@ var t = function t(_t) {
|
|
|
9736
9830
|
},
|
|
9737
9831
|
n = function n(t, _n) {
|
|
9738
9832
|
if (t.clientHeight < t.scrollHeight || t.clientWidth < t.scrollWidth) {
|
|
9739
|
-
var
|
|
9740
|
-
return e$1(
|
|
9833
|
+
var _o = getComputedStyle(t, null);
|
|
9834
|
+
return e$1(_o.overflowY, _n) || e$1(_o.overflowX, _n) || function (t) {
|
|
9741
9835
|
var e = function (t) {
|
|
9742
9836
|
if (!t.ownerDocument || !t.ownerDocument.defaultView) return null;
|
|
9743
9837
|
try {
|
|
@@ -9751,84 +9845,97 @@ var t = function t(_t) {
|
|
|
9751
9845
|
}
|
|
9752
9846
|
return !1;
|
|
9753
9847
|
},
|
|
9754
|
-
|
|
9755
|
-
return
|
|
9848
|
+
o$1 = function o(t, e, n, _o2, l, r, i, s) {
|
|
9849
|
+
return r < t && i > e || r > t && i < e ? 0 : r <= t && s <= n || i >= e && s >= n ? r - t - _o2 : i > e && s < n || r < t && s > n ? i - e + l : 0;
|
|
9756
9850
|
},
|
|
9757
|
-
|
|
9851
|
+
l = function l(t) {
|
|
9758
9852
|
var e = t.parentElement;
|
|
9759
9853
|
return null == e ? t.getRootNode().host || null : e;
|
|
9760
9854
|
},
|
|
9761
|
-
|
|
9762
|
-
var
|
|
9855
|
+
r = function r(e, _r2) {
|
|
9856
|
+
var i, s, d, h;
|
|
9763
9857
|
if ("undefined" == typeof document) return [];
|
|
9764
|
-
var
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
a =
|
|
9768
|
-
g =
|
|
9769
|
-
|
|
9858
|
+
var c = _r2.scrollMode,
|
|
9859
|
+
f = _r2.block,
|
|
9860
|
+
u = _r2.inline,
|
|
9861
|
+
a = _r2.boundary,
|
|
9862
|
+
g = _r2.skipOverflowHiddenElements,
|
|
9863
|
+
p = "function" == typeof a ? a : function (t) {
|
|
9770
9864
|
return t !== a;
|
|
9771
9865
|
};
|
|
9772
9866
|
if (!t(e)) throw new TypeError("Invalid target");
|
|
9773
|
-
var
|
|
9774
|
-
w = []
|
|
9775
|
-
|
|
9776
|
-
for (; t(W) &&
|
|
9777
|
-
if (W =
|
|
9867
|
+
var m = document.scrollingElement || document.documentElement,
|
|
9868
|
+
w = [];
|
|
9869
|
+
var W = e;
|
|
9870
|
+
for (; t(W) && p(W);) {
|
|
9871
|
+
if (W = l(W), W === m) {
|
|
9778
9872
|
w.push(W);
|
|
9779
9873
|
break;
|
|
9780
9874
|
}
|
|
9781
9875
|
null != W && W === document.body && n(W) && !n(document.documentElement) || null != W && n(W, g) && w.push(W);
|
|
9782
9876
|
}
|
|
9783
|
-
var
|
|
9784
|
-
|
|
9877
|
+
var b = null != (s = null == (i = window.visualViewport) ? void 0 : i.width) ? s : innerWidth,
|
|
9878
|
+
H = null != (h = null == (d = window.visualViewport) ? void 0 : d.height) ? h : innerHeight,
|
|
9785
9879
|
_window = window,
|
|
9786
|
-
|
|
9787
|
-
|
|
9880
|
+
y = _window.scrollX,
|
|
9881
|
+
M = _window.scrollY,
|
|
9788
9882
|
_e$getBoundingClientR = e.getBoundingClientRect(),
|
|
9789
|
-
|
|
9790
|
-
|
|
9883
|
+
v = _e$getBoundingClientR.height,
|
|
9884
|
+
E = _e$getBoundingClientR.width,
|
|
9791
9885
|
x = _e$getBoundingClientR.top,
|
|
9792
|
-
|
|
9793
|
-
|
|
9886
|
+
C = _e$getBoundingClientR.right,
|
|
9887
|
+
I = _e$getBoundingClientR.bottom,
|
|
9794
9888
|
R = _e$getBoundingClientR.left,
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9889
|
+
_ref = function (t) {
|
|
9890
|
+
var e = window.getComputedStyle(t);
|
|
9891
|
+
return {
|
|
9892
|
+
top: parseFloat(e.scrollMarginTop) || 0,
|
|
9893
|
+
right: parseFloat(e.scrollMarginRight) || 0,
|
|
9894
|
+
bottom: parseFloat(e.scrollMarginBottom) || 0,
|
|
9895
|
+
left: parseFloat(e.scrollMarginLeft) || 0
|
|
9896
|
+
};
|
|
9897
|
+
}(e),
|
|
9898
|
+
T = _ref.top,
|
|
9899
|
+
B = _ref.right,
|
|
9900
|
+
F = _ref.bottom,
|
|
9901
|
+
V = _ref.left;
|
|
9902
|
+
var k = "start" === f || "nearest" === f ? x - T : "end" === f ? I + F : x + v / 2 - T + F,
|
|
9903
|
+
D = "center" === u ? R + E / 2 - V + B : "end" === u ? C + B : R - V;
|
|
9904
|
+
var L = [];
|
|
9798
9905
|
for (var _t2 = 0; _t2 < w.length; _t2++) {
|
|
9799
9906
|
var _e2 = w[_t2],
|
|
9800
9907
|
_e$getBoundingClientR2 = _e2.getBoundingClientRect(),
|
|
9801
9908
|
_n2 = _e$getBoundingClientR2.height,
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
if ("if-needed" ===
|
|
9808
|
-
var
|
|
9809
|
-
_a = parseInt(
|
|
9810
|
-
_g = parseInt(
|
|
9811
|
-
|
|
9812
|
-
_W = parseInt(
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
if (
|
|
9820
|
-
|
|
9909
|
+
_l = _e$getBoundingClientR2.width,
|
|
9910
|
+
_r = _e$getBoundingClientR2.top,
|
|
9911
|
+
_i = _e$getBoundingClientR2.right,
|
|
9912
|
+
_s = _e$getBoundingClientR2.bottom,
|
|
9913
|
+
_d = _e$getBoundingClientR2.left;
|
|
9914
|
+
if ("if-needed" === c && x >= 0 && R >= 0 && I <= H && C <= b && x >= _r && I <= _s && R >= _d && C <= _i) return L;
|
|
9915
|
+
var _h = getComputedStyle(_e2),
|
|
9916
|
+
_a = parseInt(_h.borderLeftWidth, 10),
|
|
9917
|
+
_g = parseInt(_h.borderTopWidth, 10),
|
|
9918
|
+
_p = parseInt(_h.borderRightWidth, 10),
|
|
9919
|
+
_W = parseInt(_h.borderBottomWidth, 10);
|
|
9920
|
+
var _T = 0,
|
|
9921
|
+
_B = 0;
|
|
9922
|
+
var _F = "offsetWidth" in _e2 ? _e2.offsetWidth - _e2.clientWidth - _a - _p : 0,
|
|
9923
|
+
_V = "offsetHeight" in _e2 ? _e2.offsetHeight - _e2.clientHeight - _g - _W : 0,
|
|
9924
|
+
S = "offsetWidth" in _e2 ? 0 === _e2.offsetWidth ? 0 : _l / _e2.offsetWidth : 0,
|
|
9925
|
+
X = "offsetHeight" in _e2 ? 0 === _e2.offsetHeight ? 0 : _n2 / _e2.offsetHeight : 0;
|
|
9926
|
+
if (m === _e2) _T = "start" === f ? k : "end" === f ? k - H : "nearest" === f ? o$1(M, M + H, H, _g, _W, M + k, M + k + v, v) : k - H / 2, _B = "start" === u ? D : "center" === u ? D - b / 2 : "end" === u ? D - b : o$1(y, y + b, b, _a, _p, y + D, y + D + E, E), _T = Math.max(0, _T + M), _B = Math.max(0, _B + y);else {
|
|
9927
|
+
_T = "start" === f ? k - _r - _g : "end" === f ? k - _s + _W + _V : "nearest" === f ? o$1(_r, _s, _n2, _g, _W + _V, k, k + v, v) : k - (_r + _n2 / 2) + _V / 2, _B = "start" === u ? D - _d - _a : "center" === u ? D - (_d + _l / 2) + _F / 2 : "end" === u ? D - _i + _p + _F : o$1(_d, _i, _l, _a, _p + _F, D, D + E, E);
|
|
9821
9928
|
var _t3 = _e2.scrollLeft,
|
|
9822
|
-
|
|
9823
|
-
|
|
9929
|
+
_h2 = _e2.scrollTop;
|
|
9930
|
+
_T = 0 === X ? 0 : Math.max(0, Math.min(_h2 + _T / X, _e2.scrollHeight - _n2 / X + _V)), _B = 0 === S ? 0 : Math.max(0, Math.min(_t3 + _B / S, _e2.scrollWidth - _l / S + _F)), k += _h2 - _T, D += _t3 - _B;
|
|
9824
9931
|
}
|
|
9825
|
-
|
|
9932
|
+
L.push({
|
|
9826
9933
|
el: _e2,
|
|
9827
|
-
top:
|
|
9828
|
-
left:
|
|
9934
|
+
top: _T,
|
|
9935
|
+
left: _B
|
|
9829
9936
|
});
|
|
9830
9937
|
}
|
|
9831
|
-
return
|
|
9938
|
+
return L;
|
|
9832
9939
|
};
|
|
9833
9940
|
|
|
9834
9941
|
var o = function o(t) {
|
|
@@ -9842,7 +9949,7 @@ var o = function o(t) {
|
|
|
9842
9949
|
inline: "nearest"
|
|
9843
9950
|
};
|
|
9844
9951
|
};
|
|
9845
|
-
function e(e, r) {
|
|
9952
|
+
function e(e, r$1) {
|
|
9846
9953
|
if (!e.isConnected || !function (t) {
|
|
9847
9954
|
var o = t;
|
|
9848
9955
|
for (; o && o.parentNode;) {
|
|
@@ -9862,9 +9969,9 @@ function e(e, r) {
|
|
|
9862
9969
|
}(e);
|
|
9863
9970
|
if (function (t) {
|
|
9864
9971
|
return "object" == _typeof$1(t) && "function" == typeof t.behavior;
|
|
9865
|
-
}(r)) return r.behavior(
|
|
9866
|
-
var l = "boolean" == typeof r || null == r ? void 0 : r.behavior;
|
|
9867
|
-
var _iterator = _createForOfIteratorHelper(
|
|
9972
|
+
}(r$1)) return r$1.behavior(r(e, r$1));
|
|
9973
|
+
var l = "boolean" == typeof r$1 || null == r$1 ? void 0 : r$1.behavior;
|
|
9974
|
+
var _iterator = _createForOfIteratorHelper(r(e, o(r$1))),
|
|
9868
9975
|
_step;
|
|
9869
9976
|
try {
|
|
9870
9977
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|