@zag-js/splitter 0.2.6 → 0.2.7
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/chunk-HPRMFGOY.mjs +9 -0
- package/dist/{chunk-F2ZDEPE3.mjs → chunk-IOEWCDUH.mjs} +171 -125
- package/dist/chunk-SQ3UMXCZ.mjs +131 -0
- package/dist/chunk-T56NFB6E.mjs +102 -0
- package/dist/chunk-X2M4RMIJ.mjs +206 -0
- package/dist/index.js +466 -321
- package/dist/index.mjs +5 -4
- package/dist/splitter.anatomy.d.ts +2 -2
- package/dist/splitter.anatomy.js +1 -8
- package/dist/splitter.anatomy.mjs +1 -1
- package/dist/splitter.connect.d.ts +18 -13
- package/dist/splitter.connect.js +214 -196
- package/dist/splitter.connect.mjs +4 -3
- package/dist/splitter.dom.d.ts +15 -13
- package/dist/splitter.dom.js +54 -49
- package/dist/splitter.dom.mjs +1 -1
- package/dist/splitter.machine.js +340 -172
- package/dist/splitter.machine.mjs +3 -2
- package/dist/splitter.types.d.ts +50 -78
- package/dist/splitter.utils.d.ts +54 -0
- package/dist/splitter.utils.js +159 -0
- package/dist/splitter.utils.mjs +14 -0
- package/package.json +4 -4
- package/dist/chunk-7IDNY7GP.mjs +0 -217
- package/dist/chunk-A3GF7W2N.mjs +0 -97
- package/dist/chunk-DX6NGFGC.mjs +0 -16
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
connect
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-X2M4RMIJ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
anatomy
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HPRMFGOY.mjs";
|
|
7
7
|
import {
|
|
8
8
|
machine
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-IOEWCDUH.mjs";
|
|
10
|
+
import "./chunk-T56NFB6E.mjs";
|
|
11
|
+
import "./chunk-SQ3UMXCZ.mjs";
|
|
11
12
|
export {
|
|
12
13
|
anatomy,
|
|
13
14
|
connect,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
2
|
|
|
3
|
-
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"
|
|
4
|
-
declare const parts: Record<"
|
|
3
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "panel" | "toggleTrigger" | "resizeTrigger">;
|
|
4
|
+
declare const parts: Record<"root" | "panel" | "toggleTrigger" | "resizeTrigger", _zag_js_anatomy.AnatomyPart>;
|
|
5
5
|
|
|
6
6
|
export { anatomy, parts };
|
package/dist/splitter.anatomy.js
CHANGED
|
@@ -25,14 +25,7 @@ __export(splitter_anatomy_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(splitter_anatomy_exports);
|
|
27
27
|
var import_anatomy = require("@zag-js/anatomy");
|
|
28
|
-
var anatomy = (0, import_anatomy.createAnatomy)("splitter").parts(
|
|
29
|
-
"root",
|
|
30
|
-
"secondaryPane",
|
|
31
|
-
"primaryPane",
|
|
32
|
-
"toggleButton",
|
|
33
|
-
"label",
|
|
34
|
-
"splitter"
|
|
35
|
-
);
|
|
28
|
+
var anatomy = (0, import_anatomy.createAnatomy)("splitter").parts("root", "panel", "toggleTrigger", "resizeTrigger");
|
|
36
29
|
var parts = anatomy.build();
|
|
37
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
31
|
0 && (module.exports = {
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { PropTypes, NormalizeProps } from '@zag-js/types';
|
|
2
|
-
import { State, Send } from './splitter.types.js';
|
|
2
|
+
import { State, Send, PanelId, PanelProps, ResizeTriggerProps } from './splitter.types.js';
|
|
3
3
|
import '@zag-js/core';
|
|
4
4
|
|
|
5
5
|
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
6
|
-
isCollapsed: boolean;
|
|
7
|
-
isExpanded: boolean;
|
|
8
6
|
isFocused: boolean;
|
|
9
7
|
isDragging: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
bounds: {
|
|
9
|
+
min: number;
|
|
10
|
+
max: number;
|
|
11
|
+
} | undefined;
|
|
12
|
+
collapse(id: PanelId): void;
|
|
13
|
+
expand(id: PanelId): void;
|
|
14
|
+
toggle(id: PanelId): void;
|
|
15
|
+
setSize(id: PanelId, size: number): void;
|
|
15
16
|
rootProps: T["element"];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
getPanelProps(props: PanelProps): T["element"];
|
|
18
|
+
getResizeTriggerState(id: string): {
|
|
19
|
+
isFocused: boolean;
|
|
20
|
+
panelIds: string[];
|
|
21
|
+
min: number | undefined;
|
|
22
|
+
max: number | undefined;
|
|
23
|
+
value: number;
|
|
24
|
+
};
|
|
25
|
+
getResizeTriggerProps(props: ResizeTriggerProps): T["element"];
|
|
21
26
|
};
|
|
22
27
|
|
|
23
28
|
export { connect };
|
package/dist/splitter.connect.js
CHANGED
|
@@ -56,25 +56,7 @@ function defineDomHelpers(helpers) {
|
|
|
56
56
|
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
57
57
|
},
|
|
58
58
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
59
|
-
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
60
|
-
createEmitter: (ctx, target) => {
|
|
61
|
-
const win = dom2.getWin(ctx);
|
|
62
|
-
return function emit(evt, detail, options) {
|
|
63
|
-
const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
|
|
64
|
-
const eventName = `zag:${evt}`;
|
|
65
|
-
const init = { bubbles, cancelable, composed, detail };
|
|
66
|
-
const event = new win.CustomEvent(eventName, init);
|
|
67
|
-
target.dispatchEvent(event);
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
createListener: (target) => {
|
|
71
|
-
return function listen(evt, handler) {
|
|
72
|
-
const eventName = `zag:${evt}`;
|
|
73
|
-
const listener = (e) => handler(e);
|
|
74
|
-
target.addEventListener(eventName, listener);
|
|
75
|
-
return () => target.removeEventListener(eventName, listener);
|
|
76
|
-
};
|
|
77
|
-
}
|
|
59
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
78
60
|
};
|
|
79
61
|
return {
|
|
80
62
|
...dom2,
|
|
@@ -119,221 +101,257 @@ function getEventStep(event) {
|
|
|
119
101
|
}
|
|
120
102
|
}
|
|
121
103
|
|
|
104
|
+
// ../../utilities/dom/src/nodelist.ts
|
|
105
|
+
function queryAll(root, selector) {
|
|
106
|
+
var _a;
|
|
107
|
+
return Array.from((_a = root == null ? void 0 : root.querySelectorAll(selector)) != null ? _a : []);
|
|
108
|
+
}
|
|
109
|
+
|
|
122
110
|
// src/splitter.anatomy.ts
|
|
123
111
|
var import_anatomy = require("@zag-js/anatomy");
|
|
124
|
-
var anatomy = (0, import_anatomy.createAnatomy)("splitter").parts(
|
|
125
|
-
"root",
|
|
126
|
-
"secondaryPane",
|
|
127
|
-
"primaryPane",
|
|
128
|
-
"toggleButton",
|
|
129
|
-
"label",
|
|
130
|
-
"splitter"
|
|
131
|
-
);
|
|
112
|
+
var anatomy = (0, import_anatomy.createAnatomy)("splitter").parts("root", "panel", "toggleTrigger", "resizeTrigger");
|
|
132
113
|
var parts = anatomy.build();
|
|
133
114
|
|
|
134
115
|
// src/splitter.dom.ts
|
|
135
116
|
var dom = defineDomHelpers({
|
|
136
|
-
getRootId: (ctx) => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
var _a, _b;
|
|
146
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.toggleBtn) != null ? _b : `splitter:${ctx.id}:toggle-btn`;
|
|
147
|
-
},
|
|
148
|
-
getLabelId: (ctx) => {
|
|
149
|
-
var _a, _b;
|
|
150
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `splitter:${ctx.id}:label`;
|
|
151
|
-
},
|
|
152
|
-
getPrimaryPaneId: (ctx) => {
|
|
153
|
-
var _a, _b;
|
|
154
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.primaryPane) != null ? _b : `splitter:${ctx.id}:primary`;
|
|
155
|
-
},
|
|
156
|
-
getSecondaryPaneId: (ctx) => {
|
|
157
|
-
var _a, _b;
|
|
158
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.secondaryPane) != null ? _b : `splitter:${ctx.id}:secondary`;
|
|
159
|
-
},
|
|
160
|
-
getSplitterEl: (ctx) => dom.getById(ctx, dom.getSplitterId(ctx)),
|
|
161
|
-
getPrimaryPaneEl: (ctx) => dom.getById(ctx, dom.getPrimaryPaneId(ctx)),
|
|
117
|
+
getRootId: (ctx) => `splitter:${ctx.id}`,
|
|
118
|
+
getResizeTriggerId: (ctx, id) => `splitter:${ctx.id}:splitter:${id}`,
|
|
119
|
+
getToggleTriggerId: (ctx) => `splitter:${ctx.id}:toggle-btn`,
|
|
120
|
+
getLabelId: (ctx) => `splitter:${ctx.id}:label`,
|
|
121
|
+
getPanelId: (ctx, id) => `splitter:${ctx.id}:panel:${id}`,
|
|
122
|
+
globalCursorId: (ctx) => `splitter:${ctx.id}:global-cursor`,
|
|
123
|
+
getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
|
|
124
|
+
getResizeTriggerEl: (ctx, id) => dom.getById(ctx, dom.getResizeTriggerId(ctx, id)),
|
|
125
|
+
getPanelEl: (ctx, id) => dom.getById(ctx, dom.getPanelId(ctx, id)),
|
|
162
126
|
getCursor(ctx) {
|
|
163
|
-
if (ctx.disabled || ctx.fixed)
|
|
164
|
-
return "default";
|
|
165
127
|
const x = ctx.isHorizontal;
|
|
166
128
|
let cursor = x ? "col-resize" : "row-resize";
|
|
167
|
-
if (ctx.isAtMin)
|
|
129
|
+
if (ctx.activeResizeState.isAtMin)
|
|
168
130
|
cursor = x ? "e-resize" : "s-resize";
|
|
169
|
-
if (ctx.isAtMax)
|
|
131
|
+
if (ctx.activeResizeState.isAtMax)
|
|
170
132
|
cursor = x ? "w-resize" : "n-resize";
|
|
171
133
|
return cursor;
|
|
134
|
+
},
|
|
135
|
+
getPanelStyle(ctx, id) {
|
|
136
|
+
var _a, _b;
|
|
137
|
+
const flexGrow = (_b = (_a = ctx.panels.find((panel) => panel.id === id)) == null ? void 0 : _a.size) != null ? _b : "0";
|
|
138
|
+
return {
|
|
139
|
+
flexBasis: 0,
|
|
140
|
+
flexGrow,
|
|
141
|
+
flexShrink: 1,
|
|
142
|
+
overflow: "hidden"
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
getActiveHandleEl(ctx) {
|
|
146
|
+
const activeId = ctx.activeResizeId;
|
|
147
|
+
if (activeId == null)
|
|
148
|
+
return;
|
|
149
|
+
return dom.getById(ctx, dom.getResizeTriggerId(ctx, activeId));
|
|
150
|
+
},
|
|
151
|
+
getResizeTriggerEls(ctx) {
|
|
152
|
+
const ownerId = CSS.escape(dom.getRootId(ctx));
|
|
153
|
+
return queryAll(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
|
|
154
|
+
},
|
|
155
|
+
setupGlobalCursor(ctx) {
|
|
156
|
+
const styleEl = dom.getById(ctx, dom.globalCursorId(ctx));
|
|
157
|
+
const textContent = `* { cursor: ${dom.getCursor(ctx)} !important; }`;
|
|
158
|
+
if (styleEl) {
|
|
159
|
+
styleEl.textContent = textContent;
|
|
160
|
+
} else {
|
|
161
|
+
const style = dom.getDoc(ctx).createElement("style");
|
|
162
|
+
style.id = dom.globalCursorId(ctx);
|
|
163
|
+
style.textContent = textContent;
|
|
164
|
+
dom.getDoc(ctx).head.appendChild(style);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
removeGlobalCursor(ctx) {
|
|
168
|
+
var _a;
|
|
169
|
+
(_a = dom.getById(ctx, dom.globalCursorId(ctx))) == null ? void 0 : _a.remove();
|
|
172
170
|
}
|
|
173
171
|
});
|
|
174
172
|
|
|
173
|
+
// src/splitter.utils.ts
|
|
174
|
+
function getHandlePanels(ctx, id = ctx.activeResizeId) {
|
|
175
|
+
var _a;
|
|
176
|
+
const [beforeId, afterId] = (_a = id == null ? void 0 : id.split(":")) != null ? _a : [];
|
|
177
|
+
if (!beforeId || !afterId)
|
|
178
|
+
return;
|
|
179
|
+
const beforeIndex = ctx.previousPanels.findIndex((panel) => panel.id === beforeId);
|
|
180
|
+
const afterIndex = ctx.previousPanels.findIndex((panel) => panel.id === afterId);
|
|
181
|
+
if (beforeIndex === -1 || afterIndex === -1)
|
|
182
|
+
return;
|
|
183
|
+
const before = ctx.previousPanels[beforeIndex];
|
|
184
|
+
const after = ctx.previousPanels[afterIndex];
|
|
185
|
+
return {
|
|
186
|
+
before: {
|
|
187
|
+
...before,
|
|
188
|
+
index: beforeIndex
|
|
189
|
+
},
|
|
190
|
+
after: {
|
|
191
|
+
...after,
|
|
192
|
+
index: afterIndex
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function getHandleBounds(ctx, id = ctx.activeResizeId) {
|
|
197
|
+
const panels = getHandlePanels(ctx, id);
|
|
198
|
+
if (!panels)
|
|
199
|
+
return;
|
|
200
|
+
const { before, after } = panels;
|
|
201
|
+
return {
|
|
202
|
+
min: Math.max(before.start + before.minSize, after.end - after.maxSize),
|
|
203
|
+
max: Math.min(after.end - after.minSize, before.maxSize + before.start)
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
175
207
|
// src/splitter.connect.ts
|
|
176
208
|
function connect(state, send, normalize) {
|
|
177
209
|
const isHorizontal = state.context.isHorizontal;
|
|
178
|
-
const isDisabled = state.context.disabled;
|
|
179
210
|
const isFocused = state.hasTag("focus");
|
|
180
211
|
const isDragging = state.matches("dragging");
|
|
181
|
-
const isAtMin = state.context.isAtMin;
|
|
182
|
-
const isAtMax = state.context.isAtMax;
|
|
183
|
-
const min = state.context.min;
|
|
184
|
-
const max = state.context.max;
|
|
185
|
-
const value = state.context.value;
|
|
186
212
|
return {
|
|
187
|
-
isCollapsed: isAtMin,
|
|
188
|
-
isExpanded: isAtMax,
|
|
189
213
|
isFocused,
|
|
190
214
|
isDragging,
|
|
191
|
-
|
|
192
|
-
collapse() {
|
|
193
|
-
send("COLLAPSE");
|
|
215
|
+
bounds: getHandleBounds(state.context),
|
|
216
|
+
collapse(id) {
|
|
217
|
+
send({ type: "COLLAPSE", id });
|
|
194
218
|
},
|
|
195
|
-
expand() {
|
|
196
|
-
send("EXPAND");
|
|
219
|
+
expand(id) {
|
|
220
|
+
send({ type: "EXPAND", id });
|
|
197
221
|
},
|
|
198
|
-
toggle() {
|
|
199
|
-
send("TOGGLE");
|
|
222
|
+
toggle(id) {
|
|
223
|
+
send({ type: "TOGGLE", id });
|
|
200
224
|
},
|
|
201
|
-
setSize(size) {
|
|
202
|
-
send({ type: "SET_SIZE", size });
|
|
225
|
+
setSize(id, size) {
|
|
226
|
+
send({ type: "SET_SIZE", id, size });
|
|
203
227
|
},
|
|
204
228
|
rootProps: normalize.element({
|
|
205
229
|
...parts.root.attrs,
|
|
206
230
|
"data-orientation": state.context.orientation,
|
|
207
|
-
"data-disabled": dataAttr(isDisabled),
|
|
208
231
|
id: dom.getRootId(state.context),
|
|
232
|
+
dir: state.context.dir,
|
|
209
233
|
style: {
|
|
210
234
|
display: "flex",
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
secondaryPaneProps: normalize.element({
|
|
216
|
-
...parts.secondaryPane.attrs,
|
|
217
|
-
"data-disabled": dataAttr(isDisabled),
|
|
218
|
-
id: dom.getSecondaryPaneId(state.context),
|
|
219
|
-
style: {
|
|
220
|
-
height: isHorizontal ? "100%" : "auto",
|
|
221
|
-
width: isHorizontal ? "auto" : "100%",
|
|
222
|
-
flex: "1 1 auto",
|
|
223
|
-
position: "relative"
|
|
224
|
-
}
|
|
225
|
-
}),
|
|
226
|
-
primaryPaneProps: normalize.element({
|
|
227
|
-
...parts.primaryPane.attrs,
|
|
228
|
-
id: dom.getPrimaryPaneId(state.context),
|
|
229
|
-
"data-disabled": dataAttr(isDisabled),
|
|
230
|
-
"data-state": isAtMax ? "at-max" : isAtMin ? "at-min" : "between",
|
|
231
|
-
style: {
|
|
232
|
-
visibility: "visible",
|
|
233
|
-
flex: `0 0 ${value}px`,
|
|
234
|
-
position: "relative",
|
|
235
|
-
userSelect: isDragging ? "none" : "auto",
|
|
236
|
-
...isHorizontal ? { minWidth: `${min}px`, maxWidth: `${max}px` } : { minHeight: `${min}px`, maxHeight: `${max}px` }
|
|
235
|
+
flexDirection: isHorizontal ? "row" : "column",
|
|
236
|
+
height: "100%",
|
|
237
|
+
width: "100%",
|
|
238
|
+
overflow: "hidden"
|
|
237
239
|
}
|
|
238
240
|
}),
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return;
|
|
292
|
-
send("POINTER_LEAVE");
|
|
293
|
-
},
|
|
294
|
-
onBlur() {
|
|
295
|
-
send("BLUR");
|
|
296
|
-
},
|
|
297
|
-
onFocus() {
|
|
298
|
-
send("FOCUS");
|
|
299
|
-
},
|
|
300
|
-
onDoubleClick() {
|
|
301
|
-
if (isDisabled)
|
|
302
|
-
return;
|
|
303
|
-
send("DOUBLE_CLICK");
|
|
304
|
-
},
|
|
305
|
-
onKeyDown(event) {
|
|
306
|
-
if (isDisabled)
|
|
307
|
-
return;
|
|
308
|
-
const step = getEventStep(event) * state.context.step;
|
|
309
|
-
const keyMap = {
|
|
310
|
-
ArrowUp() {
|
|
311
|
-
send({ type: "ARROW_UP", step });
|
|
312
|
-
},
|
|
313
|
-
ArrowDown() {
|
|
314
|
-
send({ type: "ARROW_DOWN", step });
|
|
315
|
-
},
|
|
316
|
-
ArrowLeft() {
|
|
317
|
-
send({ type: "ARROW_LEFT", step });
|
|
318
|
-
},
|
|
319
|
-
ArrowRight() {
|
|
320
|
-
send({ type: "ARROW_RIGHT", step });
|
|
321
|
-
},
|
|
322
|
-
Home() {
|
|
323
|
-
send("HOME");
|
|
324
|
-
},
|
|
325
|
-
End() {
|
|
326
|
-
send("END");
|
|
241
|
+
getPanelProps(props) {
|
|
242
|
+
const { id } = props;
|
|
243
|
+
return normalize.element({
|
|
244
|
+
...parts.panel.attrs,
|
|
245
|
+
dir: state.context.dir,
|
|
246
|
+
id: dom.getPanelId(state.context, id),
|
|
247
|
+
"data-ownedby": dom.getRootId(state.context),
|
|
248
|
+
style: dom.getPanelStyle(state.context, id)
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
getResizeTriggerState(id) {
|
|
252
|
+
const ids = id.split(":");
|
|
253
|
+
const panelIds = ids.map((id2) => dom.getPanelId(state.context, id2));
|
|
254
|
+
const panels = getHandleBounds(state.context, id);
|
|
255
|
+
return {
|
|
256
|
+
isFocused: state.context.activeResizeId === id && isFocused,
|
|
257
|
+
panelIds,
|
|
258
|
+
min: panels == null ? void 0 : panels.min,
|
|
259
|
+
max: panels == null ? void 0 : panels.max,
|
|
260
|
+
value: 0
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
getResizeTriggerProps(props) {
|
|
264
|
+
const { id, disabled, step = 1 } = props;
|
|
265
|
+
const triggerState = this.getResizeTriggerState(id);
|
|
266
|
+
return normalize.element({
|
|
267
|
+
...parts.resizeTrigger.attrs,
|
|
268
|
+
dir: state.context.dir,
|
|
269
|
+
id: dom.getResizeTriggerId(state.context, id),
|
|
270
|
+
role: "separator",
|
|
271
|
+
"data-ownedby": dom.getRootId(state.context),
|
|
272
|
+
tabIndex: disabled ? void 0 : 0,
|
|
273
|
+
"aria-valuenow": triggerState.value,
|
|
274
|
+
"aria-valuemin": triggerState.min,
|
|
275
|
+
"aria-valuemax": triggerState.max,
|
|
276
|
+
"data-orientation": state.context.orientation,
|
|
277
|
+
"aria-orientation": state.context.orientation,
|
|
278
|
+
"aria-controls": triggerState.panelIds.join(" "),
|
|
279
|
+
"data-focus": dataAttr(triggerState.isFocused),
|
|
280
|
+
"data-disabled": dataAttr(disabled),
|
|
281
|
+
style: {
|
|
282
|
+
touchAction: "none",
|
|
283
|
+
userSelect: "none",
|
|
284
|
+
flex: "0 0 auto",
|
|
285
|
+
pointerEvents: isDragging && !triggerState.isFocused ? "none" : void 0,
|
|
286
|
+
cursor: isHorizontal ? "col-resize" : "row-resize",
|
|
287
|
+
[isHorizontal ? "minHeight" : "minWidth"]: "0"
|
|
288
|
+
},
|
|
289
|
+
onPointerDown(event) {
|
|
290
|
+
if (disabled) {
|
|
291
|
+
event.preventDefault();
|
|
292
|
+
return;
|
|
327
293
|
}
|
|
328
|
-
|
|
329
|
-
const key = getEventKey(event, state.context);
|
|
330
|
-
const exec = keyMap[key];
|
|
331
|
-
if (exec) {
|
|
332
|
-
exec(event);
|
|
294
|
+
send({ type: "POINTER_DOWN", id });
|
|
333
295
|
event.preventDefault();
|
|
296
|
+
event.stopPropagation();
|
|
297
|
+
},
|
|
298
|
+
onPointerOver() {
|
|
299
|
+
if (disabled)
|
|
300
|
+
return;
|
|
301
|
+
send({ type: "POINTER_OVER", id });
|
|
302
|
+
},
|
|
303
|
+
onPointerLeave() {
|
|
304
|
+
if (disabled)
|
|
305
|
+
return;
|
|
306
|
+
send({ type: "POINTER_LEAVE", id });
|
|
307
|
+
},
|
|
308
|
+
onBlur() {
|
|
309
|
+
send("BLUR");
|
|
310
|
+
},
|
|
311
|
+
onFocus() {
|
|
312
|
+
send({ type: "FOCUS", id });
|
|
313
|
+
},
|
|
314
|
+
onDoubleClick() {
|
|
315
|
+
if (disabled)
|
|
316
|
+
return;
|
|
317
|
+
send({ type: "DOUBLE_CLICK", id });
|
|
318
|
+
},
|
|
319
|
+
onKeyDown(event) {
|
|
320
|
+
if (disabled)
|
|
321
|
+
return;
|
|
322
|
+
const moveStep = getEventStep(event) * step;
|
|
323
|
+
const keyMap = {
|
|
324
|
+
Enter() {
|
|
325
|
+
send("ENTER");
|
|
326
|
+
},
|
|
327
|
+
ArrowUp() {
|
|
328
|
+
send({ type: "ARROW_UP", step: moveStep });
|
|
329
|
+
},
|
|
330
|
+
ArrowDown() {
|
|
331
|
+
send({ type: "ARROW_DOWN", step: moveStep });
|
|
332
|
+
},
|
|
333
|
+
ArrowLeft() {
|
|
334
|
+
send({ type: "ARROW_LEFT", step: moveStep });
|
|
335
|
+
},
|
|
336
|
+
ArrowRight() {
|
|
337
|
+
send({ type: "ARROW_RIGHT", step: moveStep });
|
|
338
|
+
},
|
|
339
|
+
Home() {
|
|
340
|
+
send("HOME");
|
|
341
|
+
},
|
|
342
|
+
End() {
|
|
343
|
+
send("END");
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const key = getEventKey(event, state.context);
|
|
347
|
+
const exec = keyMap[key];
|
|
348
|
+
if (exec) {
|
|
349
|
+
exec(event);
|
|
350
|
+
event.preventDefault();
|
|
351
|
+
}
|
|
334
352
|
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
337
355
|
};
|
|
338
356
|
}
|
|
339
357
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
connect
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-X2M4RMIJ.mjs";
|
|
4
|
+
import "./chunk-HPRMFGOY.mjs";
|
|
5
|
+
import "./chunk-T56NFB6E.mjs";
|
|
6
|
+
import "./chunk-SQ3UMXCZ.mjs";
|
|
6
7
|
export {
|
|
7
8
|
connect
|
|
8
9
|
};
|
package/dist/splitter.dom.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JSX } from '@zag-js/types';
|
|
2
|
+
import { MachineContext, PanelId } from './splitter.types.js';
|
|
2
3
|
import '@zag-js/core';
|
|
3
|
-
import '@zag-js/types';
|
|
4
4
|
|
|
5
5
|
declare const dom: {
|
|
6
6
|
getRootNode: (ctx: {
|
|
@@ -18,20 +18,22 @@ declare const dom: {
|
|
|
18
18
|
getById: <T = HTMLElement>(ctx: {
|
|
19
19
|
getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
|
|
20
20
|
}, id: string) => T | null;
|
|
21
|
-
createEmitter: (ctx: {
|
|
22
|
-
getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
|
|
23
|
-
}, target: HTMLElement) => (evt: string, detail: Record<string, any>, options?: EventInit | undefined) => void;
|
|
24
|
-
createListener: (target: HTMLElement) => <T_1 = any>(evt: string, handler: (e: CustomEvent<T_1>) => void) => () => void;
|
|
25
21
|
} & {
|
|
26
22
|
getRootId: (ctx: MachineContext) => string;
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
getResizeTriggerId: (ctx: MachineContext, id: string) => string;
|
|
24
|
+
getToggleTriggerId: (ctx: MachineContext) => string;
|
|
29
25
|
getLabelId: (ctx: MachineContext) => string;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
getPanelId: (ctx: MachineContext, id: string | number) => string;
|
|
27
|
+
globalCursorId: (ctx: MachineContext) => string;
|
|
28
|
+
getRootEl: (ctx: MachineContext) => HTMLElement | null;
|
|
29
|
+
getResizeTriggerEl: (ctx: MachineContext, id: string) => HTMLElement | null;
|
|
30
|
+
getPanelEl: (ctx: MachineContext, id: string | number) => HTMLElement | null;
|
|
31
|
+
getCursor(ctx: MachineContext): (string & {}) | "col-resize" | "e-resize" | "n-resize" | "row-resize" | "s-resize" | "w-resize";
|
|
32
|
+
getPanelStyle(ctx: MachineContext, id: PanelId): JSX.CSSProperties;
|
|
33
|
+
getActiveHandleEl(ctx: MachineContext): HTMLElement | null | undefined;
|
|
34
|
+
getResizeTriggerEls(ctx: MachineContext): HTMLElement[];
|
|
35
|
+
setupGlobalCursor(ctx: MachineContext): void;
|
|
36
|
+
removeGlobalCursor(ctx: MachineContext): void;
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
export { dom };
|