@zag-js/splitter 1.38.2 → 1.39.1

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.
Files changed (52) hide show
  1. package/dist/chunk-QZ7TP4HQ.mjs +7 -0
  2. package/dist/index.d.mts +1 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +4 -1
  5. package/dist/index.mjs +5 -1
  6. package/dist/splitter.anatomy.mjs +2 -0
  7. package/dist/splitter.connect.d.mts +1 -0
  8. package/dist/splitter.connect.d.ts +1 -0
  9. package/dist/splitter.connect.js +7 -3
  10. package/dist/splitter.connect.mjs +9 -3
  11. package/dist/splitter.dom.d.mts +1 -0
  12. package/dist/splitter.dom.d.ts +1 -0
  13. package/dist/splitter.dom.mjs +2 -0
  14. package/dist/splitter.machine.d.mts +1 -0
  15. package/dist/splitter.machine.d.ts +1 -0
  16. package/dist/splitter.machine.js +53 -0
  17. package/dist/splitter.machine.mjs +56 -1
  18. package/dist/splitter.props.d.mts +1 -0
  19. package/dist/splitter.props.d.ts +1 -0
  20. package/dist/splitter.props.js +2 -1
  21. package/dist/splitter.props.mjs +4 -1
  22. package/dist/splitter.types.d.mts +6 -0
  23. package/dist/splitter.types.d.ts +6 -0
  24. package/dist/utils/aria.d.mts +1 -0
  25. package/dist/utils/aria.d.ts +1 -0
  26. package/dist/utils/aria.mjs +2 -0
  27. package/dist/utils/fuzzy.mjs +2 -0
  28. package/dist/utils/intersects.d.mts +6 -0
  29. package/dist/utils/intersects.d.ts +6 -0
  30. package/dist/utils/intersects.js +40 -0
  31. package/dist/utils/intersects.mjs +16 -0
  32. package/dist/utils/panel.d.mts +1 -0
  33. package/dist/utils/panel.d.ts +1 -0
  34. package/dist/utils/panel.mjs +2 -0
  35. package/dist/utils/registry.d.mts +64 -0
  36. package/dist/utils/registry.d.ts +64 -0
  37. package/dist/utils/registry.js +206 -0
  38. package/dist/utils/registry.mjs +182 -0
  39. package/dist/utils/resize-by-delta.d.mts +1 -0
  40. package/dist/utils/resize-by-delta.d.ts +1 -0
  41. package/dist/utils/resize-by-delta.mjs +2 -0
  42. package/dist/utils/resize-panel.d.mts +1 -0
  43. package/dist/utils/resize-panel.d.ts +1 -0
  44. package/dist/utils/resize-panel.mjs +2 -0
  45. package/dist/utils/stacking-order.d.mts +9 -0
  46. package/dist/utils/stacking-order.d.ts +9 -0
  47. package/dist/utils/stacking-order.js +99 -0
  48. package/dist/utils/stacking-order.mjs +76 -0
  49. package/dist/utils/validate-sizes.d.mts +1 -0
  50. package/dist/utils/validate-sizes.d.ts +1 -0
  51. package/dist/utils/validate-sizes.mjs +2 -0
  52. package/package.json +6 -6
@@ -0,0 +1,64 @@
1
+ import { Orientation, Point } from '@zag-js/types';
2
+
3
+ interface ResizeHandleData {
4
+ id: string;
5
+ element: HTMLElement;
6
+ orientation: Orientation;
7
+ onActivate: (point: Point) => void;
8
+ onDeactivate: VoidFunction;
9
+ }
10
+ interface HitAreaMargins {
11
+ /**
12
+ * The margin for coarse pointers (touch, pen)
13
+ * @default 15
14
+ */
15
+ coarse?: number;
16
+ /**
17
+ * The margin for fine pointers (mouse)
18
+ * @default 5
19
+ */
20
+ fine?: number;
21
+ }
22
+ interface SplitterRegistryOptions {
23
+ /**
24
+ * The nonce for the injected cursor stylesheet (for CSP compliance).
25
+ */
26
+ nonce?: string;
27
+ /**
28
+ * The hit area margins for resize handles.
29
+ * Larger margins make it easier to grab handles, especially on touch devices.
30
+ */
31
+ hitAreaMargins?: HitAreaMargins;
32
+ }
33
+ declare class SplitterRegistry {
34
+ private handles;
35
+ private state;
36
+ private listenerAttached;
37
+ private options;
38
+ constructor(options?: SplitterRegistryOptions);
39
+ register(data: ResizeHandleData): VoidFunction;
40
+ private attachGlobalListeners;
41
+ private detachGlobalListeners;
42
+ private getPointerType;
43
+ private get doc();
44
+ /**
45
+ * Fast hit-test: only checks pointer proximity to handles (no stacking order).
46
+ * Used for pointermove cursor feedback.
47
+ */
48
+ private findHitHandles;
49
+ /**
50
+ * Full intersection check: hit-test + stacking order verification.
51
+ * Used for pointerdown activation where correctness matters.
52
+ */
53
+ private findIntersectingHandles;
54
+ private handlePointerMove;
55
+ private handlePointerDown;
56
+ private handlePointerUp;
57
+ private updateCursor;
58
+ private globalCursorId;
59
+ private setGlobalCursor;
60
+ private clearGlobalCursor;
61
+ }
62
+ declare const registry: (opts?: SplitterRegistryOptions) => SplitterRegistry;
63
+
64
+ export { type HitAreaMargins, type ResizeHandleData, SplitterRegistry, type SplitterRegistryOptions, registry };
@@ -0,0 +1,64 @@
1
+ import { Orientation, Point } from '@zag-js/types';
2
+
3
+ interface ResizeHandleData {
4
+ id: string;
5
+ element: HTMLElement;
6
+ orientation: Orientation;
7
+ onActivate: (point: Point) => void;
8
+ onDeactivate: VoidFunction;
9
+ }
10
+ interface HitAreaMargins {
11
+ /**
12
+ * The margin for coarse pointers (touch, pen)
13
+ * @default 15
14
+ */
15
+ coarse?: number;
16
+ /**
17
+ * The margin for fine pointers (mouse)
18
+ * @default 5
19
+ */
20
+ fine?: number;
21
+ }
22
+ interface SplitterRegistryOptions {
23
+ /**
24
+ * The nonce for the injected cursor stylesheet (for CSP compliance).
25
+ */
26
+ nonce?: string;
27
+ /**
28
+ * The hit area margins for resize handles.
29
+ * Larger margins make it easier to grab handles, especially on touch devices.
30
+ */
31
+ hitAreaMargins?: HitAreaMargins;
32
+ }
33
+ declare class SplitterRegistry {
34
+ private handles;
35
+ private state;
36
+ private listenerAttached;
37
+ private options;
38
+ constructor(options?: SplitterRegistryOptions);
39
+ register(data: ResizeHandleData): VoidFunction;
40
+ private attachGlobalListeners;
41
+ private detachGlobalListeners;
42
+ private getPointerType;
43
+ private get doc();
44
+ /**
45
+ * Fast hit-test: only checks pointer proximity to handles (no stacking order).
46
+ * Used for pointermove cursor feedback.
47
+ */
48
+ private findHitHandles;
49
+ /**
50
+ * Full intersection check: hit-test + stacking order verification.
51
+ * Used for pointerdown activation where correctness matters.
52
+ */
53
+ private findIntersectingHandles;
54
+ private handlePointerMove;
55
+ private handlePointerDown;
56
+ private handlePointerUp;
57
+ private updateCursor;
58
+ private globalCursorId;
59
+ private setGlobalCursor;
60
+ private clearGlobalCursor;
61
+ }
62
+ declare const registry: (opts?: SplitterRegistryOptions) => SplitterRegistry;
63
+
64
+ export { type HitAreaMargins, type ResizeHandleData, SplitterRegistry, type SplitterRegistryOptions, registry };
@@ -0,0 +1,206 @@
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
+
22
+ // src/utils/registry.ts
23
+ var registry_exports = {};
24
+ __export(registry_exports, {
25
+ SplitterRegistry: () => SplitterRegistry,
26
+ registry: () => registry
27
+ });
28
+ module.exports = __toCommonJS(registry_exports);
29
+ var import_dom_query = require("@zag-js/dom-query");
30
+ var import_intersects = require("./intersects.js");
31
+ var import_stacking_order = require("./stacking-order.js");
32
+ var SplitterRegistry = class {
33
+ constructor(options = {}) {
34
+ __publicField(this, "handles", /* @__PURE__ */ new Map());
35
+ __publicField(this, "state", {
36
+ activeHandleIds: /* @__PURE__ */ new Set(),
37
+ isPointerDown: false
38
+ });
39
+ __publicField(this, "listenerAttached", false);
40
+ __publicField(this, "options");
41
+ __publicField(this, "handlePointerMove", (event) => {
42
+ if (this.state.isPointerDown) return;
43
+ const pointerType = this.getPointerType(event);
44
+ const intersecting = this.findHitHandles(event.clientX, event.clientY, pointerType);
45
+ const newActiveIds = new Set(intersecting.map((h) => h.id));
46
+ const changed = newActiveIds.size !== this.state.activeHandleIds.size || [...newActiveIds].some((id) => !this.state.activeHandleIds.has(id));
47
+ if (changed) {
48
+ this.state.activeHandleIds = newActiveIds;
49
+ this.updateCursor(intersecting);
50
+ }
51
+ });
52
+ __publicField(this, "handlePointerDown", (event) => {
53
+ const pointerType = this.getPointerType(event);
54
+ const intersecting = this.findIntersectingHandles(event.clientX, event.clientY, pointerType, event.target);
55
+ if (intersecting.length > 0) {
56
+ this.state.isPointerDown = true;
57
+ this.state.activeHandleIds = new Set(intersecting.map((h) => h.id));
58
+ const point = { x: event.clientX, y: event.clientY };
59
+ intersecting.forEach((handle) => {
60
+ handle.onActivate(point);
61
+ });
62
+ this.updateCursor(intersecting);
63
+ }
64
+ });
65
+ __publicField(this, "handlePointerUp", (_event) => {
66
+ if (this.state.isPointerDown) {
67
+ this.state.isPointerDown = false;
68
+ this.handles.forEach((handle) => {
69
+ if (this.state.activeHandleIds.has(handle.id)) {
70
+ handle.onDeactivate();
71
+ }
72
+ });
73
+ this.state.activeHandleIds.clear();
74
+ this.clearGlobalCursor();
75
+ }
76
+ });
77
+ __publicField(this, "globalCursorId", "splitter-registry-cursor");
78
+ this.options = {
79
+ nonce: options.nonce ?? "",
80
+ hitAreaMargins: {
81
+ coarse: options.hitAreaMargins?.coarse ?? 15,
82
+ fine: options.hitAreaMargins?.fine ?? 5
83
+ }
84
+ };
85
+ }
86
+ register(data) {
87
+ this.handles.set(data.id, data);
88
+ this.attachGlobalListeners();
89
+ return () => {
90
+ this.handles.delete(data.id);
91
+ this.state.activeHandleIds.delete(data.id);
92
+ if (this.handles.size === 0) {
93
+ this.detachGlobalListeners();
94
+ }
95
+ };
96
+ }
97
+ attachGlobalListeners() {
98
+ if (this.listenerAttached) return;
99
+ this.doc.addEventListener("pointermove", this.handlePointerMove, true);
100
+ this.doc.addEventListener("pointerdown", this.handlePointerDown, true);
101
+ this.doc.addEventListener("pointerup", this.handlePointerUp, true);
102
+ this.listenerAttached = true;
103
+ }
104
+ detachGlobalListeners() {
105
+ if (!this.listenerAttached) return;
106
+ this.doc.removeEventListener("pointermove", this.handlePointerMove, true);
107
+ this.doc.removeEventListener("pointerdown", this.handlePointerDown, true);
108
+ this.doc.removeEventListener("pointerup", this.handlePointerUp, true);
109
+ this.listenerAttached = false;
110
+ }
111
+ getPointerType(event) {
112
+ return event.pointerType === "touch" || event.pointerType === "pen" ? "coarse" : "fine";
113
+ }
114
+ get doc() {
115
+ const firstHandle = this.handles.values().next().value;
116
+ return (0, import_dom_query.getDocument)(firstHandle?.element);
117
+ }
118
+ /**
119
+ * Fast hit-test: only checks pointer proximity to handles (no stacking order).
120
+ * Used for pointermove cursor feedback.
121
+ */
122
+ findHitHandles(x, y, pointerType) {
123
+ const intersecting = [];
124
+ const margin = this.options.hitAreaMargins[pointerType];
125
+ this.handles.forEach((handle) => {
126
+ const rect = handle.element.getBoundingClientRect();
127
+ const hit = x >= rect.left - margin && x <= rect.right + margin && y >= rect.top - margin && y <= rect.bottom + margin;
128
+ if (hit) intersecting.push(handle);
129
+ });
130
+ return intersecting;
131
+ }
132
+ /**
133
+ * Full intersection check: hit-test + stacking order verification.
134
+ * Used for pointerdown activation where correctness matters.
135
+ */
136
+ findIntersectingHandles(x, y, pointerType, eventTarget) {
137
+ const hits = this.findHitHandles(x, y, pointerType);
138
+ const targetElement = eventTarget instanceof HTMLElement || eventTarget instanceof SVGElement ? eventTarget : null;
139
+ if (!targetElement || !(0, import_dom_query.contains)(this.doc, targetElement)) return hits;
140
+ return hits.filter((handle) => {
141
+ const dragHandleElement = handle.element;
142
+ if (targetElement === dragHandleElement || (0, import_dom_query.contains)(dragHandleElement, targetElement) || (0, import_dom_query.contains)(targetElement, dragHandleElement)) {
143
+ return true;
144
+ }
145
+ try {
146
+ if ((0, import_stacking_order.compareStackingOrder)(targetElement, dragHandleElement) > 0) {
147
+ const dragHandleRect = dragHandleElement.getBoundingClientRect();
148
+ let currentElement = targetElement;
149
+ while (currentElement) {
150
+ if (currentElement.contains(dragHandleElement)) break;
151
+ const currentRect = currentElement.getBoundingClientRect();
152
+ if ((0, import_intersects.intersects)((0, import_intersects.toRect)(currentRect), (0, import_intersects.toRect)(dragHandleRect), true)) {
153
+ return false;
154
+ }
155
+ currentElement = (0, import_dom_query.getParentElement)(currentElement);
156
+ }
157
+ }
158
+ } catch {
159
+ }
160
+ return true;
161
+ });
162
+ }
163
+ updateCursor(intersecting) {
164
+ if (intersecting.length === 0) {
165
+ this.clearGlobalCursor();
166
+ return;
167
+ }
168
+ const hasHorizontal = intersecting.some((h) => h.orientation === "horizontal");
169
+ const hasVertical = intersecting.some((h) => h.orientation === "vertical");
170
+ let cursor = "default";
171
+ if (hasHorizontal && hasVertical) {
172
+ cursor = "move";
173
+ } else if (hasHorizontal) {
174
+ cursor = "ew-resize";
175
+ } else if (hasVertical) {
176
+ cursor = "ns-resize";
177
+ }
178
+ this.setGlobalCursor(cursor);
179
+ }
180
+ setGlobalCursor(cursor) {
181
+ const doc = this.doc;
182
+ let styleEl = doc.getElementById(this.globalCursorId);
183
+ const textContent = `* { cursor: ${cursor} !important; }`;
184
+ if (styleEl) {
185
+ styleEl.textContent = textContent;
186
+ } else {
187
+ styleEl = doc.createElement("style");
188
+ styleEl.id = this.globalCursorId;
189
+ styleEl.textContent = textContent;
190
+ if (this.options.nonce) {
191
+ styleEl.nonce = this.options.nonce;
192
+ }
193
+ doc.head.appendChild(styleEl);
194
+ }
195
+ }
196
+ clearGlobalCursor() {
197
+ const styleEl = this.doc.getElementById(this.globalCursorId);
198
+ styleEl?.remove();
199
+ }
200
+ };
201
+ var registry = (opts = {}) => new SplitterRegistry(opts);
202
+ // Annotate the CommonJS export names for ESM import in node:
203
+ 0 && (module.exports = {
204
+ SplitterRegistry,
205
+ registry
206
+ });
@@ -0,0 +1,182 @@
1
+ import {
2
+ __publicField
3
+ } from "../chunk-QZ7TP4HQ.mjs";
4
+
5
+ // src/utils/registry.ts
6
+ import { contains, getDocument, getParentElement } from "@zag-js/dom-query";
7
+ import { intersects, toRect } from "./intersects.mjs";
8
+ import { compareStackingOrder } from "./stacking-order.mjs";
9
+ var SplitterRegistry = class {
10
+ constructor(options = {}) {
11
+ __publicField(this, "handles", /* @__PURE__ */ new Map());
12
+ __publicField(this, "state", {
13
+ activeHandleIds: /* @__PURE__ */ new Set(),
14
+ isPointerDown: false
15
+ });
16
+ __publicField(this, "listenerAttached", false);
17
+ __publicField(this, "options");
18
+ __publicField(this, "handlePointerMove", (event) => {
19
+ if (this.state.isPointerDown) return;
20
+ const pointerType = this.getPointerType(event);
21
+ const intersecting = this.findHitHandles(event.clientX, event.clientY, pointerType);
22
+ const newActiveIds = new Set(intersecting.map((h) => h.id));
23
+ const changed = newActiveIds.size !== this.state.activeHandleIds.size || [...newActiveIds].some((id) => !this.state.activeHandleIds.has(id));
24
+ if (changed) {
25
+ this.state.activeHandleIds = newActiveIds;
26
+ this.updateCursor(intersecting);
27
+ }
28
+ });
29
+ __publicField(this, "handlePointerDown", (event) => {
30
+ const pointerType = this.getPointerType(event);
31
+ const intersecting = this.findIntersectingHandles(event.clientX, event.clientY, pointerType, event.target);
32
+ if (intersecting.length > 0) {
33
+ this.state.isPointerDown = true;
34
+ this.state.activeHandleIds = new Set(intersecting.map((h) => h.id));
35
+ const point = { x: event.clientX, y: event.clientY };
36
+ intersecting.forEach((handle) => {
37
+ handle.onActivate(point);
38
+ });
39
+ this.updateCursor(intersecting);
40
+ }
41
+ });
42
+ __publicField(this, "handlePointerUp", (_event) => {
43
+ if (this.state.isPointerDown) {
44
+ this.state.isPointerDown = false;
45
+ this.handles.forEach((handle) => {
46
+ if (this.state.activeHandleIds.has(handle.id)) {
47
+ handle.onDeactivate();
48
+ }
49
+ });
50
+ this.state.activeHandleIds.clear();
51
+ this.clearGlobalCursor();
52
+ }
53
+ });
54
+ __publicField(this, "globalCursorId", "splitter-registry-cursor");
55
+ this.options = {
56
+ nonce: options.nonce ?? "",
57
+ hitAreaMargins: {
58
+ coarse: options.hitAreaMargins?.coarse ?? 15,
59
+ fine: options.hitAreaMargins?.fine ?? 5
60
+ }
61
+ };
62
+ }
63
+ register(data) {
64
+ this.handles.set(data.id, data);
65
+ this.attachGlobalListeners();
66
+ return () => {
67
+ this.handles.delete(data.id);
68
+ this.state.activeHandleIds.delete(data.id);
69
+ if (this.handles.size === 0) {
70
+ this.detachGlobalListeners();
71
+ }
72
+ };
73
+ }
74
+ attachGlobalListeners() {
75
+ if (this.listenerAttached) return;
76
+ this.doc.addEventListener("pointermove", this.handlePointerMove, true);
77
+ this.doc.addEventListener("pointerdown", this.handlePointerDown, true);
78
+ this.doc.addEventListener("pointerup", this.handlePointerUp, true);
79
+ this.listenerAttached = true;
80
+ }
81
+ detachGlobalListeners() {
82
+ if (!this.listenerAttached) return;
83
+ this.doc.removeEventListener("pointermove", this.handlePointerMove, true);
84
+ this.doc.removeEventListener("pointerdown", this.handlePointerDown, true);
85
+ this.doc.removeEventListener("pointerup", this.handlePointerUp, true);
86
+ this.listenerAttached = false;
87
+ }
88
+ getPointerType(event) {
89
+ return event.pointerType === "touch" || event.pointerType === "pen" ? "coarse" : "fine";
90
+ }
91
+ get doc() {
92
+ const firstHandle = this.handles.values().next().value;
93
+ return getDocument(firstHandle?.element);
94
+ }
95
+ /**
96
+ * Fast hit-test: only checks pointer proximity to handles (no stacking order).
97
+ * Used for pointermove cursor feedback.
98
+ */
99
+ findHitHandles(x, y, pointerType) {
100
+ const intersecting = [];
101
+ const margin = this.options.hitAreaMargins[pointerType];
102
+ this.handles.forEach((handle) => {
103
+ const rect = handle.element.getBoundingClientRect();
104
+ const hit = x >= rect.left - margin && x <= rect.right + margin && y >= rect.top - margin && y <= rect.bottom + margin;
105
+ if (hit) intersecting.push(handle);
106
+ });
107
+ return intersecting;
108
+ }
109
+ /**
110
+ * Full intersection check: hit-test + stacking order verification.
111
+ * Used for pointerdown activation where correctness matters.
112
+ */
113
+ findIntersectingHandles(x, y, pointerType, eventTarget) {
114
+ const hits = this.findHitHandles(x, y, pointerType);
115
+ const targetElement = eventTarget instanceof HTMLElement || eventTarget instanceof SVGElement ? eventTarget : null;
116
+ if (!targetElement || !contains(this.doc, targetElement)) return hits;
117
+ return hits.filter((handle) => {
118
+ const dragHandleElement = handle.element;
119
+ if (targetElement === dragHandleElement || contains(dragHandleElement, targetElement) || contains(targetElement, dragHandleElement)) {
120
+ return true;
121
+ }
122
+ try {
123
+ if (compareStackingOrder(targetElement, dragHandleElement) > 0) {
124
+ const dragHandleRect = dragHandleElement.getBoundingClientRect();
125
+ let currentElement = targetElement;
126
+ while (currentElement) {
127
+ if (currentElement.contains(dragHandleElement)) break;
128
+ const currentRect = currentElement.getBoundingClientRect();
129
+ if (intersects(toRect(currentRect), toRect(dragHandleRect), true)) {
130
+ return false;
131
+ }
132
+ currentElement = getParentElement(currentElement);
133
+ }
134
+ }
135
+ } catch {
136
+ }
137
+ return true;
138
+ });
139
+ }
140
+ updateCursor(intersecting) {
141
+ if (intersecting.length === 0) {
142
+ this.clearGlobalCursor();
143
+ return;
144
+ }
145
+ const hasHorizontal = intersecting.some((h) => h.orientation === "horizontal");
146
+ const hasVertical = intersecting.some((h) => h.orientation === "vertical");
147
+ let cursor = "default";
148
+ if (hasHorizontal && hasVertical) {
149
+ cursor = "move";
150
+ } else if (hasHorizontal) {
151
+ cursor = "ew-resize";
152
+ } else if (hasVertical) {
153
+ cursor = "ns-resize";
154
+ }
155
+ this.setGlobalCursor(cursor);
156
+ }
157
+ setGlobalCursor(cursor) {
158
+ const doc = this.doc;
159
+ let styleEl = doc.getElementById(this.globalCursorId);
160
+ const textContent = `* { cursor: ${cursor} !important; }`;
161
+ if (styleEl) {
162
+ styleEl.textContent = textContent;
163
+ } else {
164
+ styleEl = doc.createElement("style");
165
+ styleEl.id = this.globalCursorId;
166
+ styleEl.textContent = textContent;
167
+ if (this.options.nonce) {
168
+ styleEl.nonce = this.options.nonce;
169
+ }
170
+ doc.head.appendChild(styleEl);
171
+ }
172
+ }
173
+ clearGlobalCursor() {
174
+ const styleEl = this.doc.getElementById(this.globalCursorId);
175
+ styleEl?.remove();
176
+ }
177
+ };
178
+ var registry = (opts = {}) => new SplitterRegistry(opts);
179
+ export {
180
+ SplitterRegistry,
181
+ registry
182
+ };
@@ -1,6 +1,7 @@
1
1
  import { PanelData } from '../splitter.types.mjs';
2
2
  import '@zag-js/core';
3
3
  import '@zag-js/types';
4
+ import './registry.mjs';
4
5
 
5
6
  /**
6
7
  * This code was modified from react-resizable-panels by Brian Vaughn
@@ -1,6 +1,7 @@
1
1
  import { PanelData } from '../splitter.types.js';
2
2
  import '@zag-js/core';
3
3
  import '@zag-js/types';
4
+ import './registry.js';
4
5
 
5
6
  /**
6
7
  * This code was modified from react-resizable-panels by Brian Vaughn
@@ -1,3 +1,5 @@
1
+ import "../chunk-QZ7TP4HQ.mjs";
2
+
1
3
  // src/utils/resize-by-delta.ts
2
4
  import { ensure } from "@zag-js/utils";
3
5
  import { fuzzyCompareNumbers, fuzzySizeEqual, fuzzyNumbersEqual } from "./fuzzy.mjs";
@@ -1,6 +1,7 @@
1
1
  import { PanelData } from '../splitter.types.mjs';
2
2
  import '@zag-js/core';
3
3
  import '@zag-js/types';
4
+ import './registry.mjs';
4
5
 
5
6
  /**
6
7
  * This code was modified from react-resizable-panels by Brian Vaughn
@@ -1,6 +1,7 @@
1
1
  import { PanelData } from '../splitter.types.js';
2
2
  import '@zag-js/core';
3
3
  import '@zag-js/types';
4
+ import './registry.js';
4
5
 
5
6
  /**
6
7
  * This code was modified from react-resizable-panels by Brian Vaughn
@@ -1,3 +1,5 @@
1
+ import "../chunk-QZ7TP4HQ.mjs";
2
+
1
3
  // src/utils/resize-panel.ts
2
4
  import { ensure } from "@zag-js/utils";
3
5
  import { fuzzyCompareNumbers, PRECISION } from "./fuzzy.mjs";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Determine which of two nodes appears in front of the other —
3
+ * if `a` is in front, returns 1, otherwise returns -1
4
+ * @param a First element
5
+ * @param b Second element
6
+ */
7
+ declare function compareStackingOrder(a: Element, b: Element): number;
8
+
9
+ export { compareStackingOrder };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Determine which of two nodes appears in front of the other —
3
+ * if `a` is in front, returns 1, otherwise returns -1
4
+ * @param a First element
5
+ * @param b Second element
6
+ */
7
+ declare function compareStackingOrder(a: Element, b: Element): number;
8
+
9
+ export { compareStackingOrder };
@@ -0,0 +1,99 @@
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/utils/stacking-order.ts
21
+ var stacking_order_exports = {};
22
+ __export(stacking_order_exports, {
23
+ compareStackingOrder: () => compareStackingOrder
24
+ });
25
+ module.exports = __toCommonJS(stacking_order_exports);
26
+ var import_dom_query = require("@zag-js/dom-query");
27
+ var import_utils = require("@zag-js/utils");
28
+ function compareStackingOrder(a, b) {
29
+ if (a === b) throw new Error("Cannot compare node with itself");
30
+ const ancestors = {
31
+ a: (0, import_dom_query.getAncestorElements)(a),
32
+ b: (0, import_dom_query.getAncestorElements)(b)
33
+ };
34
+ let commonAncestor = null;
35
+ while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
36
+ const currentA = ancestors.a.pop();
37
+ ancestors.b.pop();
38
+ commonAncestor = currentA;
39
+ }
40
+ (0, import_utils.ensure)(
41
+ commonAncestor,
42
+ () => "[stacking-order] Stacking order can only be calculated for elements with a common ancestor"
43
+ );
44
+ const zIndexes = {
45
+ a: getZIndex(findStackingContext(ancestors.a)),
46
+ b: getZIndex(findStackingContext(ancestors.b))
47
+ };
48
+ if (zIndexes.a === zIndexes.b) {
49
+ const children = commonAncestor.childNodes;
50
+ const furthestAncestors = {
51
+ a: ancestors.a.at(-1),
52
+ b: ancestors.b.at(-1)
53
+ };
54
+ let i = children.length;
55
+ while (i--) {
56
+ const child = children[i];
57
+ if (child === furthestAncestors.a) return 1;
58
+ if (child === furthestAncestors.b) return -1;
59
+ }
60
+ }
61
+ return Math.sign(zIndexes.a - zIndexes.b);
62
+ }
63
+ var STACKING_PROPS_REGEX = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
64
+ function isFlexItem(node) {
65
+ const parent = (0, import_dom_query.getParentElement)(node);
66
+ const display = (0, import_dom_query.getComputedStyle)(parent ?? node).display;
67
+ return display === "flex" || display === "inline-flex";
68
+ }
69
+ function createsStackingContext(node) {
70
+ const style = (0, import_dom_query.getComputedStyle)(node);
71
+ if (style.position === "fixed") return true;
72
+ if (style.zIndex !== "auto" && (style.position !== "static" || isFlexItem(node))) return true;
73
+ if (+style.opacity < 1) return true;
74
+ if ((0, import_utils.hasProp)(style, "transform") && style.transform !== "none") return true;
75
+ if ((0, import_utils.hasProp)(style, "webkitTransform") && style.webkitTransform !== "none") return true;
76
+ if ((0, import_utils.hasProp)(style, "mixBlendMode") && style.mixBlendMode !== "normal") return true;
77
+ if ((0, import_utils.hasProp)(style, "filter") && style.filter !== "none") return true;
78
+ if ((0, import_utils.hasProp)(style, "webkitFilter") && style.webkitFilter !== "none") return true;
79
+ if ((0, import_utils.hasProp)(style, "isolation") && style.isolation === "isolate") return true;
80
+ if (STACKING_PROPS_REGEX.test(style.willChange)) return true;
81
+ if (style.webkitOverflowScrolling === "touch") return true;
82
+ return false;
83
+ }
84
+ function findStackingContext(nodes) {
85
+ let i = nodes.length;
86
+ while (i--) {
87
+ const node = nodes[i];
88
+ (0, import_utils.ensure)(node, () => "[stacking-order] missing node in findStackingContext");
89
+ if (createsStackingContext(node)) return node;
90
+ }
91
+ return null;
92
+ }
93
+ var getZIndex = (node) => {
94
+ return node && Number((0, import_dom_query.getComputedStyle)(node).zIndex) || 0;
95
+ };
96
+ // Annotate the CommonJS export names for ESM import in node:
97
+ 0 && (module.exports = {
98
+ compareStackingOrder
99
+ });