@floegence/floe-webapp-core 0.35.59 → 0.36.1
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 +47 -50
- package/dist/components/deck/DeckContextMenu.d.ts +22 -0
- package/dist/components/deck/DeckContextMenu.js +73 -0
- package/dist/components/deck/DeckGrid.js +147 -104
- package/dist/components/deck/DeckTopBar.js +74 -96
- package/dist/components/deck/WidgetFrame.d.ts +7 -1
- package/dist/components/deck/WidgetFrame.js +60 -52
- package/dist/components/deck/index.d.ts +1 -0
- package/dist/components/layout/DisplayModePageShell.d.ts +8 -0
- package/dist/components/layout/DisplayModePageShell.js +22 -0
- package/dist/components/layout/DisplayModeSwitcher.d.ts +7 -0
- package/dist/components/layout/DisplayModeSwitcher.js +52 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/ui/InfiniteCanvas.d.ts +2 -0
- package/dist/components/ui/InfiniteCanvas.js +43 -37
- package/dist/components/workbench/WorkbenchCanvas.d.ts +29 -0
- package/dist/components/workbench/WorkbenchCanvas.js +83 -0
- package/dist/components/workbench/WorkbenchContextMenu.d.ts +24 -0
- package/dist/components/workbench/WorkbenchContextMenu.js +44 -0
- package/dist/components/workbench/WorkbenchFilterBar.d.ts +17 -0
- package/dist/components/workbench/WorkbenchFilterBar.js +267 -0
- package/dist/components/workbench/WorkbenchHud.d.ts +6 -0
- package/dist/components/workbench/WorkbenchHud.js +17 -0
- package/dist/components/workbench/WorkbenchLockButton.d.ts +6 -0
- package/dist/components/workbench/WorkbenchLockButton.js +49 -0
- package/dist/components/workbench/WorkbenchOverlay.d.ts +18 -0
- package/dist/components/workbench/WorkbenchOverlay.js +107 -0
- package/dist/components/workbench/WorkbenchSurface.d.ts +34 -0
- package/dist/components/workbench/WorkbenchSurface.js +200 -0
- package/dist/components/workbench/WorkbenchWidget.d.ts +26 -0
- package/dist/components/workbench/WorkbenchWidget.js +192 -0
- package/dist/components/workbench/index.d.ts +7 -0
- package/dist/components/workbench/types.d.ts +56 -0
- package/dist/components/workbench/types.js +11 -0
- package/dist/components/workbench/useWorkbenchModel.d.ts +83 -0
- package/dist/components/workbench/useWorkbenchModel.js +284 -0
- package/dist/components/workbench/widgets/CodeEditorWidget.d.ts +1 -0
- package/dist/components/workbench/widgets/CodeEditorWidget.js +144 -0
- package/dist/components/workbench/widgets/FileBrowserWidget.d.ts +1 -0
- package/dist/components/workbench/widgets/FileBrowserWidget.js +142 -0
- package/dist/components/workbench/widgets/LogViewerWidget.d.ts +1 -0
- package/dist/components/workbench/widgets/LogViewerWidget.js +86 -0
- package/dist/components/workbench/widgets/SystemMonitorWidget.d.ts +1 -0
- package/dist/components/workbench/widgets/SystemMonitorWidget.js +122 -0
- package/dist/components/workbench/widgets/TerminalWidget.d.ts +1 -0
- package/dist/components/workbench/widgets/TerminalWidget.js +70 -0
- package/dist/components/workbench/widgets/widgetRegistry.d.ts +14 -0
- package/dist/components/workbench/widgets/widgetRegistry.js +71 -0
- package/dist/components/workbench/workbenchHelpers.d.ts +26 -0
- package/dist/components/workbench/workbenchHelpers.js +139 -0
- package/dist/deck.js +14 -12
- package/dist/display-mode.css +70 -0
- package/dist/full.js +475 -468
- package/dist/hooks/useDeckDrag.js +15 -15
- package/dist/layout.js +32 -27
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +2 -0
- package/dist/ui.css +4 -0
- package/dist/workbench.css +1220 -0
- package/dist/workbench.d.ts +1 -0
- package/dist/workbench.js +23 -0
- package/package.json +5 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { insert as n, createComponent as c, memo as s, effect as d, setAttribute as u, template as k, delegateEvents as v } from "solid-js/web";
|
|
2
|
+
import { Motion as m } from "../../node_modules/.pnpm/solid-motionone@1.0.4_solid-js@1.9.11/node_modules/solid-motionone/dist/index.js";
|
|
3
|
+
import { easing as h, duration as f } from "../../utils/animations.js";
|
|
4
|
+
import { Lock as g, Unlock as _ } from "../icons/index.js";
|
|
5
|
+
var L = /* @__PURE__ */ k("<button type=button class=workbench-lock-button data-floe-canvas-interactive=true><span class=workbench-lock-button__icon>"), w = /* @__PURE__ */ k("<span class=workbench-lock-button__kbd>");
|
|
6
|
+
function y(t) {
|
|
7
|
+
const l = () => t.locked ? "Unlock canvas" : "Lock canvas";
|
|
8
|
+
return (() => {
|
|
9
|
+
var a = L(), b = a.firstChild;
|
|
10
|
+
return a.$$click = () => t.onToggle(), n(b, c(m.span, {
|
|
11
|
+
class: "workbench-lock-button__icon-swap",
|
|
12
|
+
get animate() {
|
|
13
|
+
return {
|
|
14
|
+
rotate: t.locked ? 0 : -14
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
get transition() {
|
|
18
|
+
return {
|
|
19
|
+
duration: f.fast,
|
|
20
|
+
easing: h.easeOut
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
get children() {
|
|
24
|
+
return s(() => !!t.locked)() ? c(g, {
|
|
25
|
+
class: "w-4 h-4"
|
|
26
|
+
}) : c(_, {
|
|
27
|
+
class: "w-4 h-4"
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
})), n(a, (() => {
|
|
31
|
+
var e = s(() => !!t.shortcutLabel);
|
|
32
|
+
return () => e() ? (() => {
|
|
33
|
+
var o = w();
|
|
34
|
+
return n(o, () => t.shortcutLabel), o;
|
|
35
|
+
})() : null;
|
|
36
|
+
})(), null), d((e) => {
|
|
37
|
+
var o = !!t.locked, r = t.shortcutLabel ? `${l()} (${t.shortcutLabel})` : l(), i = t.locked;
|
|
38
|
+
return o !== e.e && a.classList.toggle("is-locked", e.e = o), r !== e.t && u(a, "aria-label", e.t = r), i !== e.a && u(a, "aria-pressed", e.a = i), e;
|
|
39
|
+
}, {
|
|
40
|
+
e: void 0,
|
|
41
|
+
t: void 0,
|
|
42
|
+
a: void 0
|
|
43
|
+
}), a;
|
|
44
|
+
})();
|
|
45
|
+
}
|
|
46
|
+
v(["click"]);
|
|
47
|
+
export {
|
|
48
|
+
y as WorkbenchLockButton
|
|
49
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WorkbenchState } from './types';
|
|
2
|
+
export interface WorkbenchOverlayProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
state: () => WorkbenchState;
|
|
6
|
+
setState: (updater: (prev: WorkbenchState) => WorkbenchState) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Keyboard shortcut key for toggling lock mode.
|
|
9
|
+
* Matches `KeyboardEvent.key`. Defaults to "F1".
|
|
10
|
+
*/
|
|
11
|
+
lockShortcut?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Modal-mode wrapper around WorkbenchSurface. Use this for transient pop-in
|
|
15
|
+
* usage (a workbench launched as a tool overlay). For permanent display-mode
|
|
16
|
+
* usage, mount WorkbenchSurface directly inside your layout.
|
|
17
|
+
*/
|
|
18
|
+
export declare function WorkbenchOverlay(props: WorkbenchOverlayProps): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createComponent as t, insert as l, template as u, delegateEvents as h } from "solid-js/web";
|
|
2
|
+
import { Show as f } from "solid-js";
|
|
3
|
+
import { Motion as c } from "../../node_modules/.pnpm/solid-motionone@1.0.4_solid-js@1.9.11/node_modules/solid-motionone/dist/index.js";
|
|
4
|
+
import { easing as y, duration as i } from "../../utils/animations.js";
|
|
5
|
+
import { useOverlayMask as b } from "../../hooks/useOverlayMask.js";
|
|
6
|
+
import { X as v } from "../icons/index.js";
|
|
7
|
+
import { WorkbenchSurface as k } from "./WorkbenchSurface.js";
|
|
8
|
+
var m = /* @__PURE__ */ u('<header class=workbench-overlay__header data-floe-canvas-interactive=true><div class=workbench-overlay__header-brand><div class=workbench-overlay__header-title>Workbench</div></div><div class=workbench-overlay__header-actions><button type=button class=workbench-overlay__close aria-label="Close workbench overlay"data-floe-overlay-close=true>'), _ = /* @__PURE__ */ u("<div class=workbench-overlay__body>");
|
|
9
|
+
const s = '[data-floe-workbench-boundary="true"]';
|
|
10
|
+
function w(e) {
|
|
11
|
+
return typeof Element < "u" && e instanceof Element ? !!e.closest(s) : typeof Node < "u" && e instanceof Node ? !!e.parentElement?.closest(s) : !1;
|
|
12
|
+
}
|
|
13
|
+
function O(e) {
|
|
14
|
+
let a;
|
|
15
|
+
return b({
|
|
16
|
+
open: () => e.open,
|
|
17
|
+
root: () => a,
|
|
18
|
+
onClose: () => e.onClose(),
|
|
19
|
+
containsTarget: w,
|
|
20
|
+
lockBodyScroll: !0,
|
|
21
|
+
trapFocus: !0,
|
|
22
|
+
closeOnEscape: !0,
|
|
23
|
+
blockHotkeys: !0,
|
|
24
|
+
blockWheel: "outside",
|
|
25
|
+
blockTouchMove: "outside",
|
|
26
|
+
autoFocus: {
|
|
27
|
+
selector: '[data-floe-overlay-close="true"]'
|
|
28
|
+
},
|
|
29
|
+
restoreFocus: !0
|
|
30
|
+
}), t(f, {
|
|
31
|
+
get when() {
|
|
32
|
+
return e.open;
|
|
33
|
+
},
|
|
34
|
+
get children() {
|
|
35
|
+
return t(c.section, {
|
|
36
|
+
ref(o) {
|
|
37
|
+
var r = a;
|
|
38
|
+
typeof r == "function" ? r(o) : a = o;
|
|
39
|
+
},
|
|
40
|
+
class: "workbench-overlay",
|
|
41
|
+
role: "dialog",
|
|
42
|
+
"aria-modal": !0,
|
|
43
|
+
"aria-label": "Workbench overlay",
|
|
44
|
+
tabIndex: -1,
|
|
45
|
+
initial: {
|
|
46
|
+
opacity: 0
|
|
47
|
+
},
|
|
48
|
+
animate: {
|
|
49
|
+
opacity: 1
|
|
50
|
+
},
|
|
51
|
+
get transition() {
|
|
52
|
+
return {
|
|
53
|
+
duration: i.fast
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
get children() {
|
|
57
|
+
return t(c.div, {
|
|
58
|
+
class: "workbench-overlay__frame",
|
|
59
|
+
"data-floe-workbench-boundary": "true",
|
|
60
|
+
initial: {
|
|
61
|
+
opacity: 0,
|
|
62
|
+
y: 18,
|
|
63
|
+
scale: 0.986
|
|
64
|
+
},
|
|
65
|
+
animate: {
|
|
66
|
+
opacity: 1,
|
|
67
|
+
y: 0,
|
|
68
|
+
scale: 1
|
|
69
|
+
},
|
|
70
|
+
get transition() {
|
|
71
|
+
return {
|
|
72
|
+
duration: i.normal,
|
|
73
|
+
easing: y.easeOut
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
get children() {
|
|
77
|
+
return [(() => {
|
|
78
|
+
var o = m(), r = o.firstChild, d = r.nextSibling, n = d.firstChild;
|
|
79
|
+
return n.$$click = () => e.onClose(), l(n, t(v, {
|
|
80
|
+
class: "w-4 h-4"
|
|
81
|
+
})), o;
|
|
82
|
+
})(), (() => {
|
|
83
|
+
var o = _();
|
|
84
|
+
return l(o, t(k, {
|
|
85
|
+
class: "workbench-surface--in-overlay",
|
|
86
|
+
get state() {
|
|
87
|
+
return e.state;
|
|
88
|
+
},
|
|
89
|
+
get setState() {
|
|
90
|
+
return e.setState;
|
|
91
|
+
},
|
|
92
|
+
get lockShortcut() {
|
|
93
|
+
return e.lockShortcut;
|
|
94
|
+
}
|
|
95
|
+
})), o;
|
|
96
|
+
})()];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
h(["click"]);
|
|
105
|
+
export {
|
|
106
|
+
O as WorkbenchOverlay
|
|
107
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { WorkbenchState, WorkbenchWidgetDefinition, WorkbenchWidgetItem, WorkbenchWidgetType } from './types';
|
|
2
|
+
export interface WorkbenchSurfaceApi {
|
|
3
|
+
ensureWidget: (type: WorkbenchWidgetType, options?: {
|
|
4
|
+
centerViewport?: boolean;
|
|
5
|
+
worldX?: number;
|
|
6
|
+
worldY?: number;
|
|
7
|
+
}) => WorkbenchWidgetItem | null;
|
|
8
|
+
focusWidget: (widget: WorkbenchWidgetItem, options?: {
|
|
9
|
+
centerViewport?: boolean;
|
|
10
|
+
}) => WorkbenchWidgetItem;
|
|
11
|
+
findWidgetByType: (type: WorkbenchWidgetType) => WorkbenchWidgetItem | null;
|
|
12
|
+
}
|
|
13
|
+
export interface WorkbenchSurfaceProps {
|
|
14
|
+
state: () => WorkbenchState;
|
|
15
|
+
setState: (updater: (prev: WorkbenchState) => WorkbenchState) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Keyboard shortcut key for toggling lock mode. Matches `KeyboardEvent.key`.
|
|
18
|
+
* Defaults to "F1". Pass `null` to disable the shortcut entirely.
|
|
19
|
+
*/
|
|
20
|
+
lockShortcut?: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* If true, owns global keyboard handlers (arrows, lock, delete). Set to
|
|
23
|
+
* false when the surface is embedded in a parent that drives those keys
|
|
24
|
+
* itself. Defaults to true.
|
|
25
|
+
*/
|
|
26
|
+
enableKeyboard?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Optional class added to the surface root for layout integration.
|
|
29
|
+
*/
|
|
30
|
+
class?: string;
|
|
31
|
+
widgetDefinitions?: readonly WorkbenchWidgetDefinition[];
|
|
32
|
+
onApiReady?: (api: WorkbenchSurfaceApi | null) => void;
|
|
33
|
+
}
|
|
34
|
+
export declare function WorkbenchSurface(props: WorkbenchSurfaceProps): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { insert as c, createComponent as a, Portal as k, addEventListener as s, effect as p, className as b, template as m, delegateEvents as C } from "solid-js/web";
|
|
2
|
+
import { createEffect as d, onCleanup as g, Show as W } from "solid-js";
|
|
3
|
+
import { isTypingElement as A } from "../../utils/dom.js";
|
|
4
|
+
import { WorkbenchCanvas as y } from "./WorkbenchCanvas.js";
|
|
5
|
+
import { WorkbenchContextMenu as x } from "./WorkbenchContextMenu.js";
|
|
6
|
+
import { WorkbenchFilterBar as D } from "./WorkbenchFilterBar.js";
|
|
7
|
+
import { WorkbenchHud as M } from "./WorkbenchHud.js";
|
|
8
|
+
import { WorkbenchLockButton as S } from "./WorkbenchLockButton.js";
|
|
9
|
+
import { useWorkbenchModel as F } from "./useWorkbenchModel.js";
|
|
10
|
+
var L = /* @__PURE__ */ m("<div class=workbench-menu-backdrop data-floe-workbench-boundary=true>"), R = /* @__PURE__ */ m("<div><div class=workbench-surface__body data-floe-workbench-canvas-frame=true>");
|
|
11
|
+
const E = "F1";
|
|
12
|
+
function K(i) {
|
|
13
|
+
const e = F({
|
|
14
|
+
state: () => i.state(),
|
|
15
|
+
setState: (t) => i.setState(t),
|
|
16
|
+
widgetDefinitions: () => i.widgetDefinitions,
|
|
17
|
+
onClose: () => {
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
d(() => {
|
|
21
|
+
i.onApiReady?.({
|
|
22
|
+
ensureWidget: (t, r) => e.widgetActions.ensureWidget(t, r) ?? null,
|
|
23
|
+
focusWidget: (t, r) => e.navigation.focusWidget(t, r),
|
|
24
|
+
findWidgetByType: (t) => e.queries.findWidgetByType(t)
|
|
25
|
+
}), g(() => {
|
|
26
|
+
i.onApiReady?.(null);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
const u = () => i.lockShortcut === void 0 ? E : i.lockShortcut;
|
|
30
|
+
d(() => {
|
|
31
|
+
if (i.enableKeyboard === !1 || typeof document > "u") return;
|
|
32
|
+
const t = u(), r = (n) => {
|
|
33
|
+
if (n.defaultPrevented || n.isComposing) return;
|
|
34
|
+
if (t !== null && n.key === t) {
|
|
35
|
+
n.preventDefault(), e.lock.toggle();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const o = n.target;
|
|
39
|
+
if (!(o instanceof Element && A(o)))
|
|
40
|
+
switch (n.key) {
|
|
41
|
+
case "ArrowUp":
|
|
42
|
+
n.preventDefault(), e.navigation.handleArrowNavigation("up");
|
|
43
|
+
break;
|
|
44
|
+
case "ArrowDown":
|
|
45
|
+
n.preventDefault(), e.navigation.handleArrowNavigation("down");
|
|
46
|
+
break;
|
|
47
|
+
case "ArrowLeft":
|
|
48
|
+
n.preventDefault(), e.navigation.handleArrowNavigation("left");
|
|
49
|
+
break;
|
|
50
|
+
case "ArrowRight":
|
|
51
|
+
n.preventDefault(), e.navigation.handleArrowNavigation("right");
|
|
52
|
+
break;
|
|
53
|
+
case "Delete":
|
|
54
|
+
case "Backspace":
|
|
55
|
+
e.selectedWidgetId() && (n.preventDefault(), e.widgetActions.deleteSelected());
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
document.addEventListener("keydown", r, !0), g(() => document.removeEventListener("keydown", r, !0));
|
|
60
|
+
});
|
|
61
|
+
const f = (t, r) => {
|
|
62
|
+
const n = document.querySelector('[data-floe-workbench-canvas-frame="true"]');
|
|
63
|
+
if (!n) return null;
|
|
64
|
+
const o = n.getBoundingClientRect();
|
|
65
|
+
if (t < o.left || t > o.right || r < o.top || r > o.bottom)
|
|
66
|
+
return null;
|
|
67
|
+
const v = t - o.left, h = r - o.top, l = e.viewport();
|
|
68
|
+
return {
|
|
69
|
+
worldX: (v - l.x) / l.scale,
|
|
70
|
+
worldY: (h - l.y) / l.scale
|
|
71
|
+
};
|
|
72
|
+
}, w = (t, r, n) => {
|
|
73
|
+
const o = f(r, n);
|
|
74
|
+
o && e.widgetActions.addWidgetAtCursor(t, o.worldX, o.worldY);
|
|
75
|
+
};
|
|
76
|
+
return (() => {
|
|
77
|
+
var t = R(), r = t.firstChild;
|
|
78
|
+
return c(r, a(y, {
|
|
79
|
+
get widgetDefinitions() {
|
|
80
|
+
return e.widgetDefinitions();
|
|
81
|
+
},
|
|
82
|
+
get widgets() {
|
|
83
|
+
return e.widgets();
|
|
84
|
+
},
|
|
85
|
+
get viewport() {
|
|
86
|
+
return e.viewport();
|
|
87
|
+
},
|
|
88
|
+
get selectedWidgetId() {
|
|
89
|
+
return e.selectedWidgetId();
|
|
90
|
+
},
|
|
91
|
+
get optimisticFrontWidgetId() {
|
|
92
|
+
return e.optimisticFrontWidgetId();
|
|
93
|
+
},
|
|
94
|
+
get topZIndex() {
|
|
95
|
+
return e.topZIndex();
|
|
96
|
+
},
|
|
97
|
+
get locked() {
|
|
98
|
+
return e.locked();
|
|
99
|
+
},
|
|
100
|
+
get filters() {
|
|
101
|
+
return e.filters();
|
|
102
|
+
},
|
|
103
|
+
get setCanvasFrameRef() {
|
|
104
|
+
return e.setCanvasFrameRef;
|
|
105
|
+
},
|
|
106
|
+
get onViewportCommit() {
|
|
107
|
+
return e.canvas.commitViewport;
|
|
108
|
+
},
|
|
109
|
+
get onCanvasContextMenu() {
|
|
110
|
+
return e.canvas.openCanvasContextMenu;
|
|
111
|
+
},
|
|
112
|
+
get onSelectWidget() {
|
|
113
|
+
return e.canvas.selectWidget;
|
|
114
|
+
},
|
|
115
|
+
get onWidgetContextMenu() {
|
|
116
|
+
return e.canvas.openWidgetContextMenu;
|
|
117
|
+
},
|
|
118
|
+
get onStartOptimisticFront() {
|
|
119
|
+
return e.canvas.startOptimisticFront;
|
|
120
|
+
},
|
|
121
|
+
get onCommitFront() {
|
|
122
|
+
return e.canvas.commitFront;
|
|
123
|
+
},
|
|
124
|
+
get onCommitMove() {
|
|
125
|
+
return e.canvas.commitMove;
|
|
126
|
+
},
|
|
127
|
+
get onCommitResize() {
|
|
128
|
+
return e.canvas.commitResize;
|
|
129
|
+
},
|
|
130
|
+
get onRequestDelete() {
|
|
131
|
+
return e.widgetActions.deleteWidget;
|
|
132
|
+
}
|
|
133
|
+
})), c(t, a(S, {
|
|
134
|
+
get locked() {
|
|
135
|
+
return e.locked();
|
|
136
|
+
},
|
|
137
|
+
get onToggle() {
|
|
138
|
+
return e.lock.toggle;
|
|
139
|
+
},
|
|
140
|
+
get shortcutLabel() {
|
|
141
|
+
return u() ?? void 0;
|
|
142
|
+
}
|
|
143
|
+
}), null), c(t, a(D, {
|
|
144
|
+
get widgetDefinitions() {
|
|
145
|
+
return e.widgetDefinitions();
|
|
146
|
+
},
|
|
147
|
+
get widgets() {
|
|
148
|
+
return e.widgets();
|
|
149
|
+
},
|
|
150
|
+
get filters() {
|
|
151
|
+
return e.filters();
|
|
152
|
+
},
|
|
153
|
+
get onSoloFilter() {
|
|
154
|
+
return e.filter.solo;
|
|
155
|
+
},
|
|
156
|
+
get onShowAll() {
|
|
157
|
+
return e.filter.showAll;
|
|
158
|
+
},
|
|
159
|
+
onCreateAt: w
|
|
160
|
+
}), null), c(t, a(M, {
|
|
161
|
+
get scaleLabel() {
|
|
162
|
+
return e.scaleLabel();
|
|
163
|
+
},
|
|
164
|
+
get onZoomOut() {
|
|
165
|
+
return e.hud.zoomOut;
|
|
166
|
+
},
|
|
167
|
+
get onZoomIn() {
|
|
168
|
+
return e.hud.zoomIn;
|
|
169
|
+
}
|
|
170
|
+
}), null), c(t, a(W, {
|
|
171
|
+
get when() {
|
|
172
|
+
return e.contextMenu.state();
|
|
173
|
+
},
|
|
174
|
+
get children() {
|
|
175
|
+
return a(k, {
|
|
176
|
+
get children() {
|
|
177
|
+
return [(() => {
|
|
178
|
+
var n = L();
|
|
179
|
+
return s(n, "contextmenu", e.contextMenu.retarget, !0), s(n, "click", e.contextMenu.close, !0), n;
|
|
180
|
+
})(), a(x, {
|
|
181
|
+
get x() {
|
|
182
|
+
return e.contextMenu.position()?.left ?? 0;
|
|
183
|
+
},
|
|
184
|
+
get y() {
|
|
185
|
+
return e.contextMenu.position()?.top ?? 0;
|
|
186
|
+
},
|
|
187
|
+
get items() {
|
|
188
|
+
return e.contextMenu.items();
|
|
189
|
+
}
|
|
190
|
+
})];
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}), null), p(() => b(t, `workbench-surface${i.class ? ` ${i.class}` : ""}`)), t;
|
|
195
|
+
})();
|
|
196
|
+
}
|
|
197
|
+
C(["click", "contextmenu"]);
|
|
198
|
+
export {
|
|
199
|
+
K as WorkbenchSurface
|
|
200
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
import type { WorkbenchWidgetDefinition, WorkbenchWidgetItem } from './types';
|
|
3
|
+
export interface WorkbenchWidgetProps {
|
|
4
|
+
definition: WorkbenchWidgetDefinition;
|
|
5
|
+
item: WorkbenchWidgetItem;
|
|
6
|
+
selected: boolean;
|
|
7
|
+
optimisticFront: boolean;
|
|
8
|
+
topZIndex: number;
|
|
9
|
+
viewportScale: number;
|
|
10
|
+
locked: boolean;
|
|
11
|
+
filtered: boolean;
|
|
12
|
+
onSelect: (widgetId: string) => void;
|
|
13
|
+
onContextMenu: (event: MouseEvent, item: WorkbenchWidgetItem) => void;
|
|
14
|
+
onStartOptimisticFront: (widgetId: string) => void;
|
|
15
|
+
onCommitFront: (widgetId: string) => void;
|
|
16
|
+
onCommitMove: (widgetId: string, position: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
onCommitResize: (widgetId: string, size: {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}) => void;
|
|
24
|
+
onRequestDelete: (widgetId: string) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function WorkbenchWidget(props: WorkbenchWidgetProps): JSX.Element;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { insert as m, createComponent as f, memo as B, effect as G, setAttribute as N, setStyleProperty as v, template as A, delegateEvents as O } from "solid-js/web";
|
|
2
|
+
import { createSignal as R, onCleanup as T, untrack as I, createMemo as H } from "solid-js";
|
|
3
|
+
import { startHotInteraction as P } from "../../utils/hotInteraction.js";
|
|
4
|
+
import { GripVertical as q, X as V } from "../icons/index.js";
|
|
5
|
+
var Z = /* @__PURE__ */ A('<article class=workbench-widget><header class=workbench-widget__header><button type=button class=workbench-widget__drag aria-label="Drag widget"data-floe-canvas-interactive=true></button><div class=workbench-widget__title-area><span class=workbench-widget__title></span></div><button type=button class=workbench-widget__close aria-label="Remove widget"data-floe-canvas-interactive=true></button></header><div class=workbench-widget__body data-floe-canvas-interactive=true>'), j = /* @__PURE__ */ A('<div class=workbench-widget__resize aria-label="Resize widget"data-floe-canvas-interactive=true><svg class=workbench-widget__resize-glyph viewBox="0 0 12 12"aria-hidden=true><path d="M12 0 L0 12"></path><path d="M12 4 L4 12"></path><path d="M12 8 L8 12">');
|
|
6
|
+
const J = 220, K = 160;
|
|
7
|
+
function et(e) {
|
|
8
|
+
const [u, x] = R(null), [b, C] = R(null);
|
|
9
|
+
let g, w;
|
|
10
|
+
T(() => {
|
|
11
|
+
g?.abort(), g = void 0, w?.abort(), w = void 0, I(u)?.stopInteraction(), I(b)?.stopInteraction();
|
|
12
|
+
});
|
|
13
|
+
const M = () => u() !== null, _ = () => b() !== null, k = H(() => {
|
|
14
|
+
const i = u();
|
|
15
|
+
return i ? {
|
|
16
|
+
x: i.worldX,
|
|
17
|
+
y: i.worldY
|
|
18
|
+
} : {
|
|
19
|
+
x: e.item.x,
|
|
20
|
+
y: e.item.y
|
|
21
|
+
};
|
|
22
|
+
}), y = H(() => {
|
|
23
|
+
const i = b();
|
|
24
|
+
return i ? {
|
|
25
|
+
width: i.width,
|
|
26
|
+
height: i.height
|
|
27
|
+
} : {
|
|
28
|
+
width: e.item.width,
|
|
29
|
+
height: e.item.height
|
|
30
|
+
};
|
|
31
|
+
}), $ = (i) => {
|
|
32
|
+
const o = I(u);
|
|
33
|
+
if (!o) return;
|
|
34
|
+
const a = {
|
|
35
|
+
x: o.worldX,
|
|
36
|
+
y: o.worldY
|
|
37
|
+
}, r = {
|
|
38
|
+
x: o.startWorldX,
|
|
39
|
+
y: o.startWorldY
|
|
40
|
+
}, d = i && (Math.abs(a.x - r.x) > 1 || Math.abs(a.y - r.y) > 1);
|
|
41
|
+
e.onCommitFront(e.item.id), d && e.onCommitMove(e.item.id, a), o.stopInteraction(), x(null), g?.abort(), g = void 0;
|
|
42
|
+
}, F = (i) => {
|
|
43
|
+
if (i.button !== 0 || e.locked) return;
|
|
44
|
+
i.preventDefault(), i.stopPropagation(), g?.abort(), e.onStartOptimisticFront(e.item.id);
|
|
45
|
+
const o = P({
|
|
46
|
+
kind: "drag",
|
|
47
|
+
cursor: "grabbing"
|
|
48
|
+
}), a = Math.max(e.viewportScale, 1e-3);
|
|
49
|
+
x({
|
|
50
|
+
pointerId: i.pointerId,
|
|
51
|
+
startClientX: i.clientX,
|
|
52
|
+
startClientY: i.clientY,
|
|
53
|
+
startWorldX: e.item.x,
|
|
54
|
+
startWorldY: e.item.y,
|
|
55
|
+
worldX: e.item.x,
|
|
56
|
+
worldY: e.item.y,
|
|
57
|
+
moved: !1,
|
|
58
|
+
scale: a,
|
|
59
|
+
stopInteraction: o
|
|
60
|
+
});
|
|
61
|
+
const r = (t) => {
|
|
62
|
+
x((n) => {
|
|
63
|
+
if (!n || n.pointerId !== t.pointerId) return n;
|
|
64
|
+
const c = n.startWorldX + (t.clientX - n.startClientX) / n.scale, h = n.startWorldY + (t.clientY - n.startClientY) / n.scale;
|
|
65
|
+
return {
|
|
66
|
+
...n,
|
|
67
|
+
worldX: c,
|
|
68
|
+
worldY: h,
|
|
69
|
+
moved: n.moved || Math.abs(c - n.startWorldX) > 2 || Math.abs(h - n.startWorldY) > 2
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}, d = (t) => {
|
|
73
|
+
t.pointerId === i.pointerId && $(!0);
|
|
74
|
+
}, s = (t) => {
|
|
75
|
+
t.pointerId === i.pointerId && $(!1);
|
|
76
|
+
}, l = new AbortController();
|
|
77
|
+
g = l, window.addEventListener("pointermove", r, {
|
|
78
|
+
signal: l.signal
|
|
79
|
+
}), window.addEventListener("pointerup", d, {
|
|
80
|
+
once: !0,
|
|
81
|
+
signal: l.signal
|
|
82
|
+
}), window.addEventListener("pointercancel", s, {
|
|
83
|
+
once: !0,
|
|
84
|
+
signal: l.signal
|
|
85
|
+
});
|
|
86
|
+
}, X = (i) => {
|
|
87
|
+
const o = I(b);
|
|
88
|
+
if (!o) return;
|
|
89
|
+
const a = {
|
|
90
|
+
width: o.width,
|
|
91
|
+
height: o.height
|
|
92
|
+
}, r = Math.abs(o.width - o.startWidth) > 1 || Math.abs(o.height - o.startHeight) > 1;
|
|
93
|
+
i && r && e.onCommitResize(e.item.id, a), o.stopInteraction(), C(null), w?.abort(), w = void 0;
|
|
94
|
+
}, E = (i) => {
|
|
95
|
+
if (i.button !== 0 || e.locked) return;
|
|
96
|
+
i.preventDefault(), i.stopPropagation(), w?.abort(), e.onStartOptimisticFront(e.item.id);
|
|
97
|
+
const o = P({
|
|
98
|
+
kind: "drag",
|
|
99
|
+
cursor: "nwse-resize"
|
|
100
|
+
}), a = Math.max(e.viewportScale, 1e-3);
|
|
101
|
+
C({
|
|
102
|
+
pointerId: i.pointerId,
|
|
103
|
+
startClientX: i.clientX,
|
|
104
|
+
startClientY: i.clientY,
|
|
105
|
+
startWidth: e.item.width,
|
|
106
|
+
startHeight: e.item.height,
|
|
107
|
+
width: e.item.width,
|
|
108
|
+
height: e.item.height,
|
|
109
|
+
scale: a,
|
|
110
|
+
stopInteraction: o
|
|
111
|
+
});
|
|
112
|
+
const r = (t) => {
|
|
113
|
+
C((n) => {
|
|
114
|
+
if (!n || n.pointerId !== t.pointerId) return n;
|
|
115
|
+
const c = Math.max(J, n.startWidth + (t.clientX - n.startClientX) / n.scale), h = Math.max(K, n.startHeight + (t.clientY - n.startClientY) / n.scale);
|
|
116
|
+
return {
|
|
117
|
+
...n,
|
|
118
|
+
width: c,
|
|
119
|
+
height: h
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
}, d = (t) => {
|
|
123
|
+
t.pointerId === i.pointerId && X(!0);
|
|
124
|
+
}, s = (t) => {
|
|
125
|
+
t.pointerId === i.pointerId && X(!1);
|
|
126
|
+
}, l = new AbortController();
|
|
127
|
+
w = l, window.addEventListener("pointermove", r, {
|
|
128
|
+
signal: l.signal
|
|
129
|
+
}), window.addEventListener("pointerup", d, {
|
|
130
|
+
once: !0,
|
|
131
|
+
signal: l.signal
|
|
132
|
+
}), window.addEventListener("pointercancel", s, {
|
|
133
|
+
once: !0,
|
|
134
|
+
signal: l.signal
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
return (() => {
|
|
138
|
+
var i = Z(), o = i.firstChild, a = o.firstChild, r = a.nextSibling, d = r.firstChild, s = r.nextSibling, l = o.nextSibling;
|
|
139
|
+
return i.$$click = () => {
|
|
140
|
+
e.onSelect(e.item.id), e.onCommitFront(e.item.id);
|
|
141
|
+
}, i.$$contextmenu = (t) => {
|
|
142
|
+
t.preventDefault(), t.stopPropagation(), e.onContextMenu(t, e.item);
|
|
143
|
+
}, a.$$pointerdown = F, m(a, f(q, {
|
|
144
|
+
class: "w-3.5 h-3.5"
|
|
145
|
+
})), m(r, () => {
|
|
146
|
+
const t = e.definition.icon;
|
|
147
|
+
return f(t, {
|
|
148
|
+
class: "w-3.5 h-3.5"
|
|
149
|
+
});
|
|
150
|
+
}, d), m(d, () => e.item.title), s.$$click = (t) => {
|
|
151
|
+
t.stopPropagation(), t.preventDefault(), e.onRequestDelete(e.item.id);
|
|
152
|
+
}, s.$$pointerdown = (t) => t.stopPropagation(), m(s, f(V, {
|
|
153
|
+
class: "w-3 h-3"
|
|
154
|
+
})), m(l, () => {
|
|
155
|
+
const t = e.definition.body;
|
|
156
|
+
return f(t, {
|
|
157
|
+
get widgetId() {
|
|
158
|
+
return e.item.id;
|
|
159
|
+
},
|
|
160
|
+
get title() {
|
|
161
|
+
return e.item.title;
|
|
162
|
+
},
|
|
163
|
+
get type() {
|
|
164
|
+
return e.item.type;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}), m(i, (() => {
|
|
168
|
+
var t = B(() => !!e.locked);
|
|
169
|
+
return () => t() ? null : (() => {
|
|
170
|
+
var n = j();
|
|
171
|
+
return n.$$pointerdown = E, n;
|
|
172
|
+
})();
|
|
173
|
+
})(), null), G((t) => {
|
|
174
|
+
var n = !!e.selected, c = !!M(), h = !!_(), z = !!e.filtered, S = e.item.id, Y = `translate(${k().x}px, ${k().y}px)`, W = `${y().width}px`, L = `${y().height}px`, D = M() || _() || e.optimisticFront ? `${e.topZIndex + 1}` : `${e.item.z_index}`;
|
|
175
|
+
return n !== t.e && i.classList.toggle("is-selected", t.e = n), c !== t.t && i.classList.toggle("is-dragging", t.t = c), h !== t.a && i.classList.toggle("is-resizing", t.a = h), z !== t.o && i.classList.toggle("is-filtered-out", t.o = z), S !== t.i && N(i, "data-floe-workbench-widget-id", t.i = S), Y !== t.n && v(i, "transform", t.n = Y), W !== t.s && v(i, "width", t.s = W), L !== t.h && v(i, "height", t.h = L), D !== t.r && v(i, "z-index", t.r = D), t;
|
|
176
|
+
}, {
|
|
177
|
+
e: void 0,
|
|
178
|
+
t: void 0,
|
|
179
|
+
a: void 0,
|
|
180
|
+
o: void 0,
|
|
181
|
+
i: void 0,
|
|
182
|
+
n: void 0,
|
|
183
|
+
s: void 0,
|
|
184
|
+
h: void 0,
|
|
185
|
+
r: void 0
|
|
186
|
+
}), i;
|
|
187
|
+
})();
|
|
188
|
+
}
|
|
189
|
+
O(["contextmenu", "click", "pointerdown"]);
|
|
190
|
+
export {
|
|
191
|
+
et as WorkbenchWidget
|
|
192
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { WorkbenchOverlay, type WorkbenchOverlayProps, } from './WorkbenchOverlay';
|
|
2
|
+
export { WorkbenchSurface, type WorkbenchSurfaceApi, type WorkbenchSurfaceProps, } from './WorkbenchSurface';
|
|
3
|
+
export { WorkbenchContextMenu, type WorkbenchContextMenuItem, type WorkbenchContextMenuProps, } from './WorkbenchContextMenu';
|
|
4
|
+
export { useWorkbenchModel, type UseWorkbenchModelOptions } from './useWorkbenchModel';
|
|
5
|
+
export { WIDGET_REGISTRY, createWorkbenchFilterState, getWidgetEntry, isValidWorkbenchWidgetType, resolveWorkbenchWidgetDefinitions, type WidgetRegistryEntry, } from './widgets/widgetRegistry';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export { sanitizeWorkbenchState, createDefaultWorkbenchState, createWorkbenchId, } from './workbenchHelpers';
|