@autono/pinbox-toolbar 0.16.0 → 0.18.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/dist/index.js +1 -1
- package/dist/react.js +1 -1
- package/dist/{src-z-YC_RT4.js → src-BsWnyGwB.js} +45 -21
- package/dist/svelte.js +1 -1
- package/dist/toolbar.iife.js +45 -21
- package/dist/vue.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as HubError, c as createStore, i as HubTransport, l as deriveUiStatus, n as defineToolbarElement, o as appendThreadMessage, r as PinboxToolbarElement, s as applyHubEvent, t as Pinbox, u as upsertPin } from "./src-
|
|
1
|
+
import { a as HubError, c as createStore, i as HubTransport, l as deriveUiStatus, n as defineToolbarElement, o as appendThreadMessage, r as PinboxToolbarElement, s as applyHubEvent, t as Pinbox, u as upsertPin } from "./src-BsWnyGwB.js";
|
|
2
2
|
export { HubError, HubTransport, Pinbox, PinboxToolbarElement, appendThreadMessage, applyHubEvent, createStore, defineToolbarElement, deriveUiStatus, upsertPin };
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as defineToolbarElement, r as PinboxToolbarElement } from "./src-
|
|
1
|
+
import { n as defineToolbarElement, r as PinboxToolbarElement } from "./src-BsWnyGwB.js";
|
|
2
2
|
import { createElement, useEffect, useRef } from "react";
|
|
3
3
|
//#region src/react.ts
|
|
4
4
|
/**
|
|
@@ -239,20 +239,31 @@ const DRAG_START = 8;
|
|
|
239
239
|
/** …but a release under this much TOTAL travel is still a tap. */
|
|
240
240
|
const TAP_MAX = 12;
|
|
241
241
|
/**
|
|
242
|
-
* Attach the drag rules to `el`.
|
|
243
|
-
*
|
|
244
|
-
* is the
|
|
242
|
+
* Attach the drag rules to `el`. The press is read on `el`; move/up/cancel are read on its
|
|
243
|
+
* document while a hold is live, so the release cannot be lost to a failed capture. Pointer
|
|
244
|
+
* capture is still requested (it keeps moves flowing when the pointer leaves the window);
|
|
245
|
+
* `touch-action: none` on the element is the caller's job.
|
|
245
246
|
*/
|
|
246
247
|
function attachDrag(el, on) {
|
|
248
|
+
const doc = el.ownerDocument;
|
|
249
|
+
const win = doc.defaultView;
|
|
247
250
|
let hold = null;
|
|
251
|
+
function listen(active) {
|
|
252
|
+
const method = active ? "addEventListener" : "removeEventListener";
|
|
253
|
+
doc[method]("pointermove", onPointerMove, true);
|
|
254
|
+
doc[method]("pointerup", onPointerUp, true);
|
|
255
|
+
doc[method]("pointercancel", onPointerUp, true);
|
|
256
|
+
win?.[method]("blur", onBlur);
|
|
257
|
+
}
|
|
248
258
|
function onPointerDown(e) {
|
|
249
|
-
if (e.button !== 0) return;
|
|
259
|
+
if (e.button !== 0 || hold !== null) return;
|
|
250
260
|
const origin = on.origin();
|
|
251
261
|
if (origin === null) return;
|
|
252
262
|
try {
|
|
253
263
|
el.setPointerCapture(e.pointerId);
|
|
254
264
|
} catch {}
|
|
255
265
|
hold = {
|
|
266
|
+
pointerId: e.pointerId,
|
|
256
267
|
px: e.clientX,
|
|
257
268
|
py: e.clientY,
|
|
258
269
|
origin,
|
|
@@ -260,16 +271,17 @@ function attachDrag(el, on) {
|
|
|
260
271
|
ly: e.clientY,
|
|
261
272
|
started: false
|
|
262
273
|
};
|
|
274
|
+
listen(true);
|
|
263
275
|
}
|
|
264
276
|
function onPointerMove(e) {
|
|
265
|
-
if (hold === null) return;
|
|
277
|
+
if (hold === null || e.pointerId !== hold.pointerId) return;
|
|
266
278
|
hold.lx = e.clientX;
|
|
267
279
|
hold.ly = e.clientY;
|
|
268
280
|
const dx = e.clientX - hold.px;
|
|
269
281
|
const dy = e.clientY - hold.py;
|
|
270
282
|
if (!hold.started) {
|
|
271
283
|
if (!on.canStart()) {
|
|
272
|
-
|
|
284
|
+
release();
|
|
273
285
|
return;
|
|
274
286
|
}
|
|
275
287
|
if (Math.hypot(dx, dy) < DRAG_START) return;
|
|
@@ -281,10 +293,18 @@ function attachDrag(el, on) {
|
|
|
281
293
|
y: hold.origin.y + dy
|
|
282
294
|
});
|
|
283
295
|
}
|
|
284
|
-
function
|
|
285
|
-
if (hold === null) return;
|
|
286
|
-
const h = hold;
|
|
296
|
+
function release() {
|
|
287
297
|
hold = null;
|
|
298
|
+
listen(false);
|
|
299
|
+
}
|
|
300
|
+
/** The window lost focus mid-hold: whatever the pointer does next, we will not see it. */
|
|
301
|
+
function onBlur() {
|
|
302
|
+
if (hold !== null) onPointerUp();
|
|
303
|
+
}
|
|
304
|
+
function onPointerUp(e) {
|
|
305
|
+
if (hold === null || e !== void 0 && e.pointerId !== hold.pointerId) return;
|
|
306
|
+
const h = hold;
|
|
307
|
+
release();
|
|
288
308
|
const total = Math.hypot(h.lx - h.px, h.ly - h.py);
|
|
289
309
|
on.onEnd({
|
|
290
310
|
dragged: h.started && total >= TAP_MAX,
|
|
@@ -297,19 +317,11 @@ function attachDrag(el, on) {
|
|
|
297
317
|
});
|
|
298
318
|
}
|
|
299
319
|
el.addEventListener("pointerdown", onPointerDown);
|
|
300
|
-
el.addEventListener("pointermove", onPointerMove);
|
|
301
|
-
el.addEventListener("pointerup", onPointerUp);
|
|
302
|
-
el.addEventListener("pointercancel", onPointerUp);
|
|
303
320
|
return {
|
|
304
|
-
cancel
|
|
305
|
-
hold = null;
|
|
306
|
-
},
|
|
321
|
+
cancel: release,
|
|
307
322
|
destroy() {
|
|
308
|
-
|
|
323
|
+
release();
|
|
309
324
|
el.removeEventListener("pointerdown", onPointerDown);
|
|
310
|
-
el.removeEventListener("pointermove", onPointerMove);
|
|
311
|
-
el.removeEventListener("pointerup", onPointerUp);
|
|
312
|
-
el.removeEventListener("pointercancel", onPointerUp);
|
|
313
325
|
}
|
|
314
326
|
};
|
|
315
327
|
}
|
|
@@ -479,6 +491,7 @@ function createMinimize(host) {
|
|
|
479
491
|
ui.surface.style.borderRadius = `${m.r}px`;
|
|
480
492
|
ui.surface.style.transform = `translate(${m.x}px, ${m.y}px)`;
|
|
481
493
|
ui.carrier.style.transform = `translate(${m.x + m.w / 2 - PUCK / 2}px, ${m.y + m.h / 2 - PUCK / 2}px)`;
|
|
494
|
+
if (mode === "settle") placePuck(m.x, m.y);
|
|
482
495
|
const iconOn = mode === "drag" || mode === "settle" || (mode === "toPuck" || mode === "toBar") && m.w < CARRIER_MAX_W;
|
|
483
496
|
ui.carrier.classList.toggle("show", iconOn);
|
|
484
497
|
}
|
|
@@ -653,9 +666,17 @@ function createMinimize(host) {
|
|
|
653
666
|
if (path.includes(ui.fan) || path.includes(ui.puck)) return;
|
|
654
667
|
closeFan();
|
|
655
668
|
}
|
|
669
|
+
/** Grabbable at rest and while settling — mid-flight, the spring's current spot is the origin. */
|
|
670
|
+
const grabbable = () => mode === "puck" || mode === "settle";
|
|
656
671
|
const drag = attachDrag(ui.puck, {
|
|
657
|
-
origin: () =>
|
|
658
|
-
|
|
672
|
+
origin: () => {
|
|
673
|
+
if (mode === "settle") return {
|
|
674
|
+
x: main.cur.x,
|
|
675
|
+
y: main.cur.y
|
|
676
|
+
};
|
|
677
|
+
return mode === "puck" ? puckPos : null;
|
|
678
|
+
},
|
|
679
|
+
canStart: grabbable,
|
|
659
680
|
onStart(origin) {
|
|
660
681
|
closeFan();
|
|
661
682
|
mode = "drag";
|
|
@@ -718,6 +739,9 @@ function createMinimize(host) {
|
|
|
718
739
|
x: main.tgt.x,
|
|
719
740
|
y: main.tgt.y
|
|
720
741
|
});
|
|
742
|
+
placePuck(main.cur.x, main.cur.y);
|
|
743
|
+
ui.puck.classList.remove("pb-ghost");
|
|
744
|
+
hideMorph();
|
|
721
745
|
main.to({
|
|
722
746
|
...p,
|
|
723
747
|
w: PUCK,
|
package/dist/svelte.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as HubError, c as createStore, i as HubTransport, l as deriveUiStatus, n as defineToolbarElement, o as appendThreadMessage, r as PinboxToolbarElement, s as applyHubEvent, t as Pinbox, u as upsertPin } from "./src-
|
|
1
|
+
import { a as HubError, c as createStore, i as HubTransport, l as deriveUiStatus, n as defineToolbarElement, o as appendThreadMessage, r as PinboxToolbarElement, s as applyHubEvent, t as Pinbox, u as upsertPin } from "./src-BsWnyGwB.js";
|
|
2
2
|
//#region src/svelte.ts
|
|
3
3
|
/**
|
|
4
4
|
* `<div use:pinbox={{ endpoint }} />` — creates + configures the element BEFORE insertion
|
package/dist/toolbar.iife.js
CHANGED
|
@@ -241,20 +241,31 @@ var Pinbox = (function(exports) {
|
|
|
241
241
|
/** …but a release under this much TOTAL travel is still a tap. */
|
|
242
242
|
const TAP_MAX = 12;
|
|
243
243
|
/**
|
|
244
|
-
* Attach the drag rules to `el`.
|
|
245
|
-
*
|
|
246
|
-
* is the
|
|
244
|
+
* Attach the drag rules to `el`. The press is read on `el`; move/up/cancel are read on its
|
|
245
|
+
* document while a hold is live, so the release cannot be lost to a failed capture. Pointer
|
|
246
|
+
* capture is still requested (it keeps moves flowing when the pointer leaves the window);
|
|
247
|
+
* `touch-action: none` on the element is the caller's job.
|
|
247
248
|
*/
|
|
248
249
|
function attachDrag(el, on) {
|
|
250
|
+
const doc = el.ownerDocument;
|
|
251
|
+
const win = doc.defaultView;
|
|
249
252
|
let hold = null;
|
|
253
|
+
function listen(active) {
|
|
254
|
+
const method = active ? "addEventListener" : "removeEventListener";
|
|
255
|
+
doc[method]("pointermove", onPointerMove, true);
|
|
256
|
+
doc[method]("pointerup", onPointerUp, true);
|
|
257
|
+
doc[method]("pointercancel", onPointerUp, true);
|
|
258
|
+
win?.[method]("blur", onBlur);
|
|
259
|
+
}
|
|
250
260
|
function onPointerDown(e) {
|
|
251
|
-
if (e.button !== 0) return;
|
|
261
|
+
if (e.button !== 0 || hold !== null) return;
|
|
252
262
|
const origin = on.origin();
|
|
253
263
|
if (origin === null) return;
|
|
254
264
|
try {
|
|
255
265
|
el.setPointerCapture(e.pointerId);
|
|
256
266
|
} catch {}
|
|
257
267
|
hold = {
|
|
268
|
+
pointerId: e.pointerId,
|
|
258
269
|
px: e.clientX,
|
|
259
270
|
py: e.clientY,
|
|
260
271
|
origin,
|
|
@@ -262,16 +273,17 @@ var Pinbox = (function(exports) {
|
|
|
262
273
|
ly: e.clientY,
|
|
263
274
|
started: false
|
|
264
275
|
};
|
|
276
|
+
listen(true);
|
|
265
277
|
}
|
|
266
278
|
function onPointerMove(e) {
|
|
267
|
-
if (hold === null) return;
|
|
279
|
+
if (hold === null || e.pointerId !== hold.pointerId) return;
|
|
268
280
|
hold.lx = e.clientX;
|
|
269
281
|
hold.ly = e.clientY;
|
|
270
282
|
const dx = e.clientX - hold.px;
|
|
271
283
|
const dy = e.clientY - hold.py;
|
|
272
284
|
if (!hold.started) {
|
|
273
285
|
if (!on.canStart()) {
|
|
274
|
-
|
|
286
|
+
release();
|
|
275
287
|
return;
|
|
276
288
|
}
|
|
277
289
|
if (Math.hypot(dx, dy) < DRAG_START) return;
|
|
@@ -283,10 +295,18 @@ var Pinbox = (function(exports) {
|
|
|
283
295
|
y: hold.origin.y + dy
|
|
284
296
|
});
|
|
285
297
|
}
|
|
286
|
-
function
|
|
287
|
-
if (hold === null) return;
|
|
288
|
-
const h = hold;
|
|
298
|
+
function release() {
|
|
289
299
|
hold = null;
|
|
300
|
+
listen(false);
|
|
301
|
+
}
|
|
302
|
+
/** The window lost focus mid-hold: whatever the pointer does next, we will not see it. */
|
|
303
|
+
function onBlur() {
|
|
304
|
+
if (hold !== null) onPointerUp();
|
|
305
|
+
}
|
|
306
|
+
function onPointerUp(e) {
|
|
307
|
+
if (hold === null || e !== void 0 && e.pointerId !== hold.pointerId) return;
|
|
308
|
+
const h = hold;
|
|
309
|
+
release();
|
|
290
310
|
const total = Math.hypot(h.lx - h.px, h.ly - h.py);
|
|
291
311
|
on.onEnd({
|
|
292
312
|
dragged: h.started && total >= TAP_MAX,
|
|
@@ -299,19 +319,11 @@ var Pinbox = (function(exports) {
|
|
|
299
319
|
});
|
|
300
320
|
}
|
|
301
321
|
el.addEventListener("pointerdown", onPointerDown);
|
|
302
|
-
el.addEventListener("pointermove", onPointerMove);
|
|
303
|
-
el.addEventListener("pointerup", onPointerUp);
|
|
304
|
-
el.addEventListener("pointercancel", onPointerUp);
|
|
305
322
|
return {
|
|
306
|
-
cancel
|
|
307
|
-
hold = null;
|
|
308
|
-
},
|
|
323
|
+
cancel: release,
|
|
309
324
|
destroy() {
|
|
310
|
-
|
|
325
|
+
release();
|
|
311
326
|
el.removeEventListener("pointerdown", onPointerDown);
|
|
312
|
-
el.removeEventListener("pointermove", onPointerMove);
|
|
313
|
-
el.removeEventListener("pointerup", onPointerUp);
|
|
314
|
-
el.removeEventListener("pointercancel", onPointerUp);
|
|
315
327
|
}
|
|
316
328
|
};
|
|
317
329
|
}
|
|
@@ -481,6 +493,7 @@ var Pinbox = (function(exports) {
|
|
|
481
493
|
ui.surface.style.borderRadius = `${m.r}px`;
|
|
482
494
|
ui.surface.style.transform = `translate(${m.x}px, ${m.y}px)`;
|
|
483
495
|
ui.carrier.style.transform = `translate(${m.x + m.w / 2 - PUCK / 2}px, ${m.y + m.h / 2 - PUCK / 2}px)`;
|
|
496
|
+
if (mode === "settle") placePuck(m.x, m.y);
|
|
484
497
|
const iconOn = mode === "drag" || mode === "settle" || (mode === "toPuck" || mode === "toBar") && m.w < CARRIER_MAX_W;
|
|
485
498
|
ui.carrier.classList.toggle("show", iconOn);
|
|
486
499
|
}
|
|
@@ -655,9 +668,17 @@ var Pinbox = (function(exports) {
|
|
|
655
668
|
if (path.includes(ui.fan) || path.includes(ui.puck)) return;
|
|
656
669
|
closeFan();
|
|
657
670
|
}
|
|
671
|
+
/** Grabbable at rest and while settling — mid-flight, the spring's current spot is the origin. */
|
|
672
|
+
const grabbable = () => mode === "puck" || mode === "settle";
|
|
658
673
|
const drag = attachDrag(ui.puck, {
|
|
659
|
-
origin: () =>
|
|
660
|
-
|
|
674
|
+
origin: () => {
|
|
675
|
+
if (mode === "settle") return {
|
|
676
|
+
x: main.cur.x,
|
|
677
|
+
y: main.cur.y
|
|
678
|
+
};
|
|
679
|
+
return mode === "puck" ? puckPos : null;
|
|
680
|
+
},
|
|
681
|
+
canStart: grabbable,
|
|
661
682
|
onStart(origin) {
|
|
662
683
|
closeFan();
|
|
663
684
|
mode = "drag";
|
|
@@ -720,6 +741,9 @@ var Pinbox = (function(exports) {
|
|
|
720
741
|
x: main.tgt.x,
|
|
721
742
|
y: main.tgt.y
|
|
722
743
|
});
|
|
744
|
+
placePuck(main.cur.x, main.cur.y);
|
|
745
|
+
ui.puck.classList.remove("pb-ghost");
|
|
746
|
+
hideMorph();
|
|
723
747
|
main.to({
|
|
724
748
|
...p,
|
|
725
749
|
w: PUCK,
|
package/dist/vue.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autono/pinbox-toolbar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@autono/pinbox-core": "0.
|
|
74
|
+
"@autono/pinbox-core": "0.18.0",
|
|
75
75
|
"@types/react": "^19.2.0",
|
|
76
76
|
"typescript": "^7.0.0",
|
|
77
77
|
"tsdown": "^0.22.0",
|