@floegence/floe-webapp-core 0.36.8 → 0.36.10

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,6 +1,7 @@
1
1
  /**
2
- * Hook to set up drag handling for deck widgets
3
- * Listens for pointer events on elements with data-widget-drag-handle attribute
4
- * Only active when edit mode is enabled
2
+ * Hook to set up drag handling for deck widgets.
3
+ * The drag handle is discovered lazily from `pointerdown`, then the active
4
+ * pointer session is promoted to a document-level controller so release always
5
+ * tears down correctly even when the pointer crosses other surfaces.
5
6
  */
6
7
  export declare function useDeckDrag(): void;
@@ -1,81 +1,51 @@
1
- import { createEffect as G, onCleanup as z } from "solid-js";
2
- import { useDeck as B } from "../context/DeckContext.js";
3
- import { applyDragDelta as U } from "../utils/gridLayout.js";
4
- import { getGridConfigFromElement as N } from "../components/deck/DeckGrid.js";
5
- import { startHotInteraction as O } from "../utils/hotInteraction.js";
6
- function Z() {
7
- const h = B();
8
- let c = null, p = 0, m = 0, L = 0, f = 0, l = 0, P = 0, I = 0, A = 0, a = null, v = null, F = null, w = null, n = null, T = null, H = 0, k = 0, y = null;
9
- const C = (t) => {
10
- if (!t) {
11
- w?.(), w = null;
12
- return;
13
- }
14
- w?.(), w = O({
1
+ import { createEffect as m, onCleanup as E } from "solid-js";
2
+ import { useDeck as h } from "../context/DeckContext.js";
3
+ import { applyDragDelta as k } from "../utils/gridLayout.js";
4
+ import { startDeckPointerSession as y } from "../components/deck/deckPointerSession.js";
5
+ function L() {
6
+ const o = h();
7
+ let i = null, l = null, r = null;
8
+ const s = (e) => {
9
+ i?.stop({ commit: e }), i = null, l = null, r = null;
10
+ }, u = (e) => {
11
+ const a = e.target;
12
+ if (!a || a.closest('button, input, select, textarea, [role="button"], a') || a.closest("[data-widget-resize-handle]") || e.pointerType === "mouse" && e.button !== 0) return;
13
+ const d = a.closest("[data-widget-drag-handle]");
14
+ if (!d) return;
15
+ const n = d.dataset.widgetDragHandle;
16
+ if (!n) return;
17
+ const c = d.closest(".deck-grid");
18
+ if (!c) return;
19
+ const g = o.activeLayout()?.widgets.find((t) => t.id === n);
20
+ if (!g) return;
21
+ e.preventDefault(), e.stopPropagation(), s(!1), o.startDrag(n, e.clientX, e.clientY);
22
+ const p = o.dragState();
23
+ !p || p.widgetId !== n || (l = n, r = { ...g.position }, i = y({
15
24
  kind: "drag",
25
+ widgetId: n,
26
+ gridEl: c,
27
+ captureEl: d,
28
+ pointerEvent: e,
16
29
  cursor: "grabbing",
17
- lockUserSelect: !0
18
- });
19
- }, M = () => {
20
- c !== null && (a !== null && typeof cancelAnimationFrame < "u" && (cancelAnimationFrame(a), a = null), c = null, v = null, F = null, n = null, T = null, y = null, C(!1), h.endDrag(!0));
21
- }, Y = () => {
22
- if (!n) return;
23
- const t = T ?? n.getBoundingClientRect(), e = 48, d = 24, s = l - t.top, o = t.bottom - l;
24
- let r = 0;
25
- if (s < e ? r = -Math.ceil((e - s) / e * d) : o < e && (r = Math.ceil((e - o) / e * d)), r === 0) return;
26
- const i = n.scrollTop, g = Math.max(0, Math.min(i + r, n.scrollHeight - n.clientHeight));
27
- g !== i && (n.scrollTop = g);
28
- }, R = () => {
29
- if (a !== null || typeof requestAnimationFrame > "u") return;
30
- const t = () => {
31
- if (c === null) {
32
- a = null;
33
- return;
30
+ onMove: (t) => {
31
+ if (!l || !r) return;
32
+ const f = Math.round(t.deltaX / t.cellWidth), D = Math.round(t.deltaY / t.cellHeight), w = k(r, f, D, t.cols);
33
+ o.updateDrag(w, {
34
+ deltaX: t.deltaX,
35
+ deltaY: t.deltaY
36
+ });
37
+ },
38
+ onEnd: ({ commit: t }) => {
39
+ i = null, l = null, r = null, o.endDrag(t);
34
40
  }
35
- X(), a = requestAnimationFrame(t);
36
- };
37
- a = requestAnimationFrame(t);
38
- }, S = (t) => {
39
- const e = t.target;
40
- if (e.closest('button, input, select, textarea, [role="button"], a') || e.closest("[data-widget-resize-handle]")) return;
41
- const o = e.closest("[data-widget-drag-handle]");
42
- if (!o || t.pointerType === "mouse" && t.button !== 0) return;
43
- const r = o.dataset.widgetDragHandle;
44
- if (!r) return;
45
- const i = o.closest(".deck-grid");
46
- if (!i) return;
47
- t.preventDefault(), t.stopPropagation(), c = t.pointerId, p = t.clientX, m = t.clientY, f = p, l = m, P = p, I = m, v = r, F = o, n = i, T = i.getBoundingClientRect(), L = i.scrollTop, A = L, C(!0);
48
- const u = h.activeLayout()?.widgets.find((b) => b.id === r);
49
- y = u ? { ...u.position } : null;
50
- const E = window.getComputedStyle(i);
51
- H = parseFloat(E.paddingLeft) || 0, k = parseFloat(E.paddingRight) || 0, h.startDrag(r, p, m), o.setPointerCapture(t.pointerId), R();
52
- }, x = (t) => {
53
- c !== t.pointerId || !v || (f = t.clientX, l = t.clientY, typeof requestAnimationFrame > "u" && X());
54
- }, X = () => {
55
- if (!v || !n || !y) return;
56
- Y();
57
- const t = n.scrollTop;
58
- if (f === P && l === I && t === A) return;
59
- P = f, I = l, A = t;
60
- const e = f - p, d = l - m + (t - L), { cols: s, rowHeight: o, gap: r } = N(n), i = n.clientWidth - H - k, g = r * (s - 1), u = (i - g) / s;
61
- if (!Number.isFinite(u) || u <= 0) return;
62
- const E = o + r, b = Math.round(e / u), W = Math.round(d / E), q = U(y, b, W, s);
63
- h.updateDrag(q, { x: e, y: d });
64
- }, D = (t) => {
65
- if (c === t.pointerId) {
66
- try {
67
- F?.releasePointerCapture(t.pointerId);
68
- } catch {
69
- }
70
- M();
71
- }
41
+ }));
72
42
  };
73
- G(() => {
74
- typeof document > "u" || (document.addEventListener("pointerdown", S, !0), document.addEventListener("pointermove", x, !0), document.addEventListener("pointerup", D, !0), document.addEventListener("pointercancel", D, !0), z(() => {
75
- M(), document.removeEventListener("pointerdown", S, !0), document.removeEventListener("pointermove", x, !0), document.removeEventListener("pointerup", D, !0), document.removeEventListener("pointercancel", D, !0);
43
+ m(() => {
44
+ typeof document > "u" || (document.addEventListener("pointerdown", u, !0), E(() => {
45
+ s(!1), document.removeEventListener("pointerdown", u, !0);
76
46
  }));
77
47
  });
78
48
  }
79
49
  export {
80
- Z as useDeckDrag
50
+ L as useDeckDrag
81
51
  };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { floeColorTokenCategories as d, floeDesignTokens as g, floeFontFamilyTok
4
4
  import { CommandProvider as h, createCommandService as P, useCommand as R } from "./context/CommandContext.js";
5
5
  import { ComponentRegistryProvider as I, createComponentRegistry as S, hasComponentRegistryContext as b, useComponentContextFactory as O, useComponentRegistry as A, useOptionalComponentRegistry as E } from "./context/ComponentRegistry.js";
6
6
  import { DEFAULT_FLOE_CONFIG as B, FloeConfigProvider as N, useFloeConfig as _, useResolvedFloeConfig as w } from "./context/FloeConfigContext.js";
7
- import { DeckProvider as G, createDeckService as M, useDeck as V } from "./context/DeckContext.js";
7
+ import { DeckProvider as W, createDeckService as M, useDeck as V } from "./context/DeckContext.js";
8
8
  import { FLOE_GEOMETRY_SURFACE_ATTR as z, FLOE_HOT_INTERACTION_ATTR as H, startHotInteraction as U } from "./utils/hotInteraction.js";
9
9
  import { FileBrowserDragProvider as Y, hasFileBrowserDragContext as j, useFileBrowserDrag as q } from "./context/FileBrowserDragContext.js";
10
10
  import { LayoutProvider as X, createLayoutService as Z, useLayout as $ } from "./context/LayoutContext.js";
@@ -14,27 +14,27 @@ import { ViewActivationProvider as le, useViewActivation as fe } from "./context
14
14
  import { WidgetRegistryProvider as ge, createWidgetRegistry as Te, useWidgetRegistry as ue } from "./context/WidgetRegistry.js";
15
15
  import { WidgetStateProvider as ce, useCurrentWidgetId as Ce, useWidgetState as ye, useWidgetStateContext as ve } from "./context/WidgetStateContext.js";
16
16
  import { applyDragDelta as ke, applyResizeDelta as he, getGridCellSize as Pe, pixelDeltaToGridDelta as Re, positionToGridArea as De, snapToGrid as Ie } from "./utils/gridLayout.js";
17
- import { checkCollision as be, constrainPosition as Oe, findFreePosition as Ae, hasCollision as Ee } from "./utils/gridCollision.js";
18
- import { cn as Be } from "./utils/cn.js";
19
- import { createSimpleContext as _e } from "./context/createSimpleContext.js";
20
- import { deferAfterPaint as We, deferNonBlocking as Ge } from "./utils/defer.js";
21
- import { duration as Ve, easing as Ke, fadeIn as ze, listContainer as He, listItem as Ue, panelResize as Qe, popIn as Ye, scaleIn as je, sidebarVariants as qe, slideInFromBottom as Je, slideInFromLeft as Xe, slideInFromRight as Ze, slideInFromTop as $e, springConfig as eo } from "./utils/animations.js";
22
- import { formatKeybind as ro, isMacLikePlatform as to, isPrimaryModKeyPressed as io, matchKeybind as so, parseKeybind as no } from "./utils/keybind.js";
23
- import { isTypingElement as mo, shouldIgnoreHotkeys as po } from "./utils/dom.js";
24
- import { lockBodyStyle as fo } from "./utils/bodyStyleLock.js";
25
- import { registerCommandContributions as To, useCommandContributions as uo } from "./hooks/useCommandContributions.js";
26
- import { useDebounce as co } from "./hooks/useDebounce.js";
27
- import { useDeckDrag as yo } from "./hooks/useDeckDrag.js";
28
- import { useFileBrowserDropTarget as Fo, useFileBrowserItemDrag as ko } from "./hooks/useFileBrowserDrag.js";
29
- import { useKeybind as Po } from "./hooks/useKeybind.js";
30
- import { useMediaQuery as Do } from "./hooks/useMediaQuery.js";
31
- import { usePersisted as So } from "./hooks/usePersisted.js";
32
- import { useResizeObserver as Oo } from "./hooks/useResizeObserver.js";
17
+ import { checkCollision as be, constrainPosition as Oe, findFreePosition as Ae, hasCollision as Ee, sameGridPosition as Le } from "./utils/gridCollision.js";
18
+ import { cn as Ne } from "./utils/cn.js";
19
+ import { createSimpleContext as we } from "./context/createSimpleContext.js";
20
+ import { deferAfterPaint as We, deferNonBlocking as Me } from "./utils/defer.js";
21
+ import { duration as Ke, easing as ze, fadeIn as He, listContainer as Ue, listItem as Qe, panelResize as Ye, popIn as je, scaleIn as qe, sidebarVariants as Je, slideInFromBottom as Xe, slideInFromLeft as Ze, slideInFromRight as $e, slideInFromTop as eo, springConfig as oo } from "./utils/animations.js";
22
+ import { formatKeybind as to, isMacLikePlatform as io, isPrimaryModKeyPressed as so, matchKeybind as no, parseKeybind as ao } from "./utils/keybind.js";
23
+ import { isTypingElement as po, shouldIgnoreHotkeys as lo } from "./utils/dom.js";
24
+ import { lockBodyStyle as go } from "./utils/bodyStyleLock.js";
25
+ import { registerCommandContributions as uo, useCommandContributions as xo } from "./hooks/useCommandContributions.js";
26
+ import { useDebounce as Co } from "./hooks/useDebounce.js";
27
+ import { useDeckDrag as vo } from "./hooks/useDeckDrag.js";
28
+ import { useFileBrowserDropTarget as ko, useFileBrowserItemDrag as ho } from "./hooks/useFileBrowserDrag.js";
29
+ import { useKeybind as Ro } from "./hooks/useKeybind.js";
30
+ import { useMediaQuery as Io } from "./hooks/useMediaQuery.js";
31
+ import { usePersisted as bo } from "./hooks/usePersisted.js";
32
+ import { useResizeObserver as Ao } from "./hooks/useResizeObserver.js";
33
33
  export {
34
34
  h as CommandProvider,
35
35
  I as ComponentRegistryProvider,
36
36
  B as DEFAULT_FLOE_CONFIG,
37
- G as DeckProvider,
37
+ W as DeckProvider,
38
38
  z as FLOE_GEOMETRY_SURFACE_ATTR,
39
39
  H as FLOE_HOT_INTERACTION_ATTR,
40
40
  Y as FileBrowserDragProvider,
@@ -52,21 +52,21 @@ export {
52
52
  i as applyTheme,
53
53
  s as builtInThemes,
54
54
  be as checkCollision,
55
- Be as cn,
55
+ Ne as cn,
56
56
  Oe as constrainPosition,
57
57
  P as createCommandService,
58
58
  S as createComponentRegistry,
59
59
  M as createDeckService,
60
60
  Z as createLayoutService,
61
61
  te as createNotificationService,
62
- _e as createSimpleContext,
62
+ we as createSimpleContext,
63
63
  ae as createThemeService,
64
64
  Te as createWidgetRegistry,
65
65
  We as deferAfterPaint,
66
- Ge as deferNonBlocking,
67
- Ve as duration,
68
- Ke as easing,
69
- ze as fadeIn,
66
+ Me as deferNonBlocking,
67
+ Ke as duration,
68
+ ze as easing,
69
+ He as fadeIn,
70
70
  Ae as findFreePosition,
71
71
  d as floeColorTokenCategories,
72
72
  g as floeDesignTokens,
@@ -77,59 +77,60 @@ export {
77
77
  C as floeSpacingTokens,
78
78
  y as floeThemeColorVariables,
79
79
  v as floeTypographyTokens,
80
- ro as formatKeybind,
80
+ to as formatKeybind,
81
81
  F as getFloeColorTokenValue,
82
82
  Pe as getGridCellSize,
83
83
  n as getSystemTheme,
84
84
  Ee as hasCollision,
85
85
  b as hasComponentRegistryContext,
86
86
  j as hasFileBrowserDragContext,
87
- to as isMacLikePlatform,
88
- io as isPrimaryModKeyPressed,
89
- mo as isTypingElement,
90
- He as listContainer,
91
- Ue as listItem,
92
- fo as lockBodyStyle,
93
- so as matchKeybind,
87
+ io as isMacLikePlatform,
88
+ so as isPrimaryModKeyPressed,
89
+ po as isTypingElement,
90
+ Ue as listContainer,
91
+ Qe as listItem,
92
+ go as lockBodyStyle,
93
+ no as matchKeybind,
94
94
  a as mergeThemeTokenMaps,
95
- Qe as panelResize,
96
- no as parseKeybind,
95
+ Ye as panelResize,
96
+ ao as parseKeybind,
97
97
  Re as pixelDeltaToGridDelta,
98
- Ye as popIn,
98
+ je as popIn,
99
99
  De as positionToGridArea,
100
- To as registerCommandContributions,
100
+ uo as registerCommandContributions,
101
101
  m as resolveThemeTokenOverrides,
102
102
  p as resolveThemeTokens,
103
- je as scaleIn,
104
- po as shouldIgnoreHotkeys,
105
- qe as sidebarVariants,
106
- Je as slideInFromBottom,
107
- Xe as slideInFromLeft,
108
- Ze as slideInFromRight,
109
- $e as slideInFromTop,
103
+ Le as sameGridPosition,
104
+ qe as scaleIn,
105
+ lo as shouldIgnoreHotkeys,
106
+ Je as sidebarVariants,
107
+ Xe as slideInFromBottom,
108
+ Ze as slideInFromLeft,
109
+ $e as slideInFromRight,
110
+ eo as slideInFromTop,
110
111
  Ie as snapToGrid,
111
- eo as springConfig,
112
+ oo as springConfig,
112
113
  U as startHotInteraction,
113
114
  l as syncThemeTokenOverrides,
114
115
  R as useCommand,
115
- uo as useCommandContributions,
116
+ xo as useCommandContributions,
116
117
  O as useComponentContextFactory,
117
118
  A as useComponentRegistry,
118
119
  Ce as useCurrentWidgetId,
119
- co as useDebounce,
120
+ Co as useDebounce,
120
121
  V as useDeck,
121
- yo as useDeckDrag,
122
+ vo as useDeckDrag,
122
123
  q as useFileBrowserDrag,
123
- Fo as useFileBrowserDropTarget,
124
- ko as useFileBrowserItemDrag,
124
+ ko as useFileBrowserDropTarget,
125
+ ho as useFileBrowserItemDrag,
125
126
  _ as useFloeConfig,
126
- Po as useKeybind,
127
+ Ro as useKeybind,
127
128
  $ as useLayout,
128
- Do as useMediaQuery,
129
+ Io as useMediaQuery,
129
130
  ie as useNotification,
130
131
  E as useOptionalComponentRegistry,
131
- So as usePersisted,
132
- Oo as useResizeObserver,
132
+ bo as usePersisted,
133
+ Ao as useResizeObserver,
133
134
  w as useResolvedFloeConfig,
134
135
  me as useTheme,
135
136
  fe as useViewActivation,