@react-hive/honey-layout 17.6.0 → 17.7.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/components/HoneyGridColumn/HoneyGridColumnStyled.d.ts +1 -1
- package/dist/hooks/use-honey-overlay.d.ts +23 -10
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +12 -9
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.dev.cjs
CHANGED
|
@@ -5979,32 +5979,35 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5979
5979
|
* It can also subscribe to overlay-level events, such as `keyup`, for the matched overlay.
|
|
5980
5980
|
*
|
|
5981
5981
|
* @param targetOverlayId - The ID of the active overlay to find.
|
|
5982
|
-
* @param options - Optional overlay event handlers.
|
|
5982
|
+
* @param options - Optional configuration for resolving the overlay and attaching event handlers.
|
|
5983
5983
|
*
|
|
5984
|
-
* @returns The matching active overlay instance, or `
|
|
5984
|
+
* @returns The matching active overlay instance, or `null` when the hook is disabled
|
|
5985
|
+
* or the overlay is not currently registered.
|
|
5985
5986
|
*
|
|
5986
5987
|
* @remarks
|
|
5987
5988
|
* - The hook only works with overlays that are currently active.
|
|
5988
|
-
* - If
|
|
5989
|
-
* -
|
|
5990
|
-
* -
|
|
5989
|
+
* - If `enabled` is `false`, the hook returns `null` and does not attach listeners.
|
|
5990
|
+
* - If the overlay is inactive, unregistered, or already removed from the stack, `null` is returned.
|
|
5991
|
+
* - The `onKeyUp` listener is attached only to the matched overlay while the hook is enabled.
|
|
5992
|
+
* - Event listeners are automatically cleaned up when the overlay, handler, enabled state,
|
|
5993
|
+
* or component lifecycle changes.
|
|
5991
5994
|
*
|
|
5992
5995
|
* @example
|
|
5993
5996
|
* ```tsx
|
|
5994
5997
|
* const overlay = useHoneyOverlay('my-overlay-id', {
|
|
5998
|
+
* enabled: isOpen,
|
|
5995
5999
|
* onKeyUp: (keyCode, overlay, e) => {
|
|
5996
6000
|
* if (keyCode === 'Escape') {
|
|
5997
|
-
*
|
|
6001
|
+
* // Handle Escape key.
|
|
5998
6002
|
* }
|
|
5999
6003
|
* },
|
|
6000
6004
|
* });
|
|
6001
6005
|
* ```
|
|
6002
6006
|
*/
|
|
6003
|
-
const useHoneyOverlay = (targetOverlayId, { onKeyUp } = {}) => {
|
|
6007
|
+
const useHoneyOverlay = (targetOverlayId, { enabled = true, onKeyUp } = {}) => {
|
|
6004
6008
|
const { overlays } = (0,_hooks__WEBPACK_IMPORTED_MODULE_1__.useHoneyLayout)();
|
|
6005
|
-
const overlay = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => overlays.find(overlay => overlay.id === targetOverlayId), [overlays, targetOverlayId]);
|
|
6009
|
+
const overlay = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => (enabled ? (overlays.find(overlay => overlay.id === targetOverlayId) ?? null) : null), [enabled, overlays, targetOverlayId]);
|
|
6006
6010
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
6007
|
-
// If no overlay is found or no `onKeyUp` handler is provided, skip setting up the listener
|
|
6008
6011
|
if (!overlay || !onKeyUp) {
|
|
6009
6012
|
return;
|
|
6010
6013
|
}
|