@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.
- package/dist/components/deck/DeckCell.d.ts +3 -6
- package/dist/components/deck/DeckCell.js +35 -44
- package/dist/components/deck/DeckGrid.d.ts +2 -16
- package/dist/components/deck/DeckGrid.js +122 -122
- package/dist/components/deck/DropZonePreview.js +15 -15
- package/dist/components/deck/WidgetResizeHandle.d.ts +3 -1
- package/dist/components/deck/WidgetResizeHandle.js +46 -80
- package/dist/components/deck/deckGridMetrics.d.ts +41 -0
- package/dist/components/deck/deckGridMetrics.js +52 -0
- package/dist/components/deck/deckPointerSession.d.ts +52 -0
- package/dist/components/deck/deckPointerSession.js +113 -0
- package/dist/context/DeckContext.d.ts +13 -8
- package/dist/context/DeckContext.js +250 -242
- package/dist/deck.js +22 -21
- package/dist/floe.css +2 -0
- package/dist/full.js +384 -382
- package/dist/hooks/useDeckDrag.d.ts +4 -3
- package/dist/hooks/useDeckDrag.js +42 -72
- package/dist/index.js +54 -53
- package/dist/styles.css +1 -1
- package/dist/utils/gridCollision.d.ts +1 -0
- package/dist/utils/gridCollision.js +21 -17
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hook to set up drag handling for deck widgets
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
|
2
|
-
import { useDeck as
|
|
3
|
-
import { applyDragDelta as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
|
|
74
|
-
typeof document > "u" || (document.addEventListener("pointerdown",
|
|
75
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
19
|
-
import { createSimpleContext as
|
|
20
|
-
import { deferAfterPaint as We, deferNonBlocking as
|
|
21
|
-
import { duration as
|
|
22
|
-
import { formatKeybind as
|
|
23
|
-
import { isTypingElement as
|
|
24
|
-
import { lockBodyStyle as
|
|
25
|
-
import { registerCommandContributions as
|
|
26
|
-
import { useDebounce as
|
|
27
|
-
import { useDeckDrag as
|
|
28
|
-
import { useFileBrowserDropTarget as
|
|
29
|
-
import { useKeybind as
|
|
30
|
-
import { useMediaQuery as
|
|
31
|
-
import { usePersisted as
|
|
32
|
-
import { useResizeObserver as
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
62
|
+
we as createSimpleContext,
|
|
63
63
|
ae as createThemeService,
|
|
64
64
|
Te as createWidgetRegistry,
|
|
65
65
|
We as deferAfterPaint,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
96
|
-
|
|
95
|
+
Ye as panelResize,
|
|
96
|
+
ao as parseKeybind,
|
|
97
97
|
Re as pixelDeltaToGridDelta,
|
|
98
|
-
|
|
98
|
+
je as popIn,
|
|
99
99
|
De as positionToGridArea,
|
|
100
|
-
|
|
100
|
+
uo as registerCommandContributions,
|
|
101
101
|
m as resolveThemeTokenOverrides,
|
|
102
102
|
p as resolveThemeTokens,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Je as
|
|
107
|
-
Xe as
|
|
108
|
-
Ze as
|
|
109
|
-
$e as
|
|
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
|
-
|
|
112
|
+
oo as springConfig,
|
|
112
113
|
U as startHotInteraction,
|
|
113
114
|
l as syncThemeTokenOverrides,
|
|
114
115
|
R as useCommand,
|
|
115
|
-
|
|
116
|
+
xo as useCommandContributions,
|
|
116
117
|
O as useComponentContextFactory,
|
|
117
118
|
A as useComponentRegistry,
|
|
118
119
|
Ce as useCurrentWidgetId,
|
|
119
|
-
|
|
120
|
+
Co as useDebounce,
|
|
120
121
|
V as useDeck,
|
|
121
|
-
|
|
122
|
+
vo as useDeckDrag,
|
|
122
123
|
q as useFileBrowserDrag,
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
ko as useFileBrowserDropTarget,
|
|
125
|
+
ho as useFileBrowserItemDrag,
|
|
125
126
|
_ as useFloeConfig,
|
|
126
|
-
|
|
127
|
+
Ro as useKeybind,
|
|
127
128
|
$ as useLayout,
|
|
128
|
-
|
|
129
|
+
Io as useMediaQuery,
|
|
129
130
|
ie as useNotification,
|
|
130
131
|
E as useOptionalComponentRegistry,
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
bo as usePersisted,
|
|
133
|
+
Ao as useResizeObserver,
|
|
133
134
|
w as useResolvedFloeConfig,
|
|
134
135
|
me as useTheme,
|
|
135
136
|
fe as useViewActivation,
|