@react-hive/honey-layout 2.6.1 → 2.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.
@@ -1,11 +1,22 @@
1
1
  import { ReactNode, HTMLAttributes } from 'react';
2
2
  import { HoneyActiveOverlay, HoneyOverlayId, Nullable } from '../types';
3
3
  import { HoneyBoxProps } from './HoneyBox';
4
- export type HoneyOverlayProps = HTMLAttributes<HTMLDivElement> & HoneyBoxProps & {
4
+ type OverlayContext = {
5
5
  /**
6
- * The content of the overlay, either as static nodes or a function that receives the active overlay object.
6
+ * The current overlay instance, including methods and metadata for managing the overlay.
7
7
  */
8
- children: ReactNode | ((overlay: Nullable<HoneyActiveOverlay>) => ReactNode);
8
+ overlay: Nullable<HoneyActiveOverlay>;
9
+ /**
10
+ * Function to deactivate the overlay. Typically, triggers the `onDeactivate` callback.
11
+ */
12
+ deactivateOverlay: () => void;
13
+ };
14
+ export type HoneyOverlayProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & HoneyBoxProps & {
15
+ /**
16
+ * The content of the overlay, either as static nodes or a function that receives the object
17
+ * with the current overlay state and helper methods.
18
+ */
19
+ children: ReactNode | ((overlayContext: OverlayContext) => ReactNode);
9
20
  /**
10
21
  * Determines whether the overlay is currently active.
11
22
  */
@@ -15,13 +26,20 @@ export type HoneyOverlayProps = HTMLAttributes<HTMLDivElement> & HoneyBoxProps &
15
26
  */
16
27
  overlayId?: HoneyOverlayId;
17
28
  /**
18
- * Callback invoked when the overlay is closed.
29
+ * Callback function invoked when the overlay is deactivated.
30
+ * Typically called when the "Escape" key is pressed or another user-defined action triggers deactivation.
19
31
  */
20
- onClose: () => void;
32
+ onDeactivate: () => void;
21
33
  };
22
34
  /**
23
- * Component for creating overlays that can handle active states and keyboard interactions.
35
+ * A reusable overlay component that manages active states and keyboard interactions.
36
+ *
37
+ * The `HoneyOverlay` component integrates with the `useRegisterHoneyOverlay` hook to:
38
+ * - Automatically register/deregister the overlay.
39
+ * - Handle keyboard events, such as closing the overlay with the "Escape" key.
40
+ * - Provide a context to dynamically manage overlay content and state.
24
41
  *
25
- * @param {HoneyOverlayProps} props - The properties for configuring the overlay.
42
+ * @param {HoneyOverlayProps} props - The properties used to configure the overlay.
26
43
  */
27
- export declare const HoneyOverlay: ({ children, isActive, overlayId, onClose, ...props }: HoneyOverlayProps) => import("react/jsx-runtime").JSX.Element;
44
+ export declare const HoneyOverlay: ({ children, isActive, overlayId, onDeactivate, ...props }: HoneyOverlayProps) => import("react/jsx-runtime").JSX.Element;
45
+ export {};
package/dist/index.js CHANGED
@@ -1371,7 +1371,7 @@ const Mn = /* @__PURE__ */ Er(Dn), Fn = ({
1371
1371
  children: n,
1372
1372
  isActive: o,
1373
1373
  overlayId: i,
1374
- onClose: s,
1374
+ onDeactivate: s,
1375
1375
  ...f
1376
1376
  }) => {
1377
1377
  const c = Wn(o, {
@@ -1383,7 +1383,10 @@ const Mn = /* @__PURE__ */ Er(Dn), Fn = ({
1383
1383
  [s]
1384
1384
  )
1385
1385
  });
1386
- return /* @__PURE__ */ G.jsx(St, { ref: c == null ? void 0 : c.setContainerRef, "aria-hidden": !o, ...f, children: typeof n == "function" ? n(c) : n });
1386
+ return /* @__PURE__ */ G.jsx(St, { ref: c == null ? void 0 : c.setContainerRef, "aria-hidden": !o, ...f, children: typeof n == "function" ? n({
1387
+ overlay: c,
1388
+ deactivateOverlay: s
1389
+ }) : n });
1387
1390
  }, Yn = () => {
1388
1391
  const [n, o] = xt([]);
1389
1392
  pe(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-hive/honey-layout",
3
- "version": "2.6.1",
3
+ "version": "2.7.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "react",