@destyler/splitter 0.0.6 → 0.0.7-beta.2

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.cts CHANGED
@@ -1,4 +1,151 @@
1
- export { SplitterGroup, SplitterGroupProps, SplitterPanel, SplitterPanelProps, SplitterResizeHandle, SplitterResizeHandleProps, SplitterRoot, SplitterRootProps, splitterGroupProps, splitterPanelProps, splitterResizeHandleProps, splitterRootProps } from './component.cjs';
2
- import 'vue';
3
- import '@destyler/primitive';
4
- import '@destyler/shared';
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, Required, NormalizeProps } from '@zag-js/types';
3
+ import * as _zag_js_core from '@zag-js/core';
4
+ import { Machine, StateMachine } from '@zag-js/core';
5
+
6
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "resizeTrigger">;
7
+
8
+ type PanelId = string | number;
9
+ interface PanelSizeData {
10
+ id: PanelId;
11
+ size?: number | undefined;
12
+ minSize?: number | undefined;
13
+ maxSize?: number | undefined;
14
+ }
15
+ interface SizeChangeDetails {
16
+ size: PanelSizeData[];
17
+ activeHandleId: string | null;
18
+ }
19
+ type ElementIds = Partial<{
20
+ root: string;
21
+ resizeTrigger: (id: string) => string;
22
+ label: (id: string) => string;
23
+ panel: (id: string | number) => string;
24
+ }>;
25
+ 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;
46
+ }
47
+ type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
48
+ type NormalizedPanelData = Array<Required<PanelSizeData> & {
49
+ remainingSize: number;
50
+ minSize: number;
51
+ maxSize: number;
52
+ start: number;
53
+ end: number;
54
+ }>;
55
+ 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;
66
+ }>;
67
+ 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 {
77
+ }
78
+ interface MachineState {
79
+ value: 'idle' | 'hover:temp' | 'hover' | 'dragging' | 'focused';
80
+ tags: 'focus';
81
+ }
82
+ type State = StateMachine.State<MachineContext, MachineState>;
83
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
84
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
85
+ interface PanelProps {
86
+ id: PanelId;
87
+ snapSize?: number | undefined;
88
+ }
89
+ interface ResizeTriggerProps {
90
+ id: `${PanelId}:${PanelId}`;
91
+ step?: number | undefined;
92
+ disabled?: boolean | undefined;
93
+ }
94
+ interface ResizeTriggerState {
95
+ disabled: boolean;
96
+ focused: boolean;
97
+ panelIds: string[];
98
+ min: number | undefined;
99
+ max: number | undefined;
100
+ value: number;
101
+ }
102
+ interface PanelBounds {
103
+ min: number;
104
+ max: number;
105
+ }
106
+ 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'];
138
+ }
139
+
140
+ 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">];
146
+ declare const panelProps: (keyof PanelProps)[];
147
+ declare const splitPanelProps: <Props extends PanelProps>(props: Props) => [PanelProps, Omit<Props, keyof PanelProps>];
148
+ declare const resizeTriggerProps: (keyof ResizeTriggerProps)[];
149
+ 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 };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,151 @@
1
- export { SplitterGroup, SplitterGroupProps, SplitterPanel, SplitterPanelProps, SplitterResizeHandle, SplitterResizeHandleProps, SplitterRoot, SplitterRootProps, splitterGroupProps, splitterPanelProps, splitterResizeHandleProps, splitterRootProps } from './component.mjs';
2
- import 'vue';
3
- import '@destyler/primitive';
4
- import '@destyler/shared';
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, Required, NormalizeProps } from '@zag-js/types';
3
+ import * as _zag_js_core from '@zag-js/core';
4
+ import { Machine, StateMachine } from '@zag-js/core';
5
+
6
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "resizeTrigger">;
7
+
8
+ type PanelId = string | number;
9
+ interface PanelSizeData {
10
+ id: PanelId;
11
+ size?: number | undefined;
12
+ minSize?: number | undefined;
13
+ maxSize?: number | undefined;
14
+ }
15
+ interface SizeChangeDetails {
16
+ size: PanelSizeData[];
17
+ activeHandleId: string | null;
18
+ }
19
+ type ElementIds = Partial<{
20
+ root: string;
21
+ resizeTrigger: (id: string) => string;
22
+ label: (id: string) => string;
23
+ panel: (id: string | number) => string;
24
+ }>;
25
+ 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;
46
+ }
47
+ type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
48
+ type NormalizedPanelData = Array<Required<PanelSizeData> & {
49
+ remainingSize: number;
50
+ minSize: number;
51
+ maxSize: number;
52
+ start: number;
53
+ end: number;
54
+ }>;
55
+ 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;
66
+ }>;
67
+ 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 {
77
+ }
78
+ interface MachineState {
79
+ value: 'idle' | 'hover:temp' | 'hover' | 'dragging' | 'focused';
80
+ tags: 'focus';
81
+ }
82
+ type State = StateMachine.State<MachineContext, MachineState>;
83
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
84
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
85
+ interface PanelProps {
86
+ id: PanelId;
87
+ snapSize?: number | undefined;
88
+ }
89
+ interface ResizeTriggerProps {
90
+ id: `${PanelId}:${PanelId}`;
91
+ step?: number | undefined;
92
+ disabled?: boolean | undefined;
93
+ }
94
+ interface ResizeTriggerState {
95
+ disabled: boolean;
96
+ focused: boolean;
97
+ panelIds: string[];
98
+ min: number | undefined;
99
+ max: number | undefined;
100
+ value: number;
101
+ }
102
+ interface PanelBounds {
103
+ min: number;
104
+ max: number;
105
+ }
106
+ 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'];
138
+ }
139
+
140
+ 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">];
146
+ declare const panelProps: (keyof PanelProps)[];
147
+ declare const splitPanelProps: <Props extends PanelProps>(props: Props) => [PanelProps, Omit<Props, keyof PanelProps>];
148
+ declare const resizeTriggerProps: (keyof ResizeTriggerProps)[];
149
+ 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 };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,151 @@
1
- export { SplitterGroup, SplitterGroupProps, SplitterPanel, SplitterPanelProps, SplitterResizeHandle, SplitterResizeHandleProps, SplitterRoot, SplitterRootProps, splitterGroupProps, splitterPanelProps, splitterResizeHandleProps, splitterRootProps } from './component.js';
2
- import 'vue';
3
- import '@destyler/primitive';
4
- import '@destyler/shared';
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, Required, NormalizeProps } from '@zag-js/types';
3
+ import * as _zag_js_core from '@zag-js/core';
4
+ import { Machine, StateMachine } from '@zag-js/core';
5
+
6
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "resizeTrigger">;
7
+
8
+ type PanelId = string | number;
9
+ interface PanelSizeData {
10
+ id: PanelId;
11
+ size?: number | undefined;
12
+ minSize?: number | undefined;
13
+ maxSize?: number | undefined;
14
+ }
15
+ interface SizeChangeDetails {
16
+ size: PanelSizeData[];
17
+ activeHandleId: string | null;
18
+ }
19
+ type ElementIds = Partial<{
20
+ root: string;
21
+ resizeTrigger: (id: string) => string;
22
+ label: (id: string) => string;
23
+ panel: (id: string | number) => string;
24
+ }>;
25
+ 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;
46
+ }
47
+ type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
48
+ type NormalizedPanelData = Array<Required<PanelSizeData> & {
49
+ remainingSize: number;
50
+ minSize: number;
51
+ maxSize: number;
52
+ start: number;
53
+ end: number;
54
+ }>;
55
+ 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;
66
+ }>;
67
+ 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 {
77
+ }
78
+ interface MachineState {
79
+ value: 'idle' | 'hover:temp' | 'hover' | 'dragging' | 'focused';
80
+ tags: 'focus';
81
+ }
82
+ type State = StateMachine.State<MachineContext, MachineState>;
83
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
84
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
85
+ interface PanelProps {
86
+ id: PanelId;
87
+ snapSize?: number | undefined;
88
+ }
89
+ interface ResizeTriggerProps {
90
+ id: `${PanelId}:${PanelId}`;
91
+ step?: number | undefined;
92
+ disabled?: boolean | undefined;
93
+ }
94
+ interface ResizeTriggerState {
95
+ disabled: boolean;
96
+ focused: boolean;
97
+ panelIds: string[];
98
+ min: number | undefined;
99
+ max: number | undefined;
100
+ value: number;
101
+ }
102
+ interface PanelBounds {
103
+ min: number;
104
+ max: number;
105
+ }
106
+ 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'];
138
+ }
139
+
140
+ 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">];
146
+ declare const panelProps: (keyof PanelProps)[];
147
+ declare const splitPanelProps: <Props extends PanelProps>(props: Props) => [PanelProps, Omit<Props, keyof PanelProps>];
148
+ declare const resizeTriggerProps: (keyof ResizeTriggerProps)[];
149
+ 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 };