@ai-matrx/summon 0.1.3 → 0.1.5
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/CHANGELOG.md +4 -1
- package/README.md +22 -2
- package/dist/dock.cjs +552 -0
- package/dist/dock.cjs.map +1 -0
- package/dist/dock.d.cts +224 -0
- package/dist/dock.d.ts +224 -0
- package/dist/dock.js +537 -0
- package/dist/dock.js.map +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/persistence-data.cjs +9 -0
- package/dist/persistence-data.cjs.map +1 -1
- package/dist/persistence-data.d.cts +2 -1
- package/dist/persistence-data.d.ts +2 -1
- package/dist/persistence-data.js +9 -0
- package/dist/persistence-data.js.map +1 -1
- package/dist/persistence.cjs +6 -4
- package/dist/persistence.cjs.map +1 -1
- package/dist/persistence.js +6 -4
- package/dist/persistence.js.map +1 -1
- package/dist/react.cjs +19 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +8 -1
- package/dist/react.d.ts +8 -1
- package/dist/react.js +19 -0
- package/dist/react.js.map +1 -1
- package/dist/url.cjs +32 -50
- package/dist/url.cjs.map +1 -1
- package/dist/url.d.cts +2 -8
- package/dist/url.d.ts +2 -8
- package/dist/url.js +8 -24
- package/dist/url.js.map +1 -1
- package/dist/window-host.cjs +43 -1
- package/dist/window-host.cjs.map +1 -1
- package/dist/window-host.d.cts +45 -1
- package/dist/window-host.d.ts +45 -1
- package/dist/window-host.js +44 -2
- package/dist/window-host.js.map +1 -1
- package/dist/window.cjs +127 -149
- package/dist/window.cjs.map +1 -1
- package/dist/window.d.cts +2 -46
- package/dist/window.d.ts +2 -46
- package/dist/window.js +14 -34
- package/dist/window.js.map +1 -1
- package/package.json +14 -4
package/dist/dock.js
ADDED
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/dock/Dock.tsx
|
|
4
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
5
|
+
|
|
6
|
+
// src/dock/useDock.ts
|
|
7
|
+
import {
|
|
8
|
+
useCallback,
|
|
9
|
+
useEffect,
|
|
10
|
+
useLayoutEffect,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
useSyncExternalStore
|
|
14
|
+
} from "react";
|
|
15
|
+
import { holdDragCursor } from "@ai-matrx/design-system";
|
|
16
|
+
import { raiseTransientWindow, releaseTransientWindow } from "@ai-matrx/summon";
|
|
17
|
+
import { useOptionalSummonStore } from "@ai-matrx/summon/react";
|
|
18
|
+
|
|
19
|
+
// src/dock/geometry.ts
|
|
20
|
+
var DEFAULT_DOCK_MARGIN = 8;
|
|
21
|
+
var DEFAULT_DRAG_THRESHOLD = 4;
|
|
22
|
+
var fromLeft = (corner) => corner.endsWith("left");
|
|
23
|
+
var fromTop = (corner) => corner.startsWith("top");
|
|
24
|
+
function toScreen(offset, corner, size, viewport) {
|
|
25
|
+
return {
|
|
26
|
+
left: fromLeft(corner) ? offset.x : viewport.width - size.width - offset.x,
|
|
27
|
+
top: fromTop(corner) ? offset.y : viewport.height - size.height - offset.y
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function fromScreen(point, corner, size, viewport) {
|
|
31
|
+
return {
|
|
32
|
+
x: fromLeft(corner) ? point.left : viewport.width - size.width - point.left,
|
|
33
|
+
y: fromTop(corner) ? point.top : viewport.height - size.height - point.top
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function clampOffset(offset, corner, size, viewport, clamp = {}) {
|
|
37
|
+
const margin = clamp.margin ?? DEFAULT_DOCK_MARGIN;
|
|
38
|
+
const visible = clamp.minVisible ?? size;
|
|
39
|
+
const axis = (value, room, extent, nearIsStart) => {
|
|
40
|
+
const min = margin;
|
|
41
|
+
const max = room - extent - margin;
|
|
42
|
+
if (max < min) return Math.round(nearIsStart ? min : max);
|
|
43
|
+
return Math.round(Math.min(Math.max(value, min), max));
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
x: axis(offset.x, viewport.width, visible.width, fromLeft(corner)),
|
|
47
|
+
y: axis(offset.y, viewport.height, visible.height, fromTop(corner))
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function nearestCorner(point, size, viewport) {
|
|
51
|
+
const top = point.top + size.height / 2 < viewport.height / 2;
|
|
52
|
+
const left = point.left + size.width / 2 < viewport.width / 2;
|
|
53
|
+
return `${top ? "top" : "bottom"}-${left ? "left" : "right"}`;
|
|
54
|
+
}
|
|
55
|
+
function overlaps(a, b) {
|
|
56
|
+
return a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;
|
|
57
|
+
}
|
|
58
|
+
function avoidExclusions(point, size, excluded, gap, keepOnScreen) {
|
|
59
|
+
const bounded = keepOnScreen(point);
|
|
60
|
+
if (excluded.length === 0) return bounded;
|
|
61
|
+
const rectFor = (candidate) => ({
|
|
62
|
+
left: candidate.left,
|
|
63
|
+
top: candidate.top,
|
|
64
|
+
right: candidate.left + size.width,
|
|
65
|
+
bottom: candidate.top + size.height
|
|
66
|
+
});
|
|
67
|
+
const isClear = (candidate) => !excluded.some((target) => overlaps(rectFor(candidate), target));
|
|
68
|
+
if (isClear(bounded)) return bounded;
|
|
69
|
+
const clear = excluded.flatMap((target) => [
|
|
70
|
+
{ left: bounded.left, top: target.top - size.height - gap },
|
|
71
|
+
{ left: bounded.left, top: target.bottom + gap },
|
|
72
|
+
{ left: target.left - size.width - gap, top: bounded.top },
|
|
73
|
+
{ left: target.right + gap, top: bounded.top }
|
|
74
|
+
]).map(keepOnScreen).filter(isClear);
|
|
75
|
+
if (clear.length === 0) return bounded;
|
|
76
|
+
const distance = (candidate) => Math.hypot(candidate.left - bounded.left, candidate.top - bounded.top);
|
|
77
|
+
return clear.reduce((nearest, candidate) => distance(candidate) < distance(nearest) ? candidate : nearest);
|
|
78
|
+
}
|
|
79
|
+
function samePosition(a, b) {
|
|
80
|
+
if (!a || !b) return a === b || !a && !b;
|
|
81
|
+
return a.x === b.x && a.y === b.y && a.corner === b.corner;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/dock/store.ts
|
|
85
|
+
import { createContext, createElement, useContext } from "react";
|
|
86
|
+
var DOCK_STORAGE_PREFIX = "matrx:summon:dock:";
|
|
87
|
+
var CORNERS = ["top-left", "top-right", "bottom-left", "bottom-right"];
|
|
88
|
+
function parseDockPosition(value) {
|
|
89
|
+
if (!value || typeof value !== "object") return null;
|
|
90
|
+
const { x, y, corner } = value;
|
|
91
|
+
if (typeof x !== "number" || typeof y !== "number" || !Number.isFinite(x) || !Number.isFinite(y)) return null;
|
|
92
|
+
if (corner !== void 0 && !CORNERS.includes(corner)) return null;
|
|
93
|
+
return corner === void 0 ? { x, y } : { x, y, corner };
|
|
94
|
+
}
|
|
95
|
+
function storage() {
|
|
96
|
+
try {
|
|
97
|
+
return typeof window === "undefined" ? null : window.localStorage;
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function createLocalDockStore(prefix = DOCK_STORAGE_PREFIX) {
|
|
103
|
+
return {
|
|
104
|
+
read(id) {
|
|
105
|
+
try {
|
|
106
|
+
const raw = storage()?.getItem(prefix + id);
|
|
107
|
+
return raw ? parseDockPosition(JSON.parse(raw)) : null;
|
|
108
|
+
} catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
write(id, position) {
|
|
113
|
+
try {
|
|
114
|
+
const area = storage();
|
|
115
|
+
if (!area) return;
|
|
116
|
+
if (position) area.setItem(prefix + id, JSON.stringify(position));
|
|
117
|
+
else area.removeItem(prefix + id);
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
var memoryOnlyDockStore = { read: () => null, write: () => void 0 };
|
|
124
|
+
var defaultStore = createLocalDockStore();
|
|
125
|
+
var DockStoreContext = createContext(null);
|
|
126
|
+
function DockProvider({ store, children }) {
|
|
127
|
+
return createElement(DockStoreContext.Provider, { value: store }, children);
|
|
128
|
+
}
|
|
129
|
+
function useDockStore(own) {
|
|
130
|
+
const provided = useContext(DockStoreContext);
|
|
131
|
+
return own ?? provided ?? defaultStore;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/dock/useDock.ts
|
|
135
|
+
var DEFAULT_DOCK_IGNORE = "button,a,input,select,textarea,[contenteditable='true'],[data-no-drag]";
|
|
136
|
+
var SSR_VIEWPORT = { width: 1280, height: 800 };
|
|
137
|
+
var noopSubscribe = () => () => void 0;
|
|
138
|
+
function readViewport() {
|
|
139
|
+
return typeof window === "undefined" ? SSR_VIEWPORT : { width: window.innerWidth, height: window.innerHeight };
|
|
140
|
+
}
|
|
141
|
+
function measure(element) {
|
|
142
|
+
return { width: element?.offsetWidth ?? 0, height: element?.offsetHeight ?? 0 };
|
|
143
|
+
}
|
|
144
|
+
function excludedRects(avoid, self) {
|
|
145
|
+
if (!avoid || typeof document === "undefined") return [];
|
|
146
|
+
return [...document.querySelectorAll(avoid.selector)].filter((target) => target !== self && !self?.contains(target)).map((target) => target.getBoundingClientRect()).filter((rect) => rect.width > 0 && rect.height > 0);
|
|
147
|
+
}
|
|
148
|
+
function useDock(options) {
|
|
149
|
+
const {
|
|
150
|
+
id,
|
|
151
|
+
corner = "bottom-right",
|
|
152
|
+
defaultPosition = null,
|
|
153
|
+
anchor,
|
|
154
|
+
position: controlled,
|
|
155
|
+
onPositionChange,
|
|
156
|
+
persist = true,
|
|
157
|
+
draggable = true,
|
|
158
|
+
touch = true,
|
|
159
|
+
threshold = DEFAULT_DRAG_THRESHOLD,
|
|
160
|
+
clamp,
|
|
161
|
+
avoid,
|
|
162
|
+
snapToCorner = false,
|
|
163
|
+
zIndex: baseZ,
|
|
164
|
+
raiseOnPress = true,
|
|
165
|
+
ignore = DEFAULT_DOCK_IGNORE
|
|
166
|
+
} = options;
|
|
167
|
+
const isControlled = controlled !== void 0;
|
|
168
|
+
const providedStore = useDockStore(options.store);
|
|
169
|
+
const store = persist && !isControlled ? providedStore : memoryOnlyDockStore;
|
|
170
|
+
const [element, setElement] = useState(null);
|
|
171
|
+
const [local, setLocal] = useState(null);
|
|
172
|
+
const [pending, setPending] = useState(null);
|
|
173
|
+
const [geometry, setGeometry] = useState({ viewport: SSR_VIEWPORT, size: { width: 0, height: 0 } });
|
|
174
|
+
const [nudge, setNudge] = useState(null);
|
|
175
|
+
const [dragging, setDragging] = useState(false);
|
|
176
|
+
const pressRef = useRef(null);
|
|
177
|
+
const frameRef = useRef(null);
|
|
178
|
+
const adoptingRef = useRef(false);
|
|
179
|
+
const restoredRef = useRef(null);
|
|
180
|
+
const chosen = isControlled ? pending && samePosition(pending.forProp, controlled) ? pending.value : controlled : local;
|
|
181
|
+
const raw = chosen ?? defaultPosition;
|
|
182
|
+
const rawCorner = raw?.corner ?? corner;
|
|
183
|
+
const offset = raw ? clampOffset(raw, rawCorner, geometry.size, geometry.viewport, clamp) : null;
|
|
184
|
+
const live = useRef({ offset, rawCorner, clamp, avoid, threshold, snapToCorner, onPositionChange, isControlled, controlled, store, id });
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
live.current = { offset, rawCorner, clamp, avoid, threshold, snapToCorner, onPositionChange, isControlled, controlled, store, id };
|
|
187
|
+
});
|
|
188
|
+
useLayoutEffect(() => {
|
|
189
|
+
if (!element || restoredRef.current === id) return;
|
|
190
|
+
restoredRef.current = id;
|
|
191
|
+
if (isControlled) return;
|
|
192
|
+
setLocal(store.read(id));
|
|
193
|
+
}, [element, id, isControlled, store]);
|
|
194
|
+
useLayoutEffect(() => {
|
|
195
|
+
if (!element) return void 0;
|
|
196
|
+
let frame = null;
|
|
197
|
+
const read = () => {
|
|
198
|
+
const next = { viewport: readViewport(), size: measure(element) };
|
|
199
|
+
setGeometry(
|
|
200
|
+
(current) => current.viewport.width === next.viewport.width && current.viewport.height === next.viewport.height && current.size.width === next.size.width && current.size.height === next.size.height ? current : next
|
|
201
|
+
);
|
|
202
|
+
};
|
|
203
|
+
const schedule = () => {
|
|
204
|
+
if (frame !== null) return;
|
|
205
|
+
frame = window.requestAnimationFrame(() => {
|
|
206
|
+
frame = null;
|
|
207
|
+
read();
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
read();
|
|
211
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(schedule);
|
|
212
|
+
observer?.observe(element);
|
|
213
|
+
window.addEventListener("resize", schedule);
|
|
214
|
+
return () => {
|
|
215
|
+
observer?.disconnect();
|
|
216
|
+
window.removeEventListener("resize", schedule);
|
|
217
|
+
if (frame !== null) window.cancelAnimationFrame(frame);
|
|
218
|
+
};
|
|
219
|
+
}, [element]);
|
|
220
|
+
const avoidSelector = avoid?.selector;
|
|
221
|
+
const avoidGap = avoid?.gap;
|
|
222
|
+
useLayoutEffect(() => {
|
|
223
|
+
if (!element || !avoidSelector || offset) {
|
|
224
|
+
setNudge((current) => current === null ? current : null);
|
|
225
|
+
return void 0;
|
|
226
|
+
}
|
|
227
|
+
let frame = null;
|
|
228
|
+
let applied = null;
|
|
229
|
+
const reconcile = () => {
|
|
230
|
+
const rect = element.getBoundingClientRect();
|
|
231
|
+
const size = measure(element);
|
|
232
|
+
const viewport = readViewport();
|
|
233
|
+
const base = { left: rect.left - (applied?.left ?? 0), top: rect.top - (applied?.top ?? 0) };
|
|
234
|
+
const keep = (p) => {
|
|
235
|
+
const o = clampOffset(fromScreen(p, "top-left", size, viewport), "top-left", size, viewport, live.current.clamp);
|
|
236
|
+
return toScreen(o, "top-left", size, viewport);
|
|
237
|
+
};
|
|
238
|
+
const clear = avoidExclusions(base, size, excludedRects({ selector: avoidSelector }, element), avoidGap ?? DEFAULT_DOCK_MARGIN, keep);
|
|
239
|
+
const next = { left: Math.round(clear.left - base.left), top: Math.round(clear.top - base.top) };
|
|
240
|
+
applied = next.left === 0 && next.top === 0 ? null : next;
|
|
241
|
+
setNudge(
|
|
242
|
+
(current) => current === null && applied === null || current && applied && current.left === applied.left && current.top === applied.top ? current : applied
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
const schedule = () => {
|
|
246
|
+
if (frame !== null) return;
|
|
247
|
+
frame = window.requestAnimationFrame(() => {
|
|
248
|
+
frame = null;
|
|
249
|
+
reconcile();
|
|
250
|
+
});
|
|
251
|
+
};
|
|
252
|
+
reconcile();
|
|
253
|
+
const mutations = typeof MutationObserver === "undefined" ? null : new MutationObserver(schedule);
|
|
254
|
+
mutations?.observe(document.body, { childList: true, subtree: true });
|
|
255
|
+
window.addEventListener("resize", schedule);
|
|
256
|
+
window.addEventListener("scroll", schedule, true);
|
|
257
|
+
return () => {
|
|
258
|
+
mutations?.disconnect();
|
|
259
|
+
window.removeEventListener("resize", schedule);
|
|
260
|
+
window.removeEventListener("scroll", schedule, true);
|
|
261
|
+
if (frame !== null) window.cancelAnimationFrame(frame);
|
|
262
|
+
};
|
|
263
|
+
}, [element, avoidSelector, avoidGap, offset === null]);
|
|
264
|
+
let placed = null;
|
|
265
|
+
if (offset) {
|
|
266
|
+
placed = toScreen(offset, rawCorner, geometry.size, geometry.viewport);
|
|
267
|
+
if (avoid && element) {
|
|
268
|
+
const size = geometry.size;
|
|
269
|
+
const viewport = geometry.viewport;
|
|
270
|
+
const keep = (p) => toScreen(clampOffset(fromScreen(p, "top-left", size, viewport), "top-left", size, viewport, clamp), "top-left", size, viewport);
|
|
271
|
+
placed = avoidExclusions(placed, size, excludedRects(avoid, element), avoid.gap ?? DEFAULT_DOCK_MARGIN, keep);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const renderedOffset = placed && offset ? fromScreen(placed, rawCorner, geometry.size, geometry.viewport) : offset;
|
|
275
|
+
useLayoutEffect(() => {
|
|
276
|
+
if (!adoptingRef.current) return;
|
|
277
|
+
adoptingRef.current = false;
|
|
278
|
+
element?.style.removeProperty("translate");
|
|
279
|
+
});
|
|
280
|
+
const summonStore = useOptionalSummonStore();
|
|
281
|
+
const laneZ = useSyncExternalStore(
|
|
282
|
+
summonStore ? summonStore.subscribe : noopSubscribe,
|
|
283
|
+
() => summonStore ? summonStore.getState().windowManager?.transientZ?.[id] : void 0,
|
|
284
|
+
() => void 0
|
|
285
|
+
);
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
if (!summonStore) return void 0;
|
|
288
|
+
return () => {
|
|
289
|
+
const state = summonStore.getState();
|
|
290
|
+
if (state.windowManager?.transientZ?.[id] !== void 0) summonStore.dispatch(releaseTransientWindow(id));
|
|
291
|
+
};
|
|
292
|
+
}, [summonStore, id]);
|
|
293
|
+
const zIndex = laneZ ?? baseZ;
|
|
294
|
+
useEffect(
|
|
295
|
+
() => () => {
|
|
296
|
+
pressRef.current?.cleanup();
|
|
297
|
+
pressRef.current = null;
|
|
298
|
+
},
|
|
299
|
+
[]
|
|
300
|
+
);
|
|
301
|
+
const commit = useCallback((next) => {
|
|
302
|
+
const current = live.current;
|
|
303
|
+
adoptingRef.current = true;
|
|
304
|
+
if (current.isControlled) setPending({ value: next, forProp: current.controlled ?? null });
|
|
305
|
+
else {
|
|
306
|
+
setLocal(next);
|
|
307
|
+
current.store.write(current.id, next);
|
|
308
|
+
}
|
|
309
|
+
current.onPositionChange?.(next);
|
|
310
|
+
}, []);
|
|
311
|
+
const onPointerDown = useCallback(
|
|
312
|
+
(event) => {
|
|
313
|
+
if (!draggable || event.button !== 0 || !element) return;
|
|
314
|
+
if (!touch && event.pointerType === "touch") return;
|
|
315
|
+
const target = event.target;
|
|
316
|
+
if (ignore && target) {
|
|
317
|
+
const hit = target.closest(ignore);
|
|
318
|
+
if (hit && hit !== event.currentTarget && event.currentTarget.contains(hit)) return;
|
|
319
|
+
}
|
|
320
|
+
pressRef.current?.cleanup();
|
|
321
|
+
if (raiseOnPress && summonStore) summonStore.dispatch(raiseTransientWindow(id));
|
|
322
|
+
if (!target?.closest("button,a,input,select,textarea,label,[role=button]")) event.preventDefault();
|
|
323
|
+
const rect = element.getBoundingClientRect();
|
|
324
|
+
const viewport = readViewport();
|
|
325
|
+
const size = measure(element);
|
|
326
|
+
const press = {
|
|
327
|
+
pointerId: event.pointerId,
|
|
328
|
+
startX: event.clientX,
|
|
329
|
+
startY: event.clientY,
|
|
330
|
+
origin: { left: rect.left, top: rect.top },
|
|
331
|
+
size,
|
|
332
|
+
viewport,
|
|
333
|
+
active: false,
|
|
334
|
+
latest: { left: rect.left, top: rect.top },
|
|
335
|
+
release: null,
|
|
336
|
+
cleanup: () => void 0
|
|
337
|
+
};
|
|
338
|
+
const startOffset = live.current.offset ?? fromScreen(press.origin, live.current.rawCorner, size, viewport);
|
|
339
|
+
const startCorner = live.current.rawCorner;
|
|
340
|
+
const startScreen = toScreen(startOffset, startCorner, size, viewport);
|
|
341
|
+
const paint = () => {
|
|
342
|
+
frameRef.current = null;
|
|
343
|
+
const active = pressRef.current;
|
|
344
|
+
if (!active || !active.active) return;
|
|
345
|
+
element.style.translate = `${active.latest.left - startScreen.left}px ${active.latest.top - startScreen.top}px`;
|
|
346
|
+
};
|
|
347
|
+
const move = (e) => {
|
|
348
|
+
if (e.pointerId !== press.pointerId) return;
|
|
349
|
+
const dx = e.clientX - press.startX;
|
|
350
|
+
const dy = e.clientY - press.startY;
|
|
351
|
+
const opts = live.current;
|
|
352
|
+
if (!press.active) {
|
|
353
|
+
if (Math.abs(dx) < opts.threshold && Math.abs(dy) < opts.threshold) return;
|
|
354
|
+
press.active = true;
|
|
355
|
+
press.release = holdDragCursor("grabbing");
|
|
356
|
+
setDragging(true);
|
|
357
|
+
}
|
|
358
|
+
const desired = fromScreen({ left: startScreen.left + dx, top: startScreen.top + dy }, startCorner, size, viewport);
|
|
359
|
+
let next = toScreen(clampOffset(desired, startCorner, size, viewport, opts.clamp), startCorner, size, viewport);
|
|
360
|
+
if (opts.avoid) {
|
|
361
|
+
const keep = (p) => toScreen(clampOffset(fromScreen(p, "top-left", size, viewport), "top-left", size, viewport, opts.clamp), "top-left", size, viewport);
|
|
362
|
+
next = avoidExclusions(next, size, excludedRects(opts.avoid, element), opts.avoid.gap ?? DEFAULT_DOCK_MARGIN, keep);
|
|
363
|
+
}
|
|
364
|
+
press.latest = next;
|
|
365
|
+
if (frameRef.current === null) {
|
|
366
|
+
if (typeof window.requestAnimationFrame === "function") frameRef.current = window.requestAnimationFrame(paint);
|
|
367
|
+
else paint();
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
const end = (e) => {
|
|
371
|
+
if (e.pointerId !== press.pointerId) return;
|
|
372
|
+
press.cleanup();
|
|
373
|
+
pressRef.current = null;
|
|
374
|
+
if (!press.active) return;
|
|
375
|
+
press.release?.();
|
|
376
|
+
setDragging(false);
|
|
377
|
+
const opts = live.current;
|
|
378
|
+
const finalCorner = opts.snapToCorner ? nearestCorner(press.latest, size, viewport) : startCorner;
|
|
379
|
+
const finalOffset = clampOffset(fromScreen(press.latest, finalCorner, size, viewport), finalCorner, size, viewport, opts.clamp);
|
|
380
|
+
commit(finalCorner === corner ? { x: finalOffset.x, y: finalOffset.y } : { ...finalOffset, corner: finalCorner });
|
|
381
|
+
const swallow = (click) => {
|
|
382
|
+
click.stopPropagation();
|
|
383
|
+
click.preventDefault();
|
|
384
|
+
};
|
|
385
|
+
window.addEventListener("click", swallow, { capture: true, once: true });
|
|
386
|
+
window.setTimeout(() => window.removeEventListener("click", swallow, { capture: true }), 0);
|
|
387
|
+
};
|
|
388
|
+
press.cleanup = () => {
|
|
389
|
+
window.removeEventListener("pointermove", move);
|
|
390
|
+
window.removeEventListener("pointerup", end);
|
|
391
|
+
window.removeEventListener("pointercancel", end);
|
|
392
|
+
if (frameRef.current !== null) {
|
|
393
|
+
window.cancelAnimationFrame?.(frameRef.current);
|
|
394
|
+
frameRef.current = null;
|
|
395
|
+
}
|
|
396
|
+
if (!press.active) return;
|
|
397
|
+
press.release?.();
|
|
398
|
+
press.release = null;
|
|
399
|
+
};
|
|
400
|
+
pressRef.current = press;
|
|
401
|
+
window.addEventListener("pointermove", move);
|
|
402
|
+
window.addEventListener("pointerup", end);
|
|
403
|
+
window.addEventListener("pointercancel", end);
|
|
404
|
+
},
|
|
405
|
+
[commit, corner, draggable, element, id, ignore, raiseOnPress, summonStore, touch]
|
|
406
|
+
);
|
|
407
|
+
const reset = useCallback(() => {
|
|
408
|
+
adoptingRef.current = true;
|
|
409
|
+
commit(null);
|
|
410
|
+
}, [commit]);
|
|
411
|
+
let style;
|
|
412
|
+
if (renderedOffset) {
|
|
413
|
+
const left = rawCorner.endsWith("left");
|
|
414
|
+
const top = rawCorner.startsWith("top");
|
|
415
|
+
style = {
|
|
416
|
+
position: "fixed",
|
|
417
|
+
left: left ? renderedOffset.x : "auto",
|
|
418
|
+
right: left ? "auto" : renderedOffset.x,
|
|
419
|
+
top: top ? renderedOffset.y : "auto",
|
|
420
|
+
bottom: top ? "auto" : renderedOffset.y
|
|
421
|
+
};
|
|
422
|
+
} else {
|
|
423
|
+
const transform = [anchor?.centerX ? "translateX(-50%)" : null, nudge ? `translate(${nudge.left}px, ${nudge.top}px)` : null].filter(Boolean).join(" ");
|
|
424
|
+
style = {
|
|
425
|
+
position: "fixed",
|
|
426
|
+
top: anchor?.top,
|
|
427
|
+
bottom: anchor?.bottom,
|
|
428
|
+
left: anchor?.centerX ? "50%" : anchor?.left,
|
|
429
|
+
right: anchor?.right,
|
|
430
|
+
...transform ? { transform } : {}
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
if (zIndex !== void 0) style.zIndex = zIndex;
|
|
434
|
+
return {
|
|
435
|
+
ref: setElement,
|
|
436
|
+
element,
|
|
437
|
+
style,
|
|
438
|
+
handleProps: {
|
|
439
|
+
onPointerDown,
|
|
440
|
+
style: draggable ? { cursor: "grab", touchAction: touch ? "none" : "auto" } : {},
|
|
441
|
+
"data-dock-handle": ""
|
|
442
|
+
},
|
|
443
|
+
offset: renderedOffset,
|
|
444
|
+
corner: rawCorner,
|
|
445
|
+
dragging,
|
|
446
|
+
moved: chosen !== null,
|
|
447
|
+
zIndex,
|
|
448
|
+
reset
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// src/dock/Dock.tsx
|
|
453
|
+
import { jsx } from "react/jsx-runtime";
|
|
454
|
+
var DockContext = createContext2(null);
|
|
455
|
+
function useDockContext() {
|
|
456
|
+
const dock = useContext2(DockContext);
|
|
457
|
+
if (!dock) throw new Error("[summon] useDockContext() must be used inside <Dock>");
|
|
458
|
+
return dock;
|
|
459
|
+
}
|
|
460
|
+
var OPTION_KEYS = [
|
|
461
|
+
"id",
|
|
462
|
+
"corner",
|
|
463
|
+
"defaultPosition",
|
|
464
|
+
"anchor",
|
|
465
|
+
"position",
|
|
466
|
+
"onPositionChange",
|
|
467
|
+
"persist",
|
|
468
|
+
"store",
|
|
469
|
+
"draggable",
|
|
470
|
+
"touch",
|
|
471
|
+
"threshold",
|
|
472
|
+
"clamp",
|
|
473
|
+
"avoid",
|
|
474
|
+
"snapToCorner",
|
|
475
|
+
"zIndex",
|
|
476
|
+
"raiseOnPress",
|
|
477
|
+
"ignore"
|
|
478
|
+
];
|
|
479
|
+
function Dock(props) {
|
|
480
|
+
const options = {};
|
|
481
|
+
const rest = {};
|
|
482
|
+
for (const [key, value] of Object.entries(props)) {
|
|
483
|
+
if (OPTION_KEYS.includes(key)) options[key] = value;
|
|
484
|
+
else if (key !== "handle" && key !== "children" && key !== "style") rest[key] = value;
|
|
485
|
+
}
|
|
486
|
+
const dock = useDock(options);
|
|
487
|
+
const self = props.handle === "self";
|
|
488
|
+
const style = { ...props.style, ...dock.style, ...self ? dock.handleProps.style : {} };
|
|
489
|
+
return /* @__PURE__ */ jsx(DockContext.Provider, { value: dock, children: /* @__PURE__ */ jsx(
|
|
490
|
+
"div",
|
|
491
|
+
{
|
|
492
|
+
...rest,
|
|
493
|
+
ref: dock.ref,
|
|
494
|
+
"data-dock": props.id,
|
|
495
|
+
"data-dragging": dock.dragging ? "" : void 0,
|
|
496
|
+
style,
|
|
497
|
+
...self ? { onPointerDown: dock.handleProps.onPointerDown, "data-dock-handle": "" } : {},
|
|
498
|
+
children: typeof props.children === "function" ? props.children(dock) : props.children
|
|
499
|
+
}
|
|
500
|
+
) });
|
|
501
|
+
}
|
|
502
|
+
function DockHandle({ style, onPointerDown, ...rest }) {
|
|
503
|
+
const dock = useDockContext();
|
|
504
|
+
return /* @__PURE__ */ jsx(
|
|
505
|
+
"div",
|
|
506
|
+
{
|
|
507
|
+
...rest,
|
|
508
|
+
...dock.handleProps,
|
|
509
|
+
style: { ...style, ...dock.handleProps.style },
|
|
510
|
+
onPointerDown: (event) => {
|
|
511
|
+
onPointerDown?.(event);
|
|
512
|
+
dock.handleProps.onPointerDown(event);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
export {
|
|
518
|
+
DEFAULT_DOCK_IGNORE,
|
|
519
|
+
DEFAULT_DOCK_MARGIN,
|
|
520
|
+
DEFAULT_DRAG_THRESHOLD,
|
|
521
|
+
DOCK_STORAGE_PREFIX,
|
|
522
|
+
Dock,
|
|
523
|
+
DockHandle,
|
|
524
|
+
DockProvider,
|
|
525
|
+
avoidExclusions,
|
|
526
|
+
clampOffset,
|
|
527
|
+
createLocalDockStore,
|
|
528
|
+
fromScreen,
|
|
529
|
+
memoryOnlyDockStore,
|
|
530
|
+
nearestCorner,
|
|
531
|
+
parseDockPosition,
|
|
532
|
+
toScreen,
|
|
533
|
+
useDock,
|
|
534
|
+
useDockContext,
|
|
535
|
+
useDockStore
|
|
536
|
+
};
|
|
537
|
+
//# sourceMappingURL=dock.js.map
|
package/dist/dock.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dock/Dock.tsx","../src/dock/useDock.ts","../src/dock/geometry.ts","../src/dock/store.ts"],"sourcesContent":["/**\n * `<Dock>` — the component form of `useDock()`: a fixed, chrome-less element that\n * moves. Drag it by a `<DockHandle>` inside it, or by the whole dock with\n * `handle=\"self\"`. `useDockContext()` reaches the dock's API from anywhere inside\n * (a \"Move back to the corner\" menu item calls `reset()`).\n */\n\nimport { createContext, useContext, type CSSProperties, type HTMLAttributes, type ReactNode } from \"react\";\nimport { useDock, type DockApi, type UseDockOptions } from \"./useDock\";\n\nconst DockContext = createContext<DockApi | null>(null);\n\n/** The enclosing dock's API; throws outside a `<Dock>`. */\nexport function useDockContext(): DockApi {\n const dock = useContext(DockContext);\n if (!dock) throw new Error(\"[summon] useDockContext() must be used inside <Dock>\");\n return dock;\n}\n\nexport interface DockProps extends UseDockOptions, Omit<HTMLAttributes<HTMLDivElement>, \"id\" | \"children\" | \"draggable\"> {\n /** \"self\": the whole dock is the drag handle. Default: only `<DockHandle>`s drag. */\n handle?: \"self\" | \"inner\";\n children?: ReactNode | ((dock: DockApi) => ReactNode);\n}\n\nconst OPTION_KEYS = [\n \"id\", \"corner\", \"defaultPosition\", \"anchor\", \"position\", \"onPositionChange\", \"persist\", \"store\", \"draggable\",\n \"touch\", \"threshold\", \"clamp\", \"avoid\", \"snapToCorner\", \"zIndex\", \"raiseOnPress\", \"ignore\",\n] as const satisfies readonly (keyof UseDockOptions)[];\n\nexport function Dock(props: DockProps): ReactNode {\n const options = {} as UseDockOptions;\n const rest: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n if ((OPTION_KEYS as readonly string[]).includes(key)) (options as unknown as Record<string, unknown>)[key] = value;\n else if (key !== \"handle\" && key !== \"children\" && key !== \"style\") rest[key] = value;\n }\n const dock = useDock(options);\n const self = props.handle === \"self\";\n const style: CSSProperties = { ...props.style, ...dock.style, ...(self ? dock.handleProps.style : {}) };\n return (\n <DockContext.Provider value={dock}>\n <div\n {...(rest as HTMLAttributes<HTMLDivElement>)}\n ref={dock.ref}\n data-dock={props.id}\n data-dragging={dock.dragging ? \"\" : undefined}\n style={style}\n {...(self ? { onPointerDown: dock.handleProps.onPointerDown, \"data-dock-handle\": \"\" } : {})}\n >\n {typeof props.children === \"function\" ? props.children(dock) : props.children}\n </div>\n </DockContext.Provider>\n );\n}\n\nexport interface DockHandleProps extends HTMLAttributes<HTMLDivElement> {\n children?: ReactNode;\n}\n\n/** The part of a `<Dock>` you drag it by. Buttons and fields inside stay controls. */\nexport function DockHandle({ style, onPointerDown, ...rest }: DockHandleProps): ReactNode {\n const dock = useDockContext();\n return (\n <div\n {...rest}\n {...dock.handleProps}\n style={{ ...style, ...dock.handleProps.style }}\n onPointerDown={(event) => {\n onPointerDown?.(event);\n dock.handleProps.onPointerDown(event);\n }}\n />\n );\n}\n","/**\n * `useDock()` — the one primitive for floating chrome-less cards, pills and docks.\n *\n * THE RULE (paid for in the Workflow Studio's FloatingChatPanel and chat's\n * ChatPanel): a pointer move paints the CSS `translate` property inside ONE\n * requestAnimationFrame and React state is committed EXACTLY ONCE, on release.\n * Writing state per pointer event re-renders whatever streams inside the dock\n * sixty times a second. `translate` composes with the host's own `transform`\n * and with any `left/right/top/bottom` it computes, so a host that builds its\n * own placement (CSS variables, lifts) still drags without re-rendering.\n *\n * What else it carries:\n * - a drag is never a click: below `threshold` px the gesture stays a click;\n * past it the trailing click is swallowed once;\n * - the position is an offset from a corner, clamped to the viewport on every\n * render (a position saved on a wide monitor never strands the dock), and\n * can snap to the nearest corner on release;\n * - it remembers its place per dock id (the store chain in ./store) or reports\n * it to a controlled host (`position` + `onPositionChange`, e.g. per-user sync);\n * - it joins the window manager's z-order lane on press (raised above every\n * window, below modals) when a SummonProvider is present;\n * - THE CURSOR LAW: the drag holds `grabbing` with design-system `holdDragCursor`;\n * - zero cost until mounted: no listener exists outside an active press.\n */\n\nimport {\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type CSSProperties,\n type PointerEvent as ReactPointerEvent,\n} from \"react\";\nimport { holdDragCursor } from \"@ai-matrx/design-system\";\nimport { raiseTransientWindow, releaseTransientWindow } from \"@ai-matrx/summon\";\nimport { useOptionalSummonStore } from \"@ai-matrx/summon/react\";\nimport {\n avoidExclusions,\n clampOffset,\n DEFAULT_DOCK_MARGIN,\n DEFAULT_DRAG_THRESHOLD,\n fromScreen,\n nearestCorner,\n samePosition,\n toScreen,\n type DockClamp,\n type DockCorner,\n type DockOffset,\n type DockPosition,\n type DockSize,\n type ScreenPoint,\n type ScreenRect,\n} from \"./geometry\";\nimport { memoryOnlyDockStore, useDockStore, type DockPositionStore } from \"./store\";\n\n/** CSS placement used while the dock has no position (never moved, no `defaultPosition`). */\nexport interface DockAnchor {\n top?: string;\n bottom?: string;\n left?: string;\n right?: string;\n /** Centre horizontally (`left: 50%` + translateX(-50%)). */\n centerX?: boolean;\n}\n\n/** Controls inside the handle that stay controls — a press there never starts a drag. */\nexport const DEFAULT_DOCK_IGNORE = \"button,a,input,select,textarea,[contenteditable='true'],[data-no-drag]\";\n\nexport interface UseDockOptions {\n /** Identity: the remembered position, the z-order lane entry. Unique per dock. */\n id: string;\n /** The corner positions are measured from. Default \"bottom-right\". */\n corner?: DockCorner;\n /** Resting offset from `corner` before the person moves it. Omit to rest on `anchor`. */\n defaultPosition?: DockOffset | null;\n /** CSS resting place when there is no position at all. */\n anchor?: DockAnchor;\n /** Controlled position (the host owns storage, e.g. a per-user preference). `null` = resting. */\n position?: DockPosition | null;\n /** Told once per drag, on release, and on `reset()` (with `null`). */\n onPositionChange?: (position: DockPosition | null) => void;\n /** Remember the position across reloads (uncontrolled only). Default true. */\n persist?: boolean;\n /** This dock's own store; otherwise the nearest `<DockProvider>`, else localStorage. */\n store?: DockPositionStore;\n /** Default true. Pass false on surfaces that must not move (a phone sheet). */\n draggable?: boolean;\n /** Allow touch drags. Default true; a dock that fights page scroll passes false. */\n touch?: boolean;\n /** Px a pointer must travel before a press becomes a drag. Default 4. */\n threshold?: number;\n clamp?: DockClamp;\n /** Fixed controls the dock must stay off (nearest clear spot wins). */\n avoid?: { selector: string; gap?: number };\n /** On release, re-anchor to the nearest corner. Default false. */\n snapToCorner?: boolean;\n /** z-index before the first press raises it into the window lane. */\n zIndex?: number;\n /** Raise into the window manager's z-order lane on press. Default true. */\n raiseOnPress?: boolean;\n /** Selector of controls inside the handle that never start a drag. `null` = every press may drag. */\n ignore?: string | null;\n}\n\nexport interface DockHandleBindings {\n onPointerDown(event: ReactPointerEvent<HTMLElement>): void;\n style: CSSProperties;\n \"data-dock-handle\": \"\";\n}\n\nexport interface DockApi {\n /** Attach to the element that MOVES. */\n ref: (element: HTMLElement | null) => void;\n element: HTMLElement | null;\n /** Spread onto the moving element: fixed placement (placed or anchored) + z-index. */\n style: CSSProperties;\n /** Spread onto the element you drag BY (or the whole dock). */\n handleProps: DockHandleBindings;\n /** The clamped offset from `corner`; null while resting on `anchor`. */\n offset: DockOffset | null;\n /** The corner `offset` is measured from. */\n corner: DockCorner;\n /** True from the moment a press passes the threshold until release. */\n dragging: boolean;\n /** The person has moved it (a remembered or controlled position exists). */\n moved: boolean;\n /** Current z-index: the lane's once raised, else the `zIndex` option. */\n zIndex: number | undefined;\n /** Forget the position; the dock returns to its resting place. */\n reset(): void;\n}\n\nconst SSR_VIEWPORT: DockSize = { width: 1280, height: 800 };\nconst noopSubscribe = () => () => undefined;\n\ninterface Geometry {\n viewport: DockSize;\n size: DockSize;\n}\n\ninterface Press {\n pointerId: number;\n startX: number;\n startY: number;\n /** The dock's top-left when pressed. */\n origin: ScreenPoint;\n size: DockSize;\n viewport: DockSize;\n active: boolean;\n latest: ScreenPoint;\n release: (() => void) | null;\n cleanup: () => void;\n}\n\nfunction readViewport(): DockSize {\n return typeof window === \"undefined\" ? SSR_VIEWPORT : { width: window.innerWidth, height: window.innerHeight };\n}\n\nfunction measure(element: HTMLElement | null): DockSize {\n return { width: element?.offsetWidth ?? 0, height: element?.offsetHeight ?? 0 };\n}\n\nfunction excludedRects(avoid: UseDockOptions[\"avoid\"], self: HTMLElement | null): ScreenRect[] {\n if (!avoid || typeof document === \"undefined\") return [];\n return [...document.querySelectorAll<HTMLElement>(avoid.selector)]\n .filter((target) => target !== self && !self?.contains(target))\n .map((target) => target.getBoundingClientRect())\n .filter((rect) => rect.width > 0 && rect.height > 0);\n}\n\nexport function useDock(options: UseDockOptions): DockApi {\n const {\n id,\n corner = \"bottom-right\",\n defaultPosition = null,\n anchor,\n position: controlled,\n onPositionChange,\n persist = true,\n draggable = true,\n touch = true,\n threshold = DEFAULT_DRAG_THRESHOLD,\n clamp,\n avoid,\n snapToCorner = false,\n zIndex: baseZ,\n raiseOnPress = true,\n ignore = DEFAULT_DOCK_IGNORE,\n } = options;\n const isControlled = controlled !== undefined;\n const providedStore = useDockStore(options.store);\n const store = persist && !isControlled ? providedStore : memoryOnlyDockStore;\n\n const [element, setElement] = useState<HTMLElement | null>(null);\n const [local, setLocal] = useState<DockPosition | null>(null);\n /** A controlled commit, shown until the host's `position` changes (it may update async). */\n const [pending, setPending] = useState<{ value: DockPosition | null; forProp: DockPosition | null } | null>(null);\n const [geometry, setGeometry] = useState<Geometry>({ viewport: SSR_VIEWPORT, size: { width: 0, height: 0 } });\n const [nudge, setNudge] = useState<ScreenPoint | null>(null);\n const [dragging, setDragging] = useState(false);\n const pressRef = useRef<Press | null>(null);\n const frameRef = useRef<number | null>(null);\n const adoptingRef = useRef(false);\n const restoredRef = useRef<string | null>(null);\n\n // ── The position, resolved ───────────────────────────────────────────────\n const chosen: DockPosition | null = isControlled\n ? pending && samePosition(pending.forProp, controlled) ? pending.value : controlled\n : local;\n const raw: DockPosition | null = chosen ?? defaultPosition;\n const rawCorner = raw?.corner ?? corner;\n const offset = raw ? clampOffset(raw, rawCorner, geometry.size, geometry.viewport, clamp) : null;\n\n // Live refs for the press listeners (written in effects, never during render).\n const live = useRef({ offset, rawCorner, clamp, avoid, threshold, snapToCorner, onPositionChange, isControlled, controlled, store, id });\n useEffect(() => {\n live.current = { offset, rawCorner, clamp, avoid, threshold, snapToCorner, onPositionChange, isControlled, controlled, store, id };\n });\n\n // Restore the remembered position BEFORE paint, once per id, as soon as the element exists.\n useLayoutEffect(() => {\n if (!element || restoredRef.current === id) return;\n restoredRef.current = id;\n if (isControlled) return;\n setLocal(store.read(id));\n }, [element, id, isControlled, store]);\n\n // Track the viewport and the dock's own size (expanded/collapsed content), re-clamping on change.\n useLayoutEffect(() => {\n if (!element) return undefined;\n let frame: number | null = null;\n const read = () => {\n const next: Geometry = { viewport: readViewport(), size: measure(element) };\n setGeometry((current) =>\n current.viewport.width === next.viewport.width &&\n current.viewport.height === next.viewport.height &&\n current.size.width === next.size.width &&\n current.size.height === next.size.height\n ? current\n : next,\n );\n };\n const schedule = () => {\n if (frame !== null) return;\n frame = window.requestAnimationFrame(() => {\n frame = null;\n read();\n });\n };\n read();\n const observer = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(schedule);\n observer?.observe(element);\n window.addEventListener(\"resize\", schedule);\n return () => {\n observer?.disconnect();\n window.removeEventListener(\"resize\", schedule);\n if (frame !== null) window.cancelAnimationFrame(frame);\n };\n }, [element]);\n\n // Exclusions: a placed dock is moved to the nearest clear spot at render; a resting (anchored)\n // dock gets a measured nudge, re-read whenever the page under it changes.\n const avoidSelector = avoid?.selector;\n const avoidGap = avoid?.gap;\n useLayoutEffect(() => {\n if (!element || !avoidSelector || offset) {\n setNudge((current) => (current === null ? current : null));\n return undefined;\n }\n let frame: number | null = null;\n let applied: ScreenPoint | null = null;\n const reconcile = () => {\n const rect = element.getBoundingClientRect();\n const size = measure(element);\n const viewport = readViewport();\n const base = { left: rect.left - (applied?.left ?? 0), top: rect.top - (applied?.top ?? 0) };\n const keep = (p: ScreenPoint) => {\n const o = clampOffset(fromScreen(p, \"top-left\", size, viewport), \"top-left\", size, viewport, live.current.clamp);\n return toScreen(o, \"top-left\", size, viewport);\n };\n const clear = avoidExclusions(base, size, excludedRects({ selector: avoidSelector }, element), avoidGap ?? DEFAULT_DOCK_MARGIN, keep);\n const next = { left: Math.round(clear.left - base.left), top: Math.round(clear.top - base.top) };\n applied = next.left === 0 && next.top === 0 ? null : next;\n setNudge((current) =>\n (current === null && applied === null) || (current && applied && current.left === applied.left && current.top === applied.top)\n ? current\n : applied,\n );\n };\n const schedule = () => {\n if (frame !== null) return;\n frame = window.requestAnimationFrame(() => {\n frame = null;\n reconcile();\n });\n };\n reconcile();\n const mutations = typeof MutationObserver === \"undefined\" ? null : new MutationObserver(schedule);\n mutations?.observe(document.body, { childList: true, subtree: true });\n window.addEventListener(\"resize\", schedule);\n window.addEventListener(\"scroll\", schedule, true);\n return () => {\n mutations?.disconnect();\n window.removeEventListener(\"resize\", schedule);\n window.removeEventListener(\"scroll\", schedule, true);\n if (frame !== null) window.cancelAnimationFrame(frame);\n };\n }, [element, avoidSelector, avoidGap, offset === null]); // eslint-disable-line react-hooks/exhaustive-deps\n\n /** A placed dock that would cover an excluded control renders at the nearest clear spot. */\n let placed: ScreenPoint | null = null;\n if (offset) {\n placed = toScreen(offset, rawCorner, geometry.size, geometry.viewport);\n if (avoid && element) {\n const size = geometry.size;\n const viewport = geometry.viewport;\n const keep = (p: ScreenPoint) =>\n toScreen(clampOffset(fromScreen(p, \"top-left\", size, viewport), \"top-left\", size, viewport, clamp), \"top-left\", size, viewport);\n placed = avoidExclusions(placed, size, excludedRects(avoid, element), avoid.gap ?? DEFAULT_DOCK_MARGIN, keep);\n }\n }\n const renderedOffset = placed && offset ? fromScreen(placed, rawCorner, geometry.size, geometry.viewport) : offset;\n\n // The committed position replaces the paint offset in the SAME commit: clear `translate` now.\n useLayoutEffect(() => {\n if (!adoptingRef.current) return;\n adoptingRef.current = false;\n element?.style.removeProperty(\"translate\");\n });\n\n // ── The z-order lane ────────────────────────────────────────────────────\n const summonStore = useOptionalSummonStore();\n const laneZ = useSyncExternalStore(\n summonStore ? summonStore.subscribe : noopSubscribe,\n () => (summonStore ? (summonStore.getState() as { windowManager?: { transientZ?: Record<string, number> } }).windowManager?.transientZ?.[id] : undefined),\n () => undefined,\n );\n useEffect(() => {\n if (!summonStore) return undefined;\n return () => {\n const state = summonStore.getState() as { windowManager?: { transientZ?: Record<string, number> } };\n if (state.windowManager?.transientZ?.[id] !== undefined) summonStore.dispatch(releaseTransientWindow(id));\n };\n }, [summonStore, id]);\n const zIndex = laneZ ?? baseZ;\n\n // ── The drag ────────────────────────────────────────────────────────────\n useEffect(\n () => () => {\n pressRef.current?.cleanup();\n pressRef.current = null;\n },\n [],\n );\n\n const commit = useCallback((next: DockPosition | null) => {\n const current = live.current;\n adoptingRef.current = true;\n if (current.isControlled) setPending({ value: next, forProp: current.controlled ?? null });\n else {\n setLocal(next);\n current.store.write(current.id, next);\n }\n current.onPositionChange?.(next);\n }, []);\n\n const onPointerDown = useCallback(\n (event: ReactPointerEvent<HTMLElement>) => {\n if (!draggable || event.button !== 0 || !element) return;\n if (!touch && event.pointerType === \"touch\") return;\n const target = event.target as HTMLElement | null;\n if (ignore && target) {\n const hit = target.closest(ignore);\n if (hit && hit !== event.currentTarget && event.currentTarget.contains(hit)) return;\n }\n pressRef.current?.cleanup();\n if (raiseOnPress && summonStore) summonStore.dispatch(raiseTransientWindow(id));\n // A press on bare chrome must not start a text selection; a press on a control keeps its default.\n if (!target?.closest(\"button,a,input,select,textarea,label,[role=button]\")) event.preventDefault();\n\n const rect = element.getBoundingClientRect();\n const viewport = readViewport();\n const size = measure(element);\n const press: Press = {\n pointerId: event.pointerId,\n startX: event.clientX,\n startY: event.clientY,\n origin: { left: rect.left, top: rect.top },\n size,\n viewport,\n active: false,\n latest: { left: rect.left, top: rect.top },\n release: null,\n cleanup: () => undefined,\n };\n // A placed dock starts from its committed offset (the host may add lifts on top of it);\n // a resting dock starts from where it is on screen.\n const startOffset: DockOffset =\n live.current.offset ?? fromScreen(press.origin, live.current.rawCorner, size, viewport);\n const startCorner = live.current.rawCorner;\n const startScreen = toScreen(startOffset, startCorner, size, viewport);\n\n const paint = () => {\n frameRef.current = null;\n const active = pressRef.current;\n if (!active || !active.active) return;\n element.style.translate = `${active.latest.left - startScreen.left}px ${active.latest.top - startScreen.top}px`;\n };\n const move = (e: PointerEvent) => {\n if (e.pointerId !== press.pointerId) return;\n const dx = e.clientX - press.startX;\n const dy = e.clientY - press.startY;\n const opts = live.current;\n if (!press.active) {\n if (Math.abs(dx) < opts.threshold && Math.abs(dy) < opts.threshold) return;\n press.active = true;\n press.release = holdDragCursor(\"grabbing\");\n setDragging(true);\n }\n const desired = fromScreen({ left: startScreen.left + dx, top: startScreen.top + dy }, startCorner, size, viewport);\n let next = toScreen(clampOffset(desired, startCorner, size, viewport, opts.clamp), startCorner, size, viewport);\n if (opts.avoid) {\n const keep = (p: ScreenPoint) =>\n toScreen(clampOffset(fromScreen(p, \"top-left\", size, viewport), \"top-left\", size, viewport, opts.clamp), \"top-left\", size, viewport);\n next = avoidExclusions(next, size, excludedRects(opts.avoid, element), opts.avoid.gap ?? DEFAULT_DOCK_MARGIN, keep);\n }\n press.latest = next;\n if (frameRef.current === null) {\n if (typeof window.requestAnimationFrame === \"function\") frameRef.current = window.requestAnimationFrame(paint);\n else paint();\n }\n };\n const end = (e: PointerEvent) => {\n if (e.pointerId !== press.pointerId) return;\n press.cleanup();\n pressRef.current = null;\n if (!press.active) return;\n press.release?.();\n setDragging(false);\n const opts = live.current;\n const finalCorner = opts.snapToCorner ? nearestCorner(press.latest, size, viewport) : startCorner;\n const finalOffset = clampOffset(fromScreen(press.latest, finalCorner, size, viewport), finalCorner, size, viewport, opts.clamp);\n commit(finalCorner === corner ? { x: finalOffset.x, y: finalOffset.y } : { ...finalOffset, corner: finalCorner });\n // The click the browser fires next is the tail of this drag, never an intent.\n const swallow = (click: MouseEvent) => {\n click.stopPropagation();\n click.preventDefault();\n };\n window.addEventListener(\"click\", swallow, { capture: true, once: true });\n window.setTimeout(() => window.removeEventListener(\"click\", swallow, { capture: true }), 0);\n };\n press.cleanup = () => {\n window.removeEventListener(\"pointermove\", move);\n window.removeEventListener(\"pointerup\", end);\n window.removeEventListener(\"pointercancel\", end);\n if (frameRef.current !== null) {\n window.cancelAnimationFrame?.(frameRef.current);\n frameRef.current = null;\n }\n if (!press.active) return;\n press.release?.();\n press.release = null;\n };\n pressRef.current = press;\n window.addEventListener(\"pointermove\", move);\n window.addEventListener(\"pointerup\", end);\n window.addEventListener(\"pointercancel\", end);\n },\n [commit, corner, draggable, element, id, ignore, raiseOnPress, summonStore, touch],\n );\n\n const reset = useCallback(() => {\n adoptingRef.current = true;\n commit(null);\n }, [commit]);\n\n // ── Placement ───────────────────────────────────────────────────────────\n let style: CSSProperties;\n if (renderedOffset) {\n const left = rawCorner.endsWith(\"left\");\n const top = rawCorner.startsWith(\"top\");\n style = {\n position: \"fixed\",\n left: left ? renderedOffset.x : \"auto\",\n right: left ? \"auto\" : renderedOffset.x,\n top: top ? renderedOffset.y : \"auto\",\n bottom: top ? \"auto\" : renderedOffset.y,\n };\n } else {\n const transform = [anchor?.centerX ? \"translateX(-50%)\" : null, nudge ? `translate(${nudge.left}px, ${nudge.top}px)` : null]\n .filter(Boolean)\n .join(\" \");\n style = {\n position: \"fixed\",\n top: anchor?.top,\n bottom: anchor?.bottom,\n left: anchor?.centerX ? \"50%\" : anchor?.left,\n right: anchor?.right,\n ...(transform ? { transform } : {}),\n };\n }\n if (zIndex !== undefined) style.zIndex = zIndex;\n\n return {\n ref: setElement,\n element,\n style,\n handleProps: {\n onPointerDown,\n style: draggable ? { cursor: \"grab\", touchAction: touch ? \"none\" : \"auto\" } : {},\n \"data-dock-handle\": \"\",\n },\n offset: renderedOffset,\n corner: rawCorner,\n dragging,\n moved: chosen !== null,\n zIndex,\n reset,\n };\n}\n","/**\n * Dock geometry — the pure half of a dock: corner-relative offsets, the clamp\n * that keeps a dock reachable, the nearest-corner snap and the exclusion\n * avoidance. No DOM reads except `avoidExclusions`, which is handed the\n * rectangles it must stay off.\n *\n * A dock's position is stored as an OFFSET FROM A CORNER, not as left/top: a\n * dock resting 12px from the bottom-right keeps that relationship when the\n * window is resized, and a position saved on a wide monitor comes back next to\n * the same corner on a laptop.\n */\n\nexport type DockCorner = \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n\n/** Distance in px from the corner's horizontal (`x`) and vertical (`y`) edges. */\nexport interface DockOffset {\n x: number;\n y: number;\n}\n\n/** A remembered position: an offset and the corner it is measured from (the dock's corner when omitted). */\nexport interface DockPosition extends DockOffset {\n corner?: DockCorner;\n}\n\nexport interface DockSize {\n width: number;\n height: number;\n}\n\nexport interface DockClamp {\n /** Smallest gap kept between the dock and the viewport edge. Default 8. */\n margin?: number;\n /**\n * How much of the dock must stay on screen. Default: all of it. A dock that\n * may hang off an edge (a pill you can park half-hidden) passes its grab area.\n */\n minVisible?: DockSize;\n}\n\nexport interface ScreenPoint {\n left: number;\n top: number;\n}\n\nexport interface ScreenRect extends ScreenPoint {\n right: number;\n bottom: number;\n}\n\nexport const DEFAULT_DOCK_MARGIN = 8;\n\n/** A pointer that moved less than this is a click, not a drag. */\nexport const DEFAULT_DRAG_THRESHOLD = 4;\n\nconst fromLeft = (corner: DockCorner): boolean => corner.endsWith(\"left\");\nconst fromTop = (corner: DockCorner): boolean => corner.startsWith(\"top\");\n\n/** The offset → the dock's top-left in viewport px. */\nexport function toScreen(offset: DockOffset, corner: DockCorner, size: DockSize, viewport: DockSize): ScreenPoint {\n return {\n left: fromLeft(corner) ? offset.x : viewport.width - size.width - offset.x,\n top: fromTop(corner) ? offset.y : viewport.height - size.height - offset.y,\n };\n}\n\n/** A top-left in viewport px → the offset from `corner`. */\nexport function fromScreen(point: ScreenPoint, corner: DockCorner, size: DockSize, viewport: DockSize): DockOffset {\n return {\n x: fromLeft(corner) ? point.left : viewport.width - size.width - point.left,\n y: fromTop(corner) ? point.top : viewport.height - size.height - point.top,\n };\n}\n\n/**\n * Keep the offset inside the viewport. When the dock is larger than the room\n * there is, its TOP and LEFT stay visible — that is where a header, a grip\n * and a close button live, and an unreachable close button is how a movable\n * notice turns into an unclosable one.\n */\nexport function clampOffset(\n offset: DockOffset,\n corner: DockCorner,\n size: DockSize,\n viewport: DockSize,\n clamp: DockClamp = {},\n): DockOffset {\n const margin = clamp.margin ?? DEFAULT_DOCK_MARGIN;\n const visible = clamp.minVisible ?? size;\n const axis = (value: number, room: number, extent: number, nearIsStart: boolean): number => {\n const min = margin;\n const max = room - extent - margin;\n if (max < min) return Math.round(nearIsStart ? min : max);\n return Math.round(Math.min(Math.max(value, min), max));\n };\n return {\n x: axis(offset.x, viewport.width, visible.width, fromLeft(corner)),\n y: axis(offset.y, viewport.height, visible.height, fromTop(corner)),\n };\n}\n\n/** The corner nearest the dock's centre — where a dropped dock re-anchors when snapping is on. */\nexport function nearestCorner(point: ScreenPoint, size: DockSize, viewport: DockSize): DockCorner {\n const top = point.top + size.height / 2 < viewport.height / 2;\n const left = point.left + size.width / 2 < viewport.width / 2;\n return `${top ? \"top\" : \"bottom\"}-${left ? \"left\" : \"right\"}`;\n}\n\nfunction overlaps(a: ScreenRect, b: ScreenRect): boolean {\n return a.left < b.right && a.right > b.left && a.top < b.bottom && a.bottom > b.top;\n}\n\n/**\n * Keep the dock off fixed controls it must never cover (a table's pager, a\n * composer) without reserving page space. A clear position is returned\n * untouched; a covering one moves to the NEAREST clear candidate — never\n * further than it has to.\n */\nexport function avoidExclusions(\n point: ScreenPoint,\n size: DockSize,\n excluded: readonly ScreenRect[],\n gap: number,\n keepOnScreen: (point: ScreenPoint) => ScreenPoint,\n): ScreenPoint {\n const bounded = keepOnScreen(point);\n if (excluded.length === 0) return bounded;\n const rectFor = (candidate: ScreenPoint): ScreenRect => ({\n left: candidate.left,\n top: candidate.top,\n right: candidate.left + size.width,\n bottom: candidate.top + size.height,\n });\n const isClear = (candidate: ScreenPoint) => !excluded.some((target) => overlaps(rectFor(candidate), target));\n if (isClear(bounded)) return bounded;\n const clear = excluded\n .flatMap((target) => [\n { left: bounded.left, top: target.top - size.height - gap },\n { left: bounded.left, top: target.bottom + gap },\n { left: target.left - size.width - gap, top: bounded.top },\n { left: target.right + gap, top: bounded.top },\n ])\n .map(keepOnScreen)\n .filter(isClear);\n if (clear.length === 0) return bounded;\n const distance = (candidate: ScreenPoint) => Math.hypot(candidate.left - bounded.left, candidate.top - bounded.top);\n return clear.reduce((nearest, candidate) => (distance(candidate) < distance(nearest) ? candidate : nearest));\n}\n\nexport function samePosition(a: DockPosition | null | undefined, b: DockPosition | null | undefined): boolean {\n if (!a || !b) return a === b || (!a && !b);\n return a.x === b.x && a.y === b.y && a.corner === b.corner;\n}\n","/**\n * Where a dock remembers its position.\n *\n * The package never decides WHICH storage a host uses: a host that keeps\n * browser state behind its own declared keys (or syncs it per user) hands a\n * `DockPositionStore` to `<DockProvider>`, or to one dock through its `store`\n * option. With neither, positions live in this browser's localStorage under\n * `matrx:summon:dock:<id>` — every read and write is SSR-safe and never throws\n * (private mode, quota and disabled storage degrade to \"nothing stored\").\n */\n\nimport { createContext, createElement, useContext, type ReactNode } from \"react\";\nimport type { DockCorner, DockPosition } from \"./geometry\";\n\nexport interface DockPositionStore {\n read(id: string): DockPosition | null;\n /** `null` forgets the position (the dock goes back to its resting place). */\n write(id: string, position: DockPosition | null): void;\n}\n\nexport const DOCK_STORAGE_PREFIX = \"matrx:summon:dock:\";\n\nconst CORNERS: readonly DockCorner[] = [\"top-left\", \"top-right\", \"bottom-left\", \"bottom-right\"];\n\n/** Accept only a well-formed position; anything else reads as \"nothing stored\". */\nexport function parseDockPosition(value: unknown): DockPosition | null {\n if (!value || typeof value !== \"object\") return null;\n const { x, y, corner } = value as Record<string, unknown>;\n if (typeof x !== \"number\" || typeof y !== \"number\" || !Number.isFinite(x) || !Number.isFinite(y)) return null;\n if (corner !== undefined && !CORNERS.includes(corner as DockCorner)) return null;\n return corner === undefined ? { x, y } : { x, y, corner: corner as DockCorner };\n}\n\nfunction storage(): Storage | null {\n try {\n return typeof window === \"undefined\" ? null : window.localStorage;\n } catch {\n return null;\n }\n}\n\n/** The default store: one localStorage key per dock id. */\nexport function createLocalDockStore(prefix: string = DOCK_STORAGE_PREFIX): DockPositionStore {\n return {\n read(id) {\n try {\n const raw = storage()?.getItem(prefix + id);\n return raw ? parseDockPosition(JSON.parse(raw)) : null;\n } catch {\n return null;\n }\n },\n write(id, position) {\n try {\n const area = storage();\n if (!area) return;\n if (position) area.setItem(prefix + id, JSON.stringify(position));\n else area.removeItem(prefix + id);\n } catch {\n // Storage refused: the in-memory position still applies for this page.\n }\n },\n };\n}\n\n/** A store that remembers nothing — for docks whose place is per-moment (a toast, a stacked widget). */\nexport const memoryOnlyDockStore: DockPositionStore = { read: () => null, write: () => undefined };\n\nconst defaultStore = createLocalDockStore();\n\nconst DockStoreContext = createContext<DockPositionStore | null>(null);\n\nexport interface DockProviderProps {\n store: DockPositionStore;\n children?: ReactNode;\n}\n\n/** Hand every dock below one position store (the host's declared keys, a per-user sync). */\nexport function DockProvider({ store, children }: DockProviderProps): ReactNode {\n return createElement(DockStoreContext.Provider, { value: store }, children);\n}\n\n/** The store a dock uses: its own option, else the nearest provider, else localStorage. */\nexport function useDockStore(own?: DockPositionStore): DockPositionStore {\n const provided = useContext(DockStoreContext);\n return own ?? provided ?? defaultStore;\n}\n"],"mappings":";;;AAOA,SAAS,iBAAAA,gBAAe,cAAAC,mBAA2E;;;ACkBnG;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB,8BAA8B;AAC7D,SAAS,8BAA8B;;;ACahC,IAAM,sBAAsB;AAG5B,IAAM,yBAAyB;AAEtC,IAAM,WAAW,CAAC,WAAgC,OAAO,SAAS,MAAM;AACxE,IAAM,UAAU,CAAC,WAAgC,OAAO,WAAW,KAAK;AAGjE,SAAS,SAAS,QAAoB,QAAoB,MAAgB,UAAiC;AAChH,SAAO;AAAA,IACL,MAAM,SAAS,MAAM,IAAI,OAAO,IAAI,SAAS,QAAQ,KAAK,QAAQ,OAAO;AAAA,IACzE,KAAK,QAAQ,MAAM,IAAI,OAAO,IAAI,SAAS,SAAS,K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AAAA,MACtC;AAAA;AAAA,EACF;AAEJ;","names":["createContext","useContext","createContext","useContext"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1319,11 +1319,14 @@ var windowManagerSlice = (0, import_toolkit2.createSlice)({
|
|
|
1319
1319
|
if (!Number.isFinite(viewportWidth) || !Number.isFinite(viewportHeight) || viewportWidth <= 0 || viewportHeight <= 0) {
|
|
1320
1320
|
return;
|
|
1321
1321
|
}
|
|
1322
|
-
state2.trayViewport = { width: viewportWidth, height: viewportHeight };
|
|
1323
1322
|
const minimized = Object.values(state2.windows).filter(
|
|
1324
1323
|
(w) => w.state === "minimized" && w.traySlot !== null
|
|
1325
1324
|
);
|
|
1326
1325
|
if (minimized.length === 0) return;
|
|
1326
|
+
const tv = state2.trayViewport;
|
|
1327
|
+
if (!tv || tv.width !== viewportWidth || tv.height !== viewportHeight) {
|
|
1328
|
+
state2.trayViewport = { width: viewportWidth, height: viewportHeight };
|
|
1329
|
+
}
|
|
1327
1330
|
recomputeAllTrayRects(state2);
|
|
1328
1331
|
},
|
|
1329
1332
|
/**
|