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