@zag-js/splitter 1.34.1 → 1.35.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.
- package/dist/index.d.mts +9 -254
- package/dist/index.d.ts +9 -254
- package/dist/index.js +37 -1158
- package/dist/index.mjs +11 -1151
- package/dist/splitter.anatomy.d.mts +6 -0
- package/dist/splitter.anatomy.d.ts +6 -0
- package/dist/splitter.anatomy.js +34 -0
- package/dist/splitter.anatomy.mjs +8 -0
- package/dist/splitter.connect.d.mts +7 -0
- package/dist/splitter.connect.d.ts +7 -0
- package/dist/splitter.connect.js +298 -0
- package/dist/splitter.connect.mjs +263 -0
- package/dist/splitter.dom.d.mts +19 -0
- package/dist/splitter.dom.d.ts +19 -0
- package/dist/splitter.dom.js +89 -0
- package/dist/splitter.dom.mjs +52 -0
- package/dist/splitter.machine.d.mts +7 -0
- package/dist/splitter.machine.d.ts +7 -0
- package/dist/splitter.machine.js +509 -0
- package/dist/splitter.machine.mjs +482 -0
- package/dist/splitter.props.d.mts +12 -0
- package/dist/splitter.props.d.ts +12 -0
- package/dist/splitter.props.js +63 -0
- package/dist/splitter.props.mjs +33 -0
- package/dist/splitter.types.d.mts +237 -0
- package/dist/splitter.types.d.ts +237 -0
- package/dist/splitter.types.js +18 -0
- package/dist/splitter.types.mjs +0 -0
- package/dist/utils/aria.d.mts +27 -0
- package/dist/utils/aria.d.ts +27 -0
- package/dist/utils/aria.js +79 -0
- package/dist/utils/aria.mjs +53 -0
- package/dist/utils/fuzzy.d.mts +10 -0
- package/dist/utils/fuzzy.d.ts +10 -0
- package/dist/utils/fuzzy.js +60 -0
- package/dist/utils/fuzzy.mjs +32 -0
- package/dist/utils/panel.d.mts +34 -0
- package/dist/utils/panel.d.ts +34 -0
- package/dist/utils/panel.js +147 -0
- package/dist/utils/panel.mjs +114 -0
- package/dist/utils/resize-by-delta.d.mts +20 -0
- package/dist/utils/resize-by-delta.d.ts +20 -0
- package/dist/utils/resize-by-delta.js +165 -0
- package/dist/utils/resize-by-delta.mjs +140 -0
- package/dist/utils/resize-panel.d.mts +16 -0
- package/dist/utils/resize-panel.d.ts +16 -0
- package/dist/utils/resize-panel.js +51 -0
- package/dist/utils/resize-panel.mjs +26 -0
- package/dist/utils/validate-sizes.d.mts +15 -0
- package/dist/utils/validate-sizes.d.ts +15 -0
- package/dist/utils/validate-sizes.js +72 -0
- package/dist/utils/validate-sizes.mjs +47 -0
- package/package.json +17 -7
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { Machine, EventObject, Service } from '@zag-js/core';
|
|
2
|
+
import { PropTypes, RequiredBy, DirectionProperty, CommonProperties } from '@zag-js/types';
|
|
3
|
+
|
|
4
|
+
type ResizeEvent = PointerEvent | KeyboardEvent;
|
|
5
|
+
type PanelId = string;
|
|
6
|
+
type ResizeTriggerId = `${PanelId}:${PanelId}`;
|
|
7
|
+
interface PanelData {
|
|
8
|
+
/**
|
|
9
|
+
* The id of the panel.
|
|
10
|
+
*/
|
|
11
|
+
id: PanelId;
|
|
12
|
+
/**
|
|
13
|
+
* The order of the panel. useful of you intend to conditionally render the panel.
|
|
14
|
+
*/
|
|
15
|
+
order?: number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The minimum size of the panel.
|
|
18
|
+
*/
|
|
19
|
+
minSize?: number | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The maximum size of the panel.
|
|
22
|
+
*/
|
|
23
|
+
maxSize?: number | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the panel is collapsible.
|
|
26
|
+
*/
|
|
27
|
+
collapsible?: boolean | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The size of the panel when collapsed.
|
|
30
|
+
*/
|
|
31
|
+
collapsedSize?: number | undefined;
|
|
32
|
+
}
|
|
33
|
+
interface CursorState {
|
|
34
|
+
isAtMin: boolean;
|
|
35
|
+
isAtMax: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface ResizeDetails {
|
|
38
|
+
size: number[];
|
|
39
|
+
resizeTriggerId: string | null;
|
|
40
|
+
layout: string;
|
|
41
|
+
expandToSizes: Record<string, number>;
|
|
42
|
+
}
|
|
43
|
+
interface ResizeEndDetails {
|
|
44
|
+
size: number[];
|
|
45
|
+
resizeTriggerId: string | null;
|
|
46
|
+
}
|
|
47
|
+
interface ExpandCollapseDetails {
|
|
48
|
+
panelId: string;
|
|
49
|
+
size: number;
|
|
50
|
+
}
|
|
51
|
+
type ElementIds = Partial<{
|
|
52
|
+
root: string;
|
|
53
|
+
resizeTrigger: (id: string) => string;
|
|
54
|
+
label: (id: string) => string;
|
|
55
|
+
panel: (id: string | number) => string;
|
|
56
|
+
}>;
|
|
57
|
+
interface SplitterProps extends DirectionProperty, CommonProperties {
|
|
58
|
+
/**
|
|
59
|
+
* The orientation of the splitter. Can be `horizontal` or `vertical`
|
|
60
|
+
* @default "horizontal"
|
|
61
|
+
*/
|
|
62
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* The controlled size data of the panels
|
|
65
|
+
*/
|
|
66
|
+
size?: number[] | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* The initial size of the panels when rendered.
|
|
69
|
+
* Use when you don't need to control the size of the panels.
|
|
70
|
+
*/
|
|
71
|
+
defaultSize?: number[] | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The size constraints of the panels.
|
|
74
|
+
*/
|
|
75
|
+
panels: PanelData[];
|
|
76
|
+
/**
|
|
77
|
+
* Function called when the splitter is resized.
|
|
78
|
+
*/
|
|
79
|
+
onResize?: ((details: ResizeDetails) => void) | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Function called when the splitter resize starts.
|
|
82
|
+
*/
|
|
83
|
+
onResizeStart?: (() => void) | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Function called when the splitter resize ends.
|
|
86
|
+
*/
|
|
87
|
+
onResizeEnd?: ((details: ResizeEndDetails) => void) | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* The ids of the elements in the splitter. Useful for composition.
|
|
90
|
+
*/
|
|
91
|
+
ids?: ElementIds | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* The number of pixels to resize the panel by when the keyboard is used.
|
|
94
|
+
*/
|
|
95
|
+
keyboardResizeBy?: number | null | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* The nonce for the injected splitter cursor stylesheet.
|
|
98
|
+
*/
|
|
99
|
+
nonce?: string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Function called when a panel is collapsed.
|
|
102
|
+
*/
|
|
103
|
+
onCollapse?: ((details: ExpandCollapseDetails) => void) | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Function called when a panel is expanded.
|
|
106
|
+
*/
|
|
107
|
+
onExpand?: ((details: ExpandCollapseDetails) => void) | undefined;
|
|
108
|
+
}
|
|
109
|
+
type PropsWithDefault = "orientation" | "panels";
|
|
110
|
+
interface DragState {
|
|
111
|
+
resizeTriggerId: string;
|
|
112
|
+
resizeTriggerRect: DOMRect;
|
|
113
|
+
initialCursorPosition: number;
|
|
114
|
+
initialSize: number[];
|
|
115
|
+
}
|
|
116
|
+
interface KeyboardState {
|
|
117
|
+
resizeTriggerId: string;
|
|
118
|
+
}
|
|
119
|
+
interface Context {
|
|
120
|
+
dragState: DragState | null;
|
|
121
|
+
keyboardState: KeyboardState | null;
|
|
122
|
+
size: number[];
|
|
123
|
+
}
|
|
124
|
+
interface Refs {
|
|
125
|
+
panelSizeBeforeCollapse: Map<string, number>;
|
|
126
|
+
panelIdToLastNotifiedSizeMap: Map<string, number>;
|
|
127
|
+
prevDelta: number;
|
|
128
|
+
}
|
|
129
|
+
interface SplitterSchema {
|
|
130
|
+
state: "idle" | "hover:temp" | "hover" | "dragging" | "focused";
|
|
131
|
+
tag: "focus";
|
|
132
|
+
props: RequiredBy<SplitterProps, PropsWithDefault>;
|
|
133
|
+
context: Context;
|
|
134
|
+
computed: {
|
|
135
|
+
horizontal: boolean;
|
|
136
|
+
};
|
|
137
|
+
refs: Refs;
|
|
138
|
+
action: string;
|
|
139
|
+
event: EventObject;
|
|
140
|
+
effect: string;
|
|
141
|
+
guard: string;
|
|
142
|
+
}
|
|
143
|
+
type SplitterService = Service<SplitterSchema>;
|
|
144
|
+
type SplitterMachine = Machine<SplitterSchema>;
|
|
145
|
+
interface PanelProps {
|
|
146
|
+
id: PanelId;
|
|
147
|
+
}
|
|
148
|
+
interface ResizeTriggerProps {
|
|
149
|
+
id: ResizeTriggerId;
|
|
150
|
+
disabled?: boolean | undefined;
|
|
151
|
+
}
|
|
152
|
+
interface ResizeTriggerState {
|
|
153
|
+
dragging: boolean;
|
|
154
|
+
focused: boolean;
|
|
155
|
+
disabled: boolean;
|
|
156
|
+
}
|
|
157
|
+
interface PanelItem {
|
|
158
|
+
type: "panel";
|
|
159
|
+
id: PanelId;
|
|
160
|
+
}
|
|
161
|
+
interface ResizeTriggerItem {
|
|
162
|
+
type: "handle";
|
|
163
|
+
id: ResizeTriggerId;
|
|
164
|
+
}
|
|
165
|
+
type SplitterItem = PanelItem | ResizeTriggerItem;
|
|
166
|
+
interface SplitterApi<T extends PropTypes = PropTypes> {
|
|
167
|
+
/**
|
|
168
|
+
* Whether the splitter is currently being resized.
|
|
169
|
+
*/
|
|
170
|
+
dragging: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* The orientation of the splitter.
|
|
173
|
+
*/
|
|
174
|
+
orientation: "horizontal" | "vertical";
|
|
175
|
+
/**
|
|
176
|
+
* Returns the current sizes of the panels.
|
|
177
|
+
*/
|
|
178
|
+
getSizes: () => number[];
|
|
179
|
+
/**
|
|
180
|
+
* Sets the sizes of the panels.
|
|
181
|
+
*/
|
|
182
|
+
setSizes: (size: number[]) => void;
|
|
183
|
+
/**
|
|
184
|
+
* Returns the items of the splitter.
|
|
185
|
+
*/
|
|
186
|
+
getItems: () => SplitterItem[];
|
|
187
|
+
/**
|
|
188
|
+
* Returns the panels of the splitter.
|
|
189
|
+
*/
|
|
190
|
+
getPanels: () => PanelData[];
|
|
191
|
+
/**
|
|
192
|
+
* Returns the panel with the specified id.
|
|
193
|
+
*/
|
|
194
|
+
getPanelById: (id: PanelId) => PanelData;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the size of the specified panel.
|
|
197
|
+
*/
|
|
198
|
+
getPanelSize: (id: PanelId) => number;
|
|
199
|
+
/**
|
|
200
|
+
* Returns whether the specified panel is collapsed.
|
|
201
|
+
*/
|
|
202
|
+
isPanelCollapsed: (id: PanelId) => boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Returns whether the specified panel is expanded.
|
|
205
|
+
*/
|
|
206
|
+
isPanelExpanded: (id: PanelId) => boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Collapses the specified panel.
|
|
209
|
+
*/
|
|
210
|
+
collapsePanel: (id: PanelId) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Expands the specified panel.
|
|
213
|
+
*/
|
|
214
|
+
expandPanel: (id: PanelId, minSize?: number) => void;
|
|
215
|
+
/**
|
|
216
|
+
* Resizes the specified panel.
|
|
217
|
+
*/
|
|
218
|
+
resizePanel: (id: PanelId, unsafePanelSize: number) => void;
|
|
219
|
+
/**
|
|
220
|
+
* Returns the layout of the splitter.
|
|
221
|
+
*/
|
|
222
|
+
getLayout: () => string;
|
|
223
|
+
/**
|
|
224
|
+
* Resets the splitter to its initial state.
|
|
225
|
+
*/
|
|
226
|
+
resetSizes: VoidFunction;
|
|
227
|
+
/**
|
|
228
|
+
* Returns the state of the resize trigger.
|
|
229
|
+
*/
|
|
230
|
+
getResizeTriggerState: (props: ResizeTriggerProps) => ResizeTriggerState;
|
|
231
|
+
getRootProps: () => T["element"];
|
|
232
|
+
getPanelProps: (props: PanelProps) => T["element"];
|
|
233
|
+
getResizeTriggerProps: (props: ResizeTriggerProps) => T["element"];
|
|
234
|
+
getResizeTriggerIndicator: (props: ResizeTriggerProps) => T["element"];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export type { CursorState, DragState, ElementIds, ExpandCollapseDetails, KeyboardState, PanelData, PanelId, PanelItem, PanelProps, ResizeDetails, ResizeEndDetails, ResizeEvent, ResizeTriggerId, ResizeTriggerItem, ResizeTriggerProps, ResizeTriggerState, SplitterApi, SplitterItem, SplitterMachine, SplitterProps, SplitterSchema, SplitterService };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { Machine, EventObject, Service } from '@zag-js/core';
|
|
2
|
+
import { PropTypes, RequiredBy, DirectionProperty, CommonProperties } from '@zag-js/types';
|
|
3
|
+
|
|
4
|
+
type ResizeEvent = PointerEvent | KeyboardEvent;
|
|
5
|
+
type PanelId = string;
|
|
6
|
+
type ResizeTriggerId = `${PanelId}:${PanelId}`;
|
|
7
|
+
interface PanelData {
|
|
8
|
+
/**
|
|
9
|
+
* The id of the panel.
|
|
10
|
+
*/
|
|
11
|
+
id: PanelId;
|
|
12
|
+
/**
|
|
13
|
+
* The order of the panel. useful of you intend to conditionally render the panel.
|
|
14
|
+
*/
|
|
15
|
+
order?: number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The minimum size of the panel.
|
|
18
|
+
*/
|
|
19
|
+
minSize?: number | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The maximum size of the panel.
|
|
22
|
+
*/
|
|
23
|
+
maxSize?: number | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the panel is collapsible.
|
|
26
|
+
*/
|
|
27
|
+
collapsible?: boolean | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The size of the panel when collapsed.
|
|
30
|
+
*/
|
|
31
|
+
collapsedSize?: number | undefined;
|
|
32
|
+
}
|
|
33
|
+
interface CursorState {
|
|
34
|
+
isAtMin: boolean;
|
|
35
|
+
isAtMax: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface ResizeDetails {
|
|
38
|
+
size: number[];
|
|
39
|
+
resizeTriggerId: string | null;
|
|
40
|
+
layout: string;
|
|
41
|
+
expandToSizes: Record<string, number>;
|
|
42
|
+
}
|
|
43
|
+
interface ResizeEndDetails {
|
|
44
|
+
size: number[];
|
|
45
|
+
resizeTriggerId: string | null;
|
|
46
|
+
}
|
|
47
|
+
interface ExpandCollapseDetails {
|
|
48
|
+
panelId: string;
|
|
49
|
+
size: number;
|
|
50
|
+
}
|
|
51
|
+
type ElementIds = Partial<{
|
|
52
|
+
root: string;
|
|
53
|
+
resizeTrigger: (id: string) => string;
|
|
54
|
+
label: (id: string) => string;
|
|
55
|
+
panel: (id: string | number) => string;
|
|
56
|
+
}>;
|
|
57
|
+
interface SplitterProps extends DirectionProperty, CommonProperties {
|
|
58
|
+
/**
|
|
59
|
+
* The orientation of the splitter. Can be `horizontal` or `vertical`
|
|
60
|
+
* @default "horizontal"
|
|
61
|
+
*/
|
|
62
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* The controlled size data of the panels
|
|
65
|
+
*/
|
|
66
|
+
size?: number[] | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* The initial size of the panels when rendered.
|
|
69
|
+
* Use when you don't need to control the size of the panels.
|
|
70
|
+
*/
|
|
71
|
+
defaultSize?: number[] | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The size constraints of the panels.
|
|
74
|
+
*/
|
|
75
|
+
panels: PanelData[];
|
|
76
|
+
/**
|
|
77
|
+
* Function called when the splitter is resized.
|
|
78
|
+
*/
|
|
79
|
+
onResize?: ((details: ResizeDetails) => void) | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Function called when the splitter resize starts.
|
|
82
|
+
*/
|
|
83
|
+
onResizeStart?: (() => void) | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Function called when the splitter resize ends.
|
|
86
|
+
*/
|
|
87
|
+
onResizeEnd?: ((details: ResizeEndDetails) => void) | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* The ids of the elements in the splitter. Useful for composition.
|
|
90
|
+
*/
|
|
91
|
+
ids?: ElementIds | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* The number of pixels to resize the panel by when the keyboard is used.
|
|
94
|
+
*/
|
|
95
|
+
keyboardResizeBy?: number | null | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* The nonce for the injected splitter cursor stylesheet.
|
|
98
|
+
*/
|
|
99
|
+
nonce?: string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Function called when a panel is collapsed.
|
|
102
|
+
*/
|
|
103
|
+
onCollapse?: ((details: ExpandCollapseDetails) => void) | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Function called when a panel is expanded.
|
|
106
|
+
*/
|
|
107
|
+
onExpand?: ((details: ExpandCollapseDetails) => void) | undefined;
|
|
108
|
+
}
|
|
109
|
+
type PropsWithDefault = "orientation" | "panels";
|
|
110
|
+
interface DragState {
|
|
111
|
+
resizeTriggerId: string;
|
|
112
|
+
resizeTriggerRect: DOMRect;
|
|
113
|
+
initialCursorPosition: number;
|
|
114
|
+
initialSize: number[];
|
|
115
|
+
}
|
|
116
|
+
interface KeyboardState {
|
|
117
|
+
resizeTriggerId: string;
|
|
118
|
+
}
|
|
119
|
+
interface Context {
|
|
120
|
+
dragState: DragState | null;
|
|
121
|
+
keyboardState: KeyboardState | null;
|
|
122
|
+
size: number[];
|
|
123
|
+
}
|
|
124
|
+
interface Refs {
|
|
125
|
+
panelSizeBeforeCollapse: Map<string, number>;
|
|
126
|
+
panelIdToLastNotifiedSizeMap: Map<string, number>;
|
|
127
|
+
prevDelta: number;
|
|
128
|
+
}
|
|
129
|
+
interface SplitterSchema {
|
|
130
|
+
state: "idle" | "hover:temp" | "hover" | "dragging" | "focused";
|
|
131
|
+
tag: "focus";
|
|
132
|
+
props: RequiredBy<SplitterProps, PropsWithDefault>;
|
|
133
|
+
context: Context;
|
|
134
|
+
computed: {
|
|
135
|
+
horizontal: boolean;
|
|
136
|
+
};
|
|
137
|
+
refs: Refs;
|
|
138
|
+
action: string;
|
|
139
|
+
event: EventObject;
|
|
140
|
+
effect: string;
|
|
141
|
+
guard: string;
|
|
142
|
+
}
|
|
143
|
+
type SplitterService = Service<SplitterSchema>;
|
|
144
|
+
type SplitterMachine = Machine<SplitterSchema>;
|
|
145
|
+
interface PanelProps {
|
|
146
|
+
id: PanelId;
|
|
147
|
+
}
|
|
148
|
+
interface ResizeTriggerProps {
|
|
149
|
+
id: ResizeTriggerId;
|
|
150
|
+
disabled?: boolean | undefined;
|
|
151
|
+
}
|
|
152
|
+
interface ResizeTriggerState {
|
|
153
|
+
dragging: boolean;
|
|
154
|
+
focused: boolean;
|
|
155
|
+
disabled: boolean;
|
|
156
|
+
}
|
|
157
|
+
interface PanelItem {
|
|
158
|
+
type: "panel";
|
|
159
|
+
id: PanelId;
|
|
160
|
+
}
|
|
161
|
+
interface ResizeTriggerItem {
|
|
162
|
+
type: "handle";
|
|
163
|
+
id: ResizeTriggerId;
|
|
164
|
+
}
|
|
165
|
+
type SplitterItem = PanelItem | ResizeTriggerItem;
|
|
166
|
+
interface SplitterApi<T extends PropTypes = PropTypes> {
|
|
167
|
+
/**
|
|
168
|
+
* Whether the splitter is currently being resized.
|
|
169
|
+
*/
|
|
170
|
+
dragging: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* The orientation of the splitter.
|
|
173
|
+
*/
|
|
174
|
+
orientation: "horizontal" | "vertical";
|
|
175
|
+
/**
|
|
176
|
+
* Returns the current sizes of the panels.
|
|
177
|
+
*/
|
|
178
|
+
getSizes: () => number[];
|
|
179
|
+
/**
|
|
180
|
+
* Sets the sizes of the panels.
|
|
181
|
+
*/
|
|
182
|
+
setSizes: (size: number[]) => void;
|
|
183
|
+
/**
|
|
184
|
+
* Returns the items of the splitter.
|
|
185
|
+
*/
|
|
186
|
+
getItems: () => SplitterItem[];
|
|
187
|
+
/**
|
|
188
|
+
* Returns the panels of the splitter.
|
|
189
|
+
*/
|
|
190
|
+
getPanels: () => PanelData[];
|
|
191
|
+
/**
|
|
192
|
+
* Returns the panel with the specified id.
|
|
193
|
+
*/
|
|
194
|
+
getPanelById: (id: PanelId) => PanelData;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the size of the specified panel.
|
|
197
|
+
*/
|
|
198
|
+
getPanelSize: (id: PanelId) => number;
|
|
199
|
+
/**
|
|
200
|
+
* Returns whether the specified panel is collapsed.
|
|
201
|
+
*/
|
|
202
|
+
isPanelCollapsed: (id: PanelId) => boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Returns whether the specified panel is expanded.
|
|
205
|
+
*/
|
|
206
|
+
isPanelExpanded: (id: PanelId) => boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Collapses the specified panel.
|
|
209
|
+
*/
|
|
210
|
+
collapsePanel: (id: PanelId) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Expands the specified panel.
|
|
213
|
+
*/
|
|
214
|
+
expandPanel: (id: PanelId, minSize?: number) => void;
|
|
215
|
+
/**
|
|
216
|
+
* Resizes the specified panel.
|
|
217
|
+
*/
|
|
218
|
+
resizePanel: (id: PanelId, unsafePanelSize: number) => void;
|
|
219
|
+
/**
|
|
220
|
+
* Returns the layout of the splitter.
|
|
221
|
+
*/
|
|
222
|
+
getLayout: () => string;
|
|
223
|
+
/**
|
|
224
|
+
* Resets the splitter to its initial state.
|
|
225
|
+
*/
|
|
226
|
+
resetSizes: VoidFunction;
|
|
227
|
+
/**
|
|
228
|
+
* Returns the state of the resize trigger.
|
|
229
|
+
*/
|
|
230
|
+
getResizeTriggerState: (props: ResizeTriggerProps) => ResizeTriggerState;
|
|
231
|
+
getRootProps: () => T["element"];
|
|
232
|
+
getPanelProps: (props: PanelProps) => T["element"];
|
|
233
|
+
getResizeTriggerProps: (props: ResizeTriggerProps) => T["element"];
|
|
234
|
+
getResizeTriggerIndicator: (props: ResizeTriggerProps) => T["element"];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export type { CursorState, DragState, ElementIds, ExpandCollapseDetails, KeyboardState, PanelData, PanelId, PanelItem, PanelProps, ResizeDetails, ResizeEndDetails, ResizeEvent, ResizeTriggerId, ResizeTriggerItem, ResizeTriggerProps, ResizeTriggerState, SplitterApi, SplitterItem, SplitterMachine, SplitterProps, SplitterSchema, SplitterService };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/splitter.types.ts
|
|
17
|
+
var splitter_types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(splitter_types_exports);
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PanelData } from '../splitter.types.mjs';
|
|
2
|
+
import '@zag-js/core';
|
|
3
|
+
import '@zag-js/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This code was modified from react-resizable-panels by Brian Vaughn
|
|
7
|
+
* @see https://github.com/bvaughn/react-resizable-panels
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare function calculateAriaValues({ size, panels, pivotIndices, }: {
|
|
11
|
+
size: number[];
|
|
12
|
+
panels: PanelData[];
|
|
13
|
+
pivotIndices: number[];
|
|
14
|
+
}): {
|
|
15
|
+
valueMax: number;
|
|
16
|
+
valueMin: number;
|
|
17
|
+
valueNow: number;
|
|
18
|
+
};
|
|
19
|
+
declare function getAriaValue(size: number[], panels: PanelData[], handleId: string): {
|
|
20
|
+
beforeId: string;
|
|
21
|
+
afterId: string;
|
|
22
|
+
valueMax: number;
|
|
23
|
+
valueMin: number;
|
|
24
|
+
valueNow: number | undefined;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { calculateAriaValues, getAriaValue };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PanelData } from '../splitter.types.js';
|
|
2
|
+
import '@zag-js/core';
|
|
3
|
+
import '@zag-js/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This code was modified from react-resizable-panels by Brian Vaughn
|
|
7
|
+
* @see https://github.com/bvaughn/react-resizable-panels
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare function calculateAriaValues({ size, panels, pivotIndices, }: {
|
|
11
|
+
size: number[];
|
|
12
|
+
panels: PanelData[];
|
|
13
|
+
pivotIndices: number[];
|
|
14
|
+
}): {
|
|
15
|
+
valueMax: number;
|
|
16
|
+
valueMin: number;
|
|
17
|
+
valueNow: number;
|
|
18
|
+
};
|
|
19
|
+
declare function getAriaValue(size: number[], panels: PanelData[], handleId: string): {
|
|
20
|
+
beforeId: string;
|
|
21
|
+
afterId: string;
|
|
22
|
+
valueMax: number;
|
|
23
|
+
valueMin: number;
|
|
24
|
+
valueNow: number | undefined;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { calculateAriaValues, getAriaValue };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/aria.ts
|
|
21
|
+
var aria_exports = {};
|
|
22
|
+
__export(aria_exports, {
|
|
23
|
+
calculateAriaValues: () => calculateAriaValues,
|
|
24
|
+
getAriaValue: () => getAriaValue
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(aria_exports);
|
|
27
|
+
var import_utils = require("@zag-js/utils");
|
|
28
|
+
function calculateAriaValues({
|
|
29
|
+
size,
|
|
30
|
+
panels,
|
|
31
|
+
pivotIndices
|
|
32
|
+
}) {
|
|
33
|
+
let currentMinSize = 0;
|
|
34
|
+
let currentMaxSize = 100;
|
|
35
|
+
let totalMinSize = 0;
|
|
36
|
+
let totalMaxSize = 0;
|
|
37
|
+
const firstIndex = pivotIndices[0];
|
|
38
|
+
(0, import_utils.ensure)(firstIndex, () => "No pivot index found");
|
|
39
|
+
panels.forEach((panel, index) => {
|
|
40
|
+
const { maxSize = 100, minSize = 0 } = panel;
|
|
41
|
+
if (index === firstIndex) {
|
|
42
|
+
currentMinSize = minSize;
|
|
43
|
+
currentMaxSize = maxSize;
|
|
44
|
+
} else {
|
|
45
|
+
totalMinSize += minSize;
|
|
46
|
+
totalMaxSize += maxSize;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const valueMax = Math.min(currentMaxSize, 100 - totalMinSize);
|
|
50
|
+
const valueMin = Math.max(currentMinSize, 100 - totalMaxSize);
|
|
51
|
+
const valueNow = size[firstIndex];
|
|
52
|
+
return {
|
|
53
|
+
valueMax,
|
|
54
|
+
valueMin,
|
|
55
|
+
valueNow
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function getAriaValue(size, panels, handleId) {
|
|
59
|
+
const [beforeId, afterId] = handleId.split(":");
|
|
60
|
+
const beforeIndex = panels.findIndex((panel) => panel.id === beforeId);
|
|
61
|
+
const afterIndex = panels.findIndex((panel) => panel.id === afterId);
|
|
62
|
+
const { valueMax, valueMin, valueNow } = calculateAriaValues({
|
|
63
|
+
size,
|
|
64
|
+
panels,
|
|
65
|
+
pivotIndices: [beforeIndex, afterIndex]
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
beforeId,
|
|
69
|
+
afterId,
|
|
70
|
+
valueMax: Math.round(valueMax),
|
|
71
|
+
valueMin: Math.round(valueMin),
|
|
72
|
+
valueNow: valueNow != null ? Math.round(valueNow) : void 0
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
calculateAriaValues,
|
|
78
|
+
getAriaValue
|
|
79
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/utils/aria.ts
|
|
2
|
+
import { ensure } from "@zag-js/utils";
|
|
3
|
+
function calculateAriaValues({
|
|
4
|
+
size,
|
|
5
|
+
panels,
|
|
6
|
+
pivotIndices
|
|
7
|
+
}) {
|
|
8
|
+
let currentMinSize = 0;
|
|
9
|
+
let currentMaxSize = 100;
|
|
10
|
+
let totalMinSize = 0;
|
|
11
|
+
let totalMaxSize = 0;
|
|
12
|
+
const firstIndex = pivotIndices[0];
|
|
13
|
+
ensure(firstIndex, () => "No pivot index found");
|
|
14
|
+
panels.forEach((panel, index) => {
|
|
15
|
+
const { maxSize = 100, minSize = 0 } = panel;
|
|
16
|
+
if (index === firstIndex) {
|
|
17
|
+
currentMinSize = minSize;
|
|
18
|
+
currentMaxSize = maxSize;
|
|
19
|
+
} else {
|
|
20
|
+
totalMinSize += minSize;
|
|
21
|
+
totalMaxSize += maxSize;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const valueMax = Math.min(currentMaxSize, 100 - totalMinSize);
|
|
25
|
+
const valueMin = Math.max(currentMinSize, 100 - totalMaxSize);
|
|
26
|
+
const valueNow = size[firstIndex];
|
|
27
|
+
return {
|
|
28
|
+
valueMax,
|
|
29
|
+
valueMin,
|
|
30
|
+
valueNow
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function getAriaValue(size, panels, handleId) {
|
|
34
|
+
const [beforeId, afterId] = handleId.split(":");
|
|
35
|
+
const beforeIndex = panels.findIndex((panel) => panel.id === beforeId);
|
|
36
|
+
const afterIndex = panels.findIndex((panel) => panel.id === afterId);
|
|
37
|
+
const { valueMax, valueMin, valueNow } = calculateAriaValues({
|
|
38
|
+
size,
|
|
39
|
+
panels,
|
|
40
|
+
pivotIndices: [beforeIndex, afterIndex]
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
beforeId,
|
|
44
|
+
afterId,
|
|
45
|
+
valueMax: Math.round(valueMax),
|
|
46
|
+
valueMin: Math.round(valueMin),
|
|
47
|
+
valueNow: valueNow != null ? Math.round(valueNow) : void 0
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
calculateAriaValues,
|
|
52
|
+
getAriaValue
|
|
53
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was modified from react-resizable-panels by Brian Vaughn
|
|
3
|
+
* @see https://github.com/bvaughn/react-resizable-panels
|
|
4
|
+
*/
|
|
5
|
+
declare const PRECISION = 10;
|
|
6
|
+
declare function fuzzyCompareNumbers(actual: number, expected: number, fractionDigits?: number): number;
|
|
7
|
+
declare function fuzzyNumbersEqual(actual: number | undefined, expected: number | undefined, fractionDigits?: number): boolean;
|
|
8
|
+
declare function fuzzySizeEqual(actual: number[], expected: number[], fractionDigits?: number): boolean;
|
|
9
|
+
|
|
10
|
+
export { PRECISION, fuzzyCompareNumbers, fuzzyNumbersEqual, fuzzySizeEqual };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was modified from react-resizable-panels by Brian Vaughn
|
|
3
|
+
* @see https://github.com/bvaughn/react-resizable-panels
|
|
4
|
+
*/
|
|
5
|
+
declare const PRECISION = 10;
|
|
6
|
+
declare function fuzzyCompareNumbers(actual: number, expected: number, fractionDigits?: number): number;
|
|
7
|
+
declare function fuzzyNumbersEqual(actual: number | undefined, expected: number | undefined, fractionDigits?: number): boolean;
|
|
8
|
+
declare function fuzzySizeEqual(actual: number[], expected: number[], fractionDigits?: number): boolean;
|
|
9
|
+
|
|
10
|
+
export { PRECISION, fuzzyCompareNumbers, fuzzyNumbersEqual, fuzzySizeEqual };
|