@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.
@@ -1,10 +1,10 @@
1
- const c = 24, r = 24, g = 4, C = 20, d = 4, E = {
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 D(t) {
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 G(t, o) {
16
- const n = D(t), s = o?.paddingLeft ?? 0, a = o?.paddingRight ?? 0, i = t.clientWidth - s - a, _ = n.gap * (n.cols - 1), e = (i - _) / n.cols;
17
- return !Number.isFinite(e) || e <= 0 ? null : {
18
- ...n,
19
- cellWidth: e,
20
- cellHeight: n.rowHeight + n.gap
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
- r as DECK_DEFAULT_ROWS,
25
- g as DECK_GAP,
26
- c as DECK_GRID_COLS,
27
- E as DECK_GRID_CONFIG,
28
- C as DECK_MIN_ROW_HEIGHT,
29
- d as DECK_PADDING,
30
- D as getGridConfigFromElement,
31
- G as measureDeckGrid
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
  };
@@ -27,6 +27,8 @@ export interface DeckPointerSessionFrame {
27
27
  gap: number;
28
28
  cellWidth: number;
29
29
  cellHeight: number;
30
+ colPitch: number;
31
+ rowPitch: number;
30
32
  }
31
33
  export interface StartDeckPointerSessionOptions {
32
34
  kind: HotInteractionKind;
@@ -1,5 +1,5 @@
1
- import { startHotInteraction as X } from "../../utils/hotInteraction.js";
2
- import { measureDeckGrid as h } from "./deckGridMetrics.js";
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 l = h(e.gridEl, {
15
+ const r = P(e.gridEl, {
16
16
  paddingLeft: e.gridPaddingLeft,
17
17
  paddingRight: e.gridPaddingRight
18
18
  });
19
- return l ? {
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: l.cols,
24
- rowHeight: l.rowHeight,
25
- gap: l.gap,
26
- cellWidth: l.cellWidth,
27
- cellHeight: l.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, l = i.defaultView ?? window, d = l.getComputedStyle(e.gridEl), t = {
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: X({
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 r = C(t), c = v(t);
58
- c && e.onMove(c), n && r && o();
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 l.requestAnimationFrame != "function") {
63
+ if (typeof r.requestAnimationFrame != "function") {
62
64
  a();
63
65
  return;
64
66
  }
65
- t.rafId = l.requestAnimationFrame(a);
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
- }, Y = () => {
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 = (r) => {
77
+ }, u = (l) => {
76
78
  if (!n) return;
77
- const c = r?.event;
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 l.cancelAnimationFrame == "function" && (l.cancelAnimationFrame(t.rafId), t.rafId = null), r?.commit !== !1) {
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
- Y(), I(), t.stopHotInteraction?.(), t.stopHotInteraction = null, e.onEnd({
85
- commit: r?.commit !== !1,
86
- snapshot: t
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 = (r) => {
90
- !n || r.pointerId !== t.pointerId || (t.lastClientX = r.clientX, t.lastClientY = r.clientY, o());
91
- }, g = (r) => {
92
- f(r);
93
- }, p = (r) => {
94
- u({ event: r });
95
- }, m = (r) => {
96
- u({ event: r, commit: !1 });
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) => void;
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;