@floegence/floe-webapp-core 0.36.9 → 0.36.11
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/components/deck/DeckCell.d.ts +3 -1
- package/dist/components/deck/DeckCell.js +29 -37
- package/dist/components/deck/DeckGrid.js +125 -103
- package/dist/components/deck/DropZonePreview.js +15 -15
- package/dist/components/deck/WidgetResizeHandle.js +21 -21
- package/dist/components/deck/deckGridMetrics.d.ts +22 -0
- package/dist/components/deck/deckGridMetrics.js +51 -16
- package/dist/components/deck/deckPointerSession.d.ts +2 -0
- package/dist/components/deck/deckPointerSession.js +38 -31
- package/dist/context/DeckContext.d.ts +14 -1
- package/dist/context/DeckContext.js +187 -174
- package/dist/floe.css +2 -0
- package/dist/hooks/useDeckDrag.js +27 -24
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const D = 24, _ = 24, h = 4, s = 20, f = 4, C = {
|
|
2
2
|
cols: 24,
|
|
3
3
|
defaultRows: 24,
|
|
4
4
|
gap: 4,
|
|
5
5
|
rowHeight: 20
|
|
6
6
|
};
|
|
7
|
-
function
|
|
7
|
+
function r(t) {
|
|
8
8
|
return {
|
|
9
9
|
cols: parseInt(t.dataset.gridCols || String(24), 10),
|
|
10
10
|
rowHeight: parseFloat(t.dataset.rowHeight || String(20)),
|
|
@@ -12,21 +12,56 @@ function D(t) {
|
|
|
12
12
|
defaultRows: parseInt(t.dataset.defaultRows || String(24), 10)
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
return !Number.isFinite(
|
|
18
|
-
...
|
|
19
|
-
cellWidth:
|
|
20
|
-
cellHeight:
|
|
15
|
+
function l(t, n) {
|
|
16
|
+
const o = r(t), e = n?.paddingLeft ?? 0, c = n?.paddingRight ?? 0, i = t.clientWidth - e - c, a = o.gap * (o.cols - 1), d = (i - a) / o.cols;
|
|
17
|
+
return !Number.isFinite(d) || d <= 0 ? null : {
|
|
18
|
+
...o,
|
|
19
|
+
cellWidth: d,
|
|
20
|
+
cellHeight: o.rowHeight + o.gap
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function u(t) {
|
|
24
|
+
const n = t.ownerDocument.defaultView?.getComputedStyle(t) ?? getComputedStyle(t), o = parseFloat(n.paddingLeft) || 0, e = parseFloat(n.paddingRight) || 0, c = parseFloat(n.paddingTop) || 0, i = parseFloat(n.paddingBottom) || 0, a = l(t, { paddingLeft: o, paddingRight: e });
|
|
25
|
+
return a ? {
|
|
26
|
+
...a,
|
|
27
|
+
paddingLeft: o,
|
|
28
|
+
paddingRight: e,
|
|
29
|
+
paddingTop: c,
|
|
30
|
+
paddingBottom: i
|
|
31
|
+
} : null;
|
|
32
|
+
}
|
|
33
|
+
function g(t) {
|
|
34
|
+
return t.cellWidth + t.gap;
|
|
35
|
+
}
|
|
36
|
+
function p(t) {
|
|
37
|
+
return t.cellHeight;
|
|
38
|
+
}
|
|
39
|
+
function R(t, n) {
|
|
40
|
+
return {
|
|
41
|
+
left: n.paddingLeft + t.col * g(n),
|
|
42
|
+
top: n.paddingTop + t.row * p(n),
|
|
43
|
+
width: t.colSpan * n.cellWidth + Math.max(0, t.colSpan - 1) * n.gap,
|
|
44
|
+
height: t.rowSpan * n.rowHeight + Math.max(0, t.rowSpan - 1) * n.gap
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function G(t, n, o) {
|
|
48
|
+
return {
|
|
49
|
+
x: (n.col - t.col) * g(o),
|
|
50
|
+
y: (n.row - t.row) * p(o)
|
|
21
51
|
};
|
|
22
52
|
}
|
|
23
53
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
54
|
+
_ as DECK_DEFAULT_ROWS,
|
|
55
|
+
h as DECK_GAP,
|
|
56
|
+
D as DECK_GRID_COLS,
|
|
57
|
+
C as DECK_GRID_CONFIG,
|
|
58
|
+
s as DECK_MIN_ROW_HEIGHT,
|
|
59
|
+
f as DECK_PADDING,
|
|
60
|
+
g as getDeckGridColPitch,
|
|
61
|
+
p as getDeckGridRowPitch,
|
|
62
|
+
r as getGridConfigFromElement,
|
|
63
|
+
l as measureDeckGrid,
|
|
64
|
+
u as measureDeckGridSurface,
|
|
65
|
+
G as positionDeltaToDeckPixelOffset,
|
|
66
|
+
R as positionToDeckPixelRect
|
|
32
67
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { startHotInteraction as
|
|
2
|
-
import { measureDeckGrid as
|
|
1
|
+
import { startHotInteraction as Y } from "../../utils/hotInteraction.js";
|
|
2
|
+
import { measureDeckGrid as P } from "./deckGridMetrics.js";
|
|
3
3
|
function C(e) {
|
|
4
4
|
const d = e.lastClientY - e.gridRect.top, t = e.gridRect.bottom - e.lastClientY;
|
|
5
5
|
let n = 0;
|
|
@@ -12,23 +12,25 @@ function v(e) {
|
|
|
12
12
|
if (e.lastClientX === e.lastAppliedClientX && e.lastClientY === e.lastAppliedClientY && i === e.lastAppliedScrollTop)
|
|
13
13
|
return null;
|
|
14
14
|
e.lastAppliedClientX = e.lastClientX, e.lastAppliedClientY = e.lastClientY, e.lastAppliedScrollTop = i;
|
|
15
|
-
const
|
|
15
|
+
const r = P(e.gridEl, {
|
|
16
16
|
paddingLeft: e.gridPaddingLeft,
|
|
17
17
|
paddingRight: e.gridPaddingRight
|
|
18
18
|
});
|
|
19
|
-
return
|
|
19
|
+
return r ? {
|
|
20
20
|
snapshot: e,
|
|
21
21
|
deltaX: e.lastClientX - e.startClientX,
|
|
22
22
|
deltaY: e.lastClientY - e.startClientY + (i - e.startScrollTop),
|
|
23
|
-
cols:
|
|
24
|
-
rowHeight:
|
|
25
|
-
gap:
|
|
26
|
-
cellWidth:
|
|
27
|
-
cellHeight:
|
|
23
|
+
cols: r.cols,
|
|
24
|
+
rowHeight: r.rowHeight,
|
|
25
|
+
gap: r.gap,
|
|
26
|
+
cellWidth: r.cellWidth,
|
|
27
|
+
cellHeight: r.cellHeight,
|
|
28
|
+
colPitch: r.cellWidth + r.gap,
|
|
29
|
+
rowPitch: r.cellHeight
|
|
28
30
|
} : null;
|
|
29
31
|
}
|
|
30
32
|
function L(e) {
|
|
31
|
-
const i = e.gridEl.ownerDocument,
|
|
33
|
+
const i = e.gridEl.ownerDocument, r = i.defaultView ?? window, d = r.getComputedStyle(e.gridEl), t = {
|
|
32
34
|
pointerId: e.pointerEvent.pointerId,
|
|
33
35
|
kind: e.kind,
|
|
34
36
|
widgetId: e.widgetId,
|
|
@@ -45,7 +47,7 @@ function L(e) {
|
|
|
45
47
|
lastAppliedClientY: e.pointerEvent.clientY,
|
|
46
48
|
lastAppliedScrollTop: e.gridEl.scrollTop,
|
|
47
49
|
rafId: null,
|
|
48
|
-
stopHotInteraction:
|
|
50
|
+
stopHotInteraction: Y({
|
|
49
51
|
kind: e.kind,
|
|
50
52
|
cursor: e.cursor,
|
|
51
53
|
lockUserSelect: !0
|
|
@@ -54,15 +56,15 @@ function L(e) {
|
|
|
54
56
|
let n = !0;
|
|
55
57
|
const a = () => {
|
|
56
58
|
if (t.rafId = null, !n) return;
|
|
57
|
-
const
|
|
58
|
-
c && e.onMove(c), n &&
|
|
59
|
+
const l = C(t), c = v(t);
|
|
60
|
+
c && e.onMove(c), n && l && o();
|
|
59
61
|
}, o = () => {
|
|
60
62
|
if (!(!n || t.rafId !== null)) {
|
|
61
|
-
if (typeof
|
|
63
|
+
if (typeof r.requestAnimationFrame != "function") {
|
|
62
64
|
a();
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
|
-
t.rafId =
|
|
67
|
+
t.rafId = r.requestAnimationFrame(a);
|
|
66
68
|
}
|
|
67
69
|
}, I = () => {
|
|
68
70
|
if (!(!e.captureEl || typeof e.captureEl.releasePointerCapture != "function"))
|
|
@@ -70,30 +72,35 @@ function L(e) {
|
|
|
70
72
|
e.captureEl.releasePointerCapture(t.pointerId);
|
|
71
73
|
} catch {
|
|
72
74
|
}
|
|
73
|
-
},
|
|
75
|
+
}, h = () => {
|
|
74
76
|
i.removeEventListener("pointermove", g, !0), i.removeEventListener("pointerup", p, !0), i.removeEventListener("pointercancel", m, !0), e.captureEl?.removeEventListener("lostpointercapture", s);
|
|
75
|
-
}, u = (
|
|
77
|
+
}, u = (l) => {
|
|
76
78
|
if (!n) return;
|
|
77
|
-
const c =
|
|
79
|
+
const c = l?.event;
|
|
78
80
|
if (!(c && c.pointerId !== t.pointerId)) {
|
|
79
|
-
if (c && (t.lastClientX = c.clientX, t.lastClientY = c.clientY), n = !1, t.rafId !== null && typeof
|
|
81
|
+
if (c && (t.lastClientX = c.clientX, t.lastClientY = c.clientY), n = !1, t.rafId !== null && typeof r.cancelAnimationFrame == "function" && (r.cancelAnimationFrame(t.rafId), t.rafId = null), l?.commit !== !1) {
|
|
80
82
|
C(t);
|
|
81
83
|
const E = v(t);
|
|
82
84
|
E && e.onMove(E);
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
h(), I();
|
|
87
|
+
try {
|
|
88
|
+
e.onEnd({
|
|
89
|
+
commit: l?.commit !== !1,
|
|
90
|
+
snapshot: t
|
|
91
|
+
});
|
|
92
|
+
} finally {
|
|
93
|
+
t.stopHotInteraction?.(), t.stopHotInteraction = null;
|
|
94
|
+
}
|
|
88
95
|
}
|
|
89
|
-
}, f = (
|
|
90
|
-
!n ||
|
|
91
|
-
}, g = (
|
|
92
|
-
f(
|
|
93
|
-
}, p = (
|
|
94
|
-
u({ event:
|
|
95
|
-
}, m = (
|
|
96
|
-
u({ event:
|
|
96
|
+
}, f = (l) => {
|
|
97
|
+
!n || l.pointerId !== t.pointerId || (t.lastClientX = l.clientX, t.lastClientY = l.clientY, o());
|
|
98
|
+
}, g = (l) => {
|
|
99
|
+
f(l);
|
|
100
|
+
}, p = (l) => {
|
|
101
|
+
u({ event: l });
|
|
102
|
+
}, m = (l) => {
|
|
103
|
+
u({ event: l, commit: !1 });
|
|
97
104
|
}, s = () => {
|
|
98
105
|
u();
|
|
99
106
|
};
|
|
@@ -33,6 +33,15 @@ export interface DragState {
|
|
|
33
33
|
startX: number;
|
|
34
34
|
startY: number;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* High-frequency visual motion for an active drag session.
|
|
38
|
+
* This never participates in collision checks or final commit.
|
|
39
|
+
*/
|
|
40
|
+
export interface DragMotionState {
|
|
41
|
+
widgetId: string;
|
|
42
|
+
deltaX: number;
|
|
43
|
+
deltaY: number;
|
|
44
|
+
}
|
|
36
45
|
/**
|
|
37
46
|
* Resize state for a widget being resized
|
|
38
47
|
*/
|
|
@@ -68,8 +77,12 @@ export interface DeckContextValue {
|
|
|
68
77
|
/** Get widget state accessor for a specific widget */
|
|
69
78
|
getWidgetState: (widgetId: string) => Record<string, unknown>;
|
|
70
79
|
dragState: Accessor<DragState | null>;
|
|
80
|
+
dragMotion: Accessor<DragMotionState | null>;
|
|
71
81
|
startDrag: (widgetId: string, startX: number, startY: number) => void;
|
|
72
|
-
updateDrag: (currentPosition: GridPosition
|
|
82
|
+
updateDrag: (currentPosition: GridPosition, motion: {
|
|
83
|
+
deltaX: number;
|
|
84
|
+
deltaY: number;
|
|
85
|
+
}) => void;
|
|
73
86
|
endDrag: (commit: boolean) => void;
|
|
74
87
|
resizeState: Accessor<ResizeState | null>;
|
|
75
88
|
startResize: (widgetId: string, edge: ResizeState['edge'], startX: number, startY: number) => void;
|