@bigbinary/neetoui 5.2.10 → 5.2.11
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/formik.cjs.js +51 -12
- package/formik.cjs.js.map +1 -1
- package/formik.js +52 -13
- package/formik.js.map +1 -1
- package/index.cjs.js +51 -12
- package/index.cjs.js.map +1 -1
- package/index.js +52 -13
- package/index.js.map +1 -1
- package/layouts.cjs.js.map +1 -1
- package/layouts.js.map +1 -1
- package/managers.cjs.js +26 -2
- package/managers.cjs.js.map +1 -1
- package/managers.js +26 -2
- package/managers.js.map +1 -1
- package/package.json +1 -1
package/formik.cjs.js
CHANGED
|
@@ -16486,25 +16486,45 @@ var OverlayManager = /*#__PURE__*/function () {
|
|
|
16486
16486
|
_classCallCheck$1(this, OverlayManager);
|
|
16487
16487
|
this.overlays = [];
|
|
16488
16488
|
this.previouslyFocusedElements = [];
|
|
16489
|
+
this.subscribers = new Set();
|
|
16489
16490
|
this.add = this.add.bind(this);
|
|
16490
16491
|
this.remove = this.remove.bind(this);
|
|
16491
16492
|
this.isTopOverlay = this.isTopOverlay.bind(this);
|
|
16492
16493
|
this.hasOverlays = this.hasOverlays.bind(this);
|
|
16493
16494
|
this.getFinalFocusInOverlay = this.getFinalFocusInOverlay.bind(this);
|
|
16494
16495
|
this.getTopMostOverlay = this.getTopMostOverlay.bind(this);
|
|
16496
|
+
this.subscribe = this.subscribe.bind(this);
|
|
16495
16497
|
}
|
|
16496
16498
|
_createClass$1(OverlayManager, [{
|
|
16499
|
+
key: "subscribe",
|
|
16500
|
+
value: function subscribe(callback) {
|
|
16501
|
+
var _this = this;
|
|
16502
|
+
this.subscribers.add(callback);
|
|
16503
|
+
return function () {
|
|
16504
|
+
return _this.subscribers["delete"](callback);
|
|
16505
|
+
};
|
|
16506
|
+
}
|
|
16507
|
+
}, {
|
|
16497
16508
|
key: "add",
|
|
16498
16509
|
value: function add(overlay, elementToFocus) {
|
|
16499
16510
|
this.overlays.push(overlay);
|
|
16500
16511
|
this.previouslyFocusedElements.push(elementToFocus);
|
|
16512
|
+
this.subscribers.forEach(function (subscriber) {
|
|
16513
|
+
return subscriber();
|
|
16514
|
+
});
|
|
16501
16515
|
}
|
|
16502
16516
|
}, {
|
|
16503
16517
|
key: "remove",
|
|
16504
|
-
value: function remove(overlay) {
|
|
16518
|
+
value: function remove(overlay, elementToFocus) {
|
|
16505
16519
|
this.overlays = this.overlays.filter(function (_overlay) {
|
|
16506
16520
|
return _overlay !== overlay;
|
|
16507
16521
|
});
|
|
16522
|
+
this.previouslyFocusedElements = this.previouslyFocusedElements.filter(function (_elementToFocus) {
|
|
16523
|
+
return _elementToFocus !== elementToFocus;
|
|
16524
|
+
});
|
|
16525
|
+
this.subscribers.forEach(function (subscriber) {
|
|
16526
|
+
return subscriber();
|
|
16527
|
+
});
|
|
16508
16528
|
}
|
|
16509
16529
|
}, {
|
|
16510
16530
|
key: "isTopOverlay",
|
|
@@ -16520,7 +16540,11 @@ var OverlayManager = /*#__PURE__*/function () {
|
|
|
16520
16540
|
}, {
|
|
16521
16541
|
key: "getFinalFocusInOverlay",
|
|
16522
16542
|
value: function getFinalFocusInOverlay() {
|
|
16523
|
-
|
|
16543
|
+
var finalFocus = this.previouslyFocusedElements.pop();
|
|
16544
|
+
this.subscribers.forEach(function (subscriber) {
|
|
16545
|
+
return subscriber();
|
|
16546
|
+
});
|
|
16547
|
+
return finalFocus;
|
|
16524
16548
|
}
|
|
16525
16549
|
}, {
|
|
16526
16550
|
key: "getTopMostOverlay",
|
|
@@ -16596,14 +16620,13 @@ var hyphenize = function hyphenize(string) {
|
|
|
16596
16620
|
}
|
|
16597
16621
|
return fallbackString;
|
|
16598
16622
|
};
|
|
16599
|
-
var
|
|
16623
|
+
var trapFocusOnFocusableElements = function trapFocusOnFocusableElements(ref) {
|
|
16600
16624
|
var _ref$current, _ref$current2;
|
|
16601
|
-
var shouldFocusFirstFocusableElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
16602
16625
|
var focusableElements = 'button,[href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
16603
16626
|
var firstFocusableElement = ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelectorAll(focusableElements)[0];
|
|
16604
16627
|
var focusableContent = ref === null || ref === void 0 ? void 0 : (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.querySelectorAll(focusableElements);
|
|
16605
16628
|
var lastFocusableElement = focusableContent[(focusableContent === null || focusableContent === void 0 ? void 0 : focusableContent.length) - 1];
|
|
16606
|
-
|
|
16629
|
+
var onKeyDown = function onKeyDown(e) {
|
|
16607
16630
|
var isTabPressed = e.key === "Tab" || e.keyCode === 9;
|
|
16608
16631
|
if (!isTabPressed) {
|
|
16609
16632
|
return;
|
|
@@ -16619,8 +16642,16 @@ var renderFocusOnFocusableElements = function renderFocusOnFocusableElements(ref
|
|
|
16619
16642
|
e.preventDefault();
|
|
16620
16643
|
}
|
|
16621
16644
|
}
|
|
16622
|
-
}
|
|
16623
|
-
|
|
16645
|
+
};
|
|
16646
|
+
document.addEventListener("keydown", onKeyDown);
|
|
16647
|
+
return function () {
|
|
16648
|
+
return document.removeEventListener("keydown", onKeyDown);
|
|
16649
|
+
};
|
|
16650
|
+
};
|
|
16651
|
+
var focusFirstFocusableElement = function focusFirstFocusableElement(ref) {
|
|
16652
|
+
var _ref$current3;
|
|
16653
|
+
var focusableElements = 'button,[href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
16654
|
+
var firstFocusableElement = ref === null || ref === void 0 ? void 0 : (_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.querySelectorAll(focusableElements)[0];
|
|
16624
16655
|
firstFocusableElement === null || firstFocusableElement === void 0 ? void 0 : firstFocusableElement.focus();
|
|
16625
16656
|
};
|
|
16626
16657
|
var hideScrollAndAddMargin = function hideScrollAndAddMargin() {
|
|
@@ -16664,9 +16695,8 @@ var useOverlay = function useOverlay(_ref) {
|
|
|
16664
16695
|
if ((_initialFocusRef = initialFocusRef) !== null && _initialFocusRef !== void 0 && _initialFocusRef.current) {
|
|
16665
16696
|
var _initialFocusRef2, _initialFocusRef2$cur;
|
|
16666
16697
|
(_initialFocusRef2 = initialFocusRef) === null || _initialFocusRef2 === void 0 ? void 0 : (_initialFocusRef2$cur = _initialFocusRef2.current) === null || _initialFocusRef2$cur === void 0 ? void 0 : _initialFocusRef2$cur.focus();
|
|
16667
|
-
renderFocusOnFocusableElements(overlayWrapper, false);
|
|
16668
16698
|
} else {
|
|
16669
|
-
|
|
16699
|
+
focusFirstFocusableElement(overlayWrapper);
|
|
16670
16700
|
}
|
|
16671
16701
|
}
|
|
16672
16702
|
};
|
|
@@ -16676,18 +16706,27 @@ var useOverlay = function useOverlay(_ref) {
|
|
|
16676
16706
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
16677
16707
|
}, [onClose]);
|
|
16678
16708
|
useOnClickOutside(overlayWrapper, backdropRef, closeOnOutsideClick ? handleOverlayClose : noop$1);
|
|
16709
|
+
var isTopOverlay = React.useSyncExternalStore(manager.subscribe, function () {
|
|
16710
|
+
return manager.isTopOverlay(overlayWrapper);
|
|
16711
|
+
});
|
|
16679
16712
|
useHotkeys("esc", function () {
|
|
16680
16713
|
closeOnEsc && handleOverlayClose();
|
|
16681
16714
|
}, [handleOverlayClose, closeOnEsc]);
|
|
16682
16715
|
React.useEffect(function () {
|
|
16716
|
+
var cleanUp = noop$1;
|
|
16683
16717
|
if (isOpen) {
|
|
16684
|
-
if (hasTransitionCompleted)
|
|
16718
|
+
if (hasTransitionCompleted && isTopOverlay) {
|
|
16719
|
+
focusRequiredElementInOverlay();
|
|
16720
|
+
// Enable focus trap only for the topmost overlay
|
|
16721
|
+
cleanUp = trapFocusOnFocusableElements(overlayWrapper);
|
|
16722
|
+
}
|
|
16685
16723
|
if (shouldHideScrollAndAddMargin) hideScrollAndAddMargin();
|
|
16686
16724
|
}
|
|
16687
16725
|
return function () {
|
|
16688
16726
|
if (!manager.hasOverlays()) showScrollAndRemoveMargin();
|
|
16727
|
+
cleanUp();
|
|
16689
16728
|
};
|
|
16690
|
-
}, [isOpen, hasTransitionCompleted]);
|
|
16729
|
+
}, [isOpen, hasTransitionCompleted, isTopOverlay]);
|
|
16691
16730
|
var setFocusField = function setFocusField(fieldRef) {
|
|
16692
16731
|
if (!fieldRef) return;
|
|
16693
16732
|
initialFocusRef = {
|
|
@@ -16708,7 +16747,7 @@ var useOverlayManager = function useOverlayManager(ref, isOpen) {
|
|
|
16708
16747
|
manager.add(ref, elementToFocus);
|
|
16709
16748
|
}
|
|
16710
16749
|
return function () {
|
|
16711
|
-
manager.remove(ref);
|
|
16750
|
+
manager.remove(ref, elementToFocus);
|
|
16712
16751
|
};
|
|
16713
16752
|
}, [isOpen, ref]);
|
|
16714
16753
|
};
|