@floegence/floe-webapp-core 0.36.10 → 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.js +7 -17
- package/dist/components/deck/DeckGrid.js +64 -64
- package/dist/components/deck/WidgetResizeHandle.js +21 -21
- package/dist/components/deck/deckGridMetrics.d.ts +7 -0
- package/dist/components/deck/deckGridMetrics.js +41 -26
- package/dist/components/deck/deckPointerSession.d.ts +2 -0
- package/dist/components/deck/deckPointerSession.js +38 -31
- package/dist/hooks/useDeckDrag.js +4 -4
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { insert as s, createComponent as g, Dynamic as D, effect as W, setAttribute as b, className as S, style as k, template as m } from "solid-js/web";
|
|
2
|
-
import { createMemo as l, Show as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { useDeck as
|
|
5
|
-
import { useWidgetRegistry as
|
|
2
|
+
import { createMemo as l, Show as z } from "solid-js";
|
|
3
|
+
import { cn as C } from "../../utils/cn.js";
|
|
4
|
+
import { useDeck as R } from "../../context/DeckContext.js";
|
|
5
|
+
import { useWidgetRegistry as x } from "../../context/WidgetRegistry.js";
|
|
6
6
|
import { WidgetStateProvider as M } from "../../context/WidgetStateContext.js";
|
|
7
7
|
import { positionToGridArea as A } from "../../utils/gridLayout.js";
|
|
8
8
|
import { WidgetFrame as I } from "./WidgetFrame.js";
|
|
9
9
|
var P = /* @__PURE__ */ m("<div data-floe-dialog-surface-host=true data-floe-geometry-surface=deck-widget>"), T = /* @__PURE__ */ m('<div class="h-full flex items-center justify-center text-muted-foreground text-xs"><span>Widget: ');
|
|
10
10
|
function B(e) {
|
|
11
|
-
const r =
|
|
11
|
+
const r = R(), n = x(), f = () => r.editMode(), d = () => e.widget.type, a = l(() => n.getWidget(d())), w = l(() => A(e.position)), h = () => r.getWidgetState(e.widget.id), v = (i, t) => {
|
|
12
12
|
r.updateWidgetState(e.widget.id, i, t);
|
|
13
13
|
}, o = () => a()?.component;
|
|
14
14
|
return (() => {
|
|
@@ -27,7 +27,7 @@ function B(e) {
|
|
|
27
27
|
return e.isResizing;
|
|
28
28
|
},
|
|
29
29
|
get children() {
|
|
30
|
-
return g(
|
|
30
|
+
return g(z, {
|
|
31
31
|
get when() {
|
|
32
32
|
return o();
|
|
33
33
|
},
|
|
@@ -66,17 +66,7 @@ function B(e) {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
})), W((t) => {
|
|
69
|
-
var c = e.widget.id, u =
|
|
70
|
-
"deck-cell relative rounded-md overflow-hidden group",
|
|
71
|
-
"bg-card border border-border",
|
|
72
|
-
// Smooth transition when not dragging (for snap-back animation)
|
|
73
|
-
!e.isDragging && "transition-transform duration-200 ease-out",
|
|
74
|
-
e.isDragging && "shadow-2xl z-50 ring-2 ring-primary/70",
|
|
75
|
-
e.isResizing && "shadow-lg z-50 ring-2 ring-primary",
|
|
76
|
-
!e.isDragging && !e.isResizing && "hover:ring-1 hover:ring-primary/50",
|
|
77
|
-
"select-none",
|
|
78
|
-
e.isDragging && "cursor-grabbing"
|
|
79
|
-
), y = e.dragOverlayStyle ?? {
|
|
69
|
+
var c = e.widget.id, u = C("deck-cell relative rounded-md overflow-hidden group", "bg-card border border-border", !e.isDragging && !e.isResizing && "transition-shadow duration-150 ease-out", e.isDragging && "shadow-2xl z-50 ring-2 ring-primary/70", e.isResizing && "shadow-lg z-50 ring-2 ring-primary", !e.isDragging && !e.isResizing && "hover:ring-1 hover:ring-primary/50", "select-none", e.isDragging && "cursor-grabbing"), y = e.dragOverlayStyle ?? {
|
|
80
70
|
"grid-area": w()
|
|
81
71
|
};
|
|
82
72
|
return c !== t.e && b(i, "data-floe-deck-widget-id", t.e = c), u !== t.t && S(i, t.t = u), t.a = k(i, y, t.a), t;
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { setStyleProperty as u, setAttribute as
|
|
2
|
-
import { createSignal as
|
|
1
|
+
import { setStyleProperty as u, setAttribute as M, insert as y, createComponent as h, effect as T, className as ot, template as N, use as it, delegateEvents as at } from "solid-js/web";
|
|
2
|
+
import { createSignal as I, createMemo as d, onMount as st, Show as F, For as ct, onCleanup as lt } from "solid-js";
|
|
3
3
|
import { cn as dt } from "../../utils/cn.js";
|
|
4
4
|
import { useDeck as ut } from "../../context/DeckContext.js";
|
|
5
5
|
import { useLayout as gt } from "../../context/LayoutContext.js";
|
|
6
|
-
import { useResolvedFloeConfig as
|
|
7
|
-
import { useWidgetRegistry as
|
|
6
|
+
import { useResolvedFloeConfig as pt } from "../../context/FloeConfigContext.js";
|
|
7
|
+
import { useWidgetRegistry as mt } from "../../context/WidgetRegistry.js";
|
|
8
8
|
import { hasCollision as ft } from "../../utils/gridCollision.js";
|
|
9
9
|
import { DeckCell as vt } from "./DeckCell.js";
|
|
10
10
|
import { DeckContextMenu as ht } from "./DeckContextMenu.js";
|
|
11
11
|
import { DropZonePreview as xt } from "./DropZonePreview.js";
|
|
12
|
-
import { DECK_DEFAULT_ROWS as g, DECK_MIN_ROW_HEIGHT as
|
|
13
|
-
import { DECK_GRID_CONFIG as
|
|
14
|
-
var
|
|
15
|
-
const
|
|
16
|
-
function Lt(
|
|
17
|
-
const
|
|
12
|
+
import { DECK_DEFAULT_ROWS as g, DECK_MIN_ROW_HEIGHT as W, DECK_GAP as f, DECK_PADDING as A, DECK_GRID_COLS as S, positionToDeckPixelRect as wt, positionDeltaToDeckPixelOffset as yt, getGridConfigFromElement as bt, measureDeckGridSurface as K } from "./deckGridMetrics.js";
|
|
13
|
+
import { DECK_GRID_CONFIG as Wt } from "./deckGridMetrics.js";
|
|
14
|
+
var kt = /* @__PURE__ */ N('<div class="pointer-events-none z-0"style="grid-column:1 / -1;background-position:0 0, 0 0, 0 0, 0 0, 0 0, 0 0">'), Dt = /* @__PURE__ */ N('<div style=scrollbar-gutter:stable><div class=pointer-events-none aria-hidden=true style="grid-column:1 / -1">');
|
|
15
|
+
const Mt = (S - 1) * f;
|
|
16
|
+
function Lt(z) {
|
|
17
|
+
const p = ut(), O = gt(), X = mt(), Y = pt();
|
|
18
18
|
let n;
|
|
19
|
-
const [
|
|
19
|
+
const [C, _] = I(0), [B, j] = I(null), [b, P] = I(null), E = () => p.activeLayout()?.widgets ?? [], x = () => p.dragState(), V = () => p.dragMotion(), R = () => p.resizeState(), U = () => B() ?? (n ? K(n) : null), L = () => !O.isMobile(), Z = () => (Y.config.deck.presetsMode ?? "mutable") === "immutable" && !!p.activeLayout()?.isPreset, q = d(() => Array.from(X.widgets().values()).map((t) => ({
|
|
20
20
|
type: t.type,
|
|
21
21
|
name: t.name,
|
|
22
22
|
icon: t.icon
|
|
23
|
-
}))),
|
|
24
|
-
if (
|
|
23
|
+
}))), J = (t) => {
|
|
24
|
+
if (O.isMobile() || Z() || t.target?.closest(".deck-cell") || !n) return;
|
|
25
25
|
t.preventDefault();
|
|
26
26
|
const o = n.getBoundingClientRect(), {
|
|
27
27
|
cols: e,
|
|
28
28
|
rowHeight: i,
|
|
29
29
|
gap: s
|
|
30
|
-
} = bt(n), c = window.getComputedStyle(n), l = parseFloat(c.paddingLeft) || 0, a = parseFloat(c.paddingTop) || 0,
|
|
31
|
-
if (!Number.isFinite(
|
|
32
|
-
const
|
|
33
|
-
|
|
30
|
+
} = bt(n), c = window.getComputedStyle(n), l = parseFloat(c.paddingLeft) || 0, a = parseFloat(c.paddingTop) || 0, m = (n.clientWidth - l - (parseFloat(c.paddingRight) || 0) - s * (e - 1)) / e, v = i + s;
|
|
31
|
+
if (!Number.isFinite(m) || m <= 0) return;
|
|
32
|
+
const D = t.clientX - o.left + n.scrollLeft - l, $ = t.clientY - o.top + n.scrollTop - a, H = Math.max(0, Math.min(e - 1, Math.floor(D / (m + s)))), nt = Math.max(0, Math.floor($ / v));
|
|
33
|
+
P({
|
|
34
34
|
x: t.clientX,
|
|
35
35
|
y: t.clientY,
|
|
36
|
-
col:
|
|
36
|
+
col: H,
|
|
37
37
|
row: nt
|
|
38
38
|
});
|
|
39
|
-
},
|
|
40
|
-
const r =
|
|
41
|
-
|
|
39
|
+
}, Q = (t) => {
|
|
40
|
+
const r = b();
|
|
41
|
+
P(null), r && p.addWidget(t, {
|
|
42
42
|
col: r.col,
|
|
43
43
|
row: r.row
|
|
44
44
|
});
|
|
45
|
-
},
|
|
45
|
+
}, tt = d(() => {
|
|
46
46
|
const t = x();
|
|
47
47
|
if (!t) return !0;
|
|
48
|
-
const r =
|
|
48
|
+
const r = p.activeLayout();
|
|
49
49
|
return r ? !ft(t.currentPosition, r.widgets, t.widgetId) : !0;
|
|
50
|
-
}),
|
|
51
|
-
const t =
|
|
50
|
+
}), et = d(() => {
|
|
51
|
+
const t = E();
|
|
52
52
|
if (t.length === 0) return g;
|
|
53
53
|
let r = g;
|
|
54
54
|
for (const o of t) {
|
|
@@ -56,8 +56,8 @@ function Lt($) {
|
|
|
56
56
|
e > r && (r = e);
|
|
57
57
|
}
|
|
58
58
|
return r;
|
|
59
|
-
}),
|
|
60
|
-
let t =
|
|
59
|
+
}), G = d(() => {
|
|
60
|
+
let t = et();
|
|
61
61
|
const r = x();
|
|
62
62
|
if (r) {
|
|
63
63
|
const e = r.currentPosition.row + r.currentPosition.rowSpan;
|
|
@@ -70,36 +70,36 @@ function Lt($) {
|
|
|
70
70
|
}
|
|
71
71
|
return Math.max(g, t);
|
|
72
72
|
}), k = d(() => {
|
|
73
|
-
const t =
|
|
74
|
-
if (t <= 0) return
|
|
75
|
-
const o = (t -
|
|
76
|
-
return Math.max(
|
|
73
|
+
const t = C();
|
|
74
|
+
if (t <= 0) return W;
|
|
75
|
+
const o = (t - A * 2 - (g - 1) * f) / g;
|
|
76
|
+
return Math.max(W, o);
|
|
77
77
|
});
|
|
78
78
|
st(() => {
|
|
79
79
|
const t = () => {
|
|
80
|
-
n && (
|
|
80
|
+
n && (_(n.clientHeight), j(K(n)));
|
|
81
81
|
};
|
|
82
82
|
if (t(), !n || typeof ResizeObserver > "u") return;
|
|
83
83
|
const r = new ResizeObserver((o) => {
|
|
84
84
|
for (const e of o)
|
|
85
|
-
|
|
85
|
+
_(e.contentRect.height);
|
|
86
86
|
t();
|
|
87
87
|
});
|
|
88
88
|
r.observe(n), lt(() => r.disconnect());
|
|
89
89
|
});
|
|
90
|
-
const
|
|
90
|
+
const rt = d(() => G() > g ? !0 : C() <= 0 ? !1 : g * k() + (g - 1) * f + A * 2 > C() + 1);
|
|
91
91
|
return (() => {
|
|
92
|
-
var t =
|
|
93
|
-
t.$$contextmenu =
|
|
92
|
+
var t = Dt(), r = t.firstChild;
|
|
93
|
+
t.$$contextmenu = J;
|
|
94
94
|
var o = n;
|
|
95
|
-
return typeof o == "function" ? it(o, t) : n = t, u(t, "grid-template-columns", `repeat(${
|
|
95
|
+
return typeof o == "function" ? it(o, t) : n = t, u(t, "grid-template-columns", `repeat(${S}, 1fr)`), u(t, "gap", `${f}px`), M(t, "data-grid-cols", S), M(t, "data-gap", f), M(t, "data-default-rows", g), y(t, h(F, {
|
|
96
96
|
get when() {
|
|
97
|
-
return
|
|
97
|
+
return L();
|
|
98
98
|
},
|
|
99
99
|
get children() {
|
|
100
|
-
var e =
|
|
101
|
-
return u(e, "--deck-grid-unit-x", `calc((100% - ${
|
|
102
|
-
var s = `1 / ${
|
|
100
|
+
var e = kt();
|
|
101
|
+
return u(e, "--deck-grid-unit-x", `calc((100% - ${Mt}px) / ${S} + ${f}px)`), T((i) => {
|
|
102
|
+
var s = `1 / ${G() + 1}`, c = `${k() + f}px`, l = [
|
|
103
103
|
// Fine
|
|
104
104
|
"linear-gradient(to right, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px)",
|
|
105
105
|
"linear-gradient(to bottom, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px)",
|
|
@@ -128,7 +128,7 @@ function Lt($) {
|
|
|
128
128
|
o: void 0
|
|
129
129
|
}), e;
|
|
130
130
|
}
|
|
131
|
-
}), null),
|
|
131
|
+
}), null), y(t, h(F, {
|
|
132
132
|
get when() {
|
|
133
133
|
return x();
|
|
134
134
|
},
|
|
@@ -137,12 +137,12 @@ function Lt($) {
|
|
|
137
137
|
return e().currentPosition;
|
|
138
138
|
},
|
|
139
139
|
get isValid() {
|
|
140
|
-
return
|
|
140
|
+
return tt();
|
|
141
141
|
}
|
|
142
142
|
})
|
|
143
|
-
}), null),
|
|
143
|
+
}), null), y(t, h(ct, {
|
|
144
144
|
get each() {
|
|
145
|
-
return
|
|
145
|
+
return E();
|
|
146
146
|
},
|
|
147
147
|
children: (e) => {
|
|
148
148
|
const i = d(() => {
|
|
@@ -151,18 +151,18 @@ function Lt($) {
|
|
|
151
151
|
}), s = d(() => x()?.widgetId === e.id), c = d(() => R()?.widgetId === e.id), l = d(() => {
|
|
152
152
|
const a = x();
|
|
153
153
|
if (!a || a.widgetId !== e.id) return;
|
|
154
|
-
const w =
|
|
154
|
+
const w = V();
|
|
155
155
|
if (!w || w.widgetId !== e.id) return;
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
158
|
-
const v = wt(a.originalPosition,
|
|
156
|
+
const m = U();
|
|
157
|
+
if (!m) return;
|
|
158
|
+
const v = wt(a.currentPosition, m), D = yt(a.originalPosition, a.currentPosition, m), $ = w.deltaX - D.x, H = w.deltaY - D.y;
|
|
159
159
|
return {
|
|
160
160
|
position: "absolute",
|
|
161
161
|
left: `${v.left}px`,
|
|
162
162
|
top: `${v.top}px`,
|
|
163
163
|
width: `${v.width}px`,
|
|
164
164
|
height: `${v.height}px`,
|
|
165
|
-
transform: `translate3d(${
|
|
165
|
+
transform: `translate3d(${$}px, ${H}px, 0) scale(0.992)`,
|
|
166
166
|
"transform-origin": "center center",
|
|
167
167
|
"will-change": "transform"
|
|
168
168
|
};
|
|
@@ -183,31 +183,31 @@ function Lt($) {
|
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
-
}), null),
|
|
186
|
+
}), null), y(t, () => z.children, null), y(t, h(ht, {
|
|
187
187
|
get open() {
|
|
188
|
-
return
|
|
188
|
+
return b() !== null;
|
|
189
189
|
},
|
|
190
190
|
get x() {
|
|
191
|
-
return
|
|
191
|
+
return b()?.x ?? 0;
|
|
192
192
|
},
|
|
193
193
|
get y() {
|
|
194
|
-
return
|
|
194
|
+
return b()?.y ?? 0;
|
|
195
195
|
},
|
|
196
196
|
get items() {
|
|
197
|
-
return
|
|
197
|
+
return q();
|
|
198
198
|
},
|
|
199
|
-
onSelect:
|
|
200
|
-
onDismiss: () =>
|
|
201
|
-
}), null),
|
|
199
|
+
onSelect: Q,
|
|
200
|
+
onDismiss: () => P(null)
|
|
201
|
+
}), null), T((e) => {
|
|
202
202
|
var i = dt(
|
|
203
203
|
"deck-grid relative w-full h-full overflow-x-hidden",
|
|
204
204
|
// Only enable vertical scroll when content exceeds 24 rows
|
|
205
|
-
|
|
205
|
+
rt() ? "overflow-y-scroll" : "overflow-y-hidden",
|
|
206
206
|
"grid p-1",
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
), s = `${k()}px`, c = k(), l = `1 / ${
|
|
210
|
-
return i !== e.e && ot(t, e.e = i), s !== e.t && u(t, "grid-auto-rows", e.t = s), c !== e.a &&
|
|
207
|
+
L() && "bg-muted/20",
|
|
208
|
+
z.class
|
|
209
|
+
), s = `${k()}px`, c = k(), l = `1 / ${G() + 1}`;
|
|
210
|
+
return i !== e.e && ot(t, e.e = i), s !== e.t && u(t, "grid-auto-rows", e.t = s), c !== e.a && M(t, "data-row-height", e.a = c), l !== e.o && u(r, "grid-row", e.o = l), e;
|
|
211
211
|
}, {
|
|
212
212
|
e: void 0,
|
|
213
213
|
t: void 0,
|
|
@@ -218,7 +218,7 @@ function Lt($) {
|
|
|
218
218
|
}
|
|
219
219
|
at(["contextmenu"]);
|
|
220
220
|
export {
|
|
221
|
-
|
|
221
|
+
Wt as DECK_GRID_CONFIG,
|
|
222
222
|
Lt as DeckGrid,
|
|
223
223
|
bt as getGridConfigFromElement
|
|
224
224
|
};
|
|
@@ -2,10 +2,10 @@ import { effect as m, className as h, setAttribute as p, template as b, use as v
|
|
|
2
2
|
import { createSignal as R, onCleanup as S } from "solid-js";
|
|
3
3
|
import { cn as D } from "../../utils/cn.js";
|
|
4
4
|
import { useDeck as y } from "../../context/DeckContext.js";
|
|
5
|
-
import { applyResizeDelta as
|
|
6
|
-
import { startDeckPointerSession as
|
|
7
|
-
var
|
|
8
|
-
const
|
|
5
|
+
import { applyResizeDelta as P } from "../../utils/gridLayout.js";
|
|
6
|
+
import { startDeckPointerSession as k } from "./deckPointerSession.js";
|
|
7
|
+
var C = /* @__PURE__ */ b("<div style=touch-action:none>");
|
|
8
|
+
const M = {
|
|
9
9
|
n: "top-0 left-2 right-2 h-2 cursor-ns-resize",
|
|
10
10
|
s: "bottom-0 left-2 right-2 h-2 cursor-ns-resize",
|
|
11
11
|
e: "right-0 top-2 bottom-2 w-2 cursor-ew-resize",
|
|
@@ -24,45 +24,45 @@ const P = {
|
|
|
24
24
|
se: "nwse-resize",
|
|
25
25
|
sw: "nesw-resize"
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function W(t) {
|
|
28
28
|
const s = y(), [u, d] = R(!1);
|
|
29
|
-
let
|
|
29
|
+
let l, n = null;
|
|
30
30
|
const a = (e) => {
|
|
31
|
-
|
|
31
|
+
n?.stop({
|
|
32
32
|
commit: e
|
|
33
|
-
}),
|
|
33
|
+
}), n = null;
|
|
34
34
|
}, g = (e) => {
|
|
35
35
|
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
36
36
|
e.preventDefault(), e.stopPropagation();
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
37
|
+
const o = e.currentTarget?.closest(".deck-grid");
|
|
38
|
+
if (!o) return;
|
|
39
39
|
a(!1), s.startResize(t.widget.id, t.edge, e.clientX, e.clientY);
|
|
40
40
|
const r = s.resizeState();
|
|
41
|
-
!r || r.widgetId !== t.widget.id || r.edge !== t.edge || (d(!0),
|
|
41
|
+
!r || r.widgetId !== t.widget.id || r.edge !== t.edge || (d(!0), n = k({
|
|
42
42
|
kind: "resize",
|
|
43
43
|
widgetId: t.widget.id,
|
|
44
|
-
gridEl:
|
|
45
|
-
captureEl:
|
|
44
|
+
gridEl: o,
|
|
45
|
+
captureEl: l,
|
|
46
46
|
pointerEvent: e,
|
|
47
47
|
cursor: A[t.edge],
|
|
48
48
|
onMove: (i) => {
|
|
49
|
-
const
|
|
49
|
+
const c = Math.round(i.deltaX / i.colPitch), z = Math.round(i.deltaY / i.rowPitch), w = s.getWidgetMinConstraints(t.widget.type), f = P(t.widget.position, t.edge, c, z, w.minColSpan, w.minRowSpan, i.cols);
|
|
50
50
|
s.updateResize(f);
|
|
51
51
|
},
|
|
52
52
|
onEnd: ({
|
|
53
53
|
commit: i
|
|
54
54
|
}) => {
|
|
55
|
-
|
|
55
|
+
n = null, d(!1), s.endResize(i);
|
|
56
56
|
}
|
|
57
57
|
}));
|
|
58
58
|
};
|
|
59
59
|
return S(() => a(!1)), (() => {
|
|
60
|
-
var e =
|
|
60
|
+
var e = C();
|
|
61
61
|
e.$$pointerdown = g;
|
|
62
|
-
var
|
|
63
|
-
return typeof
|
|
64
|
-
var i = D("absolute z-30",
|
|
65
|
-
return i !== r.e && h(e, r.e = i),
|
|
62
|
+
var o = l;
|
|
63
|
+
return typeof o == "function" ? v(o, e) : l = e, m((r) => {
|
|
64
|
+
var i = D("absolute z-30", M[t.edge], "hover:bg-primary/30 transition-colors", u() && "bg-primary/50"), c = t.edge;
|
|
65
|
+
return i !== r.e && h(e, r.e = i), c !== r.t && p(e, "data-widget-resize-handle", r.t = c), r;
|
|
66
66
|
}, {
|
|
67
67
|
e: void 0,
|
|
68
68
|
t: void 0
|
|
@@ -71,5 +71,5 @@ function G(t) {
|
|
|
71
71
|
}
|
|
72
72
|
E(["pointerdown"]);
|
|
73
73
|
export {
|
|
74
|
-
|
|
74
|
+
W as WidgetResizeHandle
|
|
75
75
|
};
|
|
@@ -26,6 +26,10 @@ export interface DeckGridPixelRect {
|
|
|
26
26
|
width: number;
|
|
27
27
|
height: number;
|
|
28
28
|
}
|
|
29
|
+
export interface DeckGridPixelOffset {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}
|
|
29
33
|
export declare const DECK_GRID_CONFIG: {
|
|
30
34
|
readonly cols: 24;
|
|
31
35
|
readonly defaultRows: 24;
|
|
@@ -38,4 +42,7 @@ export declare function measureDeckGrid(gridEl: HTMLElement, options?: {
|
|
|
38
42
|
paddingRight?: number;
|
|
39
43
|
}): DeckGridMeasurements | null;
|
|
40
44
|
export declare function measureDeckGridSurface(gridEl: HTMLElement): DeckGridSurfaceMeasurements | null;
|
|
45
|
+
export declare function getDeckGridColPitch(measurements: Pick<DeckGridMeasurements, 'cellWidth' | 'gap'>): number;
|
|
46
|
+
export declare function getDeckGridRowPitch(measurements: Pick<DeckGridMeasurements, 'cellHeight'>): number;
|
|
41
47
|
export declare function positionToDeckPixelRect(position: GridPosition, measurements: DeckGridSurfaceMeasurements): DeckGridPixelRect;
|
|
48
|
+
export declare function positionDeltaToDeckPixelOffset(from: GridPosition, to: GridPosition, measurements: DeckGridSurfaceMeasurements): DeckGridPixelOffset;
|
|
@@ -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,41 +12,56 @@ function g(t) {
|
|
|
12
12
|
defaultRows: parseInt(t.dataset.defaultRows || String(24), 10)
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const o =
|
|
17
|
-
return !Number.isFinite(
|
|
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
18
|
...o,
|
|
19
|
-
cellWidth:
|
|
19
|
+
cellWidth: d,
|
|
20
20
|
cellHeight: o.rowHeight + o.gap
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const n = t.ownerDocument.defaultView?.getComputedStyle(t) ?? getComputedStyle(t), o = parseFloat(n.paddingLeft) || 0,
|
|
25
|
-
return
|
|
26
|
-
...
|
|
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
27
|
paddingLeft: o,
|
|
28
|
-
paddingRight:
|
|
29
|
-
paddingTop:
|
|
30
|
-
paddingBottom:
|
|
28
|
+
paddingRight: e,
|
|
29
|
+
paddingTop: c,
|
|
30
|
+
paddingBottom: i
|
|
31
31
|
} : null;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
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) {
|
|
34
40
|
return {
|
|
35
|
-
left: n.paddingLeft + t.col * (n
|
|
36
|
-
top: n.paddingTop + t.row * (n
|
|
41
|
+
left: n.paddingLeft + t.col * g(n),
|
|
42
|
+
top: n.paddingTop + t.row * p(n),
|
|
37
43
|
width: t.colSpan * n.cellWidth + Math.max(0, t.colSpan - 1) * n.gap,
|
|
38
44
|
height: t.rowSpan * n.rowHeight + Math.max(0, t.rowSpan - 1) * n.gap
|
|
39
45
|
};
|
|
40
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)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
41
53
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
g as
|
|
49
|
-
p as
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
52
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
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createEffect as m, onCleanup as E } from "solid-js";
|
|
2
2
|
import { useDeck as h } from "../context/DeckContext.js";
|
|
3
|
-
import { applyDragDelta as
|
|
4
|
-
import { startDeckPointerSession as
|
|
3
|
+
import { applyDragDelta as P } from "../utils/gridLayout.js";
|
|
4
|
+
import { startDeckPointerSession as k } from "../components/deck/deckPointerSession.js";
|
|
5
5
|
function L() {
|
|
6
6
|
const o = h();
|
|
7
7
|
let i = null, l = null, r = null;
|
|
@@ -20,7 +20,7 @@ function L() {
|
|
|
20
20
|
if (!g) return;
|
|
21
21
|
e.preventDefault(), e.stopPropagation(), s(!1), o.startDrag(n, e.clientX, e.clientY);
|
|
22
22
|
const p = o.dragState();
|
|
23
|
-
!p || p.widgetId !== n || (l = n, r = { ...g.position }, i =
|
|
23
|
+
!p || p.widgetId !== n || (l = n, r = { ...g.position }, i = k({
|
|
24
24
|
kind: "drag",
|
|
25
25
|
widgetId: n,
|
|
26
26
|
gridEl: c,
|
|
@@ -29,7 +29,7 @@ function L() {
|
|
|
29
29
|
cursor: "grabbing",
|
|
30
30
|
onMove: (t) => {
|
|
31
31
|
if (!l || !r) return;
|
|
32
|
-
const f = Math.round(t.deltaX / t.
|
|
32
|
+
const f = Math.round(t.deltaX / t.colPitch), D = Math.round(t.deltaY / t.rowPitch), w = P(r, f, D, t.cols);
|
|
33
33
|
o.updateDrag(w, {
|
|
34
34
|
deltaX: t.deltaX,
|
|
35
35
|
deltaY: t.deltaY
|