@floegence/floe-webapp-core 0.36.1 → 0.36.3
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 +4 -4
- package/dist/components/ui/Dialog.js +120 -87
- package/dist/components/ui/FloatingWindow.js +158 -144
- package/dist/components/ui/InfiniteCanvas.js +80 -77
- package/dist/components/ui/dialogSurfaceScope.d.ts +14 -0
- package/dist/components/ui/dialogSurfaceScope.js +45 -0
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/localInteractionSurface.d.ts +11 -0
- package/dist/components/ui/localInteractionSurface.js +20 -0
- package/dist/components/workbench/WorkbenchCanvas.js +54 -60
- package/dist/components/workbench/WorkbenchCanvasField.d.ts +25 -0
- package/dist/components/workbench/WorkbenchCanvasField.js +145 -0
- package/dist/components/workbench/WorkbenchWidget.d.ts +10 -2
- package/dist/components/workbench/WorkbenchWidget.js +74 -74
- package/dist/full.js +497 -492
- package/dist/hooks/useOverlayMask.d.ts +11 -9
- package/dist/hooks/useOverlayMask.js +54 -52
- package/dist/styles.css +1 -1
- package/dist/ui.js +90 -85
- package/package.json +1 -1
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { insert as
|
|
2
|
-
import { createSignal as
|
|
3
|
-
import { cn as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
var ne = /* @__PURE__ */
|
|
7
|
-
const re = 1,
|
|
8
|
-
function le(n,
|
|
9
|
-
return Math.max(
|
|
1
|
+
import { insert as j, effect as q, className as I, setAttribute as G, setStyleProperty as J, template as K, use as Q, delegateEvents as ee } from "solid-js/web";
|
|
2
|
+
import { createSignal as T, untrack as L, createEffect as _, onCleanup as b } from "solid-js";
|
|
3
|
+
import { cn as D } from "../../utils/cn.js";
|
|
4
|
+
import { startHotInteraction as Y } from "../../utils/hotInteraction.js";
|
|
5
|
+
import { resolveSurfaceInteractionTargetRole as te } from "./localInteractionSurface.js";
|
|
6
|
+
var ne = /* @__PURE__ */ K('<div><div style="transform-origin:0 0">');
|
|
7
|
+
const re = 1, oe = 0.45, ae = 2.2, ie = 14e-4, ce = '[data-floe-canvas-pan-surface="true"]', y = 3;
|
|
8
|
+
function le(n, i, d) {
|
|
9
|
+
return Math.max(i, Math.min(d, n));
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function A(n) {
|
|
12
12
|
return {
|
|
13
13
|
x: Number.isFinite(n.x) ? n.x : 0,
|
|
14
14
|
y: Number.isFinite(n.y) ? n.y : 0,
|
|
15
15
|
scale: Number.isFinite(n.scale) && n.scale > 0 ? n.scale : re
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function se(n,
|
|
19
|
-
return n.deltaMode === 1 ? n.deltaY * 16 : n.deltaMode === 2 ? n.deltaY * (
|
|
18
|
+
function se(n, i) {
|
|
19
|
+
return n.deltaMode === 1 ? n.deltaY * 16 : n.deltaMode === 2 ? n.deltaY * (i?.clientHeight ?? window.innerHeight) : n.deltaY;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const [
|
|
23
|
-
let
|
|
24
|
-
const
|
|
21
|
+
function ve(n) {
|
|
22
|
+
const [i, d] = T(L(() => A(n.viewport))), [p, w] = T(null);
|
|
23
|
+
let a, f, m = !1, l;
|
|
24
|
+
const M = () => n.interactiveSelector ?? '[data-floe-canvas-interactive="true"]', X = () => n.panSurfaceSelector ?? ce, R = () => n.minScale ?? oe, F = () => n.maxScale ?? ae, k = () => n.wheelZoomSpeed ?? ie, $ = () => {
|
|
25
25
|
const e = p();
|
|
26
26
|
return e ? e.startedFromPanSurface ? e.moved : !0 : !1;
|
|
27
|
-
}, v = () => {
|
|
28
|
-
f !== void 0 && (window.clearTimeout(f), f = void 0);
|
|
29
27
|
}, C = () => {
|
|
28
|
+
f !== void 0 && (window.clearTimeout(f), f = void 0);
|
|
29
|
+
}, g = () => {
|
|
30
30
|
m = !1, l !== void 0 && (window.clearTimeout(l), l = void 0);
|
|
31
|
-
},
|
|
31
|
+
}, V = () => {
|
|
32
32
|
if (typeof window > "u") {
|
|
33
33
|
m = !1;
|
|
34
34
|
return;
|
|
@@ -38,113 +38,116 @@ function we(n) {
|
|
|
38
38
|
}, 0);
|
|
39
39
|
}, h = (e) => {
|
|
40
40
|
L(() => n.onViewportChange?.(e));
|
|
41
|
-
},
|
|
41
|
+
}, N = (e) => {
|
|
42
42
|
if (typeof window > "u") {
|
|
43
43
|
h(e);
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
C(), f = window.setTimeout(() => {
|
|
47
47
|
f = void 0, h(e);
|
|
48
48
|
}, 90);
|
|
49
|
-
},
|
|
49
|
+
}, v = (e) => te({
|
|
50
|
+
target: e,
|
|
51
|
+
interactiveSelector: M(),
|
|
52
|
+
panSurfaceSelector: X()
|
|
53
|
+
}), P = (e) => {
|
|
50
54
|
const t = p();
|
|
51
55
|
if (!t || e !== void 0 && t.pointerId !== e) return;
|
|
52
56
|
t.stopInteraction?.();
|
|
53
|
-
const r =
|
|
54
|
-
|
|
57
|
+
const r = i();
|
|
58
|
+
w(null), a && a.hasPointerCapture(t.pointerId) && a.releasePointerCapture(t.pointerId), t.startedFromPanSurface && t.moved && (m = !0, V()), h(r);
|
|
55
59
|
};
|
|
56
|
-
|
|
57
|
-
p() || d(
|
|
58
|
-
}),
|
|
59
|
-
const e =
|
|
60
|
+
_(() => {
|
|
61
|
+
p() || d(A(n.viewport));
|
|
62
|
+
}), _(() => {
|
|
63
|
+
const e = a;
|
|
60
64
|
if (!e) return;
|
|
61
65
|
const t = (r) => {
|
|
62
|
-
!m ||
|
|
66
|
+
!m || v(r.target) !== "pan_surface" || (g(), r.preventDefault(), r.stopPropagation());
|
|
63
67
|
};
|
|
64
68
|
e.addEventListener("click", t, !0), e.addEventListener("wheel", x, {
|
|
65
69
|
passive: !1
|
|
66
|
-
}),
|
|
70
|
+
}), b(() => {
|
|
67
71
|
e.removeEventListener("click", t, !0), e.removeEventListener("wheel", x);
|
|
68
72
|
});
|
|
69
|
-
}),
|
|
70
|
-
|
|
73
|
+
}), b(() => {
|
|
74
|
+
C(), P(), g();
|
|
71
75
|
});
|
|
72
|
-
const
|
|
73
|
-
if (e.button !== 0 ||
|
|
74
|
-
const t =
|
|
75
|
-
|
|
76
|
+
const U = (e) => {
|
|
77
|
+
if (e.button !== 0 || n.disablePanZoom) return;
|
|
78
|
+
const t = v(e.target), r = t === "pan_surface";
|
|
79
|
+
t !== "local_surface" && (C(), g(), r || (e.preventDefault(), a?.setPointerCapture(e.pointerId)), w({
|
|
76
80
|
pointerId: e.pointerId,
|
|
77
81
|
startClientX: e.clientX,
|
|
78
82
|
startClientY: e.clientY,
|
|
79
|
-
startViewport:
|
|
83
|
+
startViewport: i(),
|
|
80
84
|
moved: !1,
|
|
81
|
-
startedFromPanSurface:
|
|
82
|
-
stopInteraction:
|
|
85
|
+
startedFromPanSurface: r,
|
|
86
|
+
stopInteraction: r ? void 0 : Y({
|
|
83
87
|
kind: "drag",
|
|
84
88
|
cursor: "grabbing"
|
|
85
89
|
})
|
|
86
90
|
}));
|
|
87
|
-
},
|
|
91
|
+
}, H = (e) => {
|
|
88
92
|
const t = p();
|
|
89
93
|
if (!t || t.pointerId !== e.pointerId) return;
|
|
90
|
-
const r = e.clientX - t.startClientX,
|
|
91
|
-
if (!(t.moved || Math.abs(r) >
|
|
92
|
-
t.moved || (e.preventDefault(),
|
|
93
|
-
const
|
|
94
|
+
const r = e.clientX - t.startClientX, o = e.clientY - t.startClientY;
|
|
95
|
+
if (!(t.moved || Math.abs(r) > y || Math.abs(o) > y)) return;
|
|
96
|
+
t.moved || (e.preventDefault(), a?.hasPointerCapture(e.pointerId) || a?.setPointerCapture(e.pointerId));
|
|
97
|
+
const s = {
|
|
94
98
|
...t.startViewport,
|
|
95
99
|
x: t.startViewport.x + r,
|
|
96
|
-
y: t.startViewport.y +
|
|
100
|
+
y: t.startViewport.y + o
|
|
97
101
|
};
|
|
98
|
-
t.moved ||
|
|
102
|
+
t.moved || w({
|
|
99
103
|
...t,
|
|
100
104
|
moved: !0,
|
|
101
|
-
stopInteraction: t.stopInteraction ??
|
|
105
|
+
stopInteraction: t.stopInteraction ?? Y({
|
|
102
106
|
kind: "drag",
|
|
103
107
|
cursor: "grabbing"
|
|
104
108
|
})
|
|
105
|
-
}), d(
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
|
|
109
|
+
}), d(s);
|
|
110
|
+
}, Z = (e) => {
|
|
111
|
+
P(e.pointerId);
|
|
112
|
+
}, O = (e) => {
|
|
113
|
+
P(e.pointerId);
|
|
110
114
|
}, x = (e) => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
if (v(e.target) !== "canvas")
|
|
116
|
+
return;
|
|
117
|
+
const r = a?.getBoundingClientRect();
|
|
118
|
+
if (!r || n.disablePanZoom)
|
|
115
119
|
return;
|
|
116
|
-
}
|
|
117
120
|
e.preventDefault();
|
|
118
|
-
const
|
|
119
|
-
if (Math.abs(
|
|
120
|
-
const
|
|
121
|
-
x:
|
|
122
|
-
y:
|
|
123
|
-
scale:
|
|
121
|
+
const o = i(), c = e.clientX - r.left, s = e.clientY - r.top, S = se(e, a), u = le(o.scale * Math.exp(-S * k()), R(), F());
|
|
122
|
+
if (Math.abs(u - o.scale) < 1e-4) return;
|
|
123
|
+
const B = (c - o.x) / o.scale, z = (s - o.y) / o.scale, E = {
|
|
124
|
+
x: c - B * u,
|
|
125
|
+
y: s - z * u,
|
|
126
|
+
scale: u
|
|
124
127
|
};
|
|
125
|
-
d(
|
|
126
|
-
},
|
|
127
|
-
if (
|
|
128
|
-
const t =
|
|
128
|
+
d(E), N(E);
|
|
129
|
+
}, W = (e) => {
|
|
130
|
+
if (v(e.target) !== "canvas") return;
|
|
131
|
+
const t = a?.getBoundingClientRect();
|
|
129
132
|
if (!t) return;
|
|
130
133
|
e.preventDefault();
|
|
131
|
-
const r = e.clientX - t.left,
|
|
134
|
+
const r = e.clientX - t.left, o = e.clientY - t.top, c = i();
|
|
132
135
|
n.onCanvasContextMenu?.({
|
|
133
136
|
clientX: e.clientX,
|
|
134
137
|
clientY: e.clientY,
|
|
135
138
|
localX: r,
|
|
136
|
-
localY:
|
|
139
|
+
localY: o,
|
|
137
140
|
worldX: (r - c.x) / c.scale,
|
|
138
|
-
worldY: (
|
|
141
|
+
worldY: (o - c.y) / c.scale
|
|
139
142
|
});
|
|
140
143
|
};
|
|
141
144
|
return (() => {
|
|
142
145
|
var e = ne(), t = e.firstChild;
|
|
143
|
-
e.$$contextmenu =
|
|
144
|
-
var r =
|
|
145
|
-
return typeof r == "function" ?
|
|
146
|
-
var c =
|
|
147
|
-
return c !==
|
|
146
|
+
e.$$contextmenu = W, e.addEventListener("pointercancel", O), e.$$pointerup = Z, e.$$pointermove = H, e.$$pointerdown = U;
|
|
147
|
+
var r = a;
|
|
148
|
+
return typeof r == "function" ? Q(r, e) : a = e, j(t, () => n.children), q((o) => {
|
|
149
|
+
var c = D("floe-infinite-canvas", $() && "is-panning", n.disablePanZoom && "is-locked", n.class), s = n.ariaLabel ?? "Infinite canvas", S = D("floe-infinite-canvas__viewport", n.contentClass), u = `translate(${i().x}px, ${i().y}px) scale(${i().scale})`;
|
|
150
|
+
return c !== o.e && I(e, o.e = c), s !== o.t && G(e, "aria-label", o.t = s), S !== o.a && I(t, o.a = S), u !== o.o && J(t, "transform", o.o = u), o;
|
|
148
151
|
}, {
|
|
149
152
|
e: void 0,
|
|
150
153
|
t: void 0,
|
|
@@ -153,7 +156,7 @@ function we(n) {
|
|
|
153
156
|
}), e;
|
|
154
157
|
})();
|
|
155
158
|
}
|
|
156
|
-
|
|
159
|
+
ee(["pointerdown", "pointermove", "pointerup", "contextmenu"]);
|
|
157
160
|
export {
|
|
158
|
-
|
|
161
|
+
ve as InfiniteCanvas
|
|
159
162
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const DIALOG_SURFACE_HOST_ATTR = "data-floe-dialog-surface-host";
|
|
2
|
+
export declare const DIALOG_SURFACE_BOUNDARY_ATTR = "data-floe-dialog-surface-boundary";
|
|
3
|
+
export type DialogSurfaceInteractionSnapshot = Readonly<{
|
|
4
|
+
target: Element | null;
|
|
5
|
+
activeElement: Element | null;
|
|
6
|
+
recordedAt: number;
|
|
7
|
+
}>;
|
|
8
|
+
export type ResolvedDialogSurfaceHost = Readonly<{
|
|
9
|
+
host: HTMLElement | null;
|
|
10
|
+
mode: 'global' | 'surface';
|
|
11
|
+
}>;
|
|
12
|
+
export declare function ensureDialogSurfaceInteractionTracking(): void;
|
|
13
|
+
export declare function resolveDialogSurfaceHost(): ResolvedDialogSurfaceHost;
|
|
14
|
+
export declare function __resetDialogSurfaceScopeForTests(): void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const a = "data-floe-dialog-surface-host", m = "data-floe-dialog-surface-boundary";
|
|
2
|
+
let o = null, t = null;
|
|
3
|
+
function d(e) {
|
|
4
|
+
return typeof Element < "u" && e instanceof Element ? e : typeof Node < "u" && e instanceof Node ? e.parentElement : null;
|
|
5
|
+
}
|
|
6
|
+
function f(e) {
|
|
7
|
+
const n = e?.activeElement;
|
|
8
|
+
return n instanceof Element ? n : null;
|
|
9
|
+
}
|
|
10
|
+
function i(e) {
|
|
11
|
+
const n = typeof document < "u" ? document : null;
|
|
12
|
+
o = {
|
|
13
|
+
target: d(e),
|
|
14
|
+
activeElement: f(n),
|
|
15
|
+
recordedAt: Date.now()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function r(e) {
|
|
19
|
+
i(e.target);
|
|
20
|
+
}
|
|
21
|
+
function u(e) {
|
|
22
|
+
i(e.target);
|
|
23
|
+
}
|
|
24
|
+
function l() {
|
|
25
|
+
typeof document > "u" || t !== document && (t && (t.removeEventListener("pointerdown", r, !0), t.removeEventListener("focusin", u, !0)), document.addEventListener("pointerdown", r, !0), document.addEventListener("focusin", u, !0), t = document);
|
|
26
|
+
}
|
|
27
|
+
function s() {
|
|
28
|
+
return !o || Date.now() - o.recordedAt > 1600 ? null : o;
|
|
29
|
+
}
|
|
30
|
+
function c(e) {
|
|
31
|
+
const n = e?.closest(`[${a}="true"]`);
|
|
32
|
+
return n instanceof HTMLElement && n.isConnected ? n : null;
|
|
33
|
+
}
|
|
34
|
+
function E() {
|
|
35
|
+
l();
|
|
36
|
+
const e = s(), n = c(e?.target ?? null) ?? c(e?.activeElement ?? null);
|
|
37
|
+
return n ? { host: n, mode: "surface" } : { host: null, mode: "global" };
|
|
38
|
+
}
|
|
39
|
+
typeof document < "u" && l();
|
|
40
|
+
export {
|
|
41
|
+
m as DIALOG_SURFACE_BOUNDARY_ATTR,
|
|
42
|
+
a as DIALOG_SURFACE_HOST_ATTR,
|
|
43
|
+
l as ensureDialogSurfaceInteractionTracking,
|
|
44
|
+
E as resolveDialogSurfaceHost
|
|
45
|
+
};
|
|
@@ -7,6 +7,7 @@ export { Dropdown, Select, type DropdownProps, type DropdownItem, type SelectPro
|
|
|
7
7
|
export { Tooltip, type TooltipProps } from './Tooltip';
|
|
8
8
|
export { CommandPalette } from './CommandPalette';
|
|
9
9
|
export { InfiniteCanvas, type InfiniteCanvasProps, type InfiniteCanvasPoint, type InfiniteCanvasContextMenuEvent, } from './InfiniteCanvas';
|
|
10
|
+
export { LOCAL_INTERACTION_SURFACE_ATTR, DEFAULT_LOCAL_INTERACTION_SURFACE_SELECTOR, isLocalInteractionSurfaceTarget, resolveSurfaceInteractionTargetRole, type SurfaceInteractionRoutingOptions, type SurfaceInteractionTargetRole, } from './localInteractionSurface';
|
|
10
11
|
export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, Interactive3DCard, AnimatedBorderCard, NeonCard, MorphCard, type CardProps, type CardVariant, type CardHeaderProps, type CardTitleProps, type CardDescriptionProps, type CardContentProps, type CardFooterProps, type Interactive3DCardProps, type AnimatedBorderCardProps, type NeonCardProps, type MorphCardProps, } from './Card';
|
|
11
12
|
export { Tabs, TabPanel, type TabsProps, type TabPanelProps, type TabItem, type TabsFeatures, type TabsSlotClassNames, type TabsIndicatorMode, type TabsIndicatorColorToken, } from './Tabs';
|
|
12
13
|
export { DirectoryPicker, type DirectoryPickerProps } from './DirectoryPicker';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const LOCAL_INTERACTION_SURFACE_ATTR = "data-floe-local-interaction-surface";
|
|
2
|
+
export declare const DEFAULT_LOCAL_INTERACTION_SURFACE_SELECTOR = "[data-floe-local-interaction-surface=\"true\"]";
|
|
3
|
+
export type SurfaceInteractionTargetRole = 'canvas' | 'local_surface' | 'pan_surface';
|
|
4
|
+
export interface SurfaceInteractionRoutingOptions {
|
|
5
|
+
target: EventTarget | null;
|
|
6
|
+
interactiveSelector: string;
|
|
7
|
+
panSurfaceSelector: string;
|
|
8
|
+
localInteractionSurfaceSelector?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveSurfaceInteractionTargetRole(options: SurfaceInteractionRoutingOptions): SurfaceInteractionTargetRole;
|
|
11
|
+
export declare function isLocalInteractionSurfaceTarget(options: SurfaceInteractionRoutingOptions): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isTypingElement as l } from "../../utils/dom.js";
|
|
2
|
+
const o = "data-floe-local-interaction-surface", s = `[${o}="true"]`;
|
|
3
|
+
function u(t) {
|
|
4
|
+
const {
|
|
5
|
+
target: n,
|
|
6
|
+
interactiveSelector: r,
|
|
7
|
+
panSurfaceSelector: c,
|
|
8
|
+
localInteractionSurfaceSelector: a = s
|
|
9
|
+
} = t, e = n instanceof Element ? n : null;
|
|
10
|
+
return e ? e.closest(c) !== null ? "pan_surface" : l(e) || e.closest(r) !== null || e.closest(a) !== null ? "local_surface" : "canvas" : "canvas";
|
|
11
|
+
}
|
|
12
|
+
function f(t) {
|
|
13
|
+
return u(t) !== "canvas";
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
s as DEFAULT_LOCAL_INTERACTION_SURFACE_SELECTOR,
|
|
17
|
+
o as LOCAL_INTERACTION_SURFACE_ATTR,
|
|
18
|
+
f as isLocalInteractionSurfaceTarget,
|
|
19
|
+
u as resolveSurfaceInteractionTargetRole
|
|
20
|
+
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { use as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var s = /* @__PURE__ */ c("<div class=workbench-canvas__field><div class=workbench-canvas__grid aria-hidden=true>"), f = /* @__PURE__ */ c("<div class=workbench-canvas>");
|
|
7
|
-
function b(e) {
|
|
1
|
+
import { use as r, insert as o, createComponent as i, effect as a, template as g } from "solid-js/web";
|
|
2
|
+
import { WorkbenchCanvasField as c } from "./WorkbenchCanvasField.js";
|
|
3
|
+
import { InfiniteCanvas as u } from "../ui/InfiniteCanvas.js";
|
|
4
|
+
var m = /* @__PURE__ */ g("<div class=workbench-canvas>");
|
|
5
|
+
function C(e) {
|
|
8
6
|
return (() => {
|
|
9
|
-
var t =
|
|
10
|
-
return typeof
|
|
7
|
+
var t = m(), n = e.setCanvasFrameRef;
|
|
8
|
+
return typeof n == "function" ? r(n, t) : e.setCanvasFrameRef = t, o(t, i(u, {
|
|
11
9
|
ariaLabel: "Workbench canvas",
|
|
12
10
|
class: "workbench-canvas__infinite",
|
|
13
11
|
get viewport() {
|
|
@@ -23,61 +21,57 @@ function b(e) {
|
|
|
23
21
|
return e.locked;
|
|
24
22
|
},
|
|
25
23
|
get children() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
return i(c, {
|
|
25
|
+
get widgetDefinitions() {
|
|
26
|
+
return e.widgetDefinitions;
|
|
27
|
+
},
|
|
28
|
+
get widgets() {
|
|
29
29
|
return e.widgets;
|
|
30
30
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
get onRequestDelete() {
|
|
73
|
-
return e.onRequestDelete;
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
}), null), r;
|
|
31
|
+
get selectedWidgetId() {
|
|
32
|
+
return e.selectedWidgetId;
|
|
33
|
+
},
|
|
34
|
+
get optimisticFrontWidgetId() {
|
|
35
|
+
return e.optimisticFrontWidgetId;
|
|
36
|
+
},
|
|
37
|
+
get topZIndex() {
|
|
38
|
+
return e.topZIndex;
|
|
39
|
+
},
|
|
40
|
+
get viewportScale() {
|
|
41
|
+
return e.viewport.scale;
|
|
42
|
+
},
|
|
43
|
+
get locked() {
|
|
44
|
+
return e.locked;
|
|
45
|
+
},
|
|
46
|
+
get filters() {
|
|
47
|
+
return e.filters;
|
|
48
|
+
},
|
|
49
|
+
get onSelectWidget() {
|
|
50
|
+
return e.onSelectWidget;
|
|
51
|
+
},
|
|
52
|
+
get onWidgetContextMenu() {
|
|
53
|
+
return e.onWidgetContextMenu;
|
|
54
|
+
},
|
|
55
|
+
get onStartOptimisticFront() {
|
|
56
|
+
return e.onStartOptimisticFront;
|
|
57
|
+
},
|
|
58
|
+
get onCommitFront() {
|
|
59
|
+
return e.onCommitFront;
|
|
60
|
+
},
|
|
61
|
+
get onCommitMove() {
|
|
62
|
+
return e.onCommitMove;
|
|
63
|
+
},
|
|
64
|
+
get onCommitResize() {
|
|
65
|
+
return e.onCommitResize;
|
|
66
|
+
},
|
|
67
|
+
get onRequestDelete() {
|
|
68
|
+
return e.onRequestDelete;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
77
71
|
}
|
|
78
|
-
})),
|
|
72
|
+
})), a(() => t.classList.toggle("is-locked", !!e.locked)), t;
|
|
79
73
|
})();
|
|
80
74
|
}
|
|
81
75
|
export {
|
|
82
|
-
|
|
76
|
+
C as WorkbenchCanvas
|
|
83
77
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { WorkbenchWidgetDefinition, WorkbenchWidgetItem, WorkbenchWidgetType } from './types';
|
|
2
|
+
export interface WorkbenchCanvasFieldProps {
|
|
3
|
+
widgetDefinitions: readonly WorkbenchWidgetDefinition[];
|
|
4
|
+
widgets: readonly WorkbenchWidgetItem[];
|
|
5
|
+
selectedWidgetId: string | null;
|
|
6
|
+
optimisticFrontWidgetId: string | null;
|
|
7
|
+
topZIndex: number;
|
|
8
|
+
viewportScale: number;
|
|
9
|
+
locked: boolean;
|
|
10
|
+
filters: Record<WorkbenchWidgetType, boolean>;
|
|
11
|
+
onSelectWidget: (widgetId: string) => void;
|
|
12
|
+
onWidgetContextMenu: (event: MouseEvent, item: WorkbenchWidgetItem) => void;
|
|
13
|
+
onStartOptimisticFront: (widgetId: string) => void;
|
|
14
|
+
onCommitFront: (widgetId: string) => void;
|
|
15
|
+
onCommitMove: (widgetId: string, position: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}) => void;
|
|
19
|
+
onCommitResize: (widgetId: string, size: {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
}) => void;
|
|
23
|
+
onRequestDelete: (widgetId: string) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function WorkbenchCanvasField(props: WorkbenchCanvasFieldProps): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { insert as o, createComponent as g, template as u } from "solid-js/web";
|
|
2
|
+
import { createMemo as r, For as m } from "solid-js";
|
|
3
|
+
import { getWidgetEntry as c } from "./widgets/widgetRegistry.js";
|
|
4
|
+
import { WorkbenchWidget as l } from "./WorkbenchWidget.js";
|
|
5
|
+
var a = /* @__PURE__ */ u("<div class=workbench-canvas__field><div class=workbench-canvas__grid aria-hidden=true>");
|
|
6
|
+
function w(t) {
|
|
7
|
+
const e = r((n) => {
|
|
8
|
+
const i = t.widgetById().get(t.widgetId);
|
|
9
|
+
if (i) return i;
|
|
10
|
+
if (n) return n;
|
|
11
|
+
throw new Error(`Workbench widget ${t.widgetId} is missing from the render map.`);
|
|
12
|
+
}), d = r(() => c(e().type, t.widgetDefinitions));
|
|
13
|
+
return g(l, {
|
|
14
|
+
get definition() {
|
|
15
|
+
return d();
|
|
16
|
+
},
|
|
17
|
+
get widgetId() {
|
|
18
|
+
return t.widgetId;
|
|
19
|
+
},
|
|
20
|
+
get widgetTitle() {
|
|
21
|
+
return e().title;
|
|
22
|
+
},
|
|
23
|
+
get widgetType() {
|
|
24
|
+
return e().type;
|
|
25
|
+
},
|
|
26
|
+
get x() {
|
|
27
|
+
return e().x;
|
|
28
|
+
},
|
|
29
|
+
get y() {
|
|
30
|
+
return e().y;
|
|
31
|
+
},
|
|
32
|
+
get width() {
|
|
33
|
+
return e().width;
|
|
34
|
+
},
|
|
35
|
+
get height() {
|
|
36
|
+
return e().height;
|
|
37
|
+
},
|
|
38
|
+
get zIndex() {
|
|
39
|
+
return e().z_index;
|
|
40
|
+
},
|
|
41
|
+
itemSnapshot: e,
|
|
42
|
+
get selected() {
|
|
43
|
+
return t.selectedWidgetId === t.widgetId;
|
|
44
|
+
},
|
|
45
|
+
get optimisticFront() {
|
|
46
|
+
return t.optimisticFrontWidgetId === t.widgetId;
|
|
47
|
+
},
|
|
48
|
+
get topZIndex() {
|
|
49
|
+
return t.topZIndex;
|
|
50
|
+
},
|
|
51
|
+
get viewportScale() {
|
|
52
|
+
return t.viewportScale;
|
|
53
|
+
},
|
|
54
|
+
get locked() {
|
|
55
|
+
return t.locked;
|
|
56
|
+
},
|
|
57
|
+
get filtered() {
|
|
58
|
+
return !t.filters[e().type];
|
|
59
|
+
},
|
|
60
|
+
get onSelect() {
|
|
61
|
+
return t.onSelectWidget;
|
|
62
|
+
},
|
|
63
|
+
get onContextMenu() {
|
|
64
|
+
return t.onWidgetContextMenu;
|
|
65
|
+
},
|
|
66
|
+
get onStartOptimisticFront() {
|
|
67
|
+
return t.onStartOptimisticFront;
|
|
68
|
+
},
|
|
69
|
+
get onCommitFront() {
|
|
70
|
+
return t.onCommitFront;
|
|
71
|
+
},
|
|
72
|
+
get onCommitMove() {
|
|
73
|
+
return t.onCommitMove;
|
|
74
|
+
},
|
|
75
|
+
get onCommitResize() {
|
|
76
|
+
return t.onCommitResize;
|
|
77
|
+
},
|
|
78
|
+
get onRequestDelete() {
|
|
79
|
+
return t.onRequestDelete;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function W(t) {
|
|
84
|
+
const e = r(() => t.widgets.map((n) => n.id)), d = r(() => new Map(t.widgets.map((n) => [n.id, n])));
|
|
85
|
+
return (() => {
|
|
86
|
+
var n = a();
|
|
87
|
+
return n.firstChild, o(n, g(m, {
|
|
88
|
+
get each() {
|
|
89
|
+
return e();
|
|
90
|
+
},
|
|
91
|
+
children: (i) => g(w, {
|
|
92
|
+
widgetId: i,
|
|
93
|
+
get widgetDefinitions() {
|
|
94
|
+
return t.widgetDefinitions;
|
|
95
|
+
},
|
|
96
|
+
get widgets() {
|
|
97
|
+
return t.widgets;
|
|
98
|
+
},
|
|
99
|
+
widgetById: d,
|
|
100
|
+
get selectedWidgetId() {
|
|
101
|
+
return t.selectedWidgetId;
|
|
102
|
+
},
|
|
103
|
+
get optimisticFrontWidgetId() {
|
|
104
|
+
return t.optimisticFrontWidgetId;
|
|
105
|
+
},
|
|
106
|
+
get topZIndex() {
|
|
107
|
+
return t.topZIndex;
|
|
108
|
+
},
|
|
109
|
+
get viewportScale() {
|
|
110
|
+
return t.viewportScale;
|
|
111
|
+
},
|
|
112
|
+
get locked() {
|
|
113
|
+
return t.locked;
|
|
114
|
+
},
|
|
115
|
+
get filters() {
|
|
116
|
+
return t.filters;
|
|
117
|
+
},
|
|
118
|
+
get onSelectWidget() {
|
|
119
|
+
return t.onSelectWidget;
|
|
120
|
+
},
|
|
121
|
+
get onWidgetContextMenu() {
|
|
122
|
+
return t.onWidgetContextMenu;
|
|
123
|
+
},
|
|
124
|
+
get onStartOptimisticFront() {
|
|
125
|
+
return t.onStartOptimisticFront;
|
|
126
|
+
},
|
|
127
|
+
get onCommitFront() {
|
|
128
|
+
return t.onCommitFront;
|
|
129
|
+
},
|
|
130
|
+
get onCommitMove() {
|
|
131
|
+
return t.onCommitMove;
|
|
132
|
+
},
|
|
133
|
+
get onCommitResize() {
|
|
134
|
+
return t.onCommitResize;
|
|
135
|
+
},
|
|
136
|
+
get onRequestDelete() {
|
|
137
|
+
return t.onRequestDelete;
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
}), null), n;
|
|
141
|
+
})();
|
|
142
|
+
}
|
|
143
|
+
export {
|
|
144
|
+
W as WorkbenchCanvasField
|
|
145
|
+
};
|