@mantine/hooks 9.2.2 → 9.3.1

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.
@@ -0,0 +1,94 @@
1
+ export interface UseSplitterPanel {
2
+ /** Initial size as percentage (0-100). All panels must sum to 100. */
3
+ defaultSize: number;
4
+ /** Minimum size percentage, `0` by default */
5
+ min?: number;
6
+ /** Maximum size percentage, `100` by default */
7
+ max?: number;
8
+ /** Whether this panel can be collapsed, `false` by default */
9
+ collapsible?: boolean;
10
+ /** Size below which the panel snaps to collapsed (percentage), defaults to `min` */
11
+ collapseThreshold?: number;
12
+ }
13
+ export interface UseSplitterRedistributeInput {
14
+ /** Current sizes before applying delta */
15
+ sizes: number[];
16
+ /** Panel configurations */
17
+ panels: UseSplitterPanel[];
18
+ /** Index of the handle being dragged */
19
+ handleIndex: number;
20
+ /** Requested size change in percentage (positive = grow before-panel) */
21
+ delta: number;
22
+ }
23
+ export type UseSplitterRedistributeFn = (input: UseSplitterRedistributeInput) => number[];
24
+ export interface UseSplitterOptions {
25
+ /** Panel configuration array (minimum 2 panels) */
26
+ panels: UseSplitterPanel[];
27
+ /** Layout direction, `'horizontal'` by default */
28
+ orientation?: 'horizontal' | 'vertical';
29
+ /** Controlled sizes (percentages summing to 100) */
30
+ sizes?: number[];
31
+ /** Called during resize with updated sizes */
32
+ onSizeChange?: (sizes: number[]) => void;
33
+ /** Called when drag starts */
34
+ onResizeStart?: (handleIndex: number) => void;
35
+ /** Called when drag ends */
36
+ onResizeEnd?: (handleIndex: number, sizes: number[]) => void;
37
+ /** Called when a panel collapses or expands */
38
+ onCollapseChange?: (panelIndex: number, collapsed: boolean) => void;
39
+ /** How to borrow space from non-adjacent panels when the immediate neighbor is at its min/max.
40
+ * `'nearest'` takes from the nearest panel in the drag direction first.
41
+ * `'equal'` distributes equally among all panels in the drag direction.
42
+ * A function receives sizes, panels, handleIndex and delta, and returns new sizes.
43
+ * When not set, only the two adjacent panels are affected. */
44
+ redistribute?: 'nearest' | 'equal' | UseSplitterRedistributeFn;
45
+ /** Keyboard step size in percentage, `1` by default */
46
+ step?: number;
47
+ /** Shift+arrow step size in percentage, `10` by default */
48
+ shiftStep?: number;
49
+ /** Text direction for keyboard nav, `'ltr'` by default */
50
+ dir?: 'ltr' | 'rtl';
51
+ /** Enable/disable the hook, `true` by default */
52
+ enabled?: boolean;
53
+ }
54
+ export interface UseSplitterReturnValue<T extends HTMLElement = any> {
55
+ /** Ref callback for the container element */
56
+ ref: React.RefCallback<T | null>;
57
+ /** Current panel sizes as percentages */
58
+ sizes: number[];
59
+ /** Which panels are currently collapsed */
60
+ collapsed: boolean[];
61
+ /** Index of handle being dragged, or -1 */
62
+ activeHandle: number;
63
+ /** Get props to spread on each resize handle */
64
+ getHandleProps: (input: {
65
+ index: number;
66
+ }) => {
67
+ ref: React.RefCallback<HTMLElement>;
68
+ role: 'separator';
69
+ 'aria-orientation': 'horizontal' | 'vertical';
70
+ 'aria-valuenow': number;
71
+ 'aria-valuemin': number;
72
+ 'aria-valuemax': number;
73
+ tabIndex: number;
74
+ onKeyDown: React.KeyboardEventHandler;
75
+ 'data-active': boolean | undefined;
76
+ 'data-orientation': 'horizontal' | 'vertical';
77
+ };
78
+ /** Programmatically set sizes */
79
+ setSizes: (sizes: number[]) => void;
80
+ /** Collapse a panel */
81
+ collapse: (panelIndex: number) => void;
82
+ /** Expand a collapsed panel */
83
+ expand: (panelIndex: number) => void;
84
+ /** Toggle collapse of a panel */
85
+ toggleCollapse: (panelIndex: number) => void;
86
+ }
87
+ export declare function useSplitter<T extends HTMLElement = any>(options: UseSplitterOptions): UseSplitterReturnValue<T>;
88
+ export declare namespace useSplitter {
89
+ type Panel = UseSplitterPanel;
90
+ type Options = UseSplitterOptions;
91
+ type RedistributeInput = UseSplitterRedistributeInput;
92
+ type RedistributeFn = UseSplitterRedistributeFn;
93
+ type ReturnValue<T extends HTMLElement = any> = UseSplitterReturnValue<T>;
94
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine/hooks",
3
- "version": "9.2.2",
3
+ "version": "9.3.1",
4
4
  "description": "A collection of 50+ hooks for state and UI management",
5
5
  "homepage": "https://mantine.dev",
6
6
  "license": "MIT",