@andrewcyuan/focusgrid 0.2.1 → 0.3.0
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/README.md +19 -18
- package/dist/core/index.cjs +194 -299
- package/dist/core/index.d.cts +18 -11
- package/dist/core/index.d.ts +18 -11
- package/dist/core/index.js +195 -299
- package/dist/dom/index.cjs +59 -145
- package/dist/dom/index.d.cts +0 -2
- package/dist/dom/index.d.ts +0 -2
- package/dist/dom/index.js +59 -145
- package/dist/react/index.cjs +52 -53
- package/dist/react/index.d.cts +22 -21
- package/dist/react/index.d.ts +22 -21
- package/dist/react/index.js +53 -54
- package/dist/react/styles.css +1 -1
- package/package.json +18 -24
package/dist/dom/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("@andrewcyuan/focusgrid/core");
|
|
3
2
|
//#region dom/src/controller.ts
|
|
4
|
-
/** Attach the renderer root; pane elements are resolved only when focus is requested. */
|
|
5
3
|
var FocusGridDomController = class {
|
|
6
4
|
root = null;
|
|
7
5
|
setRoot(root) {
|
|
@@ -19,160 +17,83 @@ var FocusGridDomController = class {
|
|
|
19
17
|
}
|
|
20
18
|
};
|
|
21
19
|
//#endregion
|
|
22
|
-
//#region dom/src/
|
|
20
|
+
//#region dom/src/pointer-resize.ts
|
|
23
21
|
function requestFrame(callback) {
|
|
24
|
-
if (typeof
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
kind: "timeout",
|
|
30
|
-
id: globalThis.setTimeout(callback, 0)
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function cancelFrame(frame) {
|
|
34
|
-
if (frame.kind === "animation") {
|
|
35
|
-
globalThis.cancelAnimationFrame(frame.id);
|
|
36
|
-
return;
|
|
22
|
+
if (typeof requestAnimationFrame === "function") {
|
|
23
|
+
const id = requestAnimationFrame(callback);
|
|
24
|
+
return () => cancelAnimationFrame(id);
|
|
37
25
|
}
|
|
38
|
-
|
|
26
|
+
const id = setTimeout(callback, 0);
|
|
27
|
+
return () => clearTimeout(id);
|
|
39
28
|
}
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region dom/src/pointer-resize.ts
|
|
42
29
|
var PointerResizeController = class {
|
|
43
30
|
controller;
|
|
44
|
-
|
|
45
|
-
onDocumentPointerMove = (event) => {
|
|
46
|
-
this.updateResize(event);
|
|
47
|
-
};
|
|
48
|
-
onDocumentPointerUp = (event) => {
|
|
49
|
-
this.endResize(event);
|
|
50
|
-
};
|
|
51
|
-
onDocumentPointerCancel = (event) => {
|
|
52
|
-
this.endResize(event);
|
|
53
|
-
};
|
|
31
|
+
drag = null;
|
|
54
32
|
constructor(controller) {
|
|
55
33
|
this.controller = controller;
|
|
56
34
|
}
|
|
57
35
|
startResize(event, handle, captureTarget) {
|
|
58
36
|
event.preventDefault();
|
|
59
37
|
this.destroy();
|
|
60
|
-
const ownerDocument = this.resolveOwnerDocument(event, captureTarget);
|
|
61
|
-
const pointerCaptureTarget = this.resolveCaptureTarget(captureTarget);
|
|
62
38
|
const startSizes = this.controller.getSplitSizes(handle.splitId);
|
|
63
39
|
if (!startSizes) return;
|
|
64
|
-
this.
|
|
65
|
-
phase: "dragging",
|
|
40
|
+
this.drag = {
|
|
66
41
|
pointerId: event.pointerId,
|
|
67
|
-
|
|
68
|
-
index: handle.index,
|
|
42
|
+
handle,
|
|
69
43
|
startX: event.clientX,
|
|
70
44
|
startY: event.clientY,
|
|
71
|
-
direction: handle.direction,
|
|
72
45
|
startSizes,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
pendingFrame: null
|
|
46
|
+
captureTarget,
|
|
47
|
+
deltaPx: 0,
|
|
48
|
+
cancelFrame: null
|
|
77
49
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.
|
|
94
|
-
...this.state,
|
|
95
|
-
pendingFrame: null
|
|
96
|
-
};
|
|
97
|
-
this.dispatchPendingResize();
|
|
50
|
+
try {
|
|
51
|
+
captureTarget.setPointerCapture(event.pointerId);
|
|
52
|
+
} catch {}
|
|
53
|
+
const ownerDocument = captureTarget.ownerDocument;
|
|
54
|
+
ownerDocument.addEventListener("pointermove", this.updateResize);
|
|
55
|
+
ownerDocument.addEventListener("pointerup", this.endResize);
|
|
56
|
+
ownerDocument.addEventListener("pointercancel", this.endResize);
|
|
57
|
+
}
|
|
58
|
+
updateResize = (event) => {
|
|
59
|
+
const drag = this.drag;
|
|
60
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
61
|
+
drag.deltaPx = drag.handle.direction === "horizontal" ? event.clientX - drag.startX : event.clientY - drag.startY;
|
|
62
|
+
if (drag.cancelFrame) return;
|
|
63
|
+
drag.cancelFrame = requestFrame(() => {
|
|
64
|
+
drag.cancelFrame = null;
|
|
65
|
+
this.applyResize(drag);
|
|
98
66
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.
|
|
109
|
-
}
|
|
67
|
+
};
|
|
68
|
+
endResize = (event) => {
|
|
69
|
+
const drag = this.drag;
|
|
70
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
71
|
+
if (drag.cancelFrame) {
|
|
72
|
+
drag.cancelFrame();
|
|
73
|
+
drag.cancelFrame = null;
|
|
74
|
+
this.applyResize(drag);
|
|
75
|
+
}
|
|
76
|
+
this.destroy();
|
|
77
|
+
};
|
|
110
78
|
destroy() {
|
|
111
|
-
this.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
this.
|
|
118
|
-
this.releasePointerCapture(captureTarget, pointerId);
|
|
119
|
-
this.state = { phase: "idle" };
|
|
120
|
-
}
|
|
121
|
-
flushPendingFrame() {
|
|
122
|
-
if (this.state.phase !== "dragging" || !this.state.pendingFrame) return;
|
|
123
|
-
cancelFrame(this.state.pendingFrame);
|
|
124
|
-
this.state = {
|
|
125
|
-
...this.state,
|
|
126
|
-
pendingFrame: null
|
|
127
|
-
};
|
|
128
|
-
this.dispatchPendingResize();
|
|
129
|
-
}
|
|
130
|
-
dispatchPendingResize() {
|
|
131
|
-
if (this.state.phase !== "dragging") return;
|
|
132
|
-
this.controller.resizeHandle(this.state.splitId, {
|
|
133
|
-
index: this.state.index,
|
|
134
|
-
deltaPx: this.state.pendingDeltaPx,
|
|
135
|
-
snapshotSizes: this.state.startSizes
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
cancelPendingFrame() {
|
|
139
|
-
if (this.state.phase !== "dragging" || !this.state.pendingFrame) return;
|
|
140
|
-
cancelFrame(this.state.pendingFrame);
|
|
141
|
-
this.state = {
|
|
142
|
-
...this.state,
|
|
143
|
-
pendingFrame: null
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
addDocumentListeners(ownerDocument) {
|
|
147
|
-
ownerDocument?.addEventListener("pointermove", this.onDocumentPointerMove);
|
|
148
|
-
ownerDocument?.addEventListener("pointerup", this.onDocumentPointerUp);
|
|
149
|
-
ownerDocument?.addEventListener("pointercancel", this.onDocumentPointerCancel);
|
|
150
|
-
}
|
|
151
|
-
removeDocumentListeners(ownerDocument) {
|
|
152
|
-
ownerDocument?.removeEventListener("pointermove", this.onDocumentPointerMove);
|
|
153
|
-
ownerDocument?.removeEventListener("pointerup", this.onDocumentPointerUp);
|
|
154
|
-
ownerDocument?.removeEventListener("pointercancel", this.onDocumentPointerCancel);
|
|
155
|
-
}
|
|
156
|
-
resolveOwnerDocument(event, captureTarget) {
|
|
157
|
-
if (captureTarget?.ownerDocument) return captureTarget.ownerDocument;
|
|
158
|
-
if (typeof Element !== "undefined" && event.target instanceof Element && event.target.ownerDocument) return event.target.ownerDocument;
|
|
159
|
-
return typeof document === "undefined" ? null : document;
|
|
160
|
-
}
|
|
161
|
-
resolveCaptureTarget(captureTarget) {
|
|
162
|
-
if (!captureTarget) return null;
|
|
163
|
-
if ("setPointerCapture" in captureTarget || "releasePointerCapture" in captureTarget) return captureTarget;
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
setPointerCapture(target, pointerId) {
|
|
79
|
+
const drag = this.drag;
|
|
80
|
+
if (!drag) return;
|
|
81
|
+
drag.cancelFrame?.();
|
|
82
|
+
const ownerDocument = drag.captureTarget.ownerDocument;
|
|
83
|
+
ownerDocument.removeEventListener("pointermove", this.updateResize);
|
|
84
|
+
ownerDocument.removeEventListener("pointerup", this.endResize);
|
|
85
|
+
ownerDocument.removeEventListener("pointercancel", this.endResize);
|
|
167
86
|
try {
|
|
168
|
-
|
|
87
|
+
drag.captureTarget.releasePointerCapture(drag.pointerId);
|
|
169
88
|
} catch {}
|
|
89
|
+
this.drag = null;
|
|
170
90
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
91
|
+
applyResize(drag) {
|
|
92
|
+
this.controller.resizeHandle(drag.handle.splitId, {
|
|
93
|
+
index: drag.handle.index,
|
|
94
|
+
deltaPx: drag.deltaPx,
|
|
95
|
+
snapshotSizes: drag.startSizes
|
|
96
|
+
});
|
|
176
97
|
}
|
|
177
98
|
};
|
|
178
99
|
//#endregion
|
|
@@ -224,16 +145,10 @@ const INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
|
|
|
224
145
|
"treegrid",
|
|
225
146
|
"treeitem"
|
|
226
147
|
]);
|
|
227
|
-
function hasInteractiveOwner(target, boundary) {
|
|
228
|
-
let element = target;
|
|
229
|
-
while (element && element !== boundary) {
|
|
230
|
-
if (element instanceof HTMLElement && isInteractiveElement(element)) return true;
|
|
231
|
-
element = element.parentElement;
|
|
232
|
-
}
|
|
233
|
-
return boundary instanceof HTMLElement && isInteractiveElement(boundary);
|
|
234
|
-
}
|
|
235
148
|
function shouldFocusPaneShellForPointer(target, paneShell) {
|
|
236
|
-
|
|
149
|
+
if (target === paneShell) return true;
|
|
150
|
+
for (let element = target; element && element !== paneShell; element = element.parentElement) if (element instanceof HTMLElement && isInteractiveElement(element)) return false;
|
|
151
|
+
return !isInteractiveElement(paneShell);
|
|
237
152
|
}
|
|
238
153
|
function isInteractiveElement(element) {
|
|
239
154
|
if (isUnavailableElement(element)) return false;
|
|
@@ -244,7 +159,7 @@ function isInteractiveElement(element) {
|
|
|
244
159
|
function isUnavailableElement(element) {
|
|
245
160
|
let current = element;
|
|
246
161
|
while (current) {
|
|
247
|
-
if (current.hidden || current.hasAttribute("
|
|
162
|
+
if (current.hidden || current.hasAttribute("inert") || current.getAttribute("aria-hidden") === "true" || current.getAttribute("aria-disabled") === "true" || "disabled" in current && Boolean(current.disabled)) return true;
|
|
248
163
|
const view = current.ownerDocument.defaultView;
|
|
249
164
|
if (view) {
|
|
250
165
|
const style = view.getComputedStyle(current);
|
|
@@ -276,7 +191,6 @@ function isEditableTarget(target) {
|
|
|
276
191
|
}
|
|
277
192
|
//#endregion
|
|
278
193
|
//#region dom/src/mount.ts
|
|
279
|
-
/** Own native grid interactions; React only attaches and detaches the root. */
|
|
280
194
|
function mountFocusGrid(root, controller, dom) {
|
|
281
195
|
dom.setRoot(root);
|
|
282
196
|
const resize = new PointerResizeController(controller);
|
|
@@ -293,7 +207,7 @@ function mountFocusGrid(root, controller, dom) {
|
|
|
293
207
|
if (!target) return;
|
|
294
208
|
const separator = target.closest("[data-resize-handle]");
|
|
295
209
|
if (separator) {
|
|
296
|
-
const handle = controller.getLayout().handles.find((
|
|
210
|
+
const handle = controller.getLayout().handles.find((candidate) => candidate.id === separator.dataset.resizeHandle);
|
|
297
211
|
if (handle) resize.startResize(event, handle, separator);
|
|
298
212
|
return;
|
|
299
213
|
}
|
package/dist/dom/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DomController, FocusGridController, PaneId } from "@andrewcyuan/focusgrid/core";
|
|
2
2
|
|
|
3
3
|
//#region dom/src/controller.d.ts
|
|
4
|
-
/** Attach the renderer root; pane elements are resolved only when focus is requested. */
|
|
5
4
|
declare class FocusGridDomController implements DomController {
|
|
6
5
|
private root;
|
|
7
6
|
setRoot(root: HTMLElement | null): void;
|
|
@@ -9,7 +8,6 @@ declare class FocusGridDomController implements DomController {
|
|
|
9
8
|
}
|
|
10
9
|
//#endregion
|
|
11
10
|
//#region dom/src/mount.d.ts
|
|
12
|
-
/** Own native grid interactions; React only attaches and detaches the root. */
|
|
13
11
|
declare function mountFocusGrid(root: HTMLElement, controller: FocusGridController, dom: FocusGridDomController): () => void;
|
|
14
12
|
//#endregion
|
|
15
13
|
//#region dom/src/interactivity.d.ts
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DomController, FocusGridController, PaneId } from "@andrewcyuan/focusgrid/core";
|
|
2
2
|
|
|
3
3
|
//#region dom/src/controller.d.ts
|
|
4
|
-
/** Attach the renderer root; pane elements are resolved only when focus is requested. */
|
|
5
4
|
declare class FocusGridDomController implements DomController {
|
|
6
5
|
private root;
|
|
7
6
|
setRoot(root: HTMLElement | null): void;
|
|
@@ -9,7 +8,6 @@ declare class FocusGridDomController implements DomController {
|
|
|
9
8
|
}
|
|
10
9
|
//#endregion
|
|
11
10
|
//#region dom/src/mount.d.ts
|
|
12
|
-
/** Own native grid interactions; React only attaches and detaches the root. */
|
|
13
11
|
declare function mountFocusGrid(root: HTMLElement, controller: FocusGridController, dom: FocusGridDomController): () => void;
|
|
14
12
|
//#endregion
|
|
15
13
|
//#region dom/src/interactivity.d.ts
|
package/dist/dom/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import "@andrewcyuan/focusgrid/core";
|
|
2
1
|
//#region dom/src/controller.ts
|
|
3
|
-
/** Attach the renderer root; pane elements are resolved only when focus is requested. */
|
|
4
2
|
var FocusGridDomController = class {
|
|
5
3
|
root = null;
|
|
6
4
|
setRoot(root) {
|
|
@@ -18,160 +16,83 @@ var FocusGridDomController = class {
|
|
|
18
16
|
}
|
|
19
17
|
};
|
|
20
18
|
//#endregion
|
|
21
|
-
//#region dom/src/
|
|
19
|
+
//#region dom/src/pointer-resize.ts
|
|
22
20
|
function requestFrame(callback) {
|
|
23
|
-
if (typeof
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
return {
|
|
28
|
-
kind: "timeout",
|
|
29
|
-
id: globalThis.setTimeout(callback, 0)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function cancelFrame(frame) {
|
|
33
|
-
if (frame.kind === "animation") {
|
|
34
|
-
globalThis.cancelAnimationFrame(frame.id);
|
|
35
|
-
return;
|
|
21
|
+
if (typeof requestAnimationFrame === "function") {
|
|
22
|
+
const id = requestAnimationFrame(callback);
|
|
23
|
+
return () => cancelAnimationFrame(id);
|
|
36
24
|
}
|
|
37
|
-
|
|
25
|
+
const id = setTimeout(callback, 0);
|
|
26
|
+
return () => clearTimeout(id);
|
|
38
27
|
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region dom/src/pointer-resize.ts
|
|
41
28
|
var PointerResizeController = class {
|
|
42
29
|
controller;
|
|
43
|
-
|
|
44
|
-
onDocumentPointerMove = (event) => {
|
|
45
|
-
this.updateResize(event);
|
|
46
|
-
};
|
|
47
|
-
onDocumentPointerUp = (event) => {
|
|
48
|
-
this.endResize(event);
|
|
49
|
-
};
|
|
50
|
-
onDocumentPointerCancel = (event) => {
|
|
51
|
-
this.endResize(event);
|
|
52
|
-
};
|
|
30
|
+
drag = null;
|
|
53
31
|
constructor(controller) {
|
|
54
32
|
this.controller = controller;
|
|
55
33
|
}
|
|
56
34
|
startResize(event, handle, captureTarget) {
|
|
57
35
|
event.preventDefault();
|
|
58
36
|
this.destroy();
|
|
59
|
-
const ownerDocument = this.resolveOwnerDocument(event, captureTarget);
|
|
60
|
-
const pointerCaptureTarget = this.resolveCaptureTarget(captureTarget);
|
|
61
37
|
const startSizes = this.controller.getSplitSizes(handle.splitId);
|
|
62
38
|
if (!startSizes) return;
|
|
63
|
-
this.
|
|
64
|
-
phase: "dragging",
|
|
39
|
+
this.drag = {
|
|
65
40
|
pointerId: event.pointerId,
|
|
66
|
-
|
|
67
|
-
index: handle.index,
|
|
41
|
+
handle,
|
|
68
42
|
startX: event.clientX,
|
|
69
43
|
startY: event.clientY,
|
|
70
|
-
direction: handle.direction,
|
|
71
44
|
startSizes,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
pendingFrame: null
|
|
45
|
+
captureTarget,
|
|
46
|
+
deltaPx: 0,
|
|
47
|
+
cancelFrame: null
|
|
76
48
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.
|
|
93
|
-
...this.state,
|
|
94
|
-
pendingFrame: null
|
|
95
|
-
};
|
|
96
|
-
this.dispatchPendingResize();
|
|
49
|
+
try {
|
|
50
|
+
captureTarget.setPointerCapture(event.pointerId);
|
|
51
|
+
} catch {}
|
|
52
|
+
const ownerDocument = captureTarget.ownerDocument;
|
|
53
|
+
ownerDocument.addEventListener("pointermove", this.updateResize);
|
|
54
|
+
ownerDocument.addEventListener("pointerup", this.endResize);
|
|
55
|
+
ownerDocument.addEventListener("pointercancel", this.endResize);
|
|
56
|
+
}
|
|
57
|
+
updateResize = (event) => {
|
|
58
|
+
const drag = this.drag;
|
|
59
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
60
|
+
drag.deltaPx = drag.handle.direction === "horizontal" ? event.clientX - drag.startX : event.clientY - drag.startY;
|
|
61
|
+
if (drag.cancelFrame) return;
|
|
62
|
+
drag.cancelFrame = requestFrame(() => {
|
|
63
|
+
drag.cancelFrame = null;
|
|
64
|
+
this.applyResize(drag);
|
|
97
65
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.
|
|
108
|
-
}
|
|
66
|
+
};
|
|
67
|
+
endResize = (event) => {
|
|
68
|
+
const drag = this.drag;
|
|
69
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
70
|
+
if (drag.cancelFrame) {
|
|
71
|
+
drag.cancelFrame();
|
|
72
|
+
drag.cancelFrame = null;
|
|
73
|
+
this.applyResize(drag);
|
|
74
|
+
}
|
|
75
|
+
this.destroy();
|
|
76
|
+
};
|
|
109
77
|
destroy() {
|
|
110
|
-
this.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this.
|
|
117
|
-
this.releasePointerCapture(captureTarget, pointerId);
|
|
118
|
-
this.state = { phase: "idle" };
|
|
119
|
-
}
|
|
120
|
-
flushPendingFrame() {
|
|
121
|
-
if (this.state.phase !== "dragging" || !this.state.pendingFrame) return;
|
|
122
|
-
cancelFrame(this.state.pendingFrame);
|
|
123
|
-
this.state = {
|
|
124
|
-
...this.state,
|
|
125
|
-
pendingFrame: null
|
|
126
|
-
};
|
|
127
|
-
this.dispatchPendingResize();
|
|
128
|
-
}
|
|
129
|
-
dispatchPendingResize() {
|
|
130
|
-
if (this.state.phase !== "dragging") return;
|
|
131
|
-
this.controller.resizeHandle(this.state.splitId, {
|
|
132
|
-
index: this.state.index,
|
|
133
|
-
deltaPx: this.state.pendingDeltaPx,
|
|
134
|
-
snapshotSizes: this.state.startSizes
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
cancelPendingFrame() {
|
|
138
|
-
if (this.state.phase !== "dragging" || !this.state.pendingFrame) return;
|
|
139
|
-
cancelFrame(this.state.pendingFrame);
|
|
140
|
-
this.state = {
|
|
141
|
-
...this.state,
|
|
142
|
-
pendingFrame: null
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
addDocumentListeners(ownerDocument) {
|
|
146
|
-
ownerDocument?.addEventListener("pointermove", this.onDocumentPointerMove);
|
|
147
|
-
ownerDocument?.addEventListener("pointerup", this.onDocumentPointerUp);
|
|
148
|
-
ownerDocument?.addEventListener("pointercancel", this.onDocumentPointerCancel);
|
|
149
|
-
}
|
|
150
|
-
removeDocumentListeners(ownerDocument) {
|
|
151
|
-
ownerDocument?.removeEventListener("pointermove", this.onDocumentPointerMove);
|
|
152
|
-
ownerDocument?.removeEventListener("pointerup", this.onDocumentPointerUp);
|
|
153
|
-
ownerDocument?.removeEventListener("pointercancel", this.onDocumentPointerCancel);
|
|
154
|
-
}
|
|
155
|
-
resolveOwnerDocument(event, captureTarget) {
|
|
156
|
-
if (captureTarget?.ownerDocument) return captureTarget.ownerDocument;
|
|
157
|
-
if (typeof Element !== "undefined" && event.target instanceof Element && event.target.ownerDocument) return event.target.ownerDocument;
|
|
158
|
-
return typeof document === "undefined" ? null : document;
|
|
159
|
-
}
|
|
160
|
-
resolveCaptureTarget(captureTarget) {
|
|
161
|
-
if (!captureTarget) return null;
|
|
162
|
-
if ("setPointerCapture" in captureTarget || "releasePointerCapture" in captureTarget) return captureTarget;
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
setPointerCapture(target, pointerId) {
|
|
78
|
+
const drag = this.drag;
|
|
79
|
+
if (!drag) return;
|
|
80
|
+
drag.cancelFrame?.();
|
|
81
|
+
const ownerDocument = drag.captureTarget.ownerDocument;
|
|
82
|
+
ownerDocument.removeEventListener("pointermove", this.updateResize);
|
|
83
|
+
ownerDocument.removeEventListener("pointerup", this.endResize);
|
|
84
|
+
ownerDocument.removeEventListener("pointercancel", this.endResize);
|
|
166
85
|
try {
|
|
167
|
-
|
|
86
|
+
drag.captureTarget.releasePointerCapture(drag.pointerId);
|
|
168
87
|
} catch {}
|
|
88
|
+
this.drag = null;
|
|
169
89
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
90
|
+
applyResize(drag) {
|
|
91
|
+
this.controller.resizeHandle(drag.handle.splitId, {
|
|
92
|
+
index: drag.handle.index,
|
|
93
|
+
deltaPx: drag.deltaPx,
|
|
94
|
+
snapshotSizes: drag.startSizes
|
|
95
|
+
});
|
|
175
96
|
}
|
|
176
97
|
};
|
|
177
98
|
//#endregion
|
|
@@ -223,16 +144,10 @@ const INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
|
|
|
223
144
|
"treegrid",
|
|
224
145
|
"treeitem"
|
|
225
146
|
]);
|
|
226
|
-
function hasInteractiveOwner(target, boundary) {
|
|
227
|
-
let element = target;
|
|
228
|
-
while (element && element !== boundary) {
|
|
229
|
-
if (element instanceof HTMLElement && isInteractiveElement(element)) return true;
|
|
230
|
-
element = element.parentElement;
|
|
231
|
-
}
|
|
232
|
-
return boundary instanceof HTMLElement && isInteractiveElement(boundary);
|
|
233
|
-
}
|
|
234
147
|
function shouldFocusPaneShellForPointer(target, paneShell) {
|
|
235
|
-
|
|
148
|
+
if (target === paneShell) return true;
|
|
149
|
+
for (let element = target; element && element !== paneShell; element = element.parentElement) if (element instanceof HTMLElement && isInteractiveElement(element)) return false;
|
|
150
|
+
return !isInteractiveElement(paneShell);
|
|
236
151
|
}
|
|
237
152
|
function isInteractiveElement(element) {
|
|
238
153
|
if (isUnavailableElement(element)) return false;
|
|
@@ -243,7 +158,7 @@ function isInteractiveElement(element) {
|
|
|
243
158
|
function isUnavailableElement(element) {
|
|
244
159
|
let current = element;
|
|
245
160
|
while (current) {
|
|
246
|
-
if (current.hidden || current.hasAttribute("
|
|
161
|
+
if (current.hidden || current.hasAttribute("inert") || current.getAttribute("aria-hidden") === "true" || current.getAttribute("aria-disabled") === "true" || "disabled" in current && Boolean(current.disabled)) return true;
|
|
247
162
|
const view = current.ownerDocument.defaultView;
|
|
248
163
|
if (view) {
|
|
249
164
|
const style = view.getComputedStyle(current);
|
|
@@ -275,7 +190,6 @@ function isEditableTarget(target) {
|
|
|
275
190
|
}
|
|
276
191
|
//#endregion
|
|
277
192
|
//#region dom/src/mount.ts
|
|
278
|
-
/** Own native grid interactions; React only attaches and detaches the root. */
|
|
279
193
|
function mountFocusGrid(root, controller, dom) {
|
|
280
194
|
dom.setRoot(root);
|
|
281
195
|
const resize = new PointerResizeController(controller);
|
|
@@ -292,7 +206,7 @@ function mountFocusGrid(root, controller, dom) {
|
|
|
292
206
|
if (!target) return;
|
|
293
207
|
const separator = target.closest("[data-resize-handle]");
|
|
294
208
|
if (separator) {
|
|
295
|
-
const handle = controller.getLayout().handles.find((
|
|
209
|
+
const handle = controller.getLayout().handles.find((candidate) => candidate.id === separator.dataset.resizeHandle);
|
|
296
210
|
if (handle) resize.startResize(event, handle, separator);
|
|
297
211
|
return;
|
|
298
212
|
}
|