anentrypoint-design 0.0.177 → 0.0.178
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/247420.js +10 -10
- package/package.json +1 -1
- package/src/components/interaction-primitives.js +48 -0
- package/src/components.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anentrypoint-design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.178",
|
|
4
4
|
"description": "247420 design system SDK — webjsx + modified ripple-ui, single-file ESM bundle for reproducible use of the AnEntrypoint design.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/247420.js",
|
|
@@ -139,6 +139,54 @@ export function useNumberScrub(el, { getValue, onChange, step = 0.01, threshold
|
|
|
139
139
|
}};
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
// usePointerDrag — free 2D pointer drag with caller-supplied onMove, for surfaces
|
|
143
|
+
// that need raw pointer coordinates each frame (a 3D viewport gizmo, a canvas
|
|
144
|
+
// handle) rather than the data-transfer DnD model of useDraggable. Pointer Events
|
|
145
|
+
// only, so mouse+touch+pen+XR-controller all drive it. The primary pointer is
|
|
146
|
+
// captured on the element (drag keeps tracking when it leaves the element or
|
|
147
|
+
// crosses a panel) and released on pointerup/pointercancel; a non-primary pointer
|
|
148
|
+
// (second finger) is ignored mid-drag so multi-touch never makes the drag jump.
|
|
149
|
+
// onStart returns false to decline the drag (e.g. a miss in the gizmo raycast),
|
|
150
|
+
// leaving the pointerdown to propagate to other handlers.
|
|
151
|
+
export function usePointerDrag(el, { onStart, onMove, onEnd, button = 0 } = {}) {
|
|
152
|
+
if (!el) return { destroy() {} };
|
|
153
|
+
let pid = null;
|
|
154
|
+
const onMoveEv = (e) => {
|
|
155
|
+
if (pid == null || e.pointerId !== pid) return;
|
|
156
|
+
if (onMove) onMove(e);
|
|
157
|
+
};
|
|
158
|
+
const finish = (e, cancelled) => {
|
|
159
|
+
if (pid == null) return;
|
|
160
|
+
try { el.releasePointerCapture(pid); } catch {}
|
|
161
|
+
pid = null;
|
|
162
|
+
el.removeAttribute('data-pointer-dragging');
|
|
163
|
+
window.removeEventListener('pointermove', onMoveEv);
|
|
164
|
+
window.removeEventListener('pointerup', onUpEv);
|
|
165
|
+
window.removeEventListener('pointercancel', onCancelEv);
|
|
166
|
+
if (onEnd) onEnd(e, cancelled);
|
|
167
|
+
};
|
|
168
|
+
const onUpEv = (e) => { if (e.pointerId === pid) finish(e, false); };
|
|
169
|
+
const onCancelEv = (e) => { if (e.pointerId === pid) finish(e, true); };
|
|
170
|
+
const onDown = (e) => {
|
|
171
|
+
if (button != null && e.button != null && e.button !== button) return;
|
|
172
|
+
if (pid != null) return; // already dragging with the primary pointer
|
|
173
|
+
if (onStart && onStart(e) === false) return; // caller declined (e.g. raycast miss)
|
|
174
|
+
pid = e.pointerId;
|
|
175
|
+
el.setAttribute('data-pointer-dragging', 'true');
|
|
176
|
+
try { el.setPointerCapture(pid); } catch {}
|
|
177
|
+
window.addEventListener('pointermove', onMoveEv);
|
|
178
|
+
window.addEventListener('pointerup', onUpEv);
|
|
179
|
+
window.addEventListener('pointercancel', onCancelEv);
|
|
180
|
+
};
|
|
181
|
+
el.addEventListener('pointerdown', onDown);
|
|
182
|
+
return { destroy() {
|
|
183
|
+
el.removeEventListener('pointerdown', onDown);
|
|
184
|
+
window.removeEventListener('pointermove', onMoveEv);
|
|
185
|
+
window.removeEventListener('pointerup', onUpEv);
|
|
186
|
+
window.removeEventListener('pointercancel', onCancelEv);
|
|
187
|
+
}, get dragging() { return pid != null; } };
|
|
188
|
+
}
|
|
189
|
+
|
|
142
190
|
export function useDropTarget(el, { accepts = [], onDrop, onDragOver } = {}) {
|
|
143
191
|
if (!el) return { destroy() {} };
|
|
144
192
|
el.setAttribute('data-drop-target', '');
|
package/src/components.js
CHANGED
|
@@ -58,7 +58,7 @@ export {
|
|
|
58
58
|
} from './components/form-primitives.js';
|
|
59
59
|
|
|
60
60
|
export {
|
|
61
|
-
useDraggable, useDropTarget, useNumberScrub, Reorderable,
|
|
61
|
+
useDraggable, useDropTarget, useNumberScrub, usePointerDrag, Reorderable,
|
|
62
62
|
useKeyboardShortcut, formatShortcut, ShortcutHint,
|
|
63
63
|
useKeyboardShortcutHelp, ShortcutHelpDialog
|
|
64
64
|
} from './components/interaction-primitives.js';
|