@zag-js/splitter 0.2.4 → 0.2.6
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-7IDNY7GP.mjs +217 -0
- package/dist/chunk-A3GF7W2N.mjs +97 -0
- package/dist/chunk-DX6NGFGC.mjs +16 -0
- package/dist/chunk-F2ZDEPE3.mjs +510 -0
- package/dist/index.d.ts +7 -966
- package/dist/index.js +37 -16
- package/dist/index.mjs +10 -794
- package/dist/splitter.anatomy.d.ts +6 -0
- package/dist/splitter.anatomy.js +41 -0
- package/dist/splitter.anatomy.mjs +8 -0
- package/dist/splitter.connect.d.ts +23 -0
- package/dist/splitter.connect.js +342 -0
- package/dist/splitter.connect.mjs +8 -0
- package/dist/splitter.dom.d.ts +37 -0
- package/dist/splitter.dom.js +123 -0
- package/dist/splitter.dom.mjs +6 -0
- package/dist/splitter.machine.d.ts +7 -0
- package/dist/splitter.machine.js +624 -0
- package/dist/splitter.machine.mjs +7 -0
- package/dist/splitter.types.d.ts +96 -0
- package/dist/splitter.types.js +18 -0
- package/dist/splitter.types.mjs +0 -0
- package/package.json +22 -12
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
|
|
3
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"splitter" | "root" | "secondaryPane" | "primaryPane" | "toggleButton" | "label">;
|
|
4
|
+
declare const parts: Record<"splitter" | "root" | "secondaryPane" | "primaryPane" | "toggleButton" | "label", _zag_js_anatomy.AnatomyPart>;
|
|
5
|
+
|
|
6
|
+
export { anatomy, parts };
|
|
@@ -0,0 +1,41 @@
|
|
|
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/splitter.anatomy.ts
|
|
21
|
+
var splitter_anatomy_exports = {};
|
|
22
|
+
__export(splitter_anatomy_exports, {
|
|
23
|
+
anatomy: () => anatomy,
|
|
24
|
+
parts: () => parts
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(splitter_anatomy_exports);
|
|
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
|
+
);
|
|
36
|
+
var parts = anatomy.build();
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
anatomy,
|
|
40
|
+
parts
|
|
41
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PropTypes, NormalizeProps } from '@zag-js/types';
|
|
2
|
+
import { State, Send } from './splitter.types.js';
|
|
3
|
+
import '@zag-js/core';
|
|
4
|
+
|
|
5
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
6
|
+
isCollapsed: boolean;
|
|
7
|
+
isExpanded: boolean;
|
|
8
|
+
isFocused: boolean;
|
|
9
|
+
isDragging: boolean;
|
|
10
|
+
value: number;
|
|
11
|
+
collapse(): void;
|
|
12
|
+
expand(): void;
|
|
13
|
+
toggle(): void;
|
|
14
|
+
setSize(size: number): void;
|
|
15
|
+
rootProps: T["element"];
|
|
16
|
+
secondaryPaneProps: T["element"];
|
|
17
|
+
primaryPaneProps: T["element"];
|
|
18
|
+
toggleButtonProps: T["element"];
|
|
19
|
+
labelProps: T["element"];
|
|
20
|
+
splitterProps: T["element"];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { connect };
|
|
@@ -0,0 +1,342 @@
|
|
|
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/splitter.connect.ts
|
|
21
|
+
var splitter_connect_exports = {};
|
|
22
|
+
__export(splitter_connect_exports, {
|
|
23
|
+
connect: () => connect
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(splitter_connect_exports);
|
|
26
|
+
|
|
27
|
+
// ../../utilities/dom/src/attrs.ts
|
|
28
|
+
var dataAttr = (guard) => {
|
|
29
|
+
return guard ? "" : void 0;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// ../../utilities/dom/src/query.ts
|
|
33
|
+
function isDocument(el) {
|
|
34
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
35
|
+
}
|
|
36
|
+
function isWindow(value) {
|
|
37
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
38
|
+
}
|
|
39
|
+
function getDocument(el) {
|
|
40
|
+
var _a;
|
|
41
|
+
if (isWindow(el))
|
|
42
|
+
return el.document;
|
|
43
|
+
if (isDocument(el))
|
|
44
|
+
return el;
|
|
45
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
46
|
+
}
|
|
47
|
+
function defineDomHelpers(helpers) {
|
|
48
|
+
const dom2 = {
|
|
49
|
+
getRootNode: (ctx) => {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
52
|
+
},
|
|
53
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
54
|
+
getWin: (ctx) => {
|
|
55
|
+
var _a;
|
|
56
|
+
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
57
|
+
},
|
|
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
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
...dom2,
|
|
81
|
+
...helpers
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ../../utilities/dom/src/keyboard-event.ts
|
|
86
|
+
var rtlKeyMap = {
|
|
87
|
+
ArrowLeft: "ArrowRight",
|
|
88
|
+
ArrowRight: "ArrowLeft"
|
|
89
|
+
};
|
|
90
|
+
var sameKeyMap = {
|
|
91
|
+
Up: "ArrowUp",
|
|
92
|
+
Down: "ArrowDown",
|
|
93
|
+
Esc: "Escape",
|
|
94
|
+
" ": "Space",
|
|
95
|
+
",": "Comma",
|
|
96
|
+
Left: "ArrowLeft",
|
|
97
|
+
Right: "ArrowRight"
|
|
98
|
+
};
|
|
99
|
+
function getEventKey(event, options = {}) {
|
|
100
|
+
var _a;
|
|
101
|
+
const { dir = "ltr", orientation = "horizontal" } = options;
|
|
102
|
+
let { key } = event;
|
|
103
|
+
key = (_a = sameKeyMap[key]) != null ? _a : key;
|
|
104
|
+
const isRtl = dir === "rtl" && orientation === "horizontal";
|
|
105
|
+
if (isRtl && key in rtlKeyMap) {
|
|
106
|
+
key = rtlKeyMap[key];
|
|
107
|
+
}
|
|
108
|
+
return key;
|
|
109
|
+
}
|
|
110
|
+
var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
|
|
111
|
+
var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
|
|
112
|
+
function getEventStep(event) {
|
|
113
|
+
if (event.ctrlKey || event.metaKey) {
|
|
114
|
+
return 0.1;
|
|
115
|
+
} else {
|
|
116
|
+
const isPageKey = PAGE_KEYS.has(event.key);
|
|
117
|
+
const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
|
|
118
|
+
return isSkipKey ? 10 : 1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/splitter.anatomy.ts
|
|
123
|
+
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
|
+
);
|
|
132
|
+
var parts = anatomy.build();
|
|
133
|
+
|
|
134
|
+
// src/splitter.dom.ts
|
|
135
|
+
var dom = defineDomHelpers({
|
|
136
|
+
getRootId: (ctx) => {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `splitter:${ctx.id}`;
|
|
139
|
+
},
|
|
140
|
+
getSplitterId: (ctx) => {
|
|
141
|
+
var _a, _b;
|
|
142
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.splitter) != null ? _b : `splitter:${ctx.id}:splitter`;
|
|
143
|
+
},
|
|
144
|
+
getToggleButtonId: (ctx) => {
|
|
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)),
|
|
162
|
+
getCursor(ctx) {
|
|
163
|
+
if (ctx.disabled || ctx.fixed)
|
|
164
|
+
return "default";
|
|
165
|
+
const x = ctx.isHorizontal;
|
|
166
|
+
let cursor = x ? "col-resize" : "row-resize";
|
|
167
|
+
if (ctx.isAtMin)
|
|
168
|
+
cursor = x ? "e-resize" : "s-resize";
|
|
169
|
+
if (ctx.isAtMax)
|
|
170
|
+
cursor = x ? "w-resize" : "n-resize";
|
|
171
|
+
return cursor;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// src/splitter.connect.ts
|
|
176
|
+
function connect(state, send, normalize) {
|
|
177
|
+
const isHorizontal = state.context.isHorizontal;
|
|
178
|
+
const isDisabled = state.context.disabled;
|
|
179
|
+
const isFocused = state.hasTag("focus");
|
|
180
|
+
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
|
+
return {
|
|
187
|
+
isCollapsed: isAtMin,
|
|
188
|
+
isExpanded: isAtMax,
|
|
189
|
+
isFocused,
|
|
190
|
+
isDragging,
|
|
191
|
+
value,
|
|
192
|
+
collapse() {
|
|
193
|
+
send("COLLAPSE");
|
|
194
|
+
},
|
|
195
|
+
expand() {
|
|
196
|
+
send("EXPAND");
|
|
197
|
+
},
|
|
198
|
+
toggle() {
|
|
199
|
+
send("TOGGLE");
|
|
200
|
+
},
|
|
201
|
+
setSize(size) {
|
|
202
|
+
send({ type: "SET_SIZE", size });
|
|
203
|
+
},
|
|
204
|
+
rootProps: normalize.element({
|
|
205
|
+
...parts.root.attrs,
|
|
206
|
+
"data-orientation": state.context.orientation,
|
|
207
|
+
"data-disabled": dataAttr(isDisabled),
|
|
208
|
+
id: dom.getRootId(state.context),
|
|
209
|
+
style: {
|
|
210
|
+
display: "flex",
|
|
211
|
+
flex: "1 1 0%",
|
|
212
|
+
flexDirection: isHorizontal ? "row" : "column"
|
|
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` }
|
|
237
|
+
}
|
|
238
|
+
}),
|
|
239
|
+
toggleButtonProps: normalize.element({
|
|
240
|
+
...parts.toggleButton.attrs,
|
|
241
|
+
id: dom.getToggleButtonId(state.context),
|
|
242
|
+
"aria-label": state.context.isAtMin ? "Expand Primary Pane" : "Collapse Primary Pane",
|
|
243
|
+
onClick() {
|
|
244
|
+
send("TOGGLE");
|
|
245
|
+
}
|
|
246
|
+
}),
|
|
247
|
+
labelProps: normalize.element({
|
|
248
|
+
...parts.label.attrs,
|
|
249
|
+
id: dom.getLabelId(state.context)
|
|
250
|
+
}),
|
|
251
|
+
splitterProps: normalize.element({
|
|
252
|
+
...parts.splitter.attrs,
|
|
253
|
+
id: dom.getSplitterId(state.context),
|
|
254
|
+
role: "separator",
|
|
255
|
+
tabIndex: isDisabled ? void 0 : 0,
|
|
256
|
+
"aria-valuenow": value,
|
|
257
|
+
"aria-valuemin": min,
|
|
258
|
+
"aria-valuemax": max,
|
|
259
|
+
"aria-orientation": state.context.orientation,
|
|
260
|
+
"aria-labelledby": dom.getLabelId(state.context),
|
|
261
|
+
"aria-controls": dom.getPrimaryPaneId(state.context),
|
|
262
|
+
"data-orientation": state.context.orientation,
|
|
263
|
+
"data-focus": dataAttr(isFocused),
|
|
264
|
+
"data-disabled": dataAttr(isDisabled),
|
|
265
|
+
style: {
|
|
266
|
+
touchAction: "none",
|
|
267
|
+
userSelect: "none",
|
|
268
|
+
WebkitUserSelect: "none",
|
|
269
|
+
msUserSelect: "none",
|
|
270
|
+
flex: "0 0 auto",
|
|
271
|
+
cursor: dom.getCursor(state.context),
|
|
272
|
+
minHeight: isHorizontal ? "0px" : void 0,
|
|
273
|
+
minWidth: isHorizontal ? void 0 : "0px"
|
|
274
|
+
},
|
|
275
|
+
onPointerDown(event) {
|
|
276
|
+
if (isDisabled) {
|
|
277
|
+
event.preventDefault();
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
send("POINTER_DOWN");
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
event.stopPropagation();
|
|
283
|
+
},
|
|
284
|
+
onPointerOver() {
|
|
285
|
+
if (isDisabled)
|
|
286
|
+
return;
|
|
287
|
+
send("POINTER_OVER");
|
|
288
|
+
},
|
|
289
|
+
onPointerLeave() {
|
|
290
|
+
if (isDisabled)
|
|
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");
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const key = getEventKey(event, state.context);
|
|
330
|
+
const exec = keyMap[key];
|
|
331
|
+
if (exec) {
|
|
332
|
+
exec(event);
|
|
333
|
+
event.preventDefault();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
})
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
340
|
+
0 && (module.exports = {
|
|
341
|
+
connect
|
|
342
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MachineContext } from './splitter.types.js';
|
|
2
|
+
import '@zag-js/core';
|
|
3
|
+
import '@zag-js/types';
|
|
4
|
+
|
|
5
|
+
declare const dom: {
|
|
6
|
+
getRootNode: (ctx: {
|
|
7
|
+
getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
|
|
8
|
+
}) => Document | ShadowRoot;
|
|
9
|
+
getDoc: (ctx: {
|
|
10
|
+
getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
|
|
11
|
+
}) => Document;
|
|
12
|
+
getWin: (ctx: {
|
|
13
|
+
getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
|
|
14
|
+
}) => Window & typeof globalThis;
|
|
15
|
+
getActiveElement: (ctx: {
|
|
16
|
+
getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
|
|
17
|
+
}) => HTMLElement | null;
|
|
18
|
+
getById: <T = HTMLElement>(ctx: {
|
|
19
|
+
getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
|
|
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
|
+
} & {
|
|
26
|
+
getRootId: (ctx: MachineContext) => string;
|
|
27
|
+
getSplitterId: (ctx: MachineContext) => string;
|
|
28
|
+
getToggleButtonId: (ctx: MachineContext) => string;
|
|
29
|
+
getLabelId: (ctx: MachineContext) => string;
|
|
30
|
+
getPrimaryPaneId: (ctx: MachineContext) => string;
|
|
31
|
+
getSecondaryPaneId: (ctx: MachineContext) => string;
|
|
32
|
+
getSplitterEl: (ctx: MachineContext) => HTMLElement | null;
|
|
33
|
+
getPrimaryPaneEl: (ctx: MachineContext) => HTMLElement | null;
|
|
34
|
+
getCursor(ctx: MachineContext): (string & {}) | "col-resize" | "default" | "e-resize" | "n-resize" | "row-resize" | "s-resize" | "w-resize";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { dom };
|
|
@@ -0,0 +1,123 @@
|
|
|
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/splitter.dom.ts
|
|
21
|
+
var splitter_dom_exports = {};
|
|
22
|
+
__export(splitter_dom_exports, {
|
|
23
|
+
dom: () => dom
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(splitter_dom_exports);
|
|
26
|
+
|
|
27
|
+
// ../../utilities/dom/src/query.ts
|
|
28
|
+
function isDocument(el) {
|
|
29
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
30
|
+
}
|
|
31
|
+
function isWindow(value) {
|
|
32
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
33
|
+
}
|
|
34
|
+
function getDocument(el) {
|
|
35
|
+
var _a;
|
|
36
|
+
if (isWindow(el))
|
|
37
|
+
return el.document;
|
|
38
|
+
if (isDocument(el))
|
|
39
|
+
return el;
|
|
40
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
41
|
+
}
|
|
42
|
+
function defineDomHelpers(helpers) {
|
|
43
|
+
const dom2 = {
|
|
44
|
+
getRootNode: (ctx) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
47
|
+
},
|
|
48
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
49
|
+
getWin: (ctx) => {
|
|
50
|
+
var _a;
|
|
51
|
+
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
52
|
+
},
|
|
53
|
+
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
54
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
55
|
+
createEmitter: (ctx, target) => {
|
|
56
|
+
const win = dom2.getWin(ctx);
|
|
57
|
+
return function emit(evt, detail, options) {
|
|
58
|
+
const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
|
|
59
|
+
const eventName = `zag:${evt}`;
|
|
60
|
+
const init = { bubbles, cancelable, composed, detail };
|
|
61
|
+
const event = new win.CustomEvent(eventName, init);
|
|
62
|
+
target.dispatchEvent(event);
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
createListener: (target) => {
|
|
66
|
+
return function listen(evt, handler) {
|
|
67
|
+
const eventName = `zag:${evt}`;
|
|
68
|
+
const listener = (e) => handler(e);
|
|
69
|
+
target.addEventListener(eventName, listener);
|
|
70
|
+
return () => target.removeEventListener(eventName, listener);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
...dom2,
|
|
76
|
+
...helpers
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/splitter.dom.ts
|
|
81
|
+
var dom = defineDomHelpers({
|
|
82
|
+
getRootId: (ctx) => {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `splitter:${ctx.id}`;
|
|
85
|
+
},
|
|
86
|
+
getSplitterId: (ctx) => {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.splitter) != null ? _b : `splitter:${ctx.id}:splitter`;
|
|
89
|
+
},
|
|
90
|
+
getToggleButtonId: (ctx) => {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.toggleBtn) != null ? _b : `splitter:${ctx.id}:toggle-btn`;
|
|
93
|
+
},
|
|
94
|
+
getLabelId: (ctx) => {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `splitter:${ctx.id}:label`;
|
|
97
|
+
},
|
|
98
|
+
getPrimaryPaneId: (ctx) => {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.primaryPane) != null ? _b : `splitter:${ctx.id}:primary`;
|
|
101
|
+
},
|
|
102
|
+
getSecondaryPaneId: (ctx) => {
|
|
103
|
+
var _a, _b;
|
|
104
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.secondaryPane) != null ? _b : `splitter:${ctx.id}:secondary`;
|
|
105
|
+
},
|
|
106
|
+
getSplitterEl: (ctx) => dom.getById(ctx, dom.getSplitterId(ctx)),
|
|
107
|
+
getPrimaryPaneEl: (ctx) => dom.getById(ctx, dom.getPrimaryPaneId(ctx)),
|
|
108
|
+
getCursor(ctx) {
|
|
109
|
+
if (ctx.disabled || ctx.fixed)
|
|
110
|
+
return "default";
|
|
111
|
+
const x = ctx.isHorizontal;
|
|
112
|
+
let cursor = x ? "col-resize" : "row-resize";
|
|
113
|
+
if (ctx.isAtMin)
|
|
114
|
+
cursor = x ? "e-resize" : "s-resize";
|
|
115
|
+
if (ctx.isAtMax)
|
|
116
|
+
cursor = x ? "w-resize" : "n-resize";
|
|
117
|
+
return cursor;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
121
|
+
0 && (module.exports = {
|
|
122
|
+
dom
|
|
123
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
2
|
+
import { UserDefinedContext, MachineContext, MachineState } from './splitter.types.js';
|
|
3
|
+
import '@zag-js/types';
|
|
4
|
+
|
|
5
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
6
|
+
|
|
7
|
+
export { machine };
|