@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.
- package/dist/components/deck/DeckCell.d.ts +3 -1
- package/dist/components/deck/DeckCell.js +29 -37
- package/dist/components/deck/DeckGrid.js +125 -103
- package/dist/components/deck/DropZonePreview.js +15 -15
- package/dist/components/deck/WidgetResizeHandle.js +21 -21
- package/dist/components/deck/deckGridMetrics.d.ts +22 -0
- package/dist/components/deck/deckGridMetrics.js +51 -16
- package/dist/components/deck/deckPointerSession.d.ts +2 -0
- package/dist/components/deck/deckPointerSession.js +38 -31
- package/dist/context/DeckContext.d.ts +14 -1
- package/dist/context/DeckContext.js +187 -174
- package/dist/floe.css +2 -0
- package/dist/hooks/useDeckDrag.js +27 -24
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
1
2
|
import { type DeckWidget } from '../../context/DeckContext';
|
|
2
3
|
import type { GridPosition } from '../../utils/gridCollision';
|
|
3
4
|
export interface DeckCellProps {
|
|
@@ -5,8 +6,9 @@ export interface DeckCellProps {
|
|
|
5
6
|
position: GridPosition;
|
|
6
7
|
isDragging?: boolean;
|
|
7
8
|
isResizing?: boolean;
|
|
9
|
+
dragOverlayStyle?: JSX.CSSProperties;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Widget cell wrapper positioned via CSS grid-area
|
|
11
13
|
*/
|
|
12
|
-
export declare function DeckCell(props: DeckCellProps):
|
|
14
|
+
export declare function DeckCell(props: DeckCellProps): JSX.Element;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { insert as
|
|
2
|
-
import { createMemo as l, Show as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { useDeck as
|
|
5
|
-
import { useWidgetRegistry as
|
|
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 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
|
-
import { WidgetFrame as
|
|
9
|
-
var
|
|
10
|
-
function
|
|
11
|
-
const r =
|
|
8
|
+
import { WidgetFrame as I } from "./WidgetFrame.js";
|
|
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
|
+
function B(e) {
|
|
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 (() => {
|
|
15
|
-
var i =
|
|
16
|
-
return
|
|
15
|
+
var i = P();
|
|
16
|
+
return s(i, g(I, {
|
|
17
17
|
get widget() {
|
|
18
18
|
return e.widget;
|
|
19
19
|
},
|
|
20
20
|
get widgetDef() {
|
|
21
|
-
return
|
|
21
|
+
return a();
|
|
22
22
|
},
|
|
23
23
|
get isDragging() {
|
|
24
24
|
return e.isDragging;
|
|
@@ -27,28 +27,28 @@ function H(e) {
|
|
|
27
27
|
return e.isResizing;
|
|
28
28
|
},
|
|
29
29
|
get children() {
|
|
30
|
-
return
|
|
30
|
+
return g(z, {
|
|
31
31
|
get when() {
|
|
32
|
-
return
|
|
32
|
+
return o();
|
|
33
33
|
},
|
|
34
34
|
get fallback() {
|
|
35
|
-
return
|
|
35
|
+
return g(_, {
|
|
36
36
|
get type() {
|
|
37
37
|
return d();
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
},
|
|
41
41
|
get children() {
|
|
42
|
-
return
|
|
42
|
+
return g(M, {
|
|
43
43
|
get widgetId() {
|
|
44
44
|
return e.widget.id;
|
|
45
45
|
},
|
|
46
|
-
state:
|
|
47
|
-
onStateChange:
|
|
46
|
+
state: h,
|
|
47
|
+
onStateChange: v,
|
|
48
48
|
get children() {
|
|
49
|
-
return
|
|
49
|
+
return g(D, {
|
|
50
50
|
get component() {
|
|
51
|
-
return
|
|
51
|
+
return o();
|
|
52
52
|
},
|
|
53
53
|
get widgetId() {
|
|
54
54
|
return e.widget.id;
|
|
@@ -57,7 +57,7 @@ function H(e) {
|
|
|
57
57
|
return e.widget.config;
|
|
58
58
|
},
|
|
59
59
|
get isEditMode() {
|
|
60
|
-
return
|
|
60
|
+
return f();
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
}
|
|
@@ -66,18 +66,10 @@ function H(e) {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
})), W((t) => {
|
|
69
|
-
var c = e.widget.id,
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
!e.isDragging && "transition-transform duration-200 ease-out",
|
|
74
|
-
e.isDragging && "shadow-xl z-50 ring-2 ring-primary scale-[1.02]",
|
|
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
|
-
), u = h();
|
|
80
|
-
return c !== t.e && b(i, "data-floe-deck-widget-id", t.e = c), s !== t.t && S(i, t.t = s), u !== t.a && C(i, "grid-area", t.a = u), t;
|
|
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 ?? {
|
|
70
|
+
"grid-area": w()
|
|
71
|
+
};
|
|
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;
|
|
81
73
|
}, {
|
|
82
74
|
e: void 0,
|
|
83
75
|
t: void 0,
|
|
@@ -87,10 +79,10 @@ function H(e) {
|
|
|
87
79
|
}
|
|
88
80
|
function _(e) {
|
|
89
81
|
return (() => {
|
|
90
|
-
var r = T(),
|
|
91
|
-
return
|
|
82
|
+
var r = T(), n = r.firstChild;
|
|
83
|
+
return n.firstChild, s(n, () => e.type, null), r;
|
|
92
84
|
})();
|
|
93
85
|
}
|
|
94
86
|
export {
|
|
95
|
-
|
|
87
|
+
B as DeckCell
|
|
96
88
|
};
|
|
@@ -1,101 +1,105 @@
|
|
|
1
|
-
import { setStyleProperty as
|
|
2
|
-
import { createSignal as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { useDeck as
|
|
5
|
-
import { useLayout as
|
|
6
|
-
import { useResolvedFloeConfig as
|
|
7
|
-
import { useWidgetRegistry as
|
|
8
|
-
import { hasCollision as
|
|
9
|
-
import { DeckCell as
|
|
10
|
-
import { DeckContextMenu as
|
|
11
|
-
import { DropZonePreview as
|
|
12
|
-
import { DECK_DEFAULT_ROWS as
|
|
13
|
-
import { DECK_GRID_CONFIG as
|
|
14
|
-
var
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
const p =
|
|
18
|
-
let
|
|
19
|
-
const [
|
|
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
|
+
import { cn as dt } from "../../utils/cn.js";
|
|
4
|
+
import { useDeck as ut } from "../../context/DeckContext.js";
|
|
5
|
+
import { useLayout as gt } from "../../context/LayoutContext.js";
|
|
6
|
+
import { useResolvedFloeConfig as pt } from "../../context/FloeConfigContext.js";
|
|
7
|
+
import { useWidgetRegistry as mt } from "../../context/WidgetRegistry.js";
|
|
8
|
+
import { hasCollision as ft } from "../../utils/gridCollision.js";
|
|
9
|
+
import { DeckCell as vt } from "./DeckCell.js";
|
|
10
|
+
import { DeckContextMenu as ht } from "./DeckContextMenu.js";
|
|
11
|
+
import { DropZonePreview as xt } from "./DropZonePreview.js";
|
|
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
|
+
let n;
|
|
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
|
-
const
|
|
26
|
+
const o = n.getBoundingClientRect(), {
|
|
27
27
|
cols: e,
|
|
28
|
-
rowHeight:
|
|
28
|
+
rowHeight: i,
|
|
29
29
|
gap: s
|
|
30
|
-
} =
|
|
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:
|
|
37
|
-
row:
|
|
36
|
+
col: H,
|
|
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
|
-
},
|
|
46
|
-
const t =
|
|
45
|
+
}, tt = d(() => {
|
|
46
|
+
const t = x();
|
|
47
47
|
if (!t) return !0;
|
|
48
48
|
const r = p.activeLayout();
|
|
49
|
-
return r ? !
|
|
50
|
-
}),
|
|
51
|
-
const t =
|
|
52
|
-
if (t.length === 0) return
|
|
53
|
-
let r =
|
|
54
|
-
for (const
|
|
55
|
-
const e =
|
|
49
|
+
return r ? !ft(t.currentPosition, r.widgets, t.widgetId) : !0;
|
|
50
|
+
}), et = d(() => {
|
|
51
|
+
const t = E();
|
|
52
|
+
if (t.length === 0) return g;
|
|
53
|
+
let r = g;
|
|
54
|
+
for (const o of t) {
|
|
55
|
+
const e = o.position.row + o.position.rowSpan;
|
|
56
56
|
e > r && (r = e);
|
|
57
57
|
}
|
|
58
58
|
return r;
|
|
59
|
-
}),
|
|
60
|
-
let t =
|
|
61
|
-
const r =
|
|
59
|
+
}), G = d(() => {
|
|
60
|
+
let t = et();
|
|
61
|
+
const r = x();
|
|
62
62
|
if (r) {
|
|
63
63
|
const e = r.currentPosition.row + r.currentPosition.rowSpan;
|
|
64
64
|
e > t && (t = e);
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
const e =
|
|
66
|
+
const o = R();
|
|
67
|
+
if (o) {
|
|
68
|
+
const e = o.currentPosition.row + o.currentPosition.rowSpan;
|
|
69
69
|
e > t && (t = e);
|
|
70
70
|
}
|
|
71
|
-
return Math.max(
|
|
72
|
-
}),
|
|
73
|
-
const t =
|
|
74
|
-
if (t <= 0) return
|
|
75
|
-
const
|
|
76
|
-
return Math.max(
|
|
71
|
+
return Math.max(g, t);
|
|
72
|
+
}), k = d(() => {
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
st(() => {
|
|
79
|
+
const t = () => {
|
|
80
|
+
n && (_(n.clientHeight), j(K(n)));
|
|
81
|
+
};
|
|
82
|
+
if (t(), !n || typeof ResizeObserver > "u") return;
|
|
83
|
+
const r = new ResizeObserver((o) => {
|
|
84
|
+
for (const e of o)
|
|
85
|
+
_(e.contentRect.height);
|
|
86
|
+
t();
|
|
83
87
|
});
|
|
84
|
-
|
|
88
|
+
r.observe(n), lt(() => r.disconnect());
|
|
85
89
|
});
|
|
86
|
-
const
|
|
90
|
+
const rt = d(() => G() > g ? !0 : C() <= 0 ? !1 : g * k() + (g - 1) * f + A * 2 > C() + 1);
|
|
87
91
|
return (() => {
|
|
88
|
-
var t =
|
|
89
|
-
t.$$contextmenu =
|
|
90
|
-
var
|
|
91
|
-
return typeof
|
|
92
|
+
var t = Dt(), r = t.firstChild;
|
|
93
|
+
t.$$contextmenu = J;
|
|
94
|
+
var o = n;
|
|
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, {
|
|
92
96
|
get when() {
|
|
93
|
-
return
|
|
97
|
+
return L();
|
|
94
98
|
},
|
|
95
99
|
get children() {
|
|
96
|
-
var e =
|
|
97
|
-
return
|
|
98
|
-
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 = [
|
|
99
103
|
// Fine
|
|
100
104
|
"linear-gradient(to right, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px)",
|
|
101
105
|
"linear-gradient(to bottom, color-mix(in srgb, var(--border) 35%, transparent) 1px, transparent 1px)",
|
|
@@ -105,7 +109,7 @@ function It(R) {
|
|
|
105
109
|
// Major (12)
|
|
106
110
|
"linear-gradient(to right, color-mix(in srgb, var(--border) 75%, transparent) 2px, transparent 2px)",
|
|
107
111
|
"linear-gradient(to bottom, color-mix(in srgb, var(--border) 75%, transparent) 2px, transparent 2px)"
|
|
108
|
-
].join(", "),
|
|
112
|
+
].join(", "), a = [
|
|
109
113
|
// Fine
|
|
110
114
|
"var(--deck-grid-unit-x) var(--deck-grid-unit-y)",
|
|
111
115
|
"var(--deck-grid-unit-x) var(--deck-grid-unit-y)",
|
|
@@ -116,7 +120,7 @@ function It(R) {
|
|
|
116
120
|
"calc(var(--deck-grid-unit-x) * 12) calc(var(--deck-grid-unit-y) * 12)",
|
|
117
121
|
"calc(var(--deck-grid-unit-x) * 12) calc(var(--deck-grid-unit-y) * 12)"
|
|
118
122
|
].join(", ");
|
|
119
|
-
return s !==
|
|
123
|
+
return s !== i.e && u(e, "grid-row", i.e = s), c !== i.t && u(e, "--deck-grid-unit-y", i.t = c), l !== i.a && u(e, "background-image", i.a = l), a !== i.o && u(e, "background-size", i.o = a), i;
|
|
120
124
|
}, {
|
|
121
125
|
e: void 0,
|
|
122
126
|
t: void 0,
|
|
@@ -124,68 +128,86 @@ function It(R) {
|
|
|
124
128
|
o: void 0
|
|
125
129
|
}), e;
|
|
126
130
|
}
|
|
127
|
-
}), null),
|
|
131
|
+
}), null), y(t, h(F, {
|
|
128
132
|
get when() {
|
|
129
|
-
return
|
|
133
|
+
return x();
|
|
130
134
|
},
|
|
131
|
-
children: (e) =>
|
|
135
|
+
children: (e) => h(xt, {
|
|
132
136
|
get position() {
|
|
133
137
|
return e().currentPosition;
|
|
134
138
|
},
|
|
135
139
|
get isValid() {
|
|
136
|
-
return
|
|
140
|
+
return tt();
|
|
137
141
|
}
|
|
138
142
|
})
|
|
139
|
-
}), null),
|
|
143
|
+
}), null), y(t, h(ct, {
|
|
140
144
|
get each() {
|
|
141
|
-
return
|
|
145
|
+
return E();
|
|
142
146
|
},
|
|
143
147
|
children: (e) => {
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
const i = d(() => {
|
|
149
|
+
const a = R();
|
|
150
|
+
return a && a.widgetId === e.id ? a.currentPosition : e.position;
|
|
151
|
+
}), s = d(() => x()?.widgetId === e.id), c = d(() => R()?.widgetId === e.id), l = d(() => {
|
|
152
|
+
const a = x();
|
|
153
|
+
if (!a || a.widgetId !== e.id) return;
|
|
154
|
+
const w = V();
|
|
155
|
+
if (!w || w.widgetId !== e.id) return;
|
|
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
|
+
return {
|
|
160
|
+
position: "absolute",
|
|
161
|
+
left: `${v.left}px`,
|
|
162
|
+
top: `${v.top}px`,
|
|
163
|
+
width: `${v.width}px`,
|
|
164
|
+
height: `${v.height}px`,
|
|
165
|
+
transform: `translate3d(${$}px, ${H}px, 0) scale(0.992)`,
|
|
166
|
+
"transform-origin": "center center",
|
|
167
|
+
"will-change": "transform"
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
return h(vt, {
|
|
152
171
|
widget: e,
|
|
153
172
|
get position() {
|
|
154
|
-
return
|
|
173
|
+
return i();
|
|
155
174
|
},
|
|
156
175
|
get isDragging() {
|
|
157
176
|
return s();
|
|
158
177
|
},
|
|
159
178
|
get isResizing() {
|
|
160
179
|
return c();
|
|
180
|
+
},
|
|
181
|
+
get dragOverlayStyle() {
|
|
182
|
+
return l();
|
|
161
183
|
}
|
|
162
184
|
});
|
|
163
185
|
}
|
|
164
|
-
}), null),
|
|
186
|
+
}), null), y(t, () => z.children, null), y(t, h(ht, {
|
|
165
187
|
get open() {
|
|
166
|
-
return
|
|
188
|
+
return b() !== null;
|
|
167
189
|
},
|
|
168
190
|
get x() {
|
|
169
|
-
return
|
|
191
|
+
return b()?.x ?? 0;
|
|
170
192
|
},
|
|
171
193
|
get y() {
|
|
172
|
-
return
|
|
194
|
+
return b()?.y ?? 0;
|
|
173
195
|
},
|
|
174
196
|
get items() {
|
|
175
|
-
return
|
|
197
|
+
return q();
|
|
176
198
|
},
|
|
177
|
-
onSelect:
|
|
178
|
-
onDismiss: () =>
|
|
179
|
-
}), null),
|
|
180
|
-
var
|
|
199
|
+
onSelect: Q,
|
|
200
|
+
onDismiss: () => P(null)
|
|
201
|
+
}), null), T((e) => {
|
|
202
|
+
var i = dt(
|
|
181
203
|
"deck-grid relative w-full h-full overflow-x-hidden",
|
|
182
204
|
// Only enable vertical scroll when content exceeds 24 rows
|
|
183
|
-
|
|
205
|
+
rt() ? "overflow-y-scroll" : "overflow-y-hidden",
|
|
184
206
|
"grid p-1",
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
), s = `${
|
|
188
|
-
return
|
|
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;
|
|
189
211
|
}, {
|
|
190
212
|
e: void 0,
|
|
191
213
|
t: void 0,
|
|
@@ -194,9 +216,9 @@ function It(R) {
|
|
|
194
216
|
}), t;
|
|
195
217
|
})();
|
|
196
218
|
}
|
|
197
|
-
|
|
219
|
+
at(["contextmenu"]);
|
|
198
220
|
export {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
221
|
+
Wt as DECK_GRID_CONFIG,
|
|
222
|
+
Lt as DeckGrid,
|
|
223
|
+
bt as getGridConfigFromElement
|
|
202
224
|
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { effect as
|
|
2
|
-
import { cn as
|
|
3
|
-
import { positionToGridArea as
|
|
4
|
-
var u = /* @__PURE__ */
|
|
5
|
-
function
|
|
6
|
-
const v = () =>
|
|
1
|
+
import { effect as g, className as c, setStyleProperty as n, template as f } from "solid-js/web";
|
|
2
|
+
import { cn as m } from "../../utils/cn.js";
|
|
3
|
+
import { positionToGridArea as b } from "../../utils/gridLayout.js";
|
|
4
|
+
var u = /* @__PURE__ */ f('<div data-floe-deck-drop-preview=true><div class="absolute inset-0 rounded-md">');
|
|
5
|
+
function w(i) {
|
|
6
|
+
const v = () => b(i.position), o = () => i.isValid !== !1 ? "--info" : "--error";
|
|
7
7
|
return (() => {
|
|
8
8
|
var e = u(), l = e.firstChild;
|
|
9
|
-
return
|
|
10
|
-
var
|
|
11
|
-
"pointer-events-none rounded-md relative",
|
|
9
|
+
return g((r) => {
|
|
10
|
+
var a = m(
|
|
11
|
+
"pointer-events-none rounded-md relative z-20",
|
|
12
12
|
"border-2 border-dashed",
|
|
13
|
-
|
|
13
|
+
i.isValid !== !1 ? "border-info/60 bg-info/10 ring-1 ring-inset ring-info/25" : "border-error/60 bg-error/10 ring-1 ring-inset ring-error/25",
|
|
14
14
|
// Subtle animation
|
|
15
15
|
"animate-in fade-in duration-150"
|
|
16
|
-
), t = v(), d = `0 4px 16px color-mix(in srgb, var(${
|
|
16
|
+
), t = v(), d = `0 4px 16px color-mix(in srgb, var(${o()}) 18%, transparent)`, s = `linear-gradient(
|
|
17
17
|
135deg,
|
|
18
|
-
color-mix(in srgb, var(${
|
|
18
|
+
color-mix(in srgb, var(${o()}) 18%, transparent) 0%,
|
|
19
19
|
transparent 55%,
|
|
20
|
-
color-mix(in srgb, var(${
|
|
20
|
+
color-mix(in srgb, var(${o()}) 10%, var(--card)) 100%
|
|
21
21
|
)`;
|
|
22
|
-
return
|
|
22
|
+
return a !== r.e && c(e, r.e = a), t !== r.t && n(e, "grid-area", r.t = t), d !== r.a && n(e, "box-shadow", r.a = d), s !== r.o && n(l, "background", r.o = s), r;
|
|
23
23
|
}, {
|
|
24
24
|
e: void 0,
|
|
25
25
|
t: void 0,
|
|
@@ -29,5 +29,5 @@ function V(o) {
|
|
|
29
29
|
})();
|
|
30
30
|
}
|
|
31
31
|
export {
|
|
32
|
-
|
|
32
|
+
w as DropZonePreview
|
|
33
33
|
};
|
|
@@ -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
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GridPosition } from '../../utils/gridCollision';
|
|
1
2
|
export declare const DECK_GRID_COLS = 24;
|
|
2
3
|
export declare const DECK_DEFAULT_ROWS = 24;
|
|
3
4
|
export declare const DECK_GAP = 4;
|
|
@@ -13,6 +14,22 @@ export interface DeckGridMeasurements extends DeckGridConfig {
|
|
|
13
14
|
cellWidth: number;
|
|
14
15
|
cellHeight: number;
|
|
15
16
|
}
|
|
17
|
+
export interface DeckGridSurfaceMeasurements extends DeckGridMeasurements {
|
|
18
|
+
paddingLeft: number;
|
|
19
|
+
paddingRight: number;
|
|
20
|
+
paddingTop: number;
|
|
21
|
+
paddingBottom: number;
|
|
22
|
+
}
|
|
23
|
+
export interface DeckGridPixelRect {
|
|
24
|
+
left: number;
|
|
25
|
+
top: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}
|
|
29
|
+
export interface DeckGridPixelOffset {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}
|
|
16
33
|
export declare const DECK_GRID_CONFIG: {
|
|
17
34
|
readonly cols: 24;
|
|
18
35
|
readonly defaultRows: 24;
|
|
@@ -24,3 +41,8 @@ export declare function measureDeckGrid(gridEl: HTMLElement, options?: {
|
|
|
24
41
|
paddingLeft?: number;
|
|
25
42
|
paddingRight?: number;
|
|
26
43
|
}): DeckGridMeasurements | null;
|
|
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;
|
|
47
|
+
export declare function positionToDeckPixelRect(position: GridPosition, measurements: DeckGridSurfaceMeasurements): DeckGridPixelRect;
|
|
48
|
+
export declare function positionDeltaToDeckPixelOffset(from: GridPosition, to: GridPosition, measurements: DeckGridSurfaceMeasurements): DeckGridPixelOffset;
|