@onereach/ui-components 8.18.2 → 8.18.3-beta.3946.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/dist/bundled/v2/components/OrModal/OrModal.js +1 -1
- package/dist/bundled/v2/components/OrRichTextEditorV3/OrRichTextEditor.js +1 -1
- package/dist/bundled/v2/components/OrSelectV3/OrSelect.vue.d.ts +7 -7
- package/dist/bundled/v2/{useFocusTrap-2354d4f3.js → useFocusTrap-2df16342.js} +307 -120
- package/dist/bundled/v3/components/OrCode/OrCode.js +1 -1
- package/dist/bundled/v3/components/OrCode/constants.js +1 -1
- package/dist/bundled/v3/components/OrCode/index.js +1 -1
- package/dist/bundled/v3/components/OrCode/lang.js +1 -1
- package/dist/bundled/v3/components/OrCode/libs.js +1 -1
- package/dist/bundled/v3/components/OrCode/theme.js +1 -1
- package/dist/bundled/v3/components/{OrCode-46b1b8aa.js → OrCode-f7708644.js} +1 -1
- package/dist/bundled/v3/components/OrCodeV3/OrCode.js +1 -1
- package/dist/bundled/v3/components/OrCodeV3/index.js +2 -2
- package/dist/bundled/v3/components/OrCodeV3/libs.js +1 -1
- package/dist/bundled/v3/components/OrCodeV3/props.js +1 -1
- package/dist/bundled/v3/components/OrCodeV3/styles.js +1 -1
- package/dist/bundled/v3/components/{OrCodeV3-d8e1ec2f.js → OrCodeV3-6dbd233d.js} +7 -7
- package/dist/bundled/v3/components/OrConfirm/OrConfirm.js +1 -1
- package/dist/bundled/v3/components/OrConfirm/index.js +1 -1
- package/dist/bundled/v3/components/{OrConfirm-f95a3ce6.js → OrConfirm-66387c1f.js} +1 -1
- package/dist/bundled/v3/components/OrConfirmV3/OrConfirm.js +1 -1
- package/dist/bundled/v3/components/OrConfirmV3/index.js +1 -1
- package/dist/bundled/v3/components/OrConfirmV3/props.js +1 -1
- package/dist/bundled/v3/components/OrConfirmV3/styles.js +1 -1
- package/dist/bundled/v3/components/{OrConfirmV3-26accd85.js → OrConfirmV3-0a0d83f0.js} +1 -1
- package/dist/bundled/v3/components/OrModal/OrModal.js +1 -1
- package/dist/bundled/v3/components/OrModal/constants.js +1 -1
- package/dist/bundled/v3/components/OrModal/index.js +1 -1
- package/dist/bundled/v3/components/{OrModal-3aad4d27.js → OrModal-70fa6d2d.js} +307 -120
- package/dist/bundled/v3/components/OrRichTextEditorV3/OrRichTextEditor.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/index.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/props.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/styles.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorNode.js +2 -2
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/codemirrorView.js +2 -2
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/index.js +1 -1
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/codemirror/theme.js +2 -2
- package/dist/bundled/v3/components/OrRichTextEditorV3/utils/markdown.js +1 -1
- package/dist/bundled/v3/components/{OrRichTextEditorV3-243f2ed9.js → OrRichTextEditorV3-51a86e18.js} +2 -2
- package/dist/bundled/v3/components/OrSelectV3/OrSelect.vue.d.ts +4 -4
- package/dist/bundled/v3/components/index.js +6 -6
- package/dist/bundled/v3/index.js +6 -6
- package/dist/esm/v2/components/or-select-v3/OrSelect.vue.d.ts +7 -7
- package/dist/esm/v3/components/or-select-v3/OrSelect.vue.d.ts +4 -4
- package/package.json +6 -6
- package/src/components/or-select-v3/OrSelect.vue +3 -3
|
@@ -572,7 +572,7 @@ var isFocusable = function isFocusable(node, options) {
|
|
|
572
572
|
};
|
|
573
573
|
|
|
574
574
|
/*!
|
|
575
|
-
* focus-trap 7.2
|
|
575
|
+
* focus-trap 7.5.2
|
|
576
576
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
577
577
|
*/
|
|
578
578
|
function ownKeys(object, enumerableOnly) {
|
|
@@ -655,10 +655,10 @@ var isSelectableInput = function isSelectableInput(node) {
|
|
|
655
655
|
return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
|
|
656
656
|
};
|
|
657
657
|
var isEscapeEvent = function isEscapeEvent(e) {
|
|
658
|
-
return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
|
|
658
|
+
return (e === null || e === void 0 ? void 0 : e.key) === 'Escape' || (e === null || e === void 0 ? void 0 : e.key) === 'Esc' || (e === null || e === void 0 ? void 0 : e.keyCode) === 27;
|
|
659
659
|
};
|
|
660
660
|
var isTabEvent = function isTabEvent(e) {
|
|
661
|
-
return e.key === 'Tab' || e.keyCode === 9;
|
|
661
|
+
return (e === null || e === void 0 ? void 0 : e.key) === 'Tab' || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
|
|
662
662
|
};
|
|
663
663
|
|
|
664
664
|
// checks for TAB by default
|
|
@@ -742,8 +742,11 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
742
742
|
// container: HTMLElement,
|
|
743
743
|
// tabbableNodes: Array<HTMLElement>, // empty if none
|
|
744
744
|
// focusableNodes: Array<HTMLElement>, // empty if none
|
|
745
|
-
//
|
|
746
|
-
//
|
|
745
|
+
// posTabIndexesFound: boolean,
|
|
746
|
+
// firstTabbableNode: HTMLElement|undefined,
|
|
747
|
+
// lastTabbableNode: HTMLElement|undefined,
|
|
748
|
+
// firstDomTabbableNode: HTMLElement|undefined,
|
|
749
|
+
// lastDomTabbableNode: HTMLElement|undefined,
|
|
747
750
|
// nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
|
|
748
751
|
// }>}
|
|
749
752
|
containerGroups: [],
|
|
@@ -760,7 +763,9 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
760
763
|
paused: false,
|
|
761
764
|
// timer ID for when delayInitialFocus is true and initial focus in this trap
|
|
762
765
|
// has been delayed during activation
|
|
763
|
-
delayInitialFocusTimer: undefined
|
|
766
|
+
delayInitialFocusTimer: undefined,
|
|
767
|
+
// the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
|
|
768
|
+
recentNavEvent: undefined
|
|
764
769
|
};
|
|
765
770
|
var trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later
|
|
766
771
|
|
|
@@ -779,23 +784,27 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
779
784
|
/**
|
|
780
785
|
* Finds the index of the container that contains the element.
|
|
781
786
|
* @param {HTMLElement} element
|
|
787
|
+
* @param {Event} [event] If available, and `element` isn't directly found in any container,
|
|
788
|
+
* the event's composed path is used to see if includes any known trap containers in the
|
|
789
|
+
* case where the element is inside a Shadow DOM.
|
|
782
790
|
* @returns {number} Index of the container in either `state.containers` or
|
|
783
791
|
* `state.containerGroups` (the order/length of these lists are the same); -1
|
|
784
792
|
* if the element isn't found.
|
|
785
793
|
*/
|
|
786
|
-
var findContainerIndex = function findContainerIndex(element) {
|
|
794
|
+
var findContainerIndex = function findContainerIndex(element, event) {
|
|
795
|
+
var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === 'function' ? event.composedPath() : undefined;
|
|
787
796
|
// NOTE: search `containerGroups` because it's possible a group contains no tabbable
|
|
788
797
|
// nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
|
|
789
798
|
// and we still need to find the element in there
|
|
790
799
|
return state.containerGroups.findIndex(function (_ref) {
|
|
791
800
|
var container = _ref.container,
|
|
792
801
|
tabbableNodes = _ref.tabbableNodes;
|
|
793
|
-
return container.contains(element) ||
|
|
802
|
+
return container.contains(element) || (
|
|
794
803
|
// fall back to explicit tabbable search which will take into consideration any
|
|
795
804
|
// web components if the `tabbableOptions.getShadowRoot` option was used for
|
|
796
805
|
// the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
|
|
797
806
|
// look inside web components even if open)
|
|
798
|
-
tabbableNodes.find(function (node) {
|
|
807
|
+
composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function (node) {
|
|
799
808
|
return node === element;
|
|
800
809
|
});
|
|
801
810
|
});
|
|
@@ -851,8 +860,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
851
860
|
if (node === false) {
|
|
852
861
|
return false;
|
|
853
862
|
}
|
|
854
|
-
if (node === undefined) {
|
|
855
|
-
// option not specified: use fallback options
|
|
863
|
+
if (node === undefined || !isFocusable(node, config.tabbableOptions)) {
|
|
864
|
+
// option not specified nor focusable: use fallback options
|
|
856
865
|
if (findContainerIndex(doc.activeElement) >= 0) {
|
|
857
866
|
node = doc.activeElement;
|
|
858
867
|
} else {
|
|
@@ -873,14 +882,41 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
873
882
|
var tabbableNodes = tabbable(container, config.tabbableOptions);
|
|
874
883
|
|
|
875
884
|
// NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
|
|
876
|
-
// are a superset of tabbable nodes
|
|
885
|
+
// are a superset of tabbable nodes since nodes with negative `tabindex` attributes
|
|
886
|
+
// are focusable but not tabbable
|
|
877
887
|
var focusableNodes = focusable(container, config.tabbableOptions);
|
|
888
|
+
var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;
|
|
889
|
+
var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : undefined;
|
|
890
|
+
var firstDomTabbableNode = focusableNodes.find(function (node) {
|
|
891
|
+
return isTabbable(node);
|
|
892
|
+
});
|
|
893
|
+
var lastDomTabbableNode = focusableNodes.slice().reverse().find(function (node) {
|
|
894
|
+
return isTabbable(node);
|
|
895
|
+
});
|
|
896
|
+
var posTabIndexesFound = !!tabbableNodes.find(function (node) {
|
|
897
|
+
return getTabIndex(node) > 0;
|
|
898
|
+
});
|
|
878
899
|
return {
|
|
879
900
|
container: container,
|
|
880
901
|
tabbableNodes: tabbableNodes,
|
|
881
902
|
focusableNodes: focusableNodes,
|
|
882
|
-
|
|
883
|
-
|
|
903
|
+
/** True if at least one node with positive `tabindex` was found in this container. */
|
|
904
|
+
posTabIndexesFound: posTabIndexesFound,
|
|
905
|
+
/** First tabbable node in container, __tabindex__ order; `undefined` if none. */
|
|
906
|
+
firstTabbableNode: firstTabbableNode,
|
|
907
|
+
/** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
|
|
908
|
+
lastTabbableNode: lastTabbableNode,
|
|
909
|
+
// NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
|
|
910
|
+
// would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
|
|
911
|
+
// because that API doesn't work with Shadow DOM as well as it should (@see
|
|
912
|
+
// https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
|
|
913
|
+
// to address an edge case related to positive tabindex support, this seems like a much easier,
|
|
914
|
+
// "close enough most of the time" alternative for positive tabindexes which should generally
|
|
915
|
+
// be avoided anyway...
|
|
916
|
+
/** First tabbable node in container, __DOM__ order; `undefined` if none. */
|
|
917
|
+
firstDomTabbableNode: firstDomTabbableNode,
|
|
918
|
+
/** Last tabbable node in container, __DOM__ order; `undefined` if none. */
|
|
919
|
+
lastDomTabbableNode: lastDomTabbableNode,
|
|
884
920
|
/**
|
|
885
921
|
* Finds the __tabbable__ node that follows the given node in the specified direction,
|
|
886
922
|
* in this container, if any.
|
|
@@ -891,30 +927,24 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
891
927
|
*/
|
|
892
928
|
nextTabbableNode: function nextTabbableNode(node) {
|
|
893
929
|
var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
894
|
-
|
|
895
|
-
// from the DOM order), this __will not work__ because the list of focusableNodes,
|
|
896
|
-
// while it contains tabbable nodes, does not sort its nodes in any order other
|
|
897
|
-
// than DOM order, because it can't: Where would you place focusable (but not
|
|
898
|
-
// tabbable) nodes in that order? They have no order, because they aren't tabbale...
|
|
899
|
-
// Support for positive tabindex is already broken and hard to manage (possibly
|
|
900
|
-
// not supportable, TBD), so this isn't going to make things worse than they
|
|
901
|
-
// already are, and at least makes things better for the majority of cases where
|
|
902
|
-
// tabindex is either 0/unset or negative.
|
|
903
|
-
// FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375
|
|
904
|
-
var nodeIdx = focusableNodes.findIndex(function (n) {
|
|
905
|
-
return n === node;
|
|
906
|
-
});
|
|
930
|
+
var nodeIdx = tabbableNodes.indexOf(node);
|
|
907
931
|
if (nodeIdx < 0) {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
932
|
+
// either not tabbable nor focusable, or was focused but not tabbable (negative tabindex):
|
|
933
|
+
// since `node` should at least have been focusable, we assume that's the case and mimic
|
|
934
|
+
// what browsers do, which is set focus to the next node in __document position order__,
|
|
935
|
+
// regardless of positive tabindexes, if any -- and for reasons explained in the NOTE
|
|
936
|
+
// above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to
|
|
937
|
+
// basic DOM order
|
|
938
|
+
if (forward) {
|
|
939
|
+
return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function (el) {
|
|
940
|
+
return isTabbable(el);
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function (el) {
|
|
944
|
+
return isTabbable(el);
|
|
913
945
|
});
|
|
914
946
|
}
|
|
915
|
-
return
|
|
916
|
-
return isTabbable(n, config.tabbableOptions);
|
|
917
|
-
});
|
|
947
|
+
return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
|
|
918
948
|
}
|
|
919
949
|
};
|
|
920
950
|
});
|
|
@@ -927,6 +957,19 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
927
957
|
) {
|
|
928
958
|
throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
|
|
929
959
|
}
|
|
960
|
+
|
|
961
|
+
// NOTE: Positive tabindexes are only properly supported in single-container traps because
|
|
962
|
+
// doing it across multiple containers where tabindexes could be all over the place
|
|
963
|
+
// would require Tabbable to support multiple containers, would require additional
|
|
964
|
+
// specialized Shadow DOM support, and would require Tabbable's multi-container support
|
|
965
|
+
// to look at those containers in document position order rather than user-provided
|
|
966
|
+
// order (as they are treated in Focus-trap, for legacy reasons). See discussion on
|
|
967
|
+
// https://github.com/focus-trap/focus-trap/issues/375 for more details.
|
|
968
|
+
if (state.containerGroups.find(function (g) {
|
|
969
|
+
return g.posTabIndexesFound;
|
|
970
|
+
}) && state.containerGroups.length > 1) {
|
|
971
|
+
throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.");
|
|
972
|
+
}
|
|
930
973
|
};
|
|
931
974
|
var tryFocus = function tryFocus(node) {
|
|
932
975
|
if (node === false) {
|
|
@@ -942,6 +985,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
942
985
|
node.focus({
|
|
943
986
|
preventScroll: !!config.preventScroll
|
|
944
987
|
});
|
|
988
|
+
// NOTE: focus() API does not trigger focusIn event so set MRU node manually
|
|
945
989
|
state.mostRecentlyFocusedNode = node;
|
|
946
990
|
if (isSelectableInput(node)) {
|
|
947
991
|
node.select();
|
|
@@ -952,76 +996,30 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
952
996
|
return node ? node : node === false ? false : previousActiveElement;
|
|
953
997
|
};
|
|
954
998
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
// NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
|
|
973
|
-
// which will result in the outside click setting focus to the node
|
|
974
|
-
// that was clicked, whether it's focusable or not; by setting
|
|
975
|
-
// `returnFocus: true`, we'll attempt to re-focus the node originally-focused
|
|
976
|
-
// on activation (or the configured `setReturnFocus` node)
|
|
977
|
-
returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions)
|
|
978
|
-
});
|
|
979
|
-
return;
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
// This is needed for mobile devices.
|
|
983
|
-
// (If we'll only let `click` events through,
|
|
984
|
-
// then on mobile they will be blocked anyways if `touchstart` is blocked.)
|
|
985
|
-
if (valueOrHandler(config.allowOutsideClick, e)) {
|
|
986
|
-
// allow the click outside the trap to take place
|
|
987
|
-
return;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
// otherwise, prevent the click
|
|
991
|
-
e.preventDefault();
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
// In case focus escapes the trap for some strange reason, pull it back in.
|
|
995
|
-
var checkFocusIn = function checkFocusIn(e) {
|
|
996
|
-
var target = getActualTarget(e);
|
|
997
|
-
var targetContained = findContainerIndex(target) >= 0;
|
|
998
|
-
|
|
999
|
-
// In Firefox when you Tab out of an iframe the Document is briefly focused.
|
|
1000
|
-
if (targetContained || target instanceof Document) {
|
|
1001
|
-
if (targetContained) {
|
|
1002
|
-
state.mostRecentlyFocusedNode = target;
|
|
1003
|
-
}
|
|
1004
|
-
} else {
|
|
1005
|
-
// escaped! pull it back in to where it just left
|
|
1006
|
-
e.stopImmediatePropagation();
|
|
1007
|
-
tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
|
|
1008
|
-
}
|
|
1009
|
-
};
|
|
1010
|
-
|
|
1011
|
-
// Hijack key nav events on the first and last focusable nodes of the trap,
|
|
1012
|
-
// in order to prevent focus from escaping. If it escapes for even a
|
|
1013
|
-
// moment it can end up scrolling the page and causing confusion so we
|
|
1014
|
-
// kind of need to capture the action at the keydown phase.
|
|
1015
|
-
var checkKeyNav = function checkKeyNav(event) {
|
|
1016
|
-
var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1017
|
-
var target = getActualTarget(event);
|
|
999
|
+
/**
|
|
1000
|
+
* Finds the next node (in either direction) where focus should move according to a
|
|
1001
|
+
* keyboard focus-in event.
|
|
1002
|
+
* @param {Object} params
|
|
1003
|
+
* @param {Node} [params.target] Known target __from which__ to navigate, if any.
|
|
1004
|
+
* @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event
|
|
1005
|
+
* will be used to determine the `target`). Ignored if `target` is specified.
|
|
1006
|
+
* @param {boolean} [params.isBackward] True if focus should move backward.
|
|
1007
|
+
* @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
|
|
1008
|
+
* determined given the current state of the trap.
|
|
1009
|
+
*/
|
|
1010
|
+
var findNextNavNode = function findNextNavNode(_ref2) {
|
|
1011
|
+
var target = _ref2.target,
|
|
1012
|
+
event = _ref2.event,
|
|
1013
|
+
_ref2$isBackward = _ref2.isBackward,
|
|
1014
|
+
isBackward = _ref2$isBackward === void 0 ? false : _ref2$isBackward;
|
|
1015
|
+
target = target || getActualTarget(event);
|
|
1018
1016
|
updateTabbableNodes();
|
|
1019
1017
|
var destinationNode = null;
|
|
1020
1018
|
if (state.tabbableGroups.length > 0) {
|
|
1021
1019
|
// make sure the target is actually contained in a group
|
|
1022
1020
|
// NOTE: the target may also be the container itself if it's focusable
|
|
1023
1021
|
// with tabIndex='-1' and was given initial focus
|
|
1024
|
-
var containerIndex = findContainerIndex(target);
|
|
1022
|
+
var containerIndex = findContainerIndex(target, event);
|
|
1025
1023
|
var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
|
|
1026
1024
|
if (containerIndex < 0) {
|
|
1027
1025
|
// target not found in any group: quite possible focus has escaped the trap,
|
|
@@ -1037,8 +1035,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1037
1035
|
// REVERSE
|
|
1038
1036
|
|
|
1039
1037
|
// is the target the first tabbable node in a group?
|
|
1040
|
-
var startOfGroupIndex = findIndex(state.tabbableGroups, function (
|
|
1041
|
-
var firstTabbableNode =
|
|
1038
|
+
var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
|
|
1039
|
+
var firstTabbableNode = _ref3.firstTabbableNode;
|
|
1042
1040
|
return target === firstTabbableNode;
|
|
1043
1041
|
});
|
|
1044
1042
|
if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
|
|
@@ -1056,7 +1054,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1056
1054
|
// the LAST group if it's the first tabbable node of the FIRST group)
|
|
1057
1055
|
var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
|
|
1058
1056
|
var destinationGroup = state.tabbableGroups[destinationGroupIndex];
|
|
1059
|
-
destinationNode = destinationGroup.lastTabbableNode;
|
|
1057
|
+
destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
|
|
1060
1058
|
} else if (!isTabEvent(event)) {
|
|
1061
1059
|
// user must have customized the nav keys so we have to move focus manually _within_
|
|
1062
1060
|
// the active group: do this based on the order determined by tabbable()
|
|
@@ -1066,8 +1064,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1066
1064
|
// FORWARD
|
|
1067
1065
|
|
|
1068
1066
|
// is the target the last tabbable node in a group?
|
|
1069
|
-
var lastOfGroupIndex = findIndex(state.tabbableGroups, function (
|
|
1070
|
-
var lastTabbableNode =
|
|
1067
|
+
var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref4) {
|
|
1068
|
+
var lastTabbableNode = _ref4.lastTabbableNode;
|
|
1071
1069
|
return target === lastTabbableNode;
|
|
1072
1070
|
});
|
|
1073
1071
|
if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
|
|
@@ -1085,7 +1083,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1085
1083
|
// group if it's the last tabbable node of the LAST group)
|
|
1086
1084
|
var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
|
|
1087
1085
|
var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
|
|
1088
|
-
destinationNode = _destinationGroup.firstTabbableNode;
|
|
1086
|
+
destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
|
|
1089
1087
|
} else if (!isTabEvent(event)) {
|
|
1090
1088
|
// user must have customized the nav keys so we have to move focus manually _within_
|
|
1091
1089
|
// the active group: do this based on the order determined by tabbable()
|
|
@@ -1097,6 +1095,153 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1097
1095
|
// NOTE: the fallbackFocus option does not support returning false to opt-out
|
|
1098
1096
|
destinationNode = getNodeForOption('fallbackFocus');
|
|
1099
1097
|
}
|
|
1098
|
+
return destinationNode;
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
// This needs to be done on mousedown and touchstart instead of click
|
|
1102
|
+
// so that it precedes the focus event.
|
|
1103
|
+
var checkPointerDown = function checkPointerDown(e) {
|
|
1104
|
+
var target = getActualTarget(e);
|
|
1105
|
+
if (findContainerIndex(target, e) >= 0) {
|
|
1106
|
+
// allow the click since it ocurred inside the trap
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
if (valueOrHandler(config.clickOutsideDeactivates, e)) {
|
|
1110
|
+
// immediately deactivate the trap
|
|
1111
|
+
trap.deactivate({
|
|
1112
|
+
// NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
|
|
1113
|
+
// which will result in the outside click setting focus to the node
|
|
1114
|
+
// that was clicked (and if not focusable, to "nothing"); by setting
|
|
1115
|
+
// `returnFocus: true`, we'll attempt to re-focus the node originally-focused
|
|
1116
|
+
// on activation (or the configured `setReturnFocus` node), whether the
|
|
1117
|
+
// outside click was on a focusable node or not
|
|
1118
|
+
returnFocus: config.returnFocusOnDeactivate
|
|
1119
|
+
});
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
// This is needed for mobile devices.
|
|
1124
|
+
// (If we'll only let `click` events through,
|
|
1125
|
+
// then on mobile they will be blocked anyways if `touchstart` is blocked.)
|
|
1126
|
+
if (valueOrHandler(config.allowOutsideClick, e)) {
|
|
1127
|
+
// allow the click outside the trap to take place
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// otherwise, prevent the click
|
|
1132
|
+
e.preventDefault();
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
// In case focus escapes the trap for some strange reason, pull it back in.
|
|
1136
|
+
// NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected
|
|
1137
|
+
// scrolling if the node that got focused was out of view; there's nothing we can do to
|
|
1138
|
+
// prevent that from happening by the time we discover that focus escaped
|
|
1139
|
+
var checkFocusIn = function checkFocusIn(event) {
|
|
1140
|
+
var target = getActualTarget(event);
|
|
1141
|
+
var targetContained = findContainerIndex(target, event) >= 0;
|
|
1142
|
+
|
|
1143
|
+
// In Firefox when you Tab out of an iframe the Document is briefly focused.
|
|
1144
|
+
if (targetContained || target instanceof Document) {
|
|
1145
|
+
if (targetContained) {
|
|
1146
|
+
state.mostRecentlyFocusedNode = target;
|
|
1147
|
+
}
|
|
1148
|
+
} else {
|
|
1149
|
+
// escaped! pull it back in to where it just left
|
|
1150
|
+
event.stopImmediatePropagation();
|
|
1151
|
+
|
|
1152
|
+
// focus will escape if the MRU node had a positive tab index and user tried to nav forward;
|
|
1153
|
+
// it will also escape if the MRU node had a 0 tab index and user tried to nav backward
|
|
1154
|
+
// toward a node with a positive tab index
|
|
1155
|
+
var nextNode; // next node to focus, if we find one
|
|
1156
|
+
var navAcrossContainers = true;
|
|
1157
|
+
if (state.mostRecentlyFocusedNode) {
|
|
1158
|
+
if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
|
|
1159
|
+
// MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...
|
|
1160
|
+
var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
|
|
1161
|
+
// there MAY not be any tabbable nodes in the container if there are at least 2 containers
|
|
1162
|
+
// and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container
|
|
1163
|
+
// with at least one tabbable node in order to function, so this could be the other container
|
|
1164
|
+
// with nothing tabbable in it)
|
|
1165
|
+
var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
|
|
1166
|
+
if (tabbableNodes.length > 0) {
|
|
1167
|
+
// MRU tab index MAY not be found if the MRU node is focusable but not tabbable
|
|
1168
|
+
var mruTabIdx = tabbableNodes.findIndex(function (node) {
|
|
1169
|
+
return node === state.mostRecentlyFocusedNode;
|
|
1170
|
+
});
|
|
1171
|
+
if (mruTabIdx >= 0) {
|
|
1172
|
+
if (config.isKeyForward(state.recentNavEvent)) {
|
|
1173
|
+
if (mruTabIdx + 1 < tabbableNodes.length) {
|
|
1174
|
+
nextNode = tabbableNodes[mruTabIdx + 1];
|
|
1175
|
+
navAcrossContainers = false;
|
|
1176
|
+
}
|
|
1177
|
+
// else, don't wrap within the container as focus should move to next/previous
|
|
1178
|
+
// container
|
|
1179
|
+
} else {
|
|
1180
|
+
if (mruTabIdx - 1 >= 0) {
|
|
1181
|
+
nextNode = tabbableNodes[mruTabIdx - 1];
|
|
1182
|
+
navAcrossContainers = false;
|
|
1183
|
+
}
|
|
1184
|
+
// else, don't wrap within the container as focus should move to next/previous
|
|
1185
|
+
// container
|
|
1186
|
+
}
|
|
1187
|
+
// else, don't find in container order without considering direction too
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
// else, no tabbable nodes in that container (which means we must have at least one other
|
|
1191
|
+
// container with at least one tabbable node in it, otherwise focus-trap would've thrown
|
|
1192
|
+
// an error the last time updateTabbableNodes() was run): find next node among all known
|
|
1193
|
+
// containers
|
|
1194
|
+
} else {
|
|
1195
|
+
// check to see if there's at least one tabbable node with a positive tab index inside
|
|
1196
|
+
// the trap because focus seems to escape when navigating backward from a tabbable node
|
|
1197
|
+
// with tabindex=0 when this is the case (instead of wrapping to the tabbable node with
|
|
1198
|
+
// the greatest positive tab index like it should)
|
|
1199
|
+
if (!state.containerGroups.some(function (g) {
|
|
1200
|
+
return g.tabbableNodes.some(function (n) {
|
|
1201
|
+
return getTabIndex(n) > 0;
|
|
1202
|
+
});
|
|
1203
|
+
})) {
|
|
1204
|
+
// no containers with tabbable nodes with positive tab indexes which means the focus
|
|
1205
|
+
// escaped for some other reason and we should just execute the fallback to the
|
|
1206
|
+
// MRU node or initial focus node, if any
|
|
1207
|
+
navAcrossContainers = false;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
} else {
|
|
1211
|
+
// no MRU node means we're likely in some initial condition when the trap has just
|
|
1212
|
+
// been activated and initial focus hasn't been given yet, in which case we should
|
|
1213
|
+
// fall through to trying to focus the initial focus node, which is what should
|
|
1214
|
+
// happen below at this point in the logic
|
|
1215
|
+
navAcrossContainers = false;
|
|
1216
|
+
}
|
|
1217
|
+
if (navAcrossContainers) {
|
|
1218
|
+
nextNode = findNextNavNode({
|
|
1219
|
+
// move FROM the MRU node, not event-related node (which will be the node that is
|
|
1220
|
+
// outside the trap causing the focus escape we're trying to fix)
|
|
1221
|
+
target: state.mostRecentlyFocusedNode,
|
|
1222
|
+
isBackward: config.isKeyBackward(state.recentNavEvent)
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
if (nextNode) {
|
|
1226
|
+
tryFocus(nextNode);
|
|
1227
|
+
} else {
|
|
1228
|
+
tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
state.recentNavEvent = undefined; // clear
|
|
1232
|
+
};
|
|
1233
|
+
|
|
1234
|
+
// Hijack key nav events on the first and last focusable nodes of the trap,
|
|
1235
|
+
// in order to prevent focus from escaping. If it escapes for even a
|
|
1236
|
+
// moment it can end up scrolling the page and causing confusion so we
|
|
1237
|
+
// kind of need to capture the action at the keydown phase.
|
|
1238
|
+
var checkKeyNav = function checkKeyNav(event) {
|
|
1239
|
+
var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1240
|
+
state.recentNavEvent = event;
|
|
1241
|
+
var destinationNode = findNextNavNode({
|
|
1242
|
+
event: event,
|
|
1243
|
+
isBackward: isBackward
|
|
1244
|
+
});
|
|
1100
1245
|
if (destinationNode) {
|
|
1101
1246
|
if (isTabEvent(event)) {
|
|
1102
1247
|
// since tab natively moves focus, we wouldn't have a destination node unless we
|
|
@@ -1122,7 +1267,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1122
1267
|
};
|
|
1123
1268
|
var checkClick = function checkClick(e) {
|
|
1124
1269
|
var target = getActualTarget(e);
|
|
1125
|
-
if (findContainerIndex(target) >= 0) {
|
|
1270
|
+
if (findContainerIndex(target, e) >= 0) {
|
|
1126
1271
|
return;
|
|
1127
1272
|
}
|
|
1128
1273
|
if (valueOrHandler(config.clickOutsideDeactivates, e)) {
|
|
@@ -1183,6 +1328,43 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1183
1328
|
return trap;
|
|
1184
1329
|
};
|
|
1185
1330
|
|
|
1331
|
+
//
|
|
1332
|
+
// MUTATION OBSERVER
|
|
1333
|
+
//
|
|
1334
|
+
|
|
1335
|
+
var checkDomRemoval = function checkDomRemoval(mutations) {
|
|
1336
|
+
var isFocusedNodeRemoved = mutations.some(function (mutation) {
|
|
1337
|
+
var removedNodes = Array.from(mutation.removedNodes);
|
|
1338
|
+
return removedNodes.some(function (node) {
|
|
1339
|
+
return node === state.mostRecentlyFocusedNode;
|
|
1340
|
+
});
|
|
1341
|
+
});
|
|
1342
|
+
|
|
1343
|
+
// If the currently focused is removed then browsers will move focus to the
|
|
1344
|
+
// <body> element. If this happens, try to move focus back into the trap.
|
|
1345
|
+
if (isFocusedNodeRemoved) {
|
|
1346
|
+
tryFocus(getInitialFocusNode());
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1350
|
+
// Use MutationObserver - if supported - to detect if focused node is removed
|
|
1351
|
+
// from the DOM.
|
|
1352
|
+
var mutationObserver = typeof window !== 'undefined' && 'MutationObserver' in window ? new MutationObserver(checkDomRemoval) : undefined;
|
|
1353
|
+
var updateObservedNodes = function updateObservedNodes() {
|
|
1354
|
+
if (!mutationObserver) {
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
mutationObserver.disconnect();
|
|
1358
|
+
if (state.active && !state.paused) {
|
|
1359
|
+
state.containers.map(function (container) {
|
|
1360
|
+
mutationObserver.observe(container, {
|
|
1361
|
+
subtree: true,
|
|
1362
|
+
childList: true
|
|
1363
|
+
});
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1186
1368
|
//
|
|
1187
1369
|
// TRAP DEFINITION
|
|
1188
1370
|
//
|
|
@@ -1207,17 +1389,14 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1207
1389
|
state.active = true;
|
|
1208
1390
|
state.paused = false;
|
|
1209
1391
|
state.nodeFocusedBeforeActivation = doc.activeElement;
|
|
1210
|
-
|
|
1211
|
-
onActivate();
|
|
1212
|
-
}
|
|
1392
|
+
onActivate === null || onActivate === void 0 ? void 0 : onActivate();
|
|
1213
1393
|
var finishActivation = function finishActivation() {
|
|
1214
1394
|
if (checkCanFocusTrap) {
|
|
1215
1395
|
updateTabbableNodes();
|
|
1216
1396
|
}
|
|
1217
1397
|
addListeners();
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
}
|
|
1398
|
+
updateObservedNodes();
|
|
1399
|
+
onPostActivate === null || onPostActivate === void 0 ? void 0 : onPostActivate();
|
|
1221
1400
|
};
|
|
1222
1401
|
if (checkCanFocusTrap) {
|
|
1223
1402
|
checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
|
|
@@ -1240,22 +1419,19 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1240
1419
|
removeListeners();
|
|
1241
1420
|
state.active = false;
|
|
1242
1421
|
state.paused = false;
|
|
1422
|
+
updateObservedNodes();
|
|
1243
1423
|
activeFocusTraps.deactivateTrap(trapStack, trap);
|
|
1244
1424
|
var onDeactivate = getOption(options, 'onDeactivate');
|
|
1245
1425
|
var onPostDeactivate = getOption(options, 'onPostDeactivate');
|
|
1246
1426
|
var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
|
|
1247
1427
|
var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
|
|
1248
|
-
|
|
1249
|
-
onDeactivate();
|
|
1250
|
-
}
|
|
1428
|
+
onDeactivate === null || onDeactivate === void 0 ? void 0 : onDeactivate();
|
|
1251
1429
|
var finishDeactivation = function finishDeactivation() {
|
|
1252
1430
|
delay(function () {
|
|
1253
1431
|
if (returnFocus) {
|
|
1254
1432
|
tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
|
|
1255
1433
|
}
|
|
1256
|
-
|
|
1257
|
-
onPostDeactivate();
|
|
1258
|
-
}
|
|
1434
|
+
onPostDeactivate === null || onPostDeactivate === void 0 ? void 0 : onPostDeactivate();
|
|
1259
1435
|
});
|
|
1260
1436
|
};
|
|
1261
1437
|
if (returnFocus && checkCanReturnFocus) {
|
|
@@ -1265,21 +1441,31 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1265
1441
|
finishDeactivation();
|
|
1266
1442
|
return this;
|
|
1267
1443
|
},
|
|
1268
|
-
pause: function pause() {
|
|
1444
|
+
pause: function pause(pauseOptions) {
|
|
1269
1445
|
if (state.paused || !state.active) {
|
|
1270
1446
|
return this;
|
|
1271
1447
|
}
|
|
1448
|
+
var onPause = getOption(pauseOptions, 'onPause');
|
|
1449
|
+
var onPostPause = getOption(pauseOptions, 'onPostPause');
|
|
1272
1450
|
state.paused = true;
|
|
1451
|
+
onPause === null || onPause === void 0 ? void 0 : onPause();
|
|
1273
1452
|
removeListeners();
|
|
1453
|
+
updateObservedNodes();
|
|
1454
|
+
onPostPause === null || onPostPause === void 0 ? void 0 : onPostPause();
|
|
1274
1455
|
return this;
|
|
1275
1456
|
},
|
|
1276
|
-
unpause: function unpause() {
|
|
1457
|
+
unpause: function unpause(unpauseOptions) {
|
|
1277
1458
|
if (!state.paused || !state.active) {
|
|
1278
1459
|
return this;
|
|
1279
1460
|
}
|
|
1461
|
+
var onUnpause = getOption(unpauseOptions, 'onUnpause');
|
|
1462
|
+
var onPostUnpause = getOption(unpauseOptions, 'onPostUnpause');
|
|
1280
1463
|
state.paused = false;
|
|
1464
|
+
onUnpause === null || onUnpause === void 0 ? void 0 : onUnpause();
|
|
1281
1465
|
updateTabbableNodes();
|
|
1282
1466
|
addListeners();
|
|
1467
|
+
updateObservedNodes();
|
|
1468
|
+
onPostUnpause === null || onPostUnpause === void 0 ? void 0 : onPostUnpause();
|
|
1283
1469
|
return this;
|
|
1284
1470
|
},
|
|
1285
1471
|
updateContainerElements: function updateContainerElements(containerElements) {
|
|
@@ -1290,6 +1476,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
1290
1476
|
if (state.active) {
|
|
1291
1477
|
updateTabbableNodes();
|
|
1292
1478
|
}
|
|
1479
|
+
updateObservedNodes();
|
|
1293
1480
|
return this;
|
|
1294
1481
|
}
|
|
1295
1482
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { q as default } from '../OrCode-
|
|
1
|
+
export { q as default } from '../OrCode-f7708644.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { O as OrCodeLanguages } from '../OrCode-
|
|
1
|
+
export { O as OrCodeLanguages } from '../OrCode-f7708644.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { q as OrCode, O as OrCodeLanguages, b as basicSetup, h as html, j as javascript, d as json, e as jsonParseLinter, c as lintGutter, l as linter } from '../OrCode-
|
|
1
|
+
export { q as OrCode, O as OrCodeLanguages, b as basicSetup, h as html, j as javascript, d as json, e as jsonParseLinter, c as lintGutter, l as linter } from '../OrCode-f7708644.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { r as CSS, u as HTML, J as JS, v as JSON, M as MD, T as TS, w as default } from '../OrCode-
|
|
1
|
+
export { r as CSS, u as HTML, J as JS, v as JSON, M as MD, T as TS, w as default } from '../OrCode-f7708644.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { b as basicSetup, h as html, j as javascript, d as json, e as jsonParseLinter, c as lintGutter, l as linter } from '../OrCode-
|
|
1
|
+
export { b as basicSetup, h as html, j as javascript, d as json, e as jsonParseLinter, c as lintGutter, l as linter } from '../OrCode-f7708644.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { x as color, A as default, z as orCodeHighlightStyle, y as orCodeTheme } from '../OrCode-
|
|
1
|
+
export { x as color, A as default, z as orCodeHighlightStyle, y as orCodeTheme } from '../OrCode-f7708644.js';
|