anentrypoint-design 0.0.177 → 0.0.179
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anentrypoint-design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.179",
|
|
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",
|
|
@@ -5,7 +5,10 @@ import { Btn, Icon } from './shell.js';
|
|
|
5
5
|
import { fileGlyph, fmtFileSize } from './files.js';
|
|
6
6
|
const h = webjsx.createElement;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// Monotonic id source for aria-labelledby wiring between a modal and its head.
|
|
9
|
+
let _modalSeq = 0;
|
|
10
|
+
|
|
11
|
+
function Backdrop({ onClose, children, kind = '', labelledBy } = {}) {
|
|
9
12
|
// webjsx invokes a ref callback with the element on mount and with null on
|
|
10
13
|
// unmount. We stash the per-element keydown teardown on the node itself so
|
|
11
14
|
// the null branch can run it — otherwise the document/element listener leaks
|
|
@@ -66,7 +69,11 @@ function Backdrop({ onClose, children, kind = '' } = {}) {
|
|
|
66
69
|
},
|
|
67
70
|
onclick: (e) => { if (e.target === e.currentTarget && onClose) onClose(); }
|
|
68
71
|
},
|
|
69
|
-
h('div', {
|
|
72
|
+
h('div', {
|
|
73
|
+
class: 'ds-modal' + (kind ? ' ds-modal-' + kind : ''),
|
|
74
|
+
role: 'dialog', 'aria-modal': 'true',
|
|
75
|
+
...(labelledBy ? { 'aria-labelledby': labelledBy } : {})
|
|
76
|
+
}, ...(Array.isArray(children) ? children : [children]))
|
|
70
77
|
);
|
|
71
78
|
}
|
|
72
79
|
|
|
@@ -75,11 +82,15 @@ function Backdrop({ onClose, children, kind = '' } = {}) {
|
|
|
75
82
|
// `actions` is an array of vnodes (already using the Btn primitive). Any of the
|
|
76
83
|
// slots may be omitted.
|
|
77
84
|
function Modal({ onClose, kind = '', head, headClass = '', headAttrs = {}, body, bodyClass = 'ds-modal-body', bodyAttrs = {}, actions } = {}) {
|
|
85
|
+
// Give the head a stable id so the dialog can point aria-labelledby at it,
|
|
86
|
+
// exposing the title as the dialog's accessible name to screen readers.
|
|
87
|
+
const headId = head != null ? ('ds-modal-head-' + (++_modalSeq)) : null;
|
|
78
88
|
return Backdrop({
|
|
79
89
|
onClose,
|
|
80
90
|
kind,
|
|
91
|
+
labelledBy: headId,
|
|
81
92
|
children: [
|
|
82
|
-
head != null ? h('div', { class: ('ds-modal-head' + (headClass ? ' ' + headClass : '')), ...headAttrs }, ...(Array.isArray(head) ? head : [head])) : null,
|
|
93
|
+
head != null ? h('div', { id: headId, class: ('ds-modal-head' + (headClass ? ' ' + headClass : '')), ...headAttrs }, ...(Array.isArray(head) ? head : [head])) : null,
|
|
83
94
|
body != null ? h('div', { class: bodyClass, ...bodyAttrs }, ...(Array.isArray(body) ? body : [body])) : null,
|
|
84
95
|
actions != null ? h('div', { class: 'ds-modal-actions' }, ...(Array.isArray(actions) ? actions : [actions])) : null,
|
|
85
96
|
].filter(Boolean)
|
|
@@ -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';
|