@react-hive/honey-layout 6.2.0 → 6.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.
@@ -1,10 +1,11 @@
1
1
  import { ReactNode } from 'react';
2
+ import { ReferenceType } from '@floating-ui/react';
2
3
  import { FastOmit } from '@react-hive/honey-style';
3
4
  import { HoneyPopupProps, HoneyPopupChildrenContextProps } from '../HoneyPopup';
4
5
  import { HoneyContextMenuOption } from './HoneyContextMenu.types';
5
6
  import { HoneyContextMenuContentProps } from './HoneyContextMenuContent';
6
- export interface HoneyContextMenuProps<Option extends HoneyContextMenuOption<Context>, Context = undefined, UseAutoSize extends boolean = boolean> extends FastOmit<HoneyPopupProps<Context, UseAutoSize>, 'content'>, Pick<HoneyContextMenuContentProps<Option, Context>, 'options' | 'optionProps'> {
7
- children: (context: HoneyPopupChildrenContextProps) => ReactNode;
8
- subProps?: FastOmit<HoneyContextMenuContentProps<Option, Context>, 'options' | 'optionProps'>;
7
+ export interface HoneyContextMenuProps<Option extends HoneyContextMenuOption<Context, Reference>, Context, Reference extends ReferenceType, UseAutoSize extends boolean> extends FastOmit<HoneyPopupProps<Context, Reference, UseAutoSize>, 'content'>, Pick<HoneyContextMenuContentProps<Option, Context, Reference, UseAutoSize>, 'options' | 'optionProps'> {
8
+ children: ReactNode | ((context: HoneyPopupChildrenContextProps<Reference>) => ReactNode);
9
+ subProps?: FastOmit<HoneyContextMenuContentProps<Option, Context, Reference, UseAutoSize>, 'options' | 'optionProps'>;
9
10
  }
10
- export declare const HoneyContextMenu: <Option extends HoneyContextMenuOption<Context>, Context = undefined, UseAutoSize extends boolean = boolean>({ children, subProps, options, optionProps, clickOptions, context, ...popupProps }: HoneyContextMenuProps<Option, Context, UseAutoSize>) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const HoneyContextMenu: <Option extends HoneyContextMenuOption<Context, Reference>, Context, Reference extends ReferenceType, UseAutoSize extends boolean>({ children, subProps, options, optionProps, clickOptions, context, ...popupProps }: HoneyContextMenuProps<Option, Context, Reference, UseAutoSize>) => import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,13 @@
1
- interface HoneyContextMenuOptionExecutionContext<Context> {
1
+ import { FloatingContext, ReferenceType } from '@floating-ui/react';
2
+ interface HoneyContextMenuOptionExecutionContext<Context, Reference extends ReferenceType> {
2
3
  context: Context | undefined;
4
+ floatingContext: FloatingContext<Reference>;
3
5
  }
4
- export interface HoneyContextMenuOption<Context = undefined> {
6
+ export interface HoneyContextMenuOption<Context = undefined, Reference extends ReferenceType = ReferenceType> {
5
7
  id: string;
6
8
  label: string;
7
- options?: HoneyContextMenuOption<Context>[];
8
- visible?: boolean | ((executionContext: HoneyContextMenuOptionExecutionContext<Context>) => boolean);
9
- onClick?: (executionContext: HoneyContextMenuOptionExecutionContext<Context>) => void;
9
+ options?: HoneyContextMenuOption<Context, Reference>[];
10
+ visible?: boolean | ((executionContext: HoneyContextMenuOptionExecutionContext<Context, Reference>) => boolean);
11
+ onClick?: (executionContext: HoneyContextMenuOptionExecutionContext<Context, Reference>) => void;
10
12
  }
11
13
  export {};
@@ -1,9 +1,10 @@
1
+ import { ReferenceType } from '@floating-ui/react';
1
2
  import { FastOmit } from '@react-hive/honey-style';
2
3
  import { HoneyPopupProps } from '../HoneyPopup';
3
4
  import { HoneyContextMenuOption } from './HoneyContextMenu.types';
4
5
  import { HoneyContextMenuContentOptionProps } from './HoneyContextMenuContentOption';
5
- export interface HoneyContextMenuContentProps<Option extends HoneyContextMenuOption<Context>, Context> extends FastOmit<HoneyPopupProps<Context>, 'children' | 'context' | 'content'> {
6
+ export interface HoneyContextMenuContentProps<Option extends HoneyContextMenuOption<Context, Reference>, Context, Reference extends ReferenceType, UseAutoSize extends boolean> extends FastOmit<HoneyPopupProps<Context, Reference, UseAutoSize>, 'children' | 'context' | 'content'> {
6
7
  options: Option[] | undefined;
7
- optionProps?: FastOmit<HoneyContextMenuContentOptionProps<Option, Context>, 'option'>;
8
+ optionProps?: FastOmit<HoneyContextMenuContentOptionProps<Option, Context, Reference>, 'option'>;
8
9
  }
9
- export declare const HoneyContextMenuContent: <Option extends HoneyContextMenuOption<Context>, Context = undefined>({ options, optionProps, floatingOptions, ...popupProps }: HoneyContextMenuContentProps<Option, Context>) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const HoneyContextMenuContent: <Option extends HoneyContextMenuOption<Context, Reference>, Context, Reference extends ReferenceType, UseAutoSize extends boolean>({ options, optionProps, floatingOptions, ...popupProps }: HoneyContextMenuContentProps<Option, Context, Reference, UseAutoSize>) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,7 @@
1
+ import { ReferenceType } from '@floating-ui/react';
1
2
  import { HoneyBoxProps } from '../HoneyBox';
2
3
  import { HoneyContextMenuOption } from './HoneyContextMenu.types';
3
- export interface HoneyContextMenuContentOptionProps<Option extends HoneyContextMenuOption<Context>, Context> extends HoneyBoxProps {
4
+ export interface HoneyContextMenuContentOptionProps<Option extends HoneyContextMenuOption<Context, Reference>, Context, Reference extends ReferenceType> extends HoneyBoxProps {
4
5
  option: Option;
5
6
  }
6
- export declare const HoneyContextMenuContentOption: <Option extends HoneyContextMenuOption<Context>, Context>({ option, ...props }: HoneyContextMenuContentOptionProps<Option, Context>) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const HoneyContextMenuContentOption: <Option extends HoneyContextMenuOption<Context, Reference>, Context, Reference extends ReferenceType>({ option, ...props }: HoneyContextMenuContentOptionProps<Option, Context, Reference>) => import("react/jsx-runtime").JSX.Element;
@@ -1,57 +1,21 @@
1
- import { CSSProperties, ReactNode } from 'react';
2
- import { UseInteractionsReturn, FloatingArrowProps, FloatingFocusManagerProps, MiddlewareData } from '@floating-ui/react';
3
- import { FastOmit } from '@react-hive/honey-style';
4
- import { HoneyPopupPortalProps } from './HoneyPopupPortal';
5
- import { HoneyPopupStyledProps } from './HoneyPopupStyled';
6
- import { HoneyPopupContextProps } from './HoneyPopupContext';
7
- import { UseHoneyPopupOptions } from './hooks';
8
- import { HoneyOverlayProps } from '../HoneyOverlay';
9
- export interface HoneyPopupChildrenContextProps {
10
- referenceProps: ReturnType<UseInteractionsReturn['getReferenceProps']>;
11
- }
12
- type InheritedHoneyOverlayProps = FastOmit<HoneyOverlayProps, 'children' | 'active' | 'onDeactivate' | '$position'>;
13
- export interface HoneyPopupProps<Context = undefined, UseAutoSize extends boolean = boolean> extends UseHoneyPopupOptions<UseAutoSize> {
14
- children: (context: HoneyPopupChildrenContextProps) => ReactNode;
15
- referenceProps?: FastOmit<HoneyPopupStyledProps, 'children' | 'content'>;
16
- /**
17
- * Content inside the popup.
18
- */
19
- content: ReactNode | ((context: HoneyPopupContextProps<Context>) => ReactNode);
1
+ import { ReferenceType } from '@floating-ui/react';
2
+ import { HoneyPopupContentProps } from './HoneyPopupContent';
3
+ export interface HoneyPopupProps<Context, Reference extends ReferenceType, UseAutoSize extends boolean> extends HoneyPopupContentProps<Context, Reference, UseAutoSize> {
20
4
  /**
21
- * Additional props for the floating content.
22
- */
23
- contentProps?: UseAutoSize extends true ? Omit<InheritedHoneyOverlayProps, '$minWidth' | '$minHeight' | '$maxWidth' | '$maxHeight'> : InheritedHoneyOverlayProps;
24
- /**
25
- * Props for managing focus inside the popup.
5
+ * Whether to wrap the popup in a `FloatingTree`.
6
+ * Required if you're using nested floating elements like tooltips or popups within a popup.
26
7
  *
27
- * @see https://floating-ui.com/docs/floatingfocusmanager#props
28
- */
29
- focusManagerProps?: FastOmit<FloatingFocusManagerProps, 'children' | 'context'>;
30
- /**
31
- * Properties for an arrow component.
8
+ * @default false
32
9
  *
33
- * @see https://floating-ui.com/docs/FloatingArrow#props
34
- */
35
- arrowProps?: FastOmit<FloatingArrowProps, 'ref' | 'context'>;
36
- /**
37
- * Properties for `HoneyPopupPortal` component.
38
- */
39
- portalProps?: FastOmit<HoneyPopupPortalProps, 'children'>;
40
- /**
41
- * Function to adjust the floating content's styles before rendering.
42
- */
43
- adjustStyles?: (styles: CSSProperties, executionContext: {
44
- middlewareData: MiddlewareData;
45
- }) => CSSProperties;
46
- /**
47
- * Optional context for the popup.
10
+ * @see https://floating-ui.com/docs/floatingtree
48
11
  */
49
- context?: Context;
12
+ useTree?: boolean;
50
13
  }
51
14
  /**
52
15
  * A popup component that provides floating behavior with customizable options.
53
16
  *
54
- * @template Context - Optional context type.
17
+ * @template Context - Optional context type passed to floating UI.
18
+ * @template Reference - The reference type used for positioning.
19
+ * @template UseAutoSize - Enables auto-sizing behavior for content if `true`.
55
20
  */
56
- export declare const HoneyPopup: <Context = undefined, UseAutoSize extends boolean = boolean>({ children, referenceProps, content, contentProps, focusManagerProps, arrowProps, portalProps, adjustStyles, context, ...popupOptions }: HoneyPopupProps<Context, UseAutoSize>) => import("react/jsx-runtime").JSX.Element;
57
- export {};
21
+ export declare const HoneyPopup: <Context, Reference extends ReferenceType, UseAutoSize extends boolean>({ useTree, ...props }: HoneyPopupProps<Context, Reference, UseAutoSize>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { FloatingContext, ReferenceType } from '@floating-ui/react';
2
+ export interface HoneyPopupChildrenContextProps<Reference extends ReferenceType> {
3
+ floatingContext: FloatingContext<Reference>;
4
+ }
@@ -0,0 +1,50 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import { ReferenceType, FloatingArrowProps, FloatingFocusManagerProps, MiddlewareData } from '@floating-ui/react';
3
+ import { FastOmit } from '@react-hive/honey-style';
4
+ import { HoneyPopupChildrenContextProps } from './HoneyPopup.types';
5
+ import { HoneyPopupPortalProps } from './HoneyPopupPortal';
6
+ import { HoneyPopupStyledProps } from './HoneyPopupStyled';
7
+ import { HoneyPopupContextProps } from './HoneyPopupContext';
8
+ import { UseHoneyPopupOptions } from './hooks';
9
+ import { HoneyOverlayProps } from '../HoneyOverlay';
10
+ type InheritedHoneyOverlayProps = FastOmit<HoneyOverlayProps, 'children' | 'active' | 'onDeactivate' | '$position'>;
11
+ export interface HoneyPopupContentProps<Context, Reference extends ReferenceType, UseAutoSize extends boolean> extends UseHoneyPopupOptions<Reference, UseAutoSize> {
12
+ children: ReactNode | ((context: HoneyPopupChildrenContextProps<Reference>) => ReactNode);
13
+ referenceProps?: FastOmit<HoneyPopupStyledProps, 'children' | 'content'>;
14
+ /**
15
+ * Content inside the popup.
16
+ */
17
+ content: ReactNode | ((context: HoneyPopupContextProps<Context, Reference>) => ReactNode);
18
+ /**
19
+ * Additional props for the floating content.
20
+ */
21
+ contentProps?: UseAutoSize extends true ? FastOmit<InheritedHoneyOverlayProps, '$minWidth' | '$minHeight' | '$maxWidth' | '$maxHeight'> : InheritedHoneyOverlayProps;
22
+ /**
23
+ * Props for managing focus inside the popup.
24
+ *
25
+ * @see https://floating-ui.com/docs/floatingfocusmanager#props
26
+ */
27
+ focusManagerProps?: FastOmit<FloatingFocusManagerProps, 'children' | 'context'>;
28
+ /**
29
+ * Properties for an arrow component.
30
+ *
31
+ * @see https://floating-ui.com/docs/FloatingArrow#props
32
+ */
33
+ arrowProps?: FastOmit<FloatingArrowProps, 'ref' | 'context'>;
34
+ /**
35
+ * Properties for `HoneyPopupPortal` component.
36
+ */
37
+ portalProps?: FastOmit<HoneyPopupPortalProps, 'children'>;
38
+ /**
39
+ * Function to adjust the floating content's styles before rendering.
40
+ */
41
+ adjustStyles?: (styles: CSSProperties, executionContext: {
42
+ middlewareData: MiddlewareData;
43
+ }) => CSSProperties;
44
+ /**
45
+ * Optional context for the popup.
46
+ */
47
+ context?: Context;
48
+ }
49
+ export declare const HoneyPopupContent: <Context, Reference extends ReferenceType, UseAutoSize extends boolean>({ children, referenceProps, content, contentProps, focusManagerProps, arrowProps, portalProps, adjustStyles, context, ...popupOptions }: HoneyPopupContentProps<Context, Reference, UseAutoSize>) => import("react/jsx-runtime").JSX.Element;
50
+ export {};
@@ -1,4 +1,6 @@
1
- export interface HoneyPopupContextProps<Context> {
1
+ import { FloatingContext, ReferenceType } from '@floating-ui/react';
2
+ export interface HoneyPopupContextProps<Context, Reference extends ReferenceType> {
2
3
  context: Context | undefined;
4
+ floatingContext: FloatingContext<Reference>;
3
5
  }
4
- export declare const HoneyPopupContext: import('react').Context<HoneyPopupContextProps<any> | undefined>;
6
+ export declare const HoneyPopupContext: import('react').Context<HoneyPopupContextProps<any, any> | undefined>;
@@ -3,4 +3,19 @@ import { FloatingTreeProps } from '@floating-ui/react';
3
3
  /**
4
4
  * @see https://floating-ui.com/docs/floatingtree
5
5
  */
6
- export declare const HoneyPopupTree: ({ children, ...props }: FloatingTreeProps) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
6
+ interface HoneyPopupTreeProps extends FloatingTreeProps {
7
+ /**
8
+ * Whether to render the `FloatingTree` component.
9
+ * Automatically disables if there is a parent floating node.
10
+ *
11
+ * @default true
12
+ */
13
+ enabled?: boolean;
14
+ }
15
+ /**
16
+ * Wrapper component for `FloatingTree` that conditionally renders based on whether there is a parent floating node.
17
+ *
18
+ * @see https://floating-ui.com/docs/floatingtree
19
+ */
20
+ export declare const HoneyPopupTree: ({ children, enabled, ...props }: HoneyPopupTreeProps) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
21
+ export {};
@@ -1 +1,3 @@
1
- export declare const useHoneyPopupContext: () => import('../HoneyPopupContext').HoneyPopupContextProps<any>;
1
+ import { ReferenceType } from '@floating-ui/react';
2
+ import { HoneyPopupContextProps } from '../HoneyPopupContext';
3
+ export declare const useHoneyPopupContext: <Context, Reference extends ReferenceType = ReferenceType>() => HoneyPopupContextProps<Context, Reference>;
@@ -1,5 +1,6 @@
1
- import { FloatingContext, UseDismissProps, UseClickProps, UseHoverProps, UseFocusProps, UseClientPointProps, UseRoleProps } from '@floating-ui/react';
1
+ import { ElementProps, FloatingContext, UseDismissProps, UseClickProps, UseHoverProps, UseFocusProps, UseClientPointProps, UseRoleProps } from '@floating-ui/react';
2
2
  import { FastOmit } from '@react-hive/honey-style';
3
+ export type HoneyPopupExtraInteraction = <Props extends object>(context: FloatingContext, props?: Props) => ElementProps;
3
4
  /**
4
5
  * Options for configuring popup interactions.
5
6
  */
@@ -53,5 +54,16 @@ export interface UseHoneyPopupInteractionsOptions {
53
54
  * @see https://floating-ui.com/docs/userole
54
55
  */
55
56
  roleOptions?: FastOmit<UseRoleProps, 'enabled'>;
57
+ /**
58
+ * Additional custom interactions to be merged with default ones.
59
+ * Useful for extending or overriding the default behavior.
60
+ *
61
+ * To define custom interaction, please use the ` HoneyPopupExtraInteraction ` type.
62
+ *
63
+ * @default []
64
+ *
65
+ * @see https://floating-ui.com/docs/custom-hooks
66
+ */
67
+ extraInteractions?: ElementProps[];
56
68
  }
57
- export declare const useHoneyPopupInteractions: (context: FloatingContext, { enabled, event, dismissOptions, clickOptions, hoverOptions, focusOptions, clientPointsOptions, roleOptions, }: UseHoneyPopupInteractionsOptions) => import('@floating-ui/react').UseInteractionsReturn;
69
+ export declare const useHoneyPopupInteractions: (context: FloatingContext, { enabled, event, dismissOptions, clickOptions, hoverOptions, focusOptions, clientPointsOptions, roleOptions, extraInteractions, }: UseHoneyPopupInteractionsOptions) => import('@floating-ui/react').UseInteractionsReturn;
@@ -1,15 +1,15 @@
1
- import { useTransitionStyles, AutoUpdateOptions, AutoPlacementOptions, ArrowOptions, FlipOptions, OffsetOptions, ShiftOptions, OpenChangeReason, UseFloatingOptions, UseFloatingReturn, UseInteractionsReturn, UseTransitionStylesProps } from '@floating-ui/react';
1
+ import { useTransitionStyles, ReferenceType, AutoUpdateOptions, AutoPlacementOptions, ArrowOptions, FlipOptions, OffsetOptions, ShiftOptions, OpenChangeReason, UseFloatingOptions, UseFloatingReturn, UseInteractionsReturn, UseTransitionStylesProps } from '@floating-ui/react';
2
2
  import { RefObject } from 'react';
3
3
  import { Derivable } from '@floating-ui/dom';
4
4
  import { FastOmit } from '@react-hive/honey-style';
5
5
  import { Nullable } from '../../../types';
6
6
  import { UseHoneyPopupInteractionsOptions } from './use-honey-popup-interactions';
7
- export interface UseHoneyPopupOptions<UseAutoSize extends boolean = boolean> extends UseHoneyPopupInteractionsOptions {
7
+ export interface UseHoneyPopupOptions<Reference extends ReferenceType, UseAutoSize extends boolean = boolean> extends FastOmit<UseHoneyPopupInteractionsOptions, 'extraInteractions'> {
8
8
  open?: boolean;
9
9
  /**
10
10
  * Options for configuring the floating UI behavior.
11
11
  */
12
- floatingOptions?: FastOmit<UseFloatingOptions, 'nodeId' | 'open' | 'whileElementsMounted' | 'onOpenChange'>;
12
+ floatingOptions?: FastOmit<UseFloatingOptions<Reference>, 'nodeId' | 'open' | 'whileElementsMounted' | 'onOpenChange'>;
13
13
  /**
14
14
  * Configuration for offset middleware.
15
15
  *
@@ -115,7 +115,7 @@ export interface UseHoneyPopupOptions<UseAutoSize extends boolean = boolean> ext
115
115
  */
116
116
  onClose?: (reason?: OpenChangeReason, event?: Event) => void;
117
117
  }
118
- interface UseHoneyPopupApi {
118
+ interface UseHoneyPopupApi<Reference extends ReferenceType> {
119
119
  /**
120
120
  * Unique identifier for the floating element.
121
121
  */
@@ -127,7 +127,7 @@ interface UseHoneyPopupApi {
127
127
  /**
128
128
  * Floating UI instance with positioning and middleware.
129
129
  */
130
- floating: UseFloatingReturn;
130
+ floating: UseFloatingReturn<Reference>;
131
131
  /**
132
132
  * Ref for the floating arrow element.
133
133
  */
@@ -145,5 +145,5 @@ interface UseHoneyPopupApi {
145
145
  *
146
146
  * @returns An object containing state and utilities for managing the popup.
147
147
  */
148
- export declare const useHoneyPopup: ({ enabled, event, dismissOptions, clickOptions, hoverOptions, focusOptions, clientPointsOptions, roleOptions, open, floatingOptions, offsetOptions, useFlip, flipOptions, useShift, shiftOptions, useArrow, arrowOptions, transitionOptions, useAutoPlacement, autoPlacementOptions, useAutoUpdate, autoUpdateOptions, useAutoSize, minAcceptableWidth, minAcceptableHeight, maxAcceptableWidth, maxAcceptableHeight, onOpen, onClose, }: UseHoneyPopupOptions) => UseHoneyPopupApi;
148
+ export declare const useHoneyPopup: <Reference extends ReferenceType>({ enabled, event, dismissOptions, clickOptions, hoverOptions, focusOptions, clientPointsOptions, roleOptions, open, floatingOptions, offsetOptions, useFlip, flipOptions, useShift, shiftOptions, useArrow, arrowOptions, transitionOptions, useAutoPlacement, autoPlacementOptions, useAutoUpdate, autoUpdateOptions, useAutoSize, minAcceptableWidth, minAcceptableHeight, maxAcceptableWidth, maxAcceptableHeight, onOpen, onClose, }: UseHoneyPopupOptions<Reference>) => UseHoneyPopupApi<Reference>;
149
149
  export {};
@@ -1,2 +1,3 @@
1
+ export * from './HoneyPopup.types';
1
2
  export * from './HoneyPopup';
2
3
  export * from './hooks';