@react-hive/honey-layout 15.0.0 → 16.0.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,45 +0,0 @@
1
- export type UseHoneyResizeHandler = () => void;
2
- interface UseHoneyResizeOptions {
3
- /**
4
- * Whether to invoke the resize handler immediately on mount.
5
- *
6
- * Useful when initial layout measurements should be performed
7
- * before any resize events occur.
8
- *
9
- * @default false
10
- */
11
- invokeOnMount?: boolean;
12
- /**
13
- * Throttle delay (in milliseconds) applied to the resize handler.
14
- *
15
- * When greater than `0`, the handler will be throttled using
16
- * `lodash.throttle` to reduce invocation frequency.
17
- *
18
- * @default 0
19
- */
20
- throttleTime?: number;
21
- /**
22
- * Enables or disables the resize listener.
23
- *
24
- * @default true
25
- */
26
- enabled?: boolean;
27
- }
28
- /**
29
- * A hook that subscribes to the window `resize` event and invokes a handler function in response.
30
- *
31
- * The handler can be optionally throttled to limit execution frequency, which is useful
32
- * for expensive layout calculations or DOM measurements.
33
- *
34
- * @example
35
- * ```ts
36
- * useHoneyResize(() => {
37
- * console.log('Window resized');
38
- * }, { throttleTime: 200 });
39
- * ```
40
- *
41
- * @param handler - Callback invoked when the window is resized.
42
- * @param options - Configuration options controlling invocation timing and performance.
43
- */
44
- export declare const useHoneyResize: (handler: UseHoneyResizeHandler, { invokeOnMount, throttleTime, enabled }?: UseHoneyResizeOptions) => void;
45
- export {};
@@ -1,19 +0,0 @@
1
- import type { UseHoneySyntheticScrollOptions } from './use-honey-synthetic-scroll';
2
- /**
3
- * Enables synthetic horizontal (X-axis) scrolling for a container element
4
- * using pointer-based drag interactions.
5
- *
6
- * This is a convenience wrapper around {@link useHoneySyntheticScroll} with
7
- * the axis fixed to `'x'`.
8
- *
9
- * All behavior, boundaries, and lifecycle guarantees are identical to the
10
- * base hook, but limited to horizontal movement only.
11
- *
12
- * @template Element - The HTML element type of the scrollable container.
13
- *
14
- * @param options - Configuration options forwarded to
15
- * {@link useHoneySyntheticScroll}, excluding the `axis` option.
16
- *
17
- * @returns A ref that must be attached to the scrollable container element.
18
- */
19
- export declare const useHoneySyntheticScrollX: <Element extends HTMLElement>(options?: Omit<UseHoneySyntheticScrollOptions<Element>, "axis">) => import("react").RefObject<import("..").Nullable<Element>>;
@@ -1,19 +0,0 @@
1
- import type { UseHoneySyntheticScrollOptions } from './use-honey-synthetic-scroll';
2
- /**
3
- * Enables synthetic vertical (Y-axis) scrolling for a container element
4
- * using pointer-based drag interactions.
5
- *
6
- * This is a convenience wrapper around {@link useHoneySyntheticScroll} with
7
- * the axis fixed to `'y'`.
8
- *
9
- * All behavior, boundaries, and lifecycle guarantees are identical to the
10
- * base hook, but limited to vertical movement only.
11
- *
12
- * @template Element - The HTML element type of the scrollable container.
13
- *
14
- * @param options - Configuration options forwarded to
15
- * {@link useHoneySyntheticScroll}, excluding the `axis` option.
16
- *
17
- * @returns A ref that must be attached to the scrollable container element.
18
- */
19
- export declare const useHoneySyntheticScrollY: <Element extends HTMLElement>(options?: Omit<UseHoneySyntheticScrollOptions<Element>, "axis">) => import("react").RefObject<import("..").Nullable<Element>>;
@@ -1,143 +0,0 @@
1
- import type { RefObject } from 'react';
2
- import type { Axis } from '@react-hive/honey-utils';
3
- import type { Nullable } from '../types';
4
- import type { UseHoneyDragHandlers } from './use-honey-drag';
5
- interface ResolveAxisTranslateOptions {
6
- /**
7
- * Drag delta for the axis (deltaX or deltaY).
8
- */
9
- delta: number;
10
- /**
11
- * Current translate value for the axis.
12
- */
13
- translate: number;
14
- /**
15
- * Visible container size for the axis (width or height).
16
- */
17
- containerSize: number;
18
- /**
19
- * Overflow size for the axis.
20
- */
21
- overflowSize: number;
22
- /**
23
- * Overscroll window percentage.
24
- */
25
- overscrollPct: number;
26
- }
27
- export declare const resolveAxisTranslate: ({ delta, translate, containerSize, overflowSize, overscrollPct, }: ResolveAxisTranslateOptions) => Nullable<number>;
28
- export interface UseHoneySyntheticScrollOptions<Element extends HTMLElement> extends Pick<UseHoneyDragHandlers<Element>, 'onStartDrag' | 'onEndDrag'> {
29
- /**
30
- * Axis along which synthetic scrolling is enabled.
31
- *
32
- * - `'x'` — horizontal only
33
- * - `'y'` — vertical only
34
- * - `'both'` — horizontal and vertical
35
- *
36
- * @default 'both'
37
- */
38
- axis?: Axis;
39
- /**
40
- * Percentage of the container size used as an overscroll buffer
41
- * on each enabled axis.
42
- *
43
- * This allows limited dragging beyond the natural content bounds
44
- * before movement is clamped.
45
- *
46
- * A value of `0` disables overscroll entirely.
47
- *
48
- * @default 0
49
- */
50
- overscrollPct?: number;
51
- /**
52
- * Controls how the hook applies scroll-related interaction styles
53
- * (`touch-action` and `overscroll-behavior`) to the container.
54
- *
55
- * Synthetic scrolling often requires restricting native browser scrolling
56
- * behavior to ensure consistent drag and wheel handling.
57
- *
58
- * However, in some embedded layouts (such as carousels placed inside a
59
- * vertically scrollable page), applying these styles can unintentionally
60
- * block natural page scrolling.
61
- *
62
- * ### Modes
63
- * - `'default'` — Applies restrictive interaction styles:
64
- * - `overscroll-behavior: contain`
65
- * - Axis-aware `touch-action` (`pan-y`, `pan-x`, or `none`)
66
- *
67
- * Recommended for standalone synthetic scroll containers.
68
- *
69
- * - `'embedded'` — Does not apply any interaction-blocking styles.
70
- *
71
- * Recommended when the container is integrated into another scrollable
72
- * context (e.g. horizontal carousel inside a page), where native scroll
73
- * chaining must remain intact.
74
- *
75
- * @default 'default'
76
- */
77
- scrollMode?: 'default' | 'embedded';
78
- /**
79
- * Whether to clear any applied translation transforms when the window resizes.
80
- *
81
- * Useful to keep the layout state consistent after dimension changes.
82
- *
83
- * @default true
84
- */
85
- resetOnResize?: boolean;
86
- /**
87
- * Enables synthetic scrolling driven by pointer-based scroll input,
88
- * such as mouse wheels and trackpads.
89
- *
90
- * When enabled, scroll input is intercepted and converted into bounded
91
- * translation using the same logic as drag gestures.
92
- *
93
- * When disabled, native scrolling behavior is preserved and no scroll
94
- * input is handled by this hook.
95
- *
96
- * @default true
97
- */
98
- enablePointerScroll?: boolean;
99
- /**
100
- * Master toggle for the synthetic scroll behavior.
101
- *
102
- * When `true`, the hook:
103
- * - Enables drag-based translation via {@link useHoneyDrag}.
104
- * - Optionally resets transforms on resize via {@link useHoneyResize}.
105
- * - Applies overscroll and touch-action styles.
106
- * - Intercepts wheel / trackpad scroll input if {@link enablePointerScroll} is enabled.
107
- *
108
- * When `false`, the hook becomes completely inert:
109
- * - No drag or wheel listeners are attached.
110
- * - No transforms are applied.
111
- * - Native scrolling behavior is preserved.
112
- *
113
- * Useful for conditionally disabling synthetic scrolling
114
- * (e.g. mobile layouts, reduced motion, or feature flags).
115
- *
116
- * @default true
117
- */
118
- enabled?: boolean;
119
- }
120
- /**
121
- * Enables synthetic scrolling for a container using pointer-based drag gestures.
122
- *
123
- * Instead of relying on native scrollbars, this hook translates the container
124
- * using CSS transforms in response to drag input.
125
- *
126
- * ### Key characteristics
127
- * - Dragging is only applied when content overflows the container on a given axis.
128
- * - Movement is clamped within calculated bounds, with optional overscroll allowance.
129
- * - Scroll position is stored purely in `transform: translate(...)`.
130
- * - Active transforms can be automatically cleared on window resize.
131
- *
132
- * ### Internals
133
- * - Uses {@link useHoneyDrag} to track mouse / touch movement.
134
- * - Uses {@link useHoneyResize} to optionally reset scroll state on resize.
135
- *
136
- * @template Element - The HTML element type of the scrollable container.
137
- *
138
- * @param options - Configuration controlling axes, boundaries, and lifecycle behavior.
139
- *
140
- * @returns A ref that must be attached to the scrollable container element.
141
- */
142
- export declare const useHoneySyntheticScroll: <Element extends HTMLElement>({ axis, overscrollPct, onStartDrag, onEndDrag, scrollMode, resetOnResize, enablePointerScroll, enabled, }?: UseHoneySyntheticScrollOptions<Element>) => RefObject<Nullable<Element>>;
143
- export {};
@@ -1,107 +0,0 @@
1
- /**
2
- * Timer operating mode.
3
- *
4
- * - `countdown` — decreases time until it reaches `targetTimeMs`
5
- * - `countup` — increases time until it reaches `targetTimeMs` (if provided)
6
- */
7
- type UseHoneyTimerMode = 'countdown' | 'countup';
8
- type UseHoneyTimerOnEndHandler = () => void;
9
- export interface UseHoneyTimerOptions {
10
- /**
11
- * Initial timer value in milliseconds.
12
- *
13
- * - Countdown: starting time
14
- * - Count-up: initial offset
15
- */
16
- initialTimeMs: number;
17
- /**
18
- * Target time in milliseconds.
19
- *
20
- * - Countdown: usually `0`
21
- * - Count-up: optional upper limit
22
- *
23
- * When reached, the timer stops and `onEnd` is invoked.
24
- *
25
- * @default 0
26
- */
27
- targetTimeMs?: number;
28
- /**
29
- * Direction in which the timer progresses.
30
- *
31
- * @default 'countdown'
32
- */
33
- mode?: UseHoneyTimerMode;
34
- /**
35
- * Whether the timer should automatically start on mount.
36
- *
37
- * @default false
38
- */
39
- autoStart?: boolean;
40
- /**
41
- * Optional callback invoked exactly once when the timer reaches the target time.
42
- */
43
- onEnd?: UseHoneyTimerOnEndHandler;
44
- }
45
- /**
46
- * Public control API returned by {@link useHoneyTimer}.
47
- */
48
- export interface UseHoneyTimerApi {
49
- /**
50
- * Current timer value in milliseconds.
51
- *
52
- * This value updates over time while the timer is running.
53
- */
54
- timeMs: number;
55
- /**
56
- * Indicates whether the timer is currently progressing.
57
- */
58
- isRunning: boolean;
59
- /**
60
- * Starts the timer from `initialTimeMs`, resetting any previous state.
61
- */
62
- start: () => void;
63
- /**
64
- * Pauses the timer while preserving the current time value.
65
- */
66
- pause: () => void;
67
- /**
68
- * Resumes the timer from its current time value.
69
- *
70
- * Has no effect if the timer is already running.
71
- */
72
- resume: () => void;
73
- /**
74
- * Resets the timer to a specific time value.
75
- *
76
- * @param timeMs - Optional new timer value. Defaults to `initialTimeMs`.
77
- */
78
- reset: (timeMs?: number) => void;
79
- }
80
- /**
81
- * A high-precision timer hook built on top of {@link useHoneyRafLoop}.
82
- *
83
- * Features:
84
- * - Frame-accurate time progression using `requestAnimationFrame`
85
- * - Supports countdown and count-up modes
86
- * - Explicit lifecycle control (start / pause / resume / reset)
87
- * - Drift-free timing using delta-based updates
88
- * - Safe completion handling via `onEnd`
89
- *
90
- * Architectural notes:
91
- * - Time progression is handled imperatively via refs to avoid stale closures and unnecessary re-renders.
92
- * - React state is updated only with the derived timer value.
93
- * - RAF lifecycle is fully delegated to `useHoneyRafLoop`.
94
- *
95
- * @example
96
- * ```ts
97
- * const timer = useHoneyTimer({
98
- * initialTimeMs: 10_000,
99
- * targetTimeMs: 0,
100
- * onEnd: () => console.log('Done'),
101
- * });
102
- *
103
- * timer.startTimer();
104
- * ```
105
- */
106
- export declare const useHoneyTimer: ({ initialTimeMs, targetTimeMs, mode, autoStart, onEnd, }: UseHoneyTimerOptions) => UseHoneyTimerApi;
107
- export {};