@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.cjs.js
CHANGED
|
@@ -1067,7 +1067,7 @@ function _objectSpread2(e) {
|
|
|
1067
1067
|
}
|
|
1068
1068
|
return e;
|
|
1069
1069
|
}
|
|
1070
|
-
function _toPrimitive
|
|
1070
|
+
function _toPrimitive(t, r) {
|
|
1071
1071
|
if ("object" != typeof t || !t) return t;
|
|
1072
1072
|
var e = t[Symbol.toPrimitive];
|
|
1073
1073
|
if (void 0 !== e) {
|
|
@@ -1077,8 +1077,8 @@ function _toPrimitive$1(t, r) {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
return ("string" === r ? String : Number)(t);
|
|
1079
1079
|
}
|
|
1080
|
-
function _toPropertyKey
|
|
1081
|
-
var i = _toPrimitive
|
|
1080
|
+
function _toPropertyKey(t) {
|
|
1081
|
+
var i = _toPrimitive(t, "string");
|
|
1082
1082
|
return "symbol" == typeof i ? i : String(i);
|
|
1083
1083
|
}
|
|
1084
1084
|
function _typeof$1(o) {
|
|
@@ -1091,7 +1091,7 @@ function _typeof$1(o) {
|
|
|
1091
1091
|
}, _typeof$1(o);
|
|
1092
1092
|
}
|
|
1093
1093
|
function _defineProperty$1(obj, key, value) {
|
|
1094
|
-
key = _toPropertyKey
|
|
1094
|
+
key = _toPropertyKey(key);
|
|
1095
1095
|
if (key in obj) {
|
|
1096
1096
|
Object.defineProperty(obj, key, {
|
|
1097
1097
|
value: value,
|
|
@@ -1408,41 +1408,70 @@ var States = function States(_ref) {
|
|
|
1408
1408
|
}));
|
|
1409
1409
|
};
|
|
1410
1410
|
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1411
|
+
/******************************************************************************
|
|
1412
|
+
Copyright (c) Microsoft Corporation.
|
|
1413
|
+
|
|
1414
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1415
|
+
purpose with or without fee is hereby granted.
|
|
1416
|
+
|
|
1417
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1418
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1419
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1420
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1421
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1422
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1423
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1424
|
+
***************************************************************************** */
|
|
1425
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
var __assign$b = function() {
|
|
1429
|
+
__assign$b = Object.assign || function __assign(t) {
|
|
1430
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1431
|
+
s = arguments[i];
|
|
1432
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1433
|
+
}
|
|
1434
|
+
return t;
|
|
1418
1435
|
};
|
|
1419
|
-
return
|
|
1436
|
+
return __assign$b.apply(this, arguments);
|
|
1420
1437
|
};
|
|
1438
|
+
|
|
1421
1439
|
function __rest$a(s, e) {
|
|
1422
1440
|
var t = {};
|
|
1423
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1441
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1442
|
+
t[p] = s[p];
|
|
1443
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1444
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1445
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1446
|
+
t[p[i]] = s[p[i]];
|
|
1447
|
+
}
|
|
1427
1448
|
return t;
|
|
1428
1449
|
}
|
|
1429
1450
|
|
|
1430
1451
|
/** @deprecated */
|
|
1431
1452
|
function __spreadArrays() {
|
|
1432
1453
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
1433
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
1454
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
1455
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
1456
|
+
r[k] = a[j];
|
|
1434
1457
|
return r;
|
|
1435
1458
|
}
|
|
1459
|
+
|
|
1436
1460
|
function __spreadArray(to, from, pack) {
|
|
1437
1461
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1462
|
+
if (ar || !(i in from)) {
|
|
1463
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1464
|
+
ar[i] = from[i];
|
|
1465
|
+
}
|
|
1442
1466
|
}
|
|
1443
1467
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1444
1468
|
}
|
|
1445
1469
|
|
|
1470
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1471
|
+
var e = new Error(message);
|
|
1472
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1446
1475
|
var zeroRightClassName = 'right-scroll-bar-position';
|
|
1447
1476
|
var fullWidthClassName = 'width-before-scroll-bar';
|
|
1448
1477
|
var noScrollbarsClassName = 'with-scroll-bars-hidden';
|
|
@@ -1515,6 +1544,7 @@ function useCallbackRef(initialValue, callback) {
|
|
|
1515
1544
|
return ref.facade;
|
|
1516
1545
|
}
|
|
1517
1546
|
|
|
1547
|
+
var currentValues = new WeakMap();
|
|
1518
1548
|
/**
|
|
1519
1549
|
* Merges two or more refs together providing a single interface to set their value
|
|
1520
1550
|
* @param {RefObject|Ref} refs
|
|
@@ -1530,11 +1560,32 @@ function useCallbackRef(initialValue, callback) {
|
|
|
1530
1560
|
* }
|
|
1531
1561
|
*/
|
|
1532
1562
|
function useMergeRefs(refs, defaultValue) {
|
|
1533
|
-
|
|
1563
|
+
var callbackRef = useCallbackRef(defaultValue || null, function (newValue) {
|
|
1534
1564
|
return refs.forEach(function (ref) {
|
|
1535
1565
|
return assignRef(ref, newValue);
|
|
1536
1566
|
});
|
|
1537
1567
|
});
|
|
1568
|
+
// handle refs changes - added or removed
|
|
1569
|
+
React__namespace.useLayoutEffect(function () {
|
|
1570
|
+
var oldValue = currentValues.get(callbackRef);
|
|
1571
|
+
if (oldValue) {
|
|
1572
|
+
var prevRefs_1 = new Set(oldValue);
|
|
1573
|
+
var nextRefs_1 = new Set(refs);
|
|
1574
|
+
var current_1 = callbackRef.current;
|
|
1575
|
+
prevRefs_1.forEach(function (ref) {
|
|
1576
|
+
if (!nextRefs_1.has(ref)) {
|
|
1577
|
+
assignRef(ref, null);
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1580
|
+
nextRefs_1.forEach(function (ref) {
|
|
1581
|
+
if (!prevRefs_1.has(ref)) {
|
|
1582
|
+
assignRef(ref, current_1);
|
|
1583
|
+
}
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
currentValues.set(callbackRef, refs);
|
|
1587
|
+
}, [refs]);
|
|
1588
|
+
return callbackRef;
|
|
1538
1589
|
}
|
|
1539
1590
|
|
|
1540
1591
|
function ItoI(a) {
|
|
@@ -1625,7 +1676,7 @@ function createSidecarMedium(options) {
|
|
|
1625
1676
|
options = {};
|
|
1626
1677
|
}
|
|
1627
1678
|
var medium = innerCreateMedium(null);
|
|
1628
|
-
medium.options =
|
|
1679
|
+
medium.options = __assign$b({
|
|
1629
1680
|
async: true,
|
|
1630
1681
|
ssr: false
|
|
1631
1682
|
}, options);
|
|
@@ -1642,7 +1693,7 @@ var SideCar$1 = function SideCar(_a) {
|
|
|
1642
1693
|
if (!Target) {
|
|
1643
1694
|
throw new Error('Sidecar medium not found');
|
|
1644
1695
|
}
|
|
1645
|
-
return /*#__PURE__*/React__namespace.createElement(Target,
|
|
1696
|
+
return /*#__PURE__*/React__namespace.createElement(Target, __assign$b({}, rest));
|
|
1646
1697
|
};
|
|
1647
1698
|
SideCar$1.isSideCarExport = true;
|
|
1648
1699
|
function exportSidecar(medium, exported) {
|
|
@@ -1683,7 +1734,7 @@ var RemoveScroll = /*#__PURE__*/React__namespace.forwardRef(function (props, par
|
|
|
1683
1734
|
rest = __rest$a(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
|
|
1684
1735
|
var SideCar = sideCar;
|
|
1685
1736
|
var containerRef = useMergeRefs([ref, parentRef]);
|
|
1686
|
-
var containerProps =
|
|
1737
|
+
var containerProps = __assign$b(__assign$b({}, rest), callbacks);
|
|
1687
1738
|
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, enabled && ( /*#__PURE__*/React__namespace.createElement(SideCar, {
|
|
1688
1739
|
sideCar: effectCar$1,
|
|
1689
1740
|
removeScrollBar: removeScrollBar,
|
|
@@ -1694,9 +1745,9 @@ var RemoveScroll = /*#__PURE__*/React__namespace.forwardRef(function (props, par
|
|
|
1694
1745
|
allowPinchZoom: !!allowPinchZoom,
|
|
1695
1746
|
lockRef: ref,
|
|
1696
1747
|
gapMode: gapMode
|
|
1697
|
-
})), forwardProps ? ( /*#__PURE__*/React__namespace.cloneElement(React__namespace.Children.only(children),
|
|
1748
|
+
})), forwardProps ? ( /*#__PURE__*/React__namespace.cloneElement(React__namespace.Children.only(children), __assign$b(__assign$b({}, containerProps), {
|
|
1698
1749
|
ref: containerRef
|
|
1699
|
-
}))) : ( /*#__PURE__*/React__namespace.createElement(Container,
|
|
1750
|
+
}))) : ( /*#__PURE__*/React__namespace.createElement(Container, __assign$b({}, containerProps, {
|
|
1700
1751
|
className: className,
|
|
1701
1752
|
ref: containerRef
|
|
1702
1753
|
}), children)));
|
|
@@ -3002,7 +3053,7 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
3002
3053
|
var hasLeadingGuards = noFocusGuards !== true;
|
|
3003
3054
|
var hasTailingGuards = hasLeadingGuards && noFocusGuards !== 'tail';
|
|
3004
3055
|
var mergedRef = useMergeRefs([parentRef, setObserveNode]);
|
|
3005
|
-
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, hasLeadingGuards && [
|
|
3056
|
+
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, hasLeadingGuards && [/*#__PURE__*/
|
|
3006
3057
|
// nearest focus guard
|
|
3007
3058
|
React__namespace.createElement("div", {
|
|
3008
3059
|
key: "guard-first",
|
|
@@ -3086,14 +3137,7 @@ FocusLock.defaultProps = {
|
|
|
3086
3137
|
var FocusLockUI = FocusLock;
|
|
3087
3138
|
|
|
3088
3139
|
function deferAction(action) {
|
|
3089
|
-
|
|
3090
|
-
var _window = window,
|
|
3091
|
-
setImmediate = _window.setImmediate;
|
|
3092
|
-
if (typeof setImmediate !== 'undefined') {
|
|
3093
|
-
setImmediate(action);
|
|
3094
|
-
} else {
|
|
3095
|
-
setTimeout(action, 1);
|
|
3096
|
-
}
|
|
3140
|
+
setTimeout(action, 1);
|
|
3097
3141
|
}
|
|
3098
3142
|
|
|
3099
3143
|
var effectCar = createSidecarMedium();
|
|
@@ -3132,7 +3176,7 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
|
|
|
3132
3176
|
var onActivation = lockProps.onActivation,
|
|
3133
3177
|
onDeactivation = lockProps.onDeactivation,
|
|
3134
3178
|
restProps = __rest$a(lockProps, ["onActivation", "onDeactivation"]);
|
|
3135
|
-
var appliedLockProps =
|
|
3179
|
+
var appliedLockProps = __assign$b(__assign$b({}, restProps), {
|
|
3136
3180
|
as: as,
|
|
3137
3181
|
style: style,
|
|
3138
3182
|
sideCar: sideCar,
|
|
@@ -3157,7 +3201,7 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
|
|
|
3157
3201
|
lockProps: appliedLockProps,
|
|
3158
3202
|
focusOptions: preventScrollOnFocus ? PREVENT_SCROLL : undefined,
|
|
3159
3203
|
as: RemoveScroll
|
|
3160
|
-
}, children), enabled && ( /*#__PURE__*/React__namespace.createElement(SideCar,
|
|
3204
|
+
}, children), enabled && ( /*#__PURE__*/React__namespace.createElement(SideCar, __assign$b({}, rest, {
|
|
3161
3205
|
sideCar: effectCar,
|
|
3162
3206
|
setLockProps: setLockProps,
|
|
3163
3207
|
shards: shards
|
|
@@ -3178,34 +3222,34 @@ function _inheritsLoose(subClass, superClass) {
|
|
|
3178
3222
|
_setPrototypeOf(subClass, superClass);
|
|
3179
3223
|
}
|
|
3180
3224
|
|
|
3181
|
-
function _typeof(
|
|
3225
|
+
function _typeof(o) {
|
|
3182
3226
|
"@babel/helpers - typeof";
|
|
3183
3227
|
|
|
3184
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (
|
|
3185
|
-
return typeof
|
|
3186
|
-
} : function (
|
|
3187
|
-
return
|
|
3188
|
-
}, _typeof(
|
|
3228
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
3229
|
+
return typeof o;
|
|
3230
|
+
} : function (o) {
|
|
3231
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
3232
|
+
}, _typeof(o);
|
|
3189
3233
|
}
|
|
3190
3234
|
|
|
3191
|
-
function
|
|
3192
|
-
if (
|
|
3193
|
-
var
|
|
3194
|
-
if (
|
|
3195
|
-
var
|
|
3196
|
-
if (
|
|
3235
|
+
function toPrimitive(t, r) {
|
|
3236
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
3237
|
+
var e = t[Symbol.toPrimitive];
|
|
3238
|
+
if (void 0 !== e) {
|
|
3239
|
+
var i = e.call(t, r || "default");
|
|
3240
|
+
if ("object" != _typeof(i)) return i;
|
|
3197
3241
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3198
3242
|
}
|
|
3199
|
-
return (
|
|
3243
|
+
return ("string" === r ? String : Number)(t);
|
|
3200
3244
|
}
|
|
3201
3245
|
|
|
3202
|
-
function
|
|
3203
|
-
var
|
|
3204
|
-
return _typeof(
|
|
3246
|
+
function toPropertyKey(t) {
|
|
3247
|
+
var i = toPrimitive(t, "string");
|
|
3248
|
+
return "symbol" == _typeof(i) ? i : String(i);
|
|
3205
3249
|
}
|
|
3206
3250
|
|
|
3207
3251
|
function _defineProperty(obj, key, value) {
|
|
3208
|
-
key =
|
|
3252
|
+
key = toPropertyKey(key);
|
|
3209
3253
|
if (key in obj) {
|
|
3210
3254
|
Object.defineProperty(obj, key, {
|
|
3211
3255
|
value: value,
|
|
@@ -3470,17 +3514,29 @@ var filterAutoFocusable = function filterAutoFocusable(nodes, cache) {
|
|
|
3470
3514
|
});
|
|
3471
3515
|
};
|
|
3472
3516
|
/**
|
|
3473
|
-
*
|
|
3474
|
-
*
|
|
3517
|
+
* !__WARNING__! Low level API.
|
|
3518
|
+
* @returns all tabbable nodes
|
|
3519
|
+
*
|
|
3520
|
+
* @see {@link getFocusableNodes} to get any focusable element
|
|
3521
|
+
*
|
|
3522
|
+
* @param topNodes - array of top level HTMLElements to search inside
|
|
3523
|
+
* @param visibilityCache - an cache to store intermediate measurements. Expected to be a fresh `new Map` on every call
|
|
3475
3524
|
*/
|
|
3476
3525
|
var getTabbableNodes = function getTabbableNodes(topNodes, visibilityCache, withGuards) {
|
|
3477
3526
|
return orderByTabIndex(filterFocusable(getFocusables(topNodes, withGuards), visibilityCache), true, withGuards);
|
|
3478
3527
|
};
|
|
3479
3528
|
/**
|
|
3480
|
-
*
|
|
3481
|
-
*
|
|
3529
|
+
* !__WARNING__! Low level API.
|
|
3530
|
+
*
|
|
3531
|
+
* @returns anything "focusable", not only tabbable. The difference is in `tabIndex=-1`
|
|
3532
|
+
* (without guards, as long as they are not expected to be ever focused)
|
|
3533
|
+
*
|
|
3534
|
+
* @see {@link getTabbableNodes} to get only tabble nodes element
|
|
3535
|
+
*
|
|
3536
|
+
* @param topNodes - array of top level HTMLElements to search inside
|
|
3537
|
+
* @param visibilityCache - an cache to store intermediate measurements. Expected to be a fresh `new Map` on every call
|
|
3482
3538
|
*/
|
|
3483
|
-
var
|
|
3539
|
+
var getFocusableNodes = function getFocusableNodes(topNodes, visibilityCache) {
|
|
3484
3540
|
return orderByTabIndex(filterFocusable(getFocusables(topNodes), visibilityCache), false);
|
|
3485
3541
|
};
|
|
3486
3542
|
/**
|
|
@@ -3552,8 +3608,8 @@ var getTopParent = function getTopParent(node) {
|
|
|
3552
3608
|
};
|
|
3553
3609
|
/**
|
|
3554
3610
|
* returns all "focus containers" inside a given node
|
|
3555
|
-
* @param node
|
|
3556
|
-
* @returns
|
|
3611
|
+
* @param node - node or nodes to look inside
|
|
3612
|
+
* @returns Element[]
|
|
3557
3613
|
*/
|
|
3558
3614
|
var getAllAffectedNodes = function getAllAffectedNodes(node) {
|
|
3559
3615
|
var nodes = asArray(node);
|
|
@@ -3575,6 +3631,10 @@ var safeProbe = function safeProbe(cb) {
|
|
|
3575
3631
|
/**
|
|
3576
3632
|
* returns active element from document or from nested shadowdoms
|
|
3577
3633
|
*/
|
|
3634
|
+
/**
|
|
3635
|
+
* returns current active element. If the active element is a "container" itself(shadowRoot or iframe) returns active element inside it
|
|
3636
|
+
* @param [inDocument]
|
|
3637
|
+
*/
|
|
3578
3638
|
var getActiveElement = function getActiveElement(inDocument) {
|
|
3579
3639
|
if (inDocument === void 0) {
|
|
3580
3640
|
inDocument = document;
|
|
@@ -3597,7 +3657,8 @@ var focusInsideIframe = function focusInsideIframe(topNode, activeElement) {
|
|
|
3597
3657
|
}));
|
|
3598
3658
|
};
|
|
3599
3659
|
/**
|
|
3600
|
-
* @returns {Boolean} true, if the current focus is inside given node or nodes
|
|
3660
|
+
* @returns {Boolean} true, if the current focus is inside given node or nodes.
|
|
3661
|
+
* Supports nodes hidden inside shadowDom
|
|
3601
3662
|
*/
|
|
3602
3663
|
var focusInside = function focusInside(topNode, activeElement) {
|
|
3603
3664
|
// const activeElement = document && getActiveElement();
|
|
@@ -3613,8 +3674,11 @@ var focusInside = function focusInside(topNode, activeElement) {
|
|
|
3613
3674
|
};
|
|
3614
3675
|
|
|
3615
3676
|
/**
|
|
3616
|
-
* focus is hidden FROM the focus-lock
|
|
3677
|
+
* checks if focus is hidden FROM the focus-lock
|
|
3617
3678
|
* ie contained inside a node focus-lock shall ignore
|
|
3679
|
+
*
|
|
3680
|
+
* This is a utility function coupled with {@link FOCUS_ALLOW} constant
|
|
3681
|
+
*
|
|
3618
3682
|
* @returns {boolean} focus is currently is in "allow" area
|
|
3619
3683
|
*/
|
|
3620
3684
|
var focusIsHidden = function focusIsHidden(inDocument) {
|
|
@@ -3839,16 +3903,21 @@ var reorderNodes = function reorderNodes(srcNodes, dstNodes) {
|
|
|
3839
3903
|
}).filter(isDefined);
|
|
3840
3904
|
};
|
|
3841
3905
|
/**
|
|
3842
|
-
*
|
|
3906
|
+
* contains the main logic of the `focus-lock` package.
|
|
3907
|
+
*
|
|
3908
|
+
* ! you probably dont need this function !
|
|
3909
|
+
*
|
|
3910
|
+
* given top node(s) and the last active element returns the element to be focused next
|
|
3911
|
+
* @returns element which should be focused to move focus inside
|
|
3843
3912
|
* @param topNode
|
|
3844
3913
|
* @param lastNode
|
|
3845
3914
|
*/
|
|
3846
|
-
var
|
|
3915
|
+
var focusSolver = function focusSolver(topNode, lastNode) {
|
|
3847
3916
|
var activeElement = getActiveElement(asArray(topNode).length > 0 ? document : getFirst(topNode).ownerDocument);
|
|
3848
3917
|
var entries = getAllAffectedNodes(topNode).filter(isNotAGuard);
|
|
3849
3918
|
var commonParent = getTopCommonParent(activeElement || topNode, topNode, entries);
|
|
3850
3919
|
var visibilityCache = new Map();
|
|
3851
|
-
var anyFocusable =
|
|
3920
|
+
var anyFocusable = getFocusableNodes(entries, visibilityCache);
|
|
3852
3921
|
var innerElements = getTabbableNodes(entries, visibilityCache).filter(function (_a) {
|
|
3853
3922
|
var node = _a.node;
|
|
3854
3923
|
return isNotAGuard(node);
|
|
@@ -3859,7 +3928,7 @@ var getFocusMerge = function getFocusMerge(topNode, lastNode) {
|
|
|
3859
3928
|
return undefined;
|
|
3860
3929
|
}
|
|
3861
3930
|
}
|
|
3862
|
-
var outerNodes =
|
|
3931
|
+
var outerNodes = getFocusableNodes([commonParent], visibilityCache).map(function (_a) {
|
|
3863
3932
|
var node = _a.node;
|
|
3864
3933
|
return node;
|
|
3865
3934
|
});
|
|
@@ -3887,10 +3956,10 @@ var getFocusMerge = function getFocusMerge(topNode, lastNode) {
|
|
|
3887
3956
|
};
|
|
3888
3957
|
|
|
3889
3958
|
/**
|
|
3890
|
-
*
|
|
3891
|
-
* @
|
|
3959
|
+
* @returns list of focusable elements inside a given top node
|
|
3960
|
+
* @see {@link getFocusableNodes} for lower level access
|
|
3892
3961
|
*/
|
|
3893
|
-
var
|
|
3962
|
+
var expandFocusableNodes = function expandFocusableNodes(topNode) {
|
|
3894
3963
|
var entries = getAllAffectedNodes(topNode).filter(isNotAGuard);
|
|
3895
3964
|
var commonParent = getTopCommonParent(topNode, topNode, entries);
|
|
3896
3965
|
var visibilityCache = new Map();
|
|
@@ -3922,26 +3991,34 @@ var focusOn = function focusOn(target, focusOptions) {
|
|
|
3922
3991
|
target.contentWindow.focus();
|
|
3923
3992
|
}
|
|
3924
3993
|
};
|
|
3994
|
+
|
|
3925
3995
|
var guardCount = 0;
|
|
3926
3996
|
var lockDisabled = false;
|
|
3927
3997
|
/**
|
|
3928
|
-
*
|
|
3998
|
+
* The main functionality of the focus-lock package
|
|
3999
|
+
*
|
|
4000
|
+
* Contains focus at a given node.
|
|
4001
|
+
* The last focused element will help to determine which element(first or last) should be focused.
|
|
4002
|
+
* The found element will be focused.
|
|
4003
|
+
*
|
|
4004
|
+
* This is one time action (move), not a persistent focus-lock
|
|
4005
|
+
*
|
|
3929
4006
|
* HTML markers (see {@link import('./constants').FOCUS_AUTO} constants) can control autofocus
|
|
3930
|
-
* @
|
|
3931
|
-
* @param lastNode
|
|
3932
|
-
* @param options
|
|
4007
|
+
* @see {@link focusSolver} for the same functionality without autofocus
|
|
3933
4008
|
*/
|
|
3934
|
-
var
|
|
4009
|
+
var moveFocusInside = function moveFocusInside(topNode, lastNode, options) {
|
|
3935
4010
|
if (options === void 0) {
|
|
3936
4011
|
options = {};
|
|
3937
4012
|
}
|
|
3938
|
-
var focusable =
|
|
4013
|
+
var focusable = focusSolver(topNode, lastNode);
|
|
4014
|
+
// global local side effect to countain recursive lock activation and resolve focus-fighting
|
|
3939
4015
|
if (lockDisabled) {
|
|
3940
4016
|
return;
|
|
3941
4017
|
}
|
|
3942
4018
|
if (focusable) {
|
|
4019
|
+
/** +FOCUS-FIGHTING prevention **/
|
|
3943
4020
|
if (guardCount > 2) {
|
|
3944
|
-
//
|
|
4021
|
+
// we have recursive entered back the lock activation
|
|
3945
4022
|
console.error('FocusLock: focus-fighting detected. Only one focus management system could be active. ' + 'See https://github.com/theKashey/focus-lock/#focus-fighting');
|
|
3946
4023
|
lockDisabled = true;
|
|
3947
4024
|
setTimeout(function () {
|
|
@@ -4054,7 +4131,7 @@ var activateTrap = function activateTrap() {
|
|
|
4054
4131
|
}
|
|
4055
4132
|
document.body.focus();
|
|
4056
4133
|
} else {
|
|
4057
|
-
result =
|
|
4134
|
+
result = moveFocusInside(workingArea, lastActiveFocus, {
|
|
4058
4135
|
focusOptions: focusOptions
|
|
4059
4136
|
});
|
|
4060
4137
|
lastPortaledElement = {};
|
|
@@ -4066,7 +4143,7 @@ var activateTrap = function activateTrap() {
|
|
|
4066
4143
|
}
|
|
4067
4144
|
if (document) {
|
|
4068
4145
|
var newActiveElement = document && document.activeElement;
|
|
4069
|
-
var allNodes =
|
|
4146
|
+
var allNodes = expandFocusableNodes(workingArea);
|
|
4070
4147
|
var focusedIndex = allNodes.map(function (_ref) {
|
|
4071
4148
|
var node = _ref.node;
|
|
4072
4149
|
return node;
|
|
@@ -4116,9 +4193,9 @@ process.env.NODE_ENV !== "production" ? {
|
|
|
4116
4193
|
var onWindowBlur = function onWindowBlur() {
|
|
4117
4194
|
focusWasOutsideWindow = 'just'; // using setTimeout to set this variable after React/sidecar reaction
|
|
4118
4195
|
|
|
4119
|
-
|
|
4196
|
+
deferAction(function () {
|
|
4120
4197
|
focusWasOutsideWindow = 'meanwhile';
|
|
4121
|
-
}
|
|
4198
|
+
});
|
|
4122
4199
|
};
|
|
4123
4200
|
var attachHandler = function attachHandler() {
|
|
4124
4201
|
document.addEventListener('focusin', onTrap);
|
|
@@ -4172,7 +4249,7 @@ mediumFocus.assignSyncMedium(onFocus);
|
|
|
4172
4249
|
mediumBlur.assignMedium(onBlur);
|
|
4173
4250
|
mediumEffect.assignMedium(function (cb) {
|
|
4174
4251
|
return cb({
|
|
4175
|
-
moveFocusInside:
|
|
4252
|
+
moveFocusInside: moveFocusInside,
|
|
4176
4253
|
focusInside: focusInside
|
|
4177
4254
|
});
|
|
4178
4255
|
});
|
|
@@ -4449,15 +4526,20 @@ var handleScroll = function handleScroll(axis, endTarget, event, sourceDelta, no
|
|
|
4449
4526
|
availableScrollTop += position;
|
|
4450
4527
|
}
|
|
4451
4528
|
}
|
|
4452
|
-
target
|
|
4529
|
+
if (target instanceof ShadowRoot) {
|
|
4530
|
+
target = target.host;
|
|
4531
|
+
} else {
|
|
4532
|
+
target = target.parentNode;
|
|
4533
|
+
}
|
|
4453
4534
|
} while (
|
|
4454
4535
|
// portaled content
|
|
4455
4536
|
!targetInLock && target !== document.body ||
|
|
4456
4537
|
// self content
|
|
4457
4538
|
targetInLock && (endTarget.contains(target) || endTarget === target));
|
|
4458
|
-
|
|
4539
|
+
// handle epsilon around 0 (non standard zoom levels)
|
|
4540
|
+
if (isDeltaPositive && (noOverscroll && Math.abs(availableScroll) < 1 || !noOverscroll && delta > availableScroll)) {
|
|
4459
4541
|
shouldCancelScroll = true;
|
|
4460
|
-
} else if (!isDeltaPositive && (noOverscroll && availableScrollTop
|
|
4542
|
+
} else if (!isDeltaPositive && (noOverscroll && Math.abs(availableScrollTop) < 1 || !noOverscroll && -delta > availableScrollTop)) {
|
|
4461
4543
|
shouldCancelScroll = true;
|
|
4462
4544
|
}
|
|
4463
4545
|
return shouldCancelScroll;
|
|
@@ -4552,7 +4634,7 @@ function RemoveScrollSideCar(props) {
|
|
|
4552
4634
|
}
|
|
4553
4635
|
var delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
|
|
4554
4636
|
var sourceEvent = shouldPreventQueue.current.filter(function (e) {
|
|
4555
|
-
return e.name === event.type && e.target === event.target && deltaCompare(e.delta, delta);
|
|
4637
|
+
return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
|
|
4556
4638
|
})[0];
|
|
4557
4639
|
// self event, and should be canceled
|
|
4558
4640
|
if (sourceEvent && sourceEvent.should) {
|
|
@@ -4579,7 +4661,8 @@ function RemoveScrollSideCar(props) {
|
|
|
4579
4661
|
name: name,
|
|
4580
4662
|
delta: delta,
|
|
4581
4663
|
target: target,
|
|
4582
|
-
should: should
|
|
4664
|
+
should: should,
|
|
4665
|
+
shadowParent: getOutermostShadowParent(target)
|
|
4583
4666
|
};
|
|
4584
4667
|
shouldPreventQueue.current.push(event);
|
|
4585
4668
|
setTimeout(function () {
|
|
@@ -4625,6 +4708,17 @@ function RemoveScrollSideCar(props) {
|
|
|
4625
4708
|
gapMode: props.gapMode
|
|
4626
4709
|
}) : null);
|
|
4627
4710
|
}
|
|
4711
|
+
function getOutermostShadowParent(node) {
|
|
4712
|
+
var shadowParent = null;
|
|
4713
|
+
while (node !== null) {
|
|
4714
|
+
if (node instanceof ShadowRoot) {
|
|
4715
|
+
shadowParent = node.host;
|
|
4716
|
+
node = node.host;
|
|
4717
|
+
}
|
|
4718
|
+
node = node.parentNode;
|
|
4719
|
+
}
|
|
4720
|
+
return shadowParent;
|
|
4721
|
+
}
|
|
4628
4722
|
|
|
4629
4723
|
exportSidecar(effectCar$1, RemoveScrollSideCar);
|
|
4630
4724
|
|
|
@@ -4878,10 +4972,10 @@ function Effect(_a) {
|
|
|
4878
4972
|
var SideCar = exportSidecar(effectCar, Effect);
|
|
4879
4973
|
|
|
4880
4974
|
var RequireSideCar = function RequireSideCar(props) {
|
|
4881
|
-
return /*#__PURE__*/React__namespace.createElement(SideCar,
|
|
4975
|
+
return /*#__PURE__*/React__namespace.createElement(SideCar, __assign$b({}, props));
|
|
4882
4976
|
};
|
|
4883
4977
|
var FocusOn = /*#__PURE__*/React__namespace.forwardRef(function (props, ref) {
|
|
4884
|
-
return /*#__PURE__*/React__namespace.createElement(FocusOn$1,
|
|
4978
|
+
return /*#__PURE__*/React__namespace.createElement(FocusOn$1, __assign$b({}, props, {
|
|
4885
4979
|
ref: ref,
|
|
4886
4980
|
sideCar: RequireSideCar
|
|
4887
4981
|
}));
|
|
@@ -9756,8 +9850,8 @@ var t = function t(_t) {
|
|
|
9756
9850
|
},
|
|
9757
9851
|
n = function n(t, _n) {
|
|
9758
9852
|
if (t.clientHeight < t.scrollHeight || t.clientWidth < t.scrollWidth) {
|
|
9759
|
-
var
|
|
9760
|
-
return e$1(
|
|
9853
|
+
var _o = getComputedStyle(t, null);
|
|
9854
|
+
return e$1(_o.overflowY, _n) || e$1(_o.overflowX, _n) || function (t) {
|
|
9761
9855
|
var e = function (t) {
|
|
9762
9856
|
if (!t.ownerDocument || !t.ownerDocument.defaultView) return null;
|
|
9763
9857
|
try {
|
|
@@ -9771,84 +9865,97 @@ var t = function t(_t) {
|
|
|
9771
9865
|
}
|
|
9772
9866
|
return !1;
|
|
9773
9867
|
},
|
|
9774
|
-
|
|
9775
|
-
return
|
|
9868
|
+
o$1 = function o(t, e, n, _o2, l, r, i, s) {
|
|
9869
|
+
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;
|
|
9776
9870
|
},
|
|
9777
|
-
|
|
9871
|
+
l = function l(t) {
|
|
9778
9872
|
var e = t.parentElement;
|
|
9779
9873
|
return null == e ? t.getRootNode().host || null : e;
|
|
9780
9874
|
},
|
|
9781
|
-
|
|
9782
|
-
var
|
|
9875
|
+
r = function r(e, _r2) {
|
|
9876
|
+
var i, s, d, h;
|
|
9783
9877
|
if ("undefined" == typeof document) return [];
|
|
9784
|
-
var
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
a =
|
|
9788
|
-
g =
|
|
9789
|
-
|
|
9878
|
+
var c = _r2.scrollMode,
|
|
9879
|
+
f = _r2.block,
|
|
9880
|
+
u = _r2.inline,
|
|
9881
|
+
a = _r2.boundary,
|
|
9882
|
+
g = _r2.skipOverflowHiddenElements,
|
|
9883
|
+
p = "function" == typeof a ? a : function (t) {
|
|
9790
9884
|
return t !== a;
|
|
9791
9885
|
};
|
|
9792
9886
|
if (!t(e)) throw new TypeError("Invalid target");
|
|
9793
|
-
var
|
|
9794
|
-
w = []
|
|
9795
|
-
|
|
9796
|
-
for (; t(W) &&
|
|
9797
|
-
if (W =
|
|
9887
|
+
var m = document.scrollingElement || document.documentElement,
|
|
9888
|
+
w = [];
|
|
9889
|
+
var W = e;
|
|
9890
|
+
for (; t(W) && p(W);) {
|
|
9891
|
+
if (W = l(W), W === m) {
|
|
9798
9892
|
w.push(W);
|
|
9799
9893
|
break;
|
|
9800
9894
|
}
|
|
9801
9895
|
null != W && W === document.body && n(W) && !n(document.documentElement) || null != W && n(W, g) && w.push(W);
|
|
9802
9896
|
}
|
|
9803
|
-
var
|
|
9804
|
-
|
|
9897
|
+
var b = null != (s = null == (i = window.visualViewport) ? void 0 : i.width) ? s : innerWidth,
|
|
9898
|
+
H = null != (h = null == (d = window.visualViewport) ? void 0 : d.height) ? h : innerHeight,
|
|
9805
9899
|
_window = window,
|
|
9806
|
-
|
|
9807
|
-
|
|
9900
|
+
y = _window.scrollX,
|
|
9901
|
+
M = _window.scrollY,
|
|
9808
9902
|
_e$getBoundingClientR = e.getBoundingClientRect(),
|
|
9809
|
-
|
|
9810
|
-
|
|
9903
|
+
v = _e$getBoundingClientR.height,
|
|
9904
|
+
E = _e$getBoundingClientR.width,
|
|
9811
9905
|
x = _e$getBoundingClientR.top,
|
|
9812
|
-
|
|
9813
|
-
|
|
9906
|
+
C = _e$getBoundingClientR.right,
|
|
9907
|
+
I = _e$getBoundingClientR.bottom,
|
|
9814
9908
|
R = _e$getBoundingClientR.left,
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
|
|
9909
|
+
_ref = function (t) {
|
|
9910
|
+
var e = window.getComputedStyle(t);
|
|
9911
|
+
return {
|
|
9912
|
+
top: parseFloat(e.scrollMarginTop) || 0,
|
|
9913
|
+
right: parseFloat(e.scrollMarginRight) || 0,
|
|
9914
|
+
bottom: parseFloat(e.scrollMarginBottom) || 0,
|
|
9915
|
+
left: parseFloat(e.scrollMarginLeft) || 0
|
|
9916
|
+
};
|
|
9917
|
+
}(e),
|
|
9918
|
+
T = _ref.top,
|
|
9919
|
+
B = _ref.right,
|
|
9920
|
+
F = _ref.bottom,
|
|
9921
|
+
V = _ref.left;
|
|
9922
|
+
var k = "start" === f || "nearest" === f ? x - T : "end" === f ? I + F : x + v / 2 - T + F,
|
|
9923
|
+
D = "center" === u ? R + E / 2 - V + B : "end" === u ? C + B : R - V;
|
|
9924
|
+
var L = [];
|
|
9818
9925
|
for (var _t2 = 0; _t2 < w.length; _t2++) {
|
|
9819
9926
|
var _e2 = w[_t2],
|
|
9820
9927
|
_e$getBoundingClientR2 = _e2.getBoundingClientRect(),
|
|
9821
9928
|
_n2 = _e$getBoundingClientR2.height,
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
if ("if-needed" ===
|
|
9828
|
-
var
|
|
9829
|
-
_a = parseInt(
|
|
9830
|
-
_g = parseInt(
|
|
9831
|
-
|
|
9832
|
-
_W = parseInt(
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
if (
|
|
9840
|
-
|
|
9929
|
+
_l = _e$getBoundingClientR2.width,
|
|
9930
|
+
_r = _e$getBoundingClientR2.top,
|
|
9931
|
+
_i = _e$getBoundingClientR2.right,
|
|
9932
|
+
_s = _e$getBoundingClientR2.bottom,
|
|
9933
|
+
_d = _e$getBoundingClientR2.left;
|
|
9934
|
+
if ("if-needed" === c && x >= 0 && R >= 0 && I <= H && C <= b && x >= _r && I <= _s && R >= _d && C <= _i) return L;
|
|
9935
|
+
var _h = getComputedStyle(_e2),
|
|
9936
|
+
_a = parseInt(_h.borderLeftWidth, 10),
|
|
9937
|
+
_g = parseInt(_h.borderTopWidth, 10),
|
|
9938
|
+
_p = parseInt(_h.borderRightWidth, 10),
|
|
9939
|
+
_W = parseInt(_h.borderBottomWidth, 10);
|
|
9940
|
+
var _T = 0,
|
|
9941
|
+
_B = 0;
|
|
9942
|
+
var _F = "offsetWidth" in _e2 ? _e2.offsetWidth - _e2.clientWidth - _a - _p : 0,
|
|
9943
|
+
_V = "offsetHeight" in _e2 ? _e2.offsetHeight - _e2.clientHeight - _g - _W : 0,
|
|
9944
|
+
S = "offsetWidth" in _e2 ? 0 === _e2.offsetWidth ? 0 : _l / _e2.offsetWidth : 0,
|
|
9945
|
+
X = "offsetHeight" in _e2 ? 0 === _e2.offsetHeight ? 0 : _n2 / _e2.offsetHeight : 0;
|
|
9946
|
+
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 {
|
|
9947
|
+
_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);
|
|
9841
9948
|
var _t3 = _e2.scrollLeft,
|
|
9842
|
-
|
|
9843
|
-
|
|
9949
|
+
_h2 = _e2.scrollTop;
|
|
9950
|
+
_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;
|
|
9844
9951
|
}
|
|
9845
|
-
|
|
9952
|
+
L.push({
|
|
9846
9953
|
el: _e2,
|
|
9847
|
-
top:
|
|
9848
|
-
left:
|
|
9954
|
+
top: _T,
|
|
9955
|
+
left: _B
|
|
9849
9956
|
});
|
|
9850
9957
|
}
|
|
9851
|
-
return
|
|
9958
|
+
return L;
|
|
9852
9959
|
};
|
|
9853
9960
|
|
|
9854
9961
|
var o = function o(t) {
|
|
@@ -9862,7 +9969,7 @@ var o = function o(t) {
|
|
|
9862
9969
|
inline: "nearest"
|
|
9863
9970
|
};
|
|
9864
9971
|
};
|
|
9865
|
-
function e(e, r) {
|
|
9972
|
+
function e(e, r$1) {
|
|
9866
9973
|
if (!e.isConnected || !function (t) {
|
|
9867
9974
|
var o = t;
|
|
9868
9975
|
for (; o && o.parentNode;) {
|
|
@@ -9882,9 +9989,9 @@ function e(e, r) {
|
|
|
9882
9989
|
}(e);
|
|
9883
9990
|
if (function (t) {
|
|
9884
9991
|
return "object" == _typeof$1(t) && "function" == typeof t.behavior;
|
|
9885
|
-
}(r)) return r.behavior(
|
|
9886
|
-
var l = "boolean" == typeof r || null == r ? void 0 : r.behavior;
|
|
9887
|
-
var _iterator = _createForOfIteratorHelper(
|
|
9992
|
+
}(r$1)) return r$1.behavior(r(e, r$1));
|
|
9993
|
+
var l = "boolean" == typeof r$1 || null == r$1 ? void 0 : r$1.behavior;
|
|
9994
|
+
var _iterator = _createForOfIteratorHelper(r(e, o(r$1))),
|
|
9888
9995
|
_step;
|
|
9889
9996
|
try {
|
|
9890
9997
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|