@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 CHANGED
@@ -1,151 +1,155 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
- import { DirectionProperty, CommonProperties, Required, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
3
- import * as _zag_js_core from '@zag-js/core';
4
- import { StateMachine, Machine } from '@zag-js/core';
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
- id: PanelId;
11
- size?: number | undefined;
12
- minSize?: number | undefined;
13
- maxSize?: number | undefined;
12
+ id: PanelId;
13
+ size?: number | undefined;
14
+ minSize?: number | undefined;
15
+ maxSize?: number | undefined;
14
16
  }
15
17
  interface SizeChangeDetails {
16
- size: PanelSizeData[];
17
- activeHandleId: string | null;
18
+ size: PanelSizeData[];
19
+ activeHandleId: string | null;
18
20
  }
19
21
  type ElementIds = Partial<{
20
- root: string;
21
- resizeTrigger: (id: string) => string;
22
- label: (id: string) => string;
23
- panel: (id: string | number) => string;
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
- * The orientation of the splitter. Can be `horizontal` or `vertical`
28
- */
29
- orientation: 'horizontal' | 'vertical';
30
- /**
31
- * The size data of the panels
32
- */
33
- size: PanelSizeData[];
34
- /**
35
- * Function called when the splitter is resized.
36
- */
37
- onSizeChange?: ((details: SizeChangeDetails) => void) | undefined;
38
- /**
39
- * Function called when the splitter resize ends.
40
- */
41
- onSizeChangeEnd?: ((details: SizeChangeDetails) => void) | undefined;
42
- /**
43
- * The ids of the elements in the splitter. Useful for composition.
44
- */
45
- ids?: ElementIds | undefined;
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
- remainingSize: number;
50
- minSize: number;
51
- maxSize: number;
52
- start: number;
53
- end: number;
51
+ remainingSize: number;
52
+ minSize: number;
53
+ maxSize: number;
54
+ start: number;
55
+ end: number;
54
56
  }>;
55
57
  type ComputedContext = Readonly<{
56
- isHorizontal: boolean;
57
- panels: NormalizedPanelData;
58
- activeResizeBounds?: {
59
- min: number;
60
- max: number;
61
- } | undefined;
62
- activeResizePanels?: {
63
- before: PanelSizeData;
64
- after: PanelSizeData;
65
- } | undefined;
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
- activeResizeId: string | null;
69
- previousPanels: NormalizedPanelData;
70
- activeResizeState: {
71
- isAtMin: boolean;
72
- isAtMax: boolean;
73
- };
74
- initialSize: Array<Required<Pick<PanelSizeData, 'id' | 'size'>>>;
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
- value: 'idle' | 'hover:temp' | 'hover' | 'dragging' | 'focused';
80
- tags: 'focus';
80
+ value: 'idle' | 'hover:temp' | 'hover' | 'dragging' | 'focused';
81
+ tags: 'focus';
81
82
  }
82
- type State = StateMachine.State<MachineContext, MachineState>;
83
- type Send = StateMachine.Send<StateMachine.AnyEventObject>;
84
- type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
83
+ type State = XState<MachineContext, MachineState>;
84
+ type Send = XSend<AnyEventObject>;
85
+ type Service = Machine<MachineContext, MachineState, AnyEventObject>;
85
86
  interface PanelProps {
86
- id: PanelId;
87
- snapSize?: number | undefined;
87
+ id: PanelId;
88
+ snapSize?: number | undefined;
88
89
  }
89
90
  interface ResizeTriggerProps {
90
- id: `${PanelId}:${PanelId}`;
91
- step?: number | undefined;
92
- disabled?: boolean | undefined;
91
+ id: `${PanelId}:${PanelId}`;
92
+ step?: number | undefined;
93
+ disabled?: boolean | undefined;
93
94
  }
94
95
  interface ResizeTriggerState {
95
- disabled: boolean;
96
- focused: boolean;
97
- panelIds: string[];
98
- min: number | undefined;
99
- max: number | undefined;
100
- value: number;
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
- min: number;
104
- max: number;
104
+ min: number;
105
+ max: number;
105
106
  }
106
107
  interface MachineApi<T extends PropTypes = PropTypes> {
107
- /**
108
- * Whether the splitter is focused.
109
- */
110
- focused: boolean;
111
- /**
112
- * Whether the splitter is being dragged.
113
- */
114
- dragging: boolean;
115
- /**
116
- * The bounds of the currently dragged splitter handle.
117
- */
118
- bounds: PanelBounds | undefined;
119
- /**
120
- * Function to set a panel to its minimum size.
121
- */
122
- setToMinSize: (id: PanelId) => void;
123
- /**
124
- * Function to set a panel to its maximum size.
125
- */
126
- setToMaxSize: (id: PanelId) => void;
127
- /**
128
- * Function to set the size of a panel.
129
- */
130
- setSize: (id: PanelId, size: number) => void;
131
- /**
132
- * Returns the state details for a resize trigger.
133
- */
134
- getResizeTriggerState: (props: ResizeTriggerProps) => ResizeTriggerState;
135
- getRootProps: () => T['element'];
136
- getPanelProps: (props: PanelProps) => T['element'];
137
- getResizeTriggerProps: (props: ResizeTriggerProps) => T['element'];
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
- declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
143
-
144
- declare const props: ("orientation" | "size" | "onSizeChange" | "onSizeChangeEnd" | "ids" | "id" | "dir" | "getRootNode")[];
145
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "orientation" | "size" | "onSizeChange" | "onSizeChangeEnd" | "ids" | "id" | "dir" | "getRootNode">];
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 };