@react-hive/honey-layout 5.2.0-beta → 5.6.0-beta
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/__mocks__/index.d.ts +1 -0
- package/dist/__mocks__/theme-mock.d.ts +2 -0
- package/dist/components/HoneyBox/HoneyBox.d.ts +8 -0
- package/dist/components/HoneyBox/index.d.ts +1 -0
- package/dist/components/HoneyContextMenu/HoneyContextMenu.d.ts +3 -2
- package/dist/components/HoneyContextMenu/HoneyContextMenu.types.d.ts +1 -1
- package/dist/components/HoneyContextMenu/HoneyContextMenuContent.d.ts +3 -2
- package/dist/components/HoneyContextMenu/HoneyContextMenuContentOption.d.ts +2 -3
- package/dist/components/HoneyFlexBox.d.ts +3 -2
- package/dist/components/HoneyGrid/HoneyGrid.d.ts +1 -4
- package/dist/components/HoneyGrid/HoneyGridStyled.d.ts +2 -3
- package/dist/components/HoneyGridColumn/HoneyGridColumn.d.ts +2 -2
- package/dist/components/HoneyGridColumn/HoneyGridColumn.types.d.ts +2 -1
- package/dist/components/HoneyGridColumn/HoneyGridColumnStyled.d.ts +4 -4
- package/dist/components/HoneyLazyContent/index.d.ts +1 -0
- package/dist/components/HoneyList/HoneyList.d.ts +3 -8
- package/dist/components/HoneyList/HoneyListStyled.d.ts +3 -1
- package/dist/components/HoneyOverlay.d.ts +21 -9
- package/dist/components/HoneyPopup/HoneyPopup.d.ts +4 -9
- package/dist/components/HoneyPopup/HoneyPopupStyled.d.ts +2 -4
- package/dist/components/HoneyPopup/hooks/use-honey-popup-interactions.d.ts +2 -1
- package/dist/components/HoneyPopup/hooks/use-honey-popup.d.ts +40 -6
- package/dist/components/index.d.ts +0 -1
- package/dist/constants.d.ts +2 -2
- package/dist/contexts/HoneyLayoutContext.d.ts +4 -4
- package/dist/helpers/helpers.d.ts +37 -25
- package/dist/hooks/index.d.ts +1 -2
- package/dist/hooks/use-honey-document-key-up-handler.d.ts +30 -9
- package/dist/hooks/use-honey-drag.d.ts +36 -18
- package/dist/hooks/use-honey-layout.d.ts +2 -3
- package/dist/hooks/use-honey-on-change.d.ts +27 -0
- package/dist/hooks/use-honey-overlay.d.ts +10 -5
- package/dist/index.js +2251 -2273
- package/dist/providers/HoneyLayoutProvider.d.ts +2 -2
- package/dist/types/css.types.d.ts +140 -31
- package/dist/types/dom.types.d.ts +6 -2
- package/dist/{utils.d.ts → utils/data-utils.d.ts} +1 -80
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/utils.d.ts +80 -0
- package/package.json +19 -15
- package/dist/components/HoneyBox.d.ts +0 -10
- package/dist/components/HoneyLoopingList/HoneyLoopingList.d.ts +0 -12
- package/dist/components/HoneyLoopingList/index.d.ts +0 -1
- package/dist/hooks/use-honey-infinite-scroll.d.ts +0 -6
- package/dist/hooks/use-honey-synthetic-scrollable-container.d.ts +0 -21
- /package/dist/components/{HoneyLazyContent.d.ts → HoneyLazyContent/HoneyLazyContent.d.ts} +0 -0
|
@@ -15,7 +15,7 @@ export type HoneyDragOnStartHandler<Element extends HTMLElement> = (draggableEle
|
|
|
15
15
|
/**
|
|
16
16
|
* Context provided to the move handler, containing information about the drag's movement.
|
|
17
17
|
*/
|
|
18
|
-
interface HoneyDragMoveContext {
|
|
18
|
+
export interface HoneyDragMoveContext {
|
|
19
19
|
/**
|
|
20
20
|
* The horizontal distance has moved since the last frame.
|
|
21
21
|
*/
|
|
@@ -88,52 +88,70 @@ interface HoneyDragEndContext {
|
|
|
88
88
|
*/
|
|
89
89
|
export type HoneyDragOnEndHandler<Element extends HTMLElement> = (context: HoneyDragEndContext, draggableElement: Element) => Promise<void>;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
* These handlers
|
|
91
|
+
* A set of handlers that define the behavior of the drag operation at different stages.
|
|
92
|
+
* These handlers are customizable for managing drag initialization, movement, and completion.
|
|
93
93
|
*/
|
|
94
94
|
export interface HoneyDragHandlers<Element extends HTMLElement> {
|
|
95
95
|
/**
|
|
96
96
|
* Optional handler triggered when the drag operation starts.
|
|
97
|
-
* This
|
|
97
|
+
* This is useful for capturing the initial state or performing any setup actions before the drag starts.
|
|
98
|
+
*
|
|
99
|
+
* @param element - The element being dragged.
|
|
100
|
+
*
|
|
101
|
+
* @returns A boolean or Promise resolving to a boolean indicating if the drag should proceed.
|
|
98
102
|
*/
|
|
99
103
|
onStartDrag?: HoneyDragOnStartHandler<Element>;
|
|
100
104
|
/**
|
|
101
105
|
* Required handler triggered continuously during the drag operation.
|
|
102
|
-
* This
|
|
106
|
+
* This handler is responsible for updating the drag state and typically tracks the element's movement.
|
|
107
|
+
*
|
|
108
|
+
* @param element - The element being dragged.
|
|
109
|
+
*
|
|
110
|
+
* @returns A boolean or Promise resolving to a boolean indicating whether the drag should continue.
|
|
103
111
|
*/
|
|
104
112
|
onMoveDrag: HoneyDragOnMoveHandler<Element>;
|
|
105
113
|
/**
|
|
106
114
|
* Optional handler triggered when the drag operation ends.
|
|
107
|
-
* This
|
|
115
|
+
* This is commonly used for cleanup or finalizing the drag process.
|
|
116
|
+
*
|
|
117
|
+
* @param context - Contains information about the drag operation, such as distance and speed.
|
|
118
|
+
* @param element - The element being dragged.
|
|
119
|
+
*
|
|
120
|
+
* @returns A Promise.
|
|
108
121
|
*/
|
|
109
122
|
onEndDrag?: HoneyDragOnEndHandler<Element>;
|
|
110
123
|
}
|
|
111
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Configuration options for the drag functionality.
|
|
126
|
+
* These options control the behavior of the drag hook and modify how the drag events are handled.
|
|
127
|
+
*/
|
|
128
|
+
export interface HoneyDragOptions<Element extends HTMLElement> extends HoneyDragHandlers<Element> {
|
|
112
129
|
/**
|
|
113
|
-
* Controls whether the `onEndDrag` handler
|
|
114
|
-
*
|
|
115
|
-
* When `true`, `onEndDrag` will not be called if dragging is interrupted due to movement restrictions
|
|
116
|
-
* or an early termination.
|
|
130
|
+
* Controls whether the `onEndDrag` handler is skipped when the drag operation is forcibly stopped.
|
|
131
|
+
* This can be useful when dragging is interrupted or terminated early due to movement restrictions.
|
|
117
132
|
*
|
|
118
133
|
* @default false
|
|
119
134
|
*/
|
|
120
|
-
|
|
135
|
+
skipOnEndDragWhenStopped?: boolean;
|
|
121
136
|
/**
|
|
122
|
-
* Determines
|
|
137
|
+
* Determines if the drag functionality is enabled or disabled.
|
|
123
138
|
*
|
|
124
139
|
* @default true
|
|
125
140
|
*/
|
|
126
|
-
|
|
141
|
+
enabled?: boolean;
|
|
127
142
|
}
|
|
128
143
|
/**
|
|
129
144
|
* A hook that provides touch and mouse-based dragging functionality for an element.
|
|
130
|
-
* It
|
|
145
|
+
* It enables the ability to drag an element on both mouse and touch interfaces,
|
|
146
|
+
* with customizable handlers for different stages of the drag.
|
|
131
147
|
*
|
|
132
148
|
* @template Element - The type of the HTML element that is being dragged.
|
|
133
149
|
*
|
|
134
150
|
* @param draggableElementRef - A reference to the element that can be dragged.
|
|
135
|
-
* @param
|
|
136
|
-
*
|
|
151
|
+
* @param options - Handlers for different stages of the drag operation and configuration options
|
|
152
|
+
* for controlling drag behavior.
|
|
153
|
+
*
|
|
154
|
+
* @returns A cleanup function to remove event listeners when the component is unmounted.
|
|
137
155
|
*/
|
|
138
|
-
export declare const useHoneyDrag: <Element extends HTMLElement>(draggableElementRef: RefObject<Nullable<Element>>, { onMoveDrag, onStartDrag, onEndDrag }:
|
|
156
|
+
export declare const useHoneyDrag: <Element extends HTMLElement>(draggableElementRef: RefObject<Nullable<Element>>, { skipOnEndDragWhenStopped, enabled, onMoveDrag, onStartDrag, onEndDrag, }: HoneyDragOptions<Element>) => void;
|
|
139
157
|
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { HoneyLayoutContextValue } from '../contexts';
|
|
2
1
|
/**
|
|
3
2
|
* Custom hook to access the Honey layout context.
|
|
4
3
|
*
|
|
5
4
|
* @throws Will throw an error if the hook is used outside of a `HoneyLayoutProvider` component.
|
|
6
5
|
*
|
|
7
|
-
* @returns
|
|
6
|
+
* @returns The context value providing theming utilities and screen state.
|
|
8
7
|
*/
|
|
9
|
-
export declare const useHoneyLayout: () => HoneyLayoutContextValue;
|
|
8
|
+
export declare const useHoneyLayout: () => import('../contexts').HoneyLayoutContextValue;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EffectCallback } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A hook that invokes a callback function whenever the provided `state` value changes.
|
|
4
|
+
*
|
|
5
|
+
* This hook stores the previous value internally and performs a shallow comparison with the current value.
|
|
6
|
+
* If a change is detected, it executes the `onChange` callback. If the callback returns a cleanup function,
|
|
7
|
+
* it will be invoked before the next change or when the component unmounts, similar to standard `useEffect` behavior.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of the state being observed.
|
|
10
|
+
*
|
|
11
|
+
* @param state - The value to monitor for changes. Can be of any type.
|
|
12
|
+
* @param onChange - A function called whenever `state` changes. It may return a cleanup function.
|
|
13
|
+
*
|
|
14
|
+
* @returns void
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* useHoneyOnChange(someValue, (newValue) => {
|
|
19
|
+
* console.log('Value changed to:', newValue);
|
|
20
|
+
*
|
|
21
|
+
* return () => {
|
|
22
|
+
* console.log('Cleanup for value:', newValue);
|
|
23
|
+
* };
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const useHoneyOnChange: <T>(state: T, onChange: (newState: T) => ReturnType<EffectCallback>) => void;
|
|
@@ -3,19 +3,24 @@ interface UseHoneyOverlayOptions {
|
|
|
3
3
|
onKeyUp?: HoneyOverlayEventListenerHandler;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* Hook
|
|
6
|
+
* Hook for interacting with an active overlay managed by `HoneyLayoutProvider`.
|
|
7
7
|
*
|
|
8
|
-
* @param targetOverlayId - The unique
|
|
9
|
-
* @param options -
|
|
8
|
+
* @param targetOverlayId - The unique ID of the overlay you want to interact with.
|
|
9
|
+
* @param options - Optional configuration such as event handlers (e.g., `onKeyUp`).
|
|
10
10
|
*
|
|
11
|
-
* @returns The overlay
|
|
11
|
+
* @returns The overlay instance matching the provided ID, or `undefined` if not found.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* - This hook only works with overlays that are currently active.
|
|
15
|
+
* - If the overlay is not active or not registered, `undefined` will be returned.
|
|
16
|
+
* - Event handlers like `onKeyUp` are automatically registered and cleaned up for the overlay.
|
|
12
17
|
*
|
|
13
18
|
* @example
|
|
14
19
|
* ```tsx
|
|
15
20
|
* const overlay = useHoneyOverlay('my-overlay-id', {
|
|
16
21
|
* onKeyUp: (keyCode, e) => {
|
|
17
22
|
* if (keyCode === 'Escape') {
|
|
18
|
-
* console.log('Escape key pressed');
|
|
23
|
+
* console.log('Escape key pressed!');
|
|
19
24
|
* }
|
|
20
25
|
* },
|
|
21
26
|
* });
|