@floegence/floe-webapp-core 0.36.8 → 0.36.9

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.
@@ -0,0 +1,26 @@
1
+ export declare const DECK_GRID_COLS = 24;
2
+ export declare const DECK_DEFAULT_ROWS = 24;
3
+ export declare const DECK_GAP = 4;
4
+ export declare const DECK_MIN_ROW_HEIGHT = 20;
5
+ export declare const DECK_PADDING = 4;
6
+ export interface DeckGridConfig {
7
+ cols: number;
8
+ rowHeight: number;
9
+ gap: number;
10
+ defaultRows: number;
11
+ }
12
+ export interface DeckGridMeasurements extends DeckGridConfig {
13
+ cellWidth: number;
14
+ cellHeight: number;
15
+ }
16
+ export declare const DECK_GRID_CONFIG: {
17
+ readonly cols: 24;
18
+ readonly defaultRows: 24;
19
+ readonly gap: 4;
20
+ readonly rowHeight: 20;
21
+ };
22
+ export declare function getGridConfigFromElement(gridEl: HTMLElement): DeckGridConfig;
23
+ export declare function measureDeckGrid(gridEl: HTMLElement, options?: {
24
+ paddingLeft?: number;
25
+ paddingRight?: number;
26
+ }): DeckGridMeasurements | null;
@@ -0,0 +1,32 @@
1
+ const c = 24, r = 24, g = 4, C = 20, d = 4, E = {
2
+ cols: 24,
3
+ defaultRows: 24,
4
+ gap: 4,
5
+ rowHeight: 20
6
+ };
7
+ function D(t) {
8
+ return {
9
+ cols: parseInt(t.dataset.gridCols || String(24), 10),
10
+ rowHeight: parseFloat(t.dataset.rowHeight || String(20)),
11
+ gap: parseInt(t.dataset.gap || String(4), 10),
12
+ defaultRows: parseInt(t.dataset.defaultRows || String(24), 10)
13
+ };
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
21
+ };
22
+ }
23
+ 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
32
+ };
@@ -0,0 +1,52 @@
1
+ import { type HotInteractionKind } from '../../utils/hotInteraction';
2
+ export interface DeckPointerSessionSnapshot {
3
+ pointerId: number;
4
+ kind: HotInteractionKind;
5
+ widgetId: string;
6
+ gridEl: HTMLElement;
7
+ gridRect: DOMRect;
8
+ gridPaddingLeft: number;
9
+ gridPaddingRight: number;
10
+ startClientX: number;
11
+ startClientY: number;
12
+ startScrollTop: number;
13
+ lastClientX: number;
14
+ lastClientY: number;
15
+ lastAppliedClientX: number;
16
+ lastAppliedClientY: number;
17
+ lastAppliedScrollTop: number;
18
+ rafId: number | null;
19
+ stopHotInteraction: (() => void) | null;
20
+ }
21
+ export interface DeckPointerSessionFrame {
22
+ snapshot: DeckPointerSessionSnapshot;
23
+ deltaX: number;
24
+ deltaY: number;
25
+ cols: number;
26
+ rowHeight: number;
27
+ gap: number;
28
+ cellWidth: number;
29
+ cellHeight: number;
30
+ }
31
+ export interface StartDeckPointerSessionOptions {
32
+ kind: HotInteractionKind;
33
+ widgetId: string;
34
+ gridEl: HTMLElement;
35
+ captureEl?: HTMLElement | null;
36
+ pointerEvent: PointerEvent;
37
+ cursor: string;
38
+ onMove: (frame: DeckPointerSessionFrame) => void;
39
+ onEnd: (options: {
40
+ commit: boolean;
41
+ snapshot: DeckPointerSessionSnapshot;
42
+ }) => void;
43
+ }
44
+ export interface DeckPointerSessionController {
45
+ snapshot: () => DeckPointerSessionSnapshot;
46
+ updatePointer: (event: Pick<PointerEvent, 'pointerId' | 'clientX' | 'clientY'>) => void;
47
+ stop: (options?: {
48
+ commit?: boolean;
49
+ event?: Pick<PointerEvent, 'pointerId' | 'clientX' | 'clientY'>;
50
+ }) => void;
51
+ }
52
+ export declare function startDeckPointerSession(options: StartDeckPointerSessionOptions): DeckPointerSessionController;
@@ -0,0 +1,113 @@
1
+ import { startHotInteraction as X } from "../../utils/hotInteraction.js";
2
+ import { measureDeckGrid as h } from "./deckGridMetrics.js";
3
+ function C(e) {
4
+ const d = e.lastClientY - e.gridRect.top, t = e.gridRect.bottom - e.lastClientY;
5
+ let n = 0;
6
+ if (d < 48 ? n = -Math.ceil((48 - d) / 48 * 24) : t < 48 && (n = Math.ceil((48 - t) / 48 * 24)), n === 0) return !1;
7
+ const a = e.gridEl.scrollTop, o = Math.max(0, Math.min(a + n, e.gridEl.scrollHeight - e.gridEl.clientHeight));
8
+ return o === a ? !1 : (e.gridEl.scrollTop = o, !0);
9
+ }
10
+ function v(e) {
11
+ const i = e.gridEl.scrollTop;
12
+ if (e.lastClientX === e.lastAppliedClientX && e.lastClientY === e.lastAppliedClientY && i === e.lastAppliedScrollTop)
13
+ return null;
14
+ e.lastAppliedClientX = e.lastClientX, e.lastAppliedClientY = e.lastClientY, e.lastAppliedScrollTop = i;
15
+ const l = h(e.gridEl, {
16
+ paddingLeft: e.gridPaddingLeft,
17
+ paddingRight: e.gridPaddingRight
18
+ });
19
+ return l ? {
20
+ snapshot: e,
21
+ deltaX: e.lastClientX - e.startClientX,
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
28
+ } : null;
29
+ }
30
+ function L(e) {
31
+ const i = e.gridEl.ownerDocument, l = i.defaultView ?? window, d = l.getComputedStyle(e.gridEl), t = {
32
+ pointerId: e.pointerEvent.pointerId,
33
+ kind: e.kind,
34
+ widgetId: e.widgetId,
35
+ gridEl: e.gridEl,
36
+ gridRect: e.gridEl.getBoundingClientRect(),
37
+ gridPaddingLeft: parseFloat(d.paddingLeft) || 0,
38
+ gridPaddingRight: parseFloat(d.paddingRight) || 0,
39
+ startClientX: e.pointerEvent.clientX,
40
+ startClientY: e.pointerEvent.clientY,
41
+ startScrollTop: e.gridEl.scrollTop,
42
+ lastClientX: e.pointerEvent.clientX,
43
+ lastClientY: e.pointerEvent.clientY,
44
+ lastAppliedClientX: e.pointerEvent.clientX,
45
+ lastAppliedClientY: e.pointerEvent.clientY,
46
+ lastAppliedScrollTop: e.gridEl.scrollTop,
47
+ rafId: null,
48
+ stopHotInteraction: X({
49
+ kind: e.kind,
50
+ cursor: e.cursor,
51
+ lockUserSelect: !0
52
+ })
53
+ };
54
+ let n = !0;
55
+ const a = () => {
56
+ if (t.rafId = null, !n) return;
57
+ const r = C(t), c = v(t);
58
+ c && e.onMove(c), n && r && o();
59
+ }, o = () => {
60
+ if (!(!n || t.rafId !== null)) {
61
+ if (typeof l.requestAnimationFrame != "function") {
62
+ a();
63
+ return;
64
+ }
65
+ t.rafId = l.requestAnimationFrame(a);
66
+ }
67
+ }, I = () => {
68
+ if (!(!e.captureEl || typeof e.captureEl.releasePointerCapture != "function"))
69
+ try {
70
+ e.captureEl.releasePointerCapture(t.pointerId);
71
+ } catch {
72
+ }
73
+ }, Y = () => {
74
+ i.removeEventListener("pointermove", g, !0), i.removeEventListener("pointerup", p, !0), i.removeEventListener("pointercancel", m, !0), e.captureEl?.removeEventListener("lostpointercapture", s);
75
+ }, u = (r) => {
76
+ if (!n) return;
77
+ const c = r?.event;
78
+ 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) {
80
+ C(t);
81
+ const E = v(t);
82
+ E && e.onMove(E);
83
+ }
84
+ Y(), I(), t.stopHotInteraction?.(), t.stopHotInteraction = null, e.onEnd({
85
+ commit: r?.commit !== !1,
86
+ snapshot: t
87
+ });
88
+ }
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 });
97
+ }, s = () => {
98
+ u();
99
+ };
100
+ if (i.addEventListener("pointermove", g, !0), i.addEventListener("pointerup", p, !0), i.addEventListener("pointercancel", m, !0), e.captureEl?.addEventListener("lostpointercapture", s), e.captureEl && typeof e.captureEl.setPointerCapture == "function")
101
+ try {
102
+ e.captureEl.setPointerCapture(t.pointerId);
103
+ } catch {
104
+ }
105
+ return {
106
+ snapshot: () => t,
107
+ updatePointer: f,
108
+ stop: u
109
+ };
110
+ }
111
+ export {
112
+ L as startDeckPointerSession
113
+ };
@@ -30,11 +30,6 @@ export interface DragState {
30
30
  widgetId: string;
31
31
  originalPosition: GridPosition;
32
32
  currentPosition: GridPosition;
33
- /** Pixel offset for smooth visual following */
34
- pixelOffset: {
35
- x: number;
36
- y: number;
37
- };
38
33
  startX: number;
39
34
  startY: number;
40
35
  }
@@ -74,10 +69,7 @@ export interface DeckContextValue {
74
69
  getWidgetState: (widgetId: string) => Record<string, unknown>;
75
70
  dragState: Accessor<DragState | null>;
76
71
  startDrag: (widgetId: string, startX: number, startY: number) => void;
77
- updateDrag: (currentPosition: GridPosition, pixelOffset: {
78
- x: number;
79
- y: number;
80
- }) => void;
72
+ updateDrag: (currentPosition: GridPosition) => void;
81
73
  endDrag: (commit: boolean) => void;
82
74
  resizeState: Accessor<ResizeState | null>;
83
75
  startResize: (widgetId: string, edge: ResizeState['edge'], startX: number, startY: number) => void;