@zag-js/splitter 0.2.12 → 0.2.14

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.
@@ -23,80 +23,8 @@ __export(splitter_connect_exports, {
23
23
  connect: () => connect
24
24
  });
25
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?.toString() === "[object Window]";
38
- }
39
- function getDocument(el) {
40
- if (isWindow(el))
41
- return el.document;
42
- if (isDocument(el))
43
- return el;
44
- return el?.ownerDocument ?? document;
45
- }
46
- function defineDomHelpers(helpers) {
47
- const dom2 = {
48
- getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
49
- getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
50
- getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
51
- getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
52
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
53
- };
54
- return {
55
- ...dom2,
56
- ...helpers
57
- };
58
- }
59
-
60
- // ../../utilities/dom/src/keyboard-event.ts
61
- var rtlKeyMap = {
62
- ArrowLeft: "ArrowRight",
63
- ArrowRight: "ArrowLeft"
64
- };
65
- var sameKeyMap = {
66
- Up: "ArrowUp",
67
- Down: "ArrowDown",
68
- Esc: "Escape",
69
- " ": "Space",
70
- ",": "Comma",
71
- Left: "ArrowLeft",
72
- Right: "ArrowRight"
73
- };
74
- function getEventKey(event, options = {}) {
75
- const { dir = "ltr", orientation = "horizontal" } = options;
76
- let { key } = event;
77
- key = sameKeyMap[key] ?? key;
78
- const isRtl = dir === "rtl" && orientation === "horizontal";
79
- if (isRtl && key in rtlKeyMap) {
80
- key = rtlKeyMap[key];
81
- }
82
- return key;
83
- }
84
- var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
85
- var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
86
- function getEventStep(event) {
87
- if (event.ctrlKey || event.metaKey) {
88
- return 0.1;
89
- } else {
90
- const isPageKey = PAGE_KEYS.has(event.key);
91
- const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
92
- return isSkipKey ? 10 : 1;
93
- }
94
- }
95
-
96
- // ../../utilities/dom/src/nodelist.ts
97
- function queryAll(root, selector) {
98
- return Array.from(root?.querySelectorAll(selector) ?? []);
99
- }
26
+ var import_dom_event = require("@zag-js/dom-event");
27
+ var import_dom_query2 = require("@zag-js/dom-query");
100
28
 
101
29
  // src/splitter.anatomy.ts
102
30
  var import_anatomy = require("@zag-js/anatomy");
@@ -104,7 +32,8 @@ var anatomy = (0, import_anatomy.createAnatomy)("splitter").parts("root", "panel
104
32
  var parts = anatomy.build();
105
33
 
106
34
  // src/splitter.dom.ts
107
- var dom = defineDomHelpers({
35
+ var import_dom_query = require("@zag-js/dom-query");
36
+ var dom = (0, import_dom_query.createScope)({
108
37
  getRootId: (ctx) => `splitter:${ctx.id}`,
109
38
  getResizeTriggerId: (ctx, id) => `splitter:${ctx.id}:splitter:${id}`,
110
39
  getToggleTriggerId: (ctx) => `splitter:${ctx.id}:toggle-btn`,
@@ -140,7 +69,7 @@ var dom = defineDomHelpers({
140
69
  },
141
70
  getResizeTriggerEls(ctx) {
142
71
  const ownerId = CSS.escape(dom.getRootId(ctx));
143
- return queryAll(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
72
+ return (0, import_dom_query.queryAll)(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
144
73
  },
145
74
  setupGlobalCursor(ctx) {
146
75
  const styleEl = dom.getById(ctx, dom.globalCursorId(ctx));
@@ -198,21 +127,59 @@ function connect(state, send, normalize) {
198
127
  const isFocused = state.hasTag("focus");
199
128
  const isDragging = state.matches("dragging");
200
129
  const api = {
130
+ /**
131
+ * Whether the splitter is focused.
132
+ */
201
133
  isFocused,
134
+ /**
135
+ * Whether the splitter is being dragged.
136
+ */
202
137
  isDragging,
138
+ /**
139
+ * The bounds of the currently dragged splitter handle.
140
+ */
203
141
  bounds: getHandleBounds(state.context),
142
+ /**
143
+ * Function to collapse a panel.
144
+ */
204
145
  collapse(id) {
205
146
  send({ type: "COLLAPSE", id });
206
147
  },
148
+ /**
149
+ * Function to expand a panel.
150
+ */
207
151
  expand(id) {
208
152
  send({ type: "EXPAND", id });
209
153
  },
154
+ /**
155
+ * Function to toggle a panel between collapsed and expanded.
156
+ */
210
157
  toggle(id) {
211
158
  send({ type: "TOGGLE", id });
212
159
  },
160
+ /**
161
+ * Function to set the size of a panel.
162
+ */
213
163
  setSize(id, size) {
214
164
  send({ type: "SET_SIZE", id, size });
215
165
  },
166
+ /**
167
+ * Returns the state details for a resize trigger.
168
+ */
169
+ getResizeTriggerState(props) {
170
+ const { id, disabled } = props;
171
+ const ids = id.split(":");
172
+ const panelIds = ids.map((id2) => dom.getPanelId(state.context, id2));
173
+ const panels = getHandleBounds(state.context, id);
174
+ return {
175
+ isDisabled: !!disabled,
176
+ isFocused: state.context.activeResizeId === id && isFocused,
177
+ panelIds,
178
+ min: panels?.min,
179
+ max: panels?.max,
180
+ value: 0
181
+ };
182
+ },
216
183
  rootProps: normalize.element({
217
184
  ...parts.root.attrs,
218
185
  "data-orientation": state.context.orientation,
@@ -236,20 +203,14 @@ function connect(state, send, normalize) {
236
203
  style: dom.getPanelStyle(state.context, id)
237
204
  });
238
205
  },
239
- getResizeTriggerState(props) {
240
- const { id, disabled } = props;
241
- const ids = id.split(":");
242
- const panelIds = ids.map((id2) => dom.getPanelId(state.context, id2));
243
- const panels = getHandleBounds(state.context, id);
244
- return {
245
- isDisabled: !!disabled,
246
- isFocused: state.context.activeResizeId === id && isFocused,
247
- panelIds,
248
- min: panels?.min,
249
- max: panels?.max,
250
- value: 0
251
- };
252
- },
206
+ // toggleTriggerProps: normalize.element({
207
+ // ...parts.toggleButton.attrs,
208
+ // id: dom.getToggleButtonId(state.context),
209
+ // "aria-label": state.context.isAtMin ? "Expand Primary Pane" : "Collapse Primary Pane",
210
+ // onClick() {
211
+ // send("TOGGLE")
212
+ // },
213
+ // }),
253
214
  getResizeTriggerProps(props) {
254
215
  const { id, disabled, step = 1 } = props;
255
216
  const triggerState = api.getResizeTriggerState(props);
@@ -266,8 +227,8 @@ function connect(state, send, normalize) {
266
227
  "data-orientation": state.context.orientation,
267
228
  "aria-orientation": state.context.orientation,
268
229
  "aria-controls": triggerState.panelIds.join(" "),
269
- "data-focus": dataAttr(triggerState.isFocused),
270
- "data-disabled": dataAttr(disabled),
230
+ "data-focus": (0, import_dom_query2.dataAttr)(triggerState.isFocused),
231
+ "data-disabled": (0, import_dom_query2.dataAttr)(disabled),
271
232
  style: {
272
233
  touchAction: "none",
273
234
  userSelect: "none",
@@ -309,7 +270,7 @@ function connect(state, send, normalize) {
309
270
  onKeyDown(event) {
310
271
  if (disabled)
311
272
  return;
312
- const moveStep = getEventStep(event) * step;
273
+ const moveStep = (0, import_dom_event.getEventStep)(event) * step;
313
274
  const keyMap = {
314
275
  Enter() {
315
276
  send("ENTER");
@@ -333,7 +294,7 @@ function connect(state, send, normalize) {
333
294
  send("END");
334
295
  }
335
296
  };
336
- const key = getEventKey(event, state.context);
297
+ const key = (0, import_dom_event.getEventKey)(event, state.context);
337
298
  const exec = keyMap[key];
338
299
  if (exec) {
339
300
  exec(event);
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-JYQICU6Y.mjs";
3
+ } from "./chunk-CQT32RFW.mjs";
4
4
  import "./chunk-HPRMFGOY.mjs";
5
- import "./chunk-QY3R66FZ.mjs";
5
+ import "./chunk-BSW3DTW4.mjs";
6
6
  import "./chunk-MV44GBQY.mjs";
7
7
  export {
8
8
  connect
@@ -4,20 +4,23 @@ import '@zag-js/core';
4
4
 
5
5
  declare const dom: {
6
6
  getRootNode: (ctx: {
7
- getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
7
+ getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
8
8
  }) => Document | ShadowRoot;
9
9
  getDoc: (ctx: {
10
- getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
10
+ getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
11
11
  }) => Document;
12
12
  getWin: (ctx: {
13
- getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
13
+ getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
14
14
  }) => Window & typeof globalThis;
15
15
  getActiveElement: (ctx: {
16
- getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
16
+ getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
17
17
  }) => HTMLElement | null;
18
- getById: <T = HTMLElement>(ctx: {
19
- getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
18
+ getById: <T extends HTMLElement = HTMLElement>(ctx: {
19
+ getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
20
20
  }, id: string) => T | null;
21
+ queryById: <T_1 extends HTMLElement = HTMLElement>(ctx: {
22
+ getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
23
+ }, id: string) => T_1;
21
24
  } & {
22
25
  getRootId: (ctx: MachineContext) => string;
23
26
  getResizeTriggerId: (ctx: MachineContext, id: string) => string;
@@ -23,42 +23,8 @@ __export(splitter_dom_exports, {
23
23
  dom: () => dom
24
24
  });
25
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?.toString() === "[object Window]";
33
- }
34
- function getDocument(el) {
35
- if (isWindow(el))
36
- return el.document;
37
- if (isDocument(el))
38
- return el;
39
- return el?.ownerDocument ?? document;
40
- }
41
- function defineDomHelpers(helpers) {
42
- const dom2 = {
43
- getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
44
- getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
45
- getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
46
- getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
47
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
48
- };
49
- return {
50
- ...dom2,
51
- ...helpers
52
- };
53
- }
54
-
55
- // ../../utilities/dom/src/nodelist.ts
56
- function queryAll(root, selector) {
57
- return Array.from(root?.querySelectorAll(selector) ?? []);
58
- }
59
-
60
- // src/splitter.dom.ts
61
- var dom = defineDomHelpers({
26
+ var import_dom_query = require("@zag-js/dom-query");
27
+ var dom = (0, import_dom_query.createScope)({
62
28
  getRootId: (ctx) => `splitter:${ctx.id}`,
63
29
  getResizeTriggerId: (ctx, id) => `splitter:${ctx.id}:splitter:${id}`,
64
30
  getToggleTriggerId: (ctx) => `splitter:${ctx.id}:toggle-btn`,
@@ -94,7 +60,7 @@ var dom = defineDomHelpers({
94
60
  },
95
61
  getResizeTriggerEls(ctx) {
96
62
  const ownerId = CSS.escape(dom.getRootId(ctx));
97
- return queryAll(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
63
+ return (0, import_dom_query.queryAll)(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
98
64
  },
99
65
  setupGlobalCursor(ctx) {
100
66
  const styleEl = dom.getById(ctx, dom.globalCursorId(ctx));
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  dom
3
- } from "./chunk-QY3R66FZ.mjs";
3
+ } from "./chunk-BSW3DTW4.mjs";
4
4
  export {
5
5
  dom
6
6
  };
@@ -24,293 +24,13 @@ __export(splitter_machine_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(splitter_machine_exports);
26
26
  var import_core = require("@zag-js/core");
27
-
28
- // ../../utilities/core/src/functions.ts
29
- var runIfFn = (v, ...a) => {
30
- const res = typeof v === "function" ? v(...a) : v;
31
- return res ?? void 0;
32
- };
33
- var callAll = (...fns) => (...a) => {
34
- fns.forEach(function(fn) {
35
- fn?.(...a);
36
- });
37
- };
38
-
39
- // ../../utilities/core/src/guard.ts
40
- var isArray = (v) => Array.isArray(v);
41
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
42
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
43
-
44
- // ../../utilities/core/src/object.ts
45
- function compact(obj) {
46
- if (obj === void 0)
47
- return obj;
48
- return Object.fromEntries(
49
- Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
50
- );
51
- }
52
-
53
- // ../../utilities/dom/src/platform.ts
54
- var isDom = () => typeof window !== "undefined";
55
- function getPlatform() {
56
- const agent = navigator.userAgentData;
57
- return agent?.platform ?? navigator.platform;
58
- }
59
- var pt = (v) => isDom() && v.test(getPlatform());
60
- var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
61
- var isMac = () => pt(/^Mac/) && !isTouchDevice;
62
- var isApple = () => pt(/mac|iphone|ipad|ipod/i);
63
- var isIos = () => isApple() && !isMac();
64
-
65
- // ../../utilities/dom/src/query.ts
66
- function isDocument(el) {
67
- return el.nodeType === Node.DOCUMENT_NODE;
68
- }
69
- function isWindow(value) {
70
- return value?.toString() === "[object Window]";
71
- }
72
- function getDocument(el) {
73
- if (isWindow(el))
74
- return el.document;
75
- if (isDocument(el))
76
- return el;
77
- return el?.ownerDocument ?? document;
78
- }
79
- function defineDomHelpers(helpers) {
80
- const dom2 = {
81
- getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
82
- getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
83
- getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
84
- getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
85
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
86
- };
87
- return {
88
- ...dom2,
89
- ...helpers
90
- };
91
- }
92
-
93
- // ../../utilities/dom/src/event.ts
94
- var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
95
- var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
96
- var supportsMouseEvent = () => isDom() && window.onmousedown === null;
97
- var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
98
- var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
99
- var isLeftClick = (v) => v.button === 0;
100
-
101
- // ../../utilities/dom/src/get-element-offset.ts
102
- function getElementOffset(element) {
103
- let left = 0;
104
- let top = 0;
105
- let el = element;
106
- if (el.parentNode) {
107
- do {
108
- left += el.offsetLeft;
109
- top += el.offsetTop;
110
- } while ((el = el.offsetParent) && el.nodeType < 9);
111
- el = element;
112
- do {
113
- left -= el.scrollLeft;
114
- top -= el.scrollTop;
115
- } while ((el = el.parentNode) && !/body/i.test(el.nodeName));
116
- }
117
- return {
118
- top,
119
- right: innerWidth - left - element.offsetWidth,
120
- bottom: innerHeight - top - element.offsetHeight,
121
- left
122
- };
123
- }
124
-
125
- // ../../utilities/dom/src/get-point-relative-to-element.ts
126
- function getPointRelativeToNode(point, element) {
127
- const offset = getElementOffset(element);
128
- const x = point.x - offset.left;
129
- const y = point.y - offset.top;
130
- return { x, y };
131
- }
132
- var clampPercent = (value) => Math.max(0, Math.min(100, value));
133
- function getPointPercentRelativeToNode(point, element) {
134
- const relativePoint = getPointRelativeToNode(point, element);
135
- const x = relativePoint.x / element.offsetWidth * 100;
136
- const y = relativePoint.y / element.offsetHeight * 100;
137
- return { x: clampPercent(x), y: clampPercent(y) };
138
- }
139
- function normalizePointValue(point, options) {
140
- const { dir = "ltr", orientation = "horizontal" } = options;
141
- const { x, y } = point;
142
- let result = { x, y };
143
- if (orientation === "horizontal" && dir === "rtl") {
144
- result = { x: 100 - x, y };
145
- }
146
- return orientation === "horizontal" ? result.x : result.y;
147
- }
148
-
149
- // ../../utilities/dom/src/listener.ts
150
- var isRef = (v) => hasProp(v, "current");
151
- var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
152
- function extractInfo(event, type = "page") {
153
- const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
154
- return {
155
- point: {
156
- x: point[`${type}X`],
157
- y: point[`${type}Y`]
158
- }
159
- };
160
- }
161
- function addDomEvent(target, eventName, handler, options) {
162
- const node = isRef(target) ? target.current : runIfFn(target);
163
- node?.addEventListener(eventName, handler, options);
164
- return () => {
165
- node?.removeEventListener(eventName, handler, options);
166
- };
167
- }
168
- function addPointerEvent(target, event, listener, options) {
169
- const type = getEventName(event) ?? event;
170
- return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
171
- }
172
- function wrapHandler(fn, filter = false) {
173
- const listener = (event) => {
174
- fn(event, extractInfo(event));
175
- };
176
- return filter ? filterPrimaryPointer(listener) : listener;
177
- }
178
- function filterPrimaryPointer(fn) {
179
- return (event) => {
180
- const win = event.view ?? window;
181
- const isMouseEvent2 = event instanceof win.MouseEvent;
182
- const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
183
- if (isPrimary)
184
- fn(event);
185
- };
186
- }
187
- var mouseEventNames = {
188
- pointerdown: "mousedown",
189
- pointermove: "mousemove",
190
- pointerup: "mouseup",
191
- pointercancel: "mousecancel",
192
- pointerover: "mouseover",
193
- pointerout: "mouseout",
194
- pointerenter: "mouseenter",
195
- pointerleave: "mouseleave"
196
- };
197
- var touchEventNames = {
198
- pointerdown: "touchstart",
199
- pointermove: "touchmove",
200
- pointerup: "touchend",
201
- pointercancel: "touchcancel"
202
- };
203
- function getEventName(evt) {
204
- if (supportsPointerEvent())
205
- return evt;
206
- if (supportsTouchEvent())
207
- return touchEventNames[evt];
208
- if (supportsMouseEvent())
209
- return mouseEventNames[evt];
210
- return evt;
211
- }
212
-
213
- // ../../utilities/dom/src/next-tick.ts
214
- function nextTick(fn) {
215
- const set = /* @__PURE__ */ new Set();
216
- function raf2(fn2) {
217
- const id = globalThis.requestAnimationFrame(fn2);
218
- set.add(() => globalThis.cancelAnimationFrame(id));
219
- }
220
- raf2(() => raf2(fn));
221
- return function cleanup() {
222
- set.forEach(function(fn2) {
223
- fn2();
224
- });
225
- };
226
- }
227
- function raf(fn) {
228
- const id = globalThis.requestAnimationFrame(fn);
229
- return function cleanup() {
230
- globalThis.cancelAnimationFrame(id);
231
- };
232
- }
233
-
234
- // ../../utilities/dom/src/nodelist.ts
235
- function queryAll(root, selector) {
236
- return Array.from(root?.querySelectorAll(selector) ?? []);
237
- }
238
-
239
- // ../../utilities/dom/src/text-selection.ts
240
- var state = "default";
241
- var savedUserSelect = "";
242
- var modifiedElementMap = /* @__PURE__ */ new WeakMap();
243
- function disableTextSelection({ target, doc } = {}) {
244
- const _document = doc ?? document;
245
- if (isIos()) {
246
- if (state === "default") {
247
- savedUserSelect = _document.documentElement.style.webkitUserSelect;
248
- _document.documentElement.style.webkitUserSelect = "none";
249
- }
250
- state = "disabled";
251
- } else if (target) {
252
- modifiedElementMap.set(target, target.style.userSelect);
253
- target.style.userSelect = "none";
254
- }
255
- return () => restoreTextSelection({ target, doc: _document });
256
- }
257
- function restoreTextSelection({ target, doc } = {}) {
258
- const _document = doc ?? document;
259
- if (isIos()) {
260
- if (state !== "disabled")
261
- return;
262
- state = "restoring";
263
- setTimeout(() => {
264
- nextTick(() => {
265
- if (state === "restoring") {
266
- if (_document.documentElement.style.webkitUserSelect === "none") {
267
- _document.documentElement.style.webkitUserSelect = savedUserSelect || "";
268
- }
269
- savedUserSelect = "";
270
- state = "default";
271
- }
272
- });
273
- }, 300);
274
- } else {
275
- if (target && modifiedElementMap.has(target)) {
276
- let targetOldUserSelect = modifiedElementMap.get(target);
277
- if (target.style.userSelect === "none") {
278
- target.style.userSelect = targetOldUserSelect ?? "";
279
- }
280
- if (target.getAttribute("style") === "") {
281
- target.removeAttribute("style");
282
- }
283
- modifiedElementMap.delete(target);
284
- }
285
- }
286
- }
287
-
288
- // ../../utilities/dom/src/pointer-event.ts
289
- var THRESHOLD = 5;
290
- function trackPointerMove(doc, opts) {
291
- const { onPointerMove, onPointerUp } = opts;
292
- const handlePointerMove = (event, info) => {
293
- const { point: p } = info;
294
- const distance = Math.sqrt(p.x ** 2 + p.y ** 2);
295
- if (distance < THRESHOLD)
296
- return;
297
- if (isMouseEvent(event) && isLeftClick(event)) {
298
- onPointerUp();
299
- return;
300
- }
301
- onPointerMove(info, event);
302
- };
303
- return callAll(
304
- addPointerEvent(doc, "pointermove", handlePointerMove, false),
305
- addPointerEvent(doc, "pointerup", onPointerUp, false),
306
- addPointerEvent(doc, "pointercancel", onPointerUp, false),
307
- addPointerEvent(doc, "contextmenu", onPointerUp, false),
308
- disableTextSelection({ doc })
309
- );
310
- }
27
+ var import_dom_event = require("@zag-js/dom-event");
28
+ var import_dom_query2 = require("@zag-js/dom-query");
29
+ var import_utils = require("@zag-js/utils");
311
30
 
312
31
  // src/splitter.dom.ts
313
- var dom = defineDomHelpers({
32
+ var import_dom_query = require("@zag-js/dom-query");
33
+ var dom = (0, import_dom_query.createScope)({
314
34
  getRootId: (ctx) => `splitter:${ctx.id}`,
315
35
  getResizeTriggerId: (ctx, id) => `splitter:${ctx.id}:splitter:${id}`,
316
36
  getToggleTriggerId: (ctx) => `splitter:${ctx.id}:toggle-btn`,
@@ -346,7 +66,7 @@ var dom = defineDomHelpers({
346
66
  },
347
67
  getResizeTriggerEls(ctx) {
348
68
  const ownerId = CSS.escape(dom.getRootId(ctx));
349
- return queryAll(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
69
+ return (0, import_dom_query.queryAll)(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
350
70
  },
351
71
  setupGlobalCursor(ctx) {
352
72
  const styleEl = dom.getById(ctx, dom.globalCursorId(ctx));
@@ -489,7 +209,7 @@ function clamp(value, min, max) {
489
209
 
490
210
  // src/splitter.machine.ts
491
211
  function machine(userContext) {
492
- const ctx = compact(userContext);
212
+ const ctx = (0, import_utils.compact)(userContext);
493
213
  return (0, import_core.createMachine)(
494
214
  {
495
215
  id: "splitter",
@@ -629,7 +349,7 @@ function machine(userContext) {
629
349
  activities: {
630
350
  trackPointerMove: (ctx2, _evt, { send }) => {
631
351
  const doc = dom.getDoc(ctx2);
632
- return trackPointerMove(doc, {
352
+ return (0, import_dom_event.trackPointerMove)(doc, {
633
353
  onPointerMove(info) {
634
354
  send({ type: "POINTER_MOVE", point: info.point });
635
355
  },
@@ -717,12 +437,12 @@ function machine(userContext) {
717
437
  ctx2.size[after.index].size = ctx2.initialSize[after.index].size;
718
438
  },
719
439
  focusResizeHandle(ctx2) {
720
- raf(() => {
440
+ (0, import_dom_query2.raf)(() => {
721
441
  dom.getActiveHandleEl(ctx2)?.focus({ preventScroll: true });
722
442
  });
723
443
  },
724
444
  blurResizeHandle(ctx2) {
725
- raf(() => {
445
+ (0, import_dom_query2.raf)(() => {
726
446
  dom.getActiveHandleEl(ctx2)?.blur();
727
447
  });
728
448
  },
@@ -745,8 +465,7 @@ function machine(userContext) {
745
465
  const rootEl = dom.getRootEl(ctx2);
746
466
  if (!panels || !rootEl || !bounds)
747
467
  return;
748
- const percent = getPointPercentRelativeToNode(evt.point, rootEl);
749
- let pointValue = normalizePointValue(percent, ctx2);
468
+ let pointValue = (0, import_dom_event.getRelativePointPercent)(evt.point, rootEl).normalize(ctx2);
750
469
  ctx2.activeResizeState = {
751
470
  isAtMin: pointValue < bounds.min,
752
471
  isAtMax: pointValue > bounds.max
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  machine
3
- } from "./chunk-AO5KCFS2.mjs";
4
- import "./chunk-QY3R66FZ.mjs";
3
+ } from "./chunk-63NJ553U.mjs";
4
+ import "./chunk-BSW3DTW4.mjs";
5
5
  import "./chunk-MV44GBQY.mjs";
6
6
  export {
7
7
  machine