@zag-js/splitter 0.10.5 → 0.11.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.
- package/dist/index.d.mts +144 -0
- package/dist/index.d.ts +144 -4
- package/dist/index.js +670 -8
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +646 -3
- package/dist/index.mjs.map +1 -0
- package/package.json +9 -9
- package/dist/splitter.anatomy.d.ts +0 -3
- package/dist/splitter.anatomy.js +0 -11
- package/dist/splitter.anatomy.mjs +0 -6
- package/dist/splitter.connect.d.ts +0 -45
- package/dist/splitter.connect.js +0 -185
- package/dist/splitter.connect.mjs +0 -181
- package/dist/splitter.dom.d.ts +0 -38
- package/dist/splitter.dom.js +0 -62
- package/dist/splitter.dom.mjs +0 -58
- package/dist/splitter.machine.d.ts +0 -3
- package/dist/splitter.machine.js +0 -285
- package/dist/splitter.machine.mjs +0 -281
- package/dist/splitter.types.d.ts +0 -92
- package/dist/splitter.utils.d.ts +0 -49
- package/dist/splitter.utils.js +0 -130
- package/dist/splitter.utils.mjs +0 -122
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
import { RequiredBy, DirectionProperty, CommonProperties, Context, PropTypes, NormalizeProps } from '@zag-js/types';
|
|
3
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
+
import { StateMachine } from '@zag-js/core';
|
|
5
|
+
|
|
6
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "toggleTrigger" | "resizeTrigger">;
|
|
7
|
+
|
|
8
|
+
type PanelId = string | number;
|
|
9
|
+
type PanelSizeData = {
|
|
10
|
+
id: PanelId;
|
|
11
|
+
size?: number;
|
|
12
|
+
minSize?: number;
|
|
13
|
+
maxSize?: number;
|
|
14
|
+
};
|
|
15
|
+
type ResizeDetails = {
|
|
16
|
+
size: PanelSizeData[];
|
|
17
|
+
activeHandleId: string | null;
|
|
18
|
+
};
|
|
19
|
+
type ElementIds = Partial<{
|
|
20
|
+
root: string;
|
|
21
|
+
resizeTrigger(id: string): string;
|
|
22
|
+
toggleTrigger(id: string): string;
|
|
23
|
+
label(id: string): string;
|
|
24
|
+
panel(id: string | number): string;
|
|
25
|
+
}>;
|
|
26
|
+
type PublicContext = DirectionProperty & CommonProperties & {
|
|
27
|
+
/**
|
|
28
|
+
* The orientation of the splitter. Can be `horizontal` or `vertical`
|
|
29
|
+
*/
|
|
30
|
+
orientation: "horizontal" | "vertical";
|
|
31
|
+
/**
|
|
32
|
+
* The size data of the panels
|
|
33
|
+
*/
|
|
34
|
+
size: PanelSizeData[];
|
|
35
|
+
/**
|
|
36
|
+
* Function called when the splitter is resized.
|
|
37
|
+
*/
|
|
38
|
+
onResize?: (details: ResizeDetails) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Function called when the splitter resize starts.
|
|
41
|
+
*/
|
|
42
|
+
onResizeStart?: (details: ResizeDetails) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Function called when the splitter resize ends.
|
|
45
|
+
*/
|
|
46
|
+
onResizeEnd?: (details: ResizeDetails) => void;
|
|
47
|
+
/**
|
|
48
|
+
* The ids of the elements in the splitter. Useful for composition.
|
|
49
|
+
*/
|
|
50
|
+
ids?: ElementIds;
|
|
51
|
+
};
|
|
52
|
+
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
53
|
+
type NormalizedPanelData = Array<Required<PanelSizeData> & {
|
|
54
|
+
remainingSize: number;
|
|
55
|
+
minSize: number;
|
|
56
|
+
maxSize: number;
|
|
57
|
+
start: number;
|
|
58
|
+
end: number;
|
|
59
|
+
}>;
|
|
60
|
+
type ComputedContext = Readonly<{
|
|
61
|
+
isHorizontal: boolean;
|
|
62
|
+
panels: NormalizedPanelData;
|
|
63
|
+
activeResizeBounds?: {
|
|
64
|
+
min: number;
|
|
65
|
+
max: number;
|
|
66
|
+
};
|
|
67
|
+
activeResizePanels?: {
|
|
68
|
+
before: PanelSizeData;
|
|
69
|
+
after: PanelSizeData;
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
72
|
+
type PrivateContext = Context<{
|
|
73
|
+
activeResizeId: string | null;
|
|
74
|
+
previousPanels: NormalizedPanelData;
|
|
75
|
+
activeResizeState: {
|
|
76
|
+
isAtMin: boolean;
|
|
77
|
+
isAtMax: boolean;
|
|
78
|
+
};
|
|
79
|
+
initialSize: Array<Required<Pick<PanelSizeData, "id" | "size">>>;
|
|
80
|
+
}>;
|
|
81
|
+
type MachineContext = PublicContext & ComputedContext & PrivateContext;
|
|
82
|
+
type MachineState = {
|
|
83
|
+
value: "idle" | "hover:temp" | "hover" | "dragging" | "focused";
|
|
84
|
+
tags: "focus";
|
|
85
|
+
};
|
|
86
|
+
type State = StateMachine.State<MachineContext, MachineState>;
|
|
87
|
+
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
88
|
+
type PanelProps = {
|
|
89
|
+
id: PanelId;
|
|
90
|
+
snapSize?: number;
|
|
91
|
+
};
|
|
92
|
+
type ResizeTriggerProps = {
|
|
93
|
+
id: `${PanelId}:${PanelId}`;
|
|
94
|
+
step?: number;
|
|
95
|
+
disabled?: boolean;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
99
|
+
/**
|
|
100
|
+
* Whether the splitter is focused.
|
|
101
|
+
*/
|
|
102
|
+
isFocused: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Whether the splitter is being dragged.
|
|
105
|
+
*/
|
|
106
|
+
isDragging: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* The bounds of the currently dragged splitter handle.
|
|
109
|
+
*/
|
|
110
|
+
bounds: {
|
|
111
|
+
min: number;
|
|
112
|
+
max: number;
|
|
113
|
+
} | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Function to set a panel to its minimum size.
|
|
116
|
+
*/
|
|
117
|
+
setToMinSize(id: PanelId): void;
|
|
118
|
+
/**
|
|
119
|
+
* Function to set a panel to its maximum size.
|
|
120
|
+
*/
|
|
121
|
+
setToMaxSize(id: PanelId): void;
|
|
122
|
+
/**
|
|
123
|
+
* Function to set the size of a panel.
|
|
124
|
+
*/
|
|
125
|
+
setSize(id: PanelId, size: number): void;
|
|
126
|
+
/**
|
|
127
|
+
* Returns the state details for a resize trigger.
|
|
128
|
+
*/
|
|
129
|
+
getResizeTriggerState(props: ResizeTriggerProps): {
|
|
130
|
+
isDisabled: boolean;
|
|
131
|
+
isFocused: boolean;
|
|
132
|
+
panelIds: string[];
|
|
133
|
+
min: number | undefined;
|
|
134
|
+
max: number | undefined;
|
|
135
|
+
value: number;
|
|
136
|
+
};
|
|
137
|
+
rootProps: T["element"];
|
|
138
|
+
getPanelProps(props: PanelProps): T["element"];
|
|
139
|
+
getResizeTriggerProps(props: ResizeTriggerProps): T["element"];
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
143
|
+
|
|
144
|
+
export { UserDefinedContext as Context, MachineState, PanelProps, ResizeTriggerProps, anatomy, connect, machine };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,144 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
import { RequiredBy, DirectionProperty, CommonProperties, Context, PropTypes, NormalizeProps } from '@zag-js/types';
|
|
3
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
+
import { StateMachine } from '@zag-js/core';
|
|
5
|
+
|
|
6
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "toggleTrigger" | "resizeTrigger">;
|
|
7
|
+
|
|
8
|
+
type PanelId = string | number;
|
|
9
|
+
type PanelSizeData = {
|
|
10
|
+
id: PanelId;
|
|
11
|
+
size?: number;
|
|
12
|
+
minSize?: number;
|
|
13
|
+
maxSize?: number;
|
|
14
|
+
};
|
|
15
|
+
type ResizeDetails = {
|
|
16
|
+
size: PanelSizeData[];
|
|
17
|
+
activeHandleId: string | null;
|
|
18
|
+
};
|
|
19
|
+
type ElementIds = Partial<{
|
|
20
|
+
root: string;
|
|
21
|
+
resizeTrigger(id: string): string;
|
|
22
|
+
toggleTrigger(id: string): string;
|
|
23
|
+
label(id: string): string;
|
|
24
|
+
panel(id: string | number): string;
|
|
25
|
+
}>;
|
|
26
|
+
type PublicContext = DirectionProperty & CommonProperties & {
|
|
27
|
+
/**
|
|
28
|
+
* The orientation of the splitter. Can be `horizontal` or `vertical`
|
|
29
|
+
*/
|
|
30
|
+
orientation: "horizontal" | "vertical";
|
|
31
|
+
/**
|
|
32
|
+
* The size data of the panels
|
|
33
|
+
*/
|
|
34
|
+
size: PanelSizeData[];
|
|
35
|
+
/**
|
|
36
|
+
* Function called when the splitter is resized.
|
|
37
|
+
*/
|
|
38
|
+
onResize?: (details: ResizeDetails) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Function called when the splitter resize starts.
|
|
41
|
+
*/
|
|
42
|
+
onResizeStart?: (details: ResizeDetails) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Function called when the splitter resize ends.
|
|
45
|
+
*/
|
|
46
|
+
onResizeEnd?: (details: ResizeDetails) => void;
|
|
47
|
+
/**
|
|
48
|
+
* The ids of the elements in the splitter. Useful for composition.
|
|
49
|
+
*/
|
|
50
|
+
ids?: ElementIds;
|
|
51
|
+
};
|
|
52
|
+
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
53
|
+
type NormalizedPanelData = Array<Required<PanelSizeData> & {
|
|
54
|
+
remainingSize: number;
|
|
55
|
+
minSize: number;
|
|
56
|
+
maxSize: number;
|
|
57
|
+
start: number;
|
|
58
|
+
end: number;
|
|
59
|
+
}>;
|
|
60
|
+
type ComputedContext = Readonly<{
|
|
61
|
+
isHorizontal: boolean;
|
|
62
|
+
panels: NormalizedPanelData;
|
|
63
|
+
activeResizeBounds?: {
|
|
64
|
+
min: number;
|
|
65
|
+
max: number;
|
|
66
|
+
};
|
|
67
|
+
activeResizePanels?: {
|
|
68
|
+
before: PanelSizeData;
|
|
69
|
+
after: PanelSizeData;
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
72
|
+
type PrivateContext = Context<{
|
|
73
|
+
activeResizeId: string | null;
|
|
74
|
+
previousPanels: NormalizedPanelData;
|
|
75
|
+
activeResizeState: {
|
|
76
|
+
isAtMin: boolean;
|
|
77
|
+
isAtMax: boolean;
|
|
78
|
+
};
|
|
79
|
+
initialSize: Array<Required<Pick<PanelSizeData, "id" | "size">>>;
|
|
80
|
+
}>;
|
|
81
|
+
type MachineContext = PublicContext & ComputedContext & PrivateContext;
|
|
82
|
+
type MachineState = {
|
|
83
|
+
value: "idle" | "hover:temp" | "hover" | "dragging" | "focused";
|
|
84
|
+
tags: "focus";
|
|
85
|
+
};
|
|
86
|
+
type State = StateMachine.State<MachineContext, MachineState>;
|
|
87
|
+
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
88
|
+
type PanelProps = {
|
|
89
|
+
id: PanelId;
|
|
90
|
+
snapSize?: number;
|
|
91
|
+
};
|
|
92
|
+
type ResizeTriggerProps = {
|
|
93
|
+
id: `${PanelId}:${PanelId}`;
|
|
94
|
+
step?: number;
|
|
95
|
+
disabled?: boolean;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
99
|
+
/**
|
|
100
|
+
* Whether the splitter is focused.
|
|
101
|
+
*/
|
|
102
|
+
isFocused: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Whether the splitter is being dragged.
|
|
105
|
+
*/
|
|
106
|
+
isDragging: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* The bounds of the currently dragged splitter handle.
|
|
109
|
+
*/
|
|
110
|
+
bounds: {
|
|
111
|
+
min: number;
|
|
112
|
+
max: number;
|
|
113
|
+
} | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Function to set a panel to its minimum size.
|
|
116
|
+
*/
|
|
117
|
+
setToMinSize(id: PanelId): void;
|
|
118
|
+
/**
|
|
119
|
+
* Function to set a panel to its maximum size.
|
|
120
|
+
*/
|
|
121
|
+
setToMaxSize(id: PanelId): void;
|
|
122
|
+
/**
|
|
123
|
+
* Function to set the size of a panel.
|
|
124
|
+
*/
|
|
125
|
+
setSize(id: PanelId, size: number): void;
|
|
126
|
+
/**
|
|
127
|
+
* Returns the state details for a resize trigger.
|
|
128
|
+
*/
|
|
129
|
+
getResizeTriggerState(props: ResizeTriggerProps): {
|
|
130
|
+
isDisabled: boolean;
|
|
131
|
+
isFocused: boolean;
|
|
132
|
+
panelIds: string[];
|
|
133
|
+
min: number | undefined;
|
|
134
|
+
max: number | undefined;
|
|
135
|
+
value: number;
|
|
136
|
+
};
|
|
137
|
+
rootProps: T["element"];
|
|
138
|
+
getPanelProps(props: PanelProps): T["element"];
|
|
139
|
+
getResizeTriggerProps(props: ResizeTriggerProps): T["element"];
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
143
|
+
|
|
144
|
+
export { UserDefinedContext as Context, MachineState, PanelProps, ResizeTriggerProps, anatomy, connect, machine };
|