@floegence/floe-webapp-core 0.36.7 → 0.36.8
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/editor/CodeEditor.d.ts +2 -0
- package/dist/components/editor/CodeEditor.js +24 -24
- package/dist/components/editor/index.d.ts +1 -0
- package/dist/components/editor/monacoStandaloneRuntime.d.ts +15 -3
- package/dist/components/editor/monacoStandaloneRuntime.js +45 -17
- package/dist/components/ui/InfiniteCanvas.d.ts +2 -0
- package/dist/components/ui/InfiniteCanvas.js +85 -84
- package/dist/components/ui/index.d.ts +1 -1
- package/dist/components/ui/localInteractionSurface.d.ts +19 -0
- package/dist/components/ui/localInteractionSurface.js +38 -23
- package/dist/components/workbench/WorkbenchCanvas.d.ts +4 -0
- package/dist/components/workbench/WorkbenchCanvas.js +176 -11
- package/dist/components/workbench/WorkbenchSurface.js +9 -6
- package/dist/components/workbench/WorkbenchWidget.d.ts +4 -1
- package/dist/components/workbench/WorkbenchWidget.js +153 -120
- package/dist/components/workbench/index.d.ts +1 -1
- package/dist/components/workbench/types.d.ts +19 -0
- package/dist/components/workbench/useWorkbenchModel.d.ts +4 -0
- package/dist/components/workbench/useWorkbenchModel.js +33 -32
- package/dist/components/workbench/workbenchHelpers.d.ts +14 -1
- package/dist/components/workbench/workbenchHelpers.js +117 -90
- package/dist/editor.js +5 -2
- package/dist/full.js +519 -516
- package/dist/styles.css +1 -1
- package/dist/ui.js +97 -94
- package/dist/workbench.css +16 -0
- package/dist/workbench.js +17 -14
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { type JSX } from 'solid-js';
|
|
2
2
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
|
|
3
3
|
import 'monaco-editor/min/vs/editor/editor.main.css';
|
|
4
|
+
import { type CodeEditorRuntimeOptions } from './monacoStandaloneRuntime';
|
|
4
5
|
export interface CodeEditorProps {
|
|
5
6
|
path: string;
|
|
6
7
|
language?: string;
|
|
7
8
|
value: string;
|
|
8
9
|
options?: monaco.editor.IStandaloneEditorConstructionOptions;
|
|
10
|
+
runtimeOptions?: CodeEditorRuntimeOptions;
|
|
9
11
|
class?: string;
|
|
10
12
|
style?: JSX.CSSProperties;
|
|
11
13
|
onReady?: (api: CodeEditorApi) => void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { use as L, effect as
|
|
2
|
-
import { onMount as b, onCleanup as
|
|
3
|
-
import { useTheme as
|
|
4
|
-
import { useResizeObserver as
|
|
1
|
+
import { use as L, effect as O, className as D, style as F, template as V } from "solid-js/web";
|
|
2
|
+
import { onMount as b, onCleanup as q, createEffect as g } from "solid-js";
|
|
3
|
+
import { useTheme as w } from "../../context/ThemeContext.js";
|
|
4
|
+
import { useResizeObserver as A } from "../../hooks/useResizeObserver.js";
|
|
5
5
|
import * as f from "monaco-editor/esm/vs/editor/editor.api.js";
|
|
6
6
|
import "monaco-editor/min/vs/editor/editor.main.css";
|
|
7
|
-
import { resolveCodeEditorLanguageSpec as
|
|
8
|
-
import { ensureMonacoEnvironment as
|
|
7
|
+
import { resolveCodeEditorLanguageSpec as U } from "./languages.js";
|
|
8
|
+
import { ensureMonacoEnvironment as p } from "./monacoEnvironment.js";
|
|
9
9
|
import { ensureMonacoStandaloneRuntime as N } from "./monacoStandaloneRuntime.js";
|
|
10
10
|
var _ = /* @__PURE__ */ V("<div>");
|
|
11
11
|
const E = {
|
|
@@ -30,11 +30,11 @@ function B(t, c) {
|
|
|
30
30
|
return !r || r.isEmpty() ? "" : c.getValueInRange(r);
|
|
31
31
|
}
|
|
32
32
|
function X(t) {
|
|
33
|
-
const c =
|
|
33
|
+
const c = w();
|
|
34
34
|
let r;
|
|
35
35
|
const R = ++$;
|
|
36
|
-
let n, o,
|
|
37
|
-
const x =
|
|
36
|
+
let n, o, d, S = null, v = 0;
|
|
37
|
+
const x = A(() => r), y = () => {
|
|
38
38
|
f.editor.setTheme(c.resolvedTheme() === "dark" ? "vs-dark" : "vs");
|
|
39
39
|
}, m = () => !n || !o ? null : {
|
|
40
40
|
editor: n,
|
|
@@ -52,7 +52,7 @@ function X(t) {
|
|
|
52
52
|
e && t.onSelectionChange?.(e.getSelectedText(), e);
|
|
53
53
|
}, I = async () => {
|
|
54
54
|
if (!n) return;
|
|
55
|
-
const e = ++v, a =
|
|
55
|
+
const e = ++v, a = U(t.language);
|
|
56
56
|
let i = a.id;
|
|
57
57
|
try {
|
|
58
58
|
await a.load?.();
|
|
@@ -61,34 +61,34 @@ function X(t) {
|
|
|
61
61
|
i = "plaintext";
|
|
62
62
|
}
|
|
63
63
|
if (!n || e !== v) return;
|
|
64
|
-
const
|
|
65
|
-
if (o && o.uri.toString() ===
|
|
64
|
+
const u = k(R, t.path);
|
|
65
|
+
if (o && o.uri.toString() === u.toString()) {
|
|
66
66
|
o.getLanguageId() !== i && f.editor.setModelLanguage(o, i), o.getValue() !== t.value && o.setValue(t.value), C(), M();
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
const l = f.editor.createModel(t.value, i,
|
|
69
|
+
const l = f.editor.createModel(t.value, i, u);
|
|
70
70
|
o?.dispose(), o = l, n.setModel(o), C(), M();
|
|
71
71
|
};
|
|
72
72
|
return b(() => {
|
|
73
73
|
let e = !1, a, i;
|
|
74
74
|
(async () => {
|
|
75
|
-
if (!r || (
|
|
75
|
+
if (!r || (p(), await N(t.runtimeOptions), e || !r) || (n = f.editor.create(r, {
|
|
76
76
|
model: null,
|
|
77
77
|
...E,
|
|
78
78
|
...t.options ?? {}
|
|
79
79
|
}), y(), await I(), e || !n)) return;
|
|
80
80
|
const l = t.onContentChange, T = t.onChange, z = t.onSelectionChange;
|
|
81
|
-
a = n.onDidChangeModelContent((
|
|
81
|
+
a = n.onDidChangeModelContent((s) => {
|
|
82
82
|
const h = m();
|
|
83
|
-
h && (l?.(
|
|
83
|
+
h && (l?.(s, h), T && T(h.getValue()));
|
|
84
84
|
}), i = n.onDidChangeCursorSelection(() => {
|
|
85
|
-
const
|
|
86
|
-
|
|
85
|
+
const s = m();
|
|
86
|
+
s && z?.(s.getSelectedText(), s);
|
|
87
87
|
});
|
|
88
88
|
})().catch((l) => {
|
|
89
89
|
console.error("Failed to initialize Monaco editor runtime", l);
|
|
90
|
-
}),
|
|
91
|
-
e = !0, a?.dispose(), i?.dispose(),
|
|
90
|
+
}), q(() => {
|
|
91
|
+
e = !0, a?.dispose(), i?.dispose(), d && cancelAnimationFrame(d), n?.dispose(), o?.dispose(), n = void 0, o = void 0;
|
|
92
92
|
});
|
|
93
93
|
}), g(() => {
|
|
94
94
|
y();
|
|
@@ -101,7 +101,7 @@ function X(t) {
|
|
|
101
101
|
t.path, t.language, t.value, I();
|
|
102
102
|
}), g(() => {
|
|
103
103
|
const e = x();
|
|
104
|
-
!e || !n || (
|
|
104
|
+
!e || !n || (d && cancelAnimationFrame(d), d = requestAnimationFrame(() => {
|
|
105
105
|
n?.layout({
|
|
106
106
|
width: e.width,
|
|
107
107
|
height: e.height
|
|
@@ -109,9 +109,9 @@ function X(t) {
|
|
|
109
109
|
}));
|
|
110
110
|
}), (() => {
|
|
111
111
|
var e = _(), a = r;
|
|
112
|
-
return typeof a == "function" ? L(a, e) : r = e,
|
|
113
|
-
var
|
|
114
|
-
return
|
|
112
|
+
return typeof a == "function" ? L(a, e) : r = e, O((i) => {
|
|
113
|
+
var u = t.class, l = t.style;
|
|
114
|
+
return u !== i.e && D(e, i.e = u), i.t = F(e, l, i.t), i;
|
|
115
115
|
}, {
|
|
116
116
|
e: void 0,
|
|
117
117
|
t: void 0
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { CodeEditor, type CodeEditorProps, type CodeEditorApi } from './CodeEditor';
|
|
2
2
|
export { resolveCodeEditorLanguageSpec, isCodeEditorLanguageSupported, type CodeEditorLanguageSpec } from './languages';
|
|
3
|
+
export { DEFAULT_MONACO_STANDALONE_FEATURES, normalizeMonacoRuntimeFeatureSet, type CodeEditorRuntimeOptions, type MonacoRuntimeFeatureSet, } from './monacoStandaloneRuntime';
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export interface MonacoRuntimeFeatureSet {
|
|
2
|
+
suggestMemory: boolean;
|
|
3
|
+
codeLensCache: boolean;
|
|
4
|
+
inlayHintsCache: boolean;
|
|
5
|
+
treeViewsDnd: boolean;
|
|
6
|
+
actionWidget: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CodeEditorRuntimeOptions {
|
|
9
|
+
standaloneFeatures?: Partial<MonacoRuntimeFeatureSet>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DEFAULT_MONACO_STANDALONE_FEATURES: MonacoRuntimeFeatureSet;
|
|
12
|
+
type MonacoStandaloneRuntimeLoader = (features: MonacoRuntimeFeatureSet) => Promise<unknown>;
|
|
13
|
+
export declare function normalizeMonacoRuntimeFeatureSet(standaloneFeatures?: Partial<MonacoRuntimeFeatureSet>): MonacoRuntimeFeatureSet;
|
|
14
|
+
export declare function createMonacoStandaloneRuntime(loader: MonacoStandaloneRuntimeLoader): (options?: CodeEditorRuntimeOptions) => Promise<void>;
|
|
15
|
+
export declare const ensureMonacoStandaloneRuntime: (options?: CodeEditorRuntimeOptions) => Promise<void>;
|
|
4
16
|
export {};
|
|
@@ -1,21 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const s = {
|
|
2
|
+
suggestMemory: !0,
|
|
3
|
+
codeLensCache: !0,
|
|
4
|
+
inlayHintsCache: !0,
|
|
5
|
+
treeViewsDnd: !0,
|
|
6
|
+
actionWidget: !0
|
|
7
|
+
};
|
|
8
|
+
function u(e) {
|
|
9
|
+
return {
|
|
10
|
+
...s,
|
|
11
|
+
...e ?? {}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function d(e) {
|
|
15
|
+
return [
|
|
16
|
+
`suggestMemory:${e.suggestMemory ? "1" : "0"}`,
|
|
17
|
+
`codeLensCache:${e.codeLensCache ? "1" : "0"}`,
|
|
18
|
+
`inlayHintsCache:${e.inlayHintsCache ? "1" : "0"}`,
|
|
19
|
+
`treeViewsDnd:${e.treeViewsDnd ? "1" : "0"}`,
|
|
20
|
+
`actionWidget:${e.actionWidget ? "1" : "0"}`
|
|
21
|
+
].join("|");
|
|
22
|
+
}
|
|
23
|
+
function m(e) {
|
|
24
|
+
const n = /* @__PURE__ */ new Map();
|
|
25
|
+
return (r) => {
|
|
26
|
+
const o = u(r?.standaloneFeatures), t = d(o), i = n.get(t);
|
|
27
|
+
if (i) return i;
|
|
28
|
+
const c = e(o).then(() => {
|
|
29
|
+
}).catch((a) => {
|
|
30
|
+
throw n.delete(t), a;
|
|
31
|
+
});
|
|
32
|
+
return n.set(t, c), c;
|
|
33
|
+
};
|
|
7
34
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
import("monaco-editor/esm/vs/editor/edcore.main.js")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import("monaco-editor/esm/vs/editor/common/services/treeViewsDndService.js"),
|
|
14
|
-
import("monaco-editor/esm/vs/platform/actionWidget/browser/actionWidget.js")
|
|
15
|
-
]);
|
|
35
|
+
function h(e) {
|
|
36
|
+
const n = [
|
|
37
|
+
import("monaco-editor/esm/vs/editor/edcore.main.js")
|
|
38
|
+
];
|
|
39
|
+
return e.suggestMemory && n.push(import("monaco-editor/esm/vs/editor/contrib/suggest/browser/suggestMemory.js")), e.codeLensCache && n.push(import("monaco-editor/esm/vs/editor/contrib/codelens/browser/codeLensCache.js")), e.inlayHintsCache && n.push(import("monaco-editor/esm/vs/editor/contrib/inlayHints/browser/inlayHintsContribution.js")), e.treeViewsDnd && n.push(import("monaco-editor/esm/vs/editor/common/services/treeViewsDndService.js")), e.actionWidget && n.push(import("monaco-editor/esm/vs/platform/actionWidget/browser/actionWidget.js")), Promise.all(n);
|
|
16
40
|
}
|
|
17
|
-
const
|
|
41
|
+
const g = m(
|
|
42
|
+
h
|
|
43
|
+
);
|
|
18
44
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
45
|
+
s as DEFAULT_MONACO_STANDALONE_FEATURES,
|
|
46
|
+
m as createMonacoStandaloneRuntime,
|
|
47
|
+
g as ensureMonacoStandaloneRuntime,
|
|
48
|
+
u as normalizeMonacoRuntimeFeatureSet
|
|
21
49
|
};
|
|
@@ -14,6 +14,7 @@ export interface InfiniteCanvasContextMenuEvent {
|
|
|
14
14
|
}
|
|
15
15
|
export interface InfiniteCanvasProps {
|
|
16
16
|
children: JSX.Element;
|
|
17
|
+
overlay?: (viewport: InfiniteCanvasPoint) => JSX.Element;
|
|
17
18
|
viewport: InfiniteCanvasPoint;
|
|
18
19
|
onViewportChange?: (viewport: InfiniteCanvasPoint) => void;
|
|
19
20
|
onCanvasContextMenu?: (event: InfiniteCanvasContextMenuEvent) => void;
|
|
@@ -22,6 +23,7 @@ export interface InfiniteCanvasProps {
|
|
|
22
23
|
contentClass?: string;
|
|
23
24
|
interactiveSelector?: string;
|
|
24
25
|
panSurfaceSelector?: string;
|
|
26
|
+
wheelInteractiveSelector?: string;
|
|
25
27
|
minScale?: number;
|
|
26
28
|
maxScale?: number;
|
|
27
29
|
wheelZoomSpeed?: number;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { insert as
|
|
2
|
-
import { createSignal as
|
|
1
|
+
import { insert as x, effect as G, className as T, setAttribute as J, setStyleProperty as K, template as Q, use as ee, delegateEvents as te } from "solid-js/web";
|
|
2
|
+
import { createSignal as _, untrack as L, createEffect as b, onCleanup as A } from "solid-js";
|
|
3
3
|
import { cn as D } from "../../utils/cn.js";
|
|
4
|
-
import { startHotInteraction as
|
|
5
|
-
import { resolveSurfaceInteractionTargetRole as
|
|
6
|
-
var
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
return Math.max(
|
|
4
|
+
import { startHotInteraction as y } from "../../utils/hotInteraction.js";
|
|
5
|
+
import { resolveSurfaceInteractionTargetRole as ne, resolveSurfaceWheelRouting as re, DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR as oe } from "./localInteractionSurface.js";
|
|
6
|
+
var ae = /* @__PURE__ */ Q('<div><div style="transform-origin:0 0">');
|
|
7
|
+
const ie = 1, ce = 0.45, le = 2.2, se = 14e-4, ue = '[data-floe-canvas-pan-surface="true"]', Y = 3;
|
|
8
|
+
function de(n, a, d) {
|
|
9
|
+
return Math.max(a, Math.min(d, n));
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function M(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
|
-
scale: Number.isFinite(n.scale) && n.scale > 0 ? n.scale :
|
|
15
|
+
scale: Number.isFinite(n.scale) && n.scale > 0 ? n.scale : ie
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return n.deltaMode === 1 ? n.deltaY * 16 : n.deltaMode === 2 ? n.deltaY * (
|
|
18
|
+
function fe(n, a) {
|
|
19
|
+
return n.deltaMode === 1 ? n.deltaY * 16 : n.deltaMode === 2 ? n.deltaY * (a?.clientHeight ?? window.innerHeight) : n.deltaY;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const [
|
|
23
|
-
let
|
|
24
|
-
const
|
|
25
|
-
const e =
|
|
21
|
+
function Ce(n) {
|
|
22
|
+
const [a, d] = _(L(() => M(n.viewport))), [v, w] = _(null);
|
|
23
|
+
let i, f, m = !1, l;
|
|
24
|
+
const R = () => n.interactiveSelector ?? '[data-floe-canvas-interactive="true"]', X = () => n.panSurfaceSelector ?? ue, F = () => n.wheelInteractiveSelector ?? oe, k = () => n.minScale ?? ce, V = () => n.maxScale ?? le, $ = () => n.wheelZoomSpeed ?? se, N = () => {
|
|
25
|
+
const e = v();
|
|
26
26
|
return e ? e.startedFromPanSurface ? e.moved : !0 : !1;
|
|
27
|
-
},
|
|
27
|
+
}, p = () => {
|
|
28
28
|
f !== void 0 && (window.clearTimeout(f), f = void 0);
|
|
29
|
-
},
|
|
29
|
+
}, C = () => {
|
|
30
30
|
m = !1, l !== void 0 && (window.clearTimeout(l), l = void 0);
|
|
31
|
-
},
|
|
31
|
+
}, U = () => {
|
|
32
32
|
if (typeof window > "u") {
|
|
33
33
|
m = !1;
|
|
34
34
|
return;
|
|
@@ -38,116 +38,117 @@ function ve(n) {
|
|
|
38
38
|
}, 0);
|
|
39
39
|
}, h = (e) => {
|
|
40
40
|
L(() => n.onViewportChange?.(e));
|
|
41
|
-
},
|
|
41
|
+
}, H = (e) => {
|
|
42
42
|
if (typeof window > "u") {
|
|
43
43
|
h(e);
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
p(), f = window.setTimeout(() => {
|
|
47
47
|
f = void 0, h(e);
|
|
48
48
|
}, 90);
|
|
49
|
-
},
|
|
49
|
+
}, g = (e) => ne({
|
|
50
50
|
target: e,
|
|
51
|
-
interactiveSelector:
|
|
51
|
+
interactiveSelector: R(),
|
|
52
52
|
panSurfaceSelector: X()
|
|
53
|
-
}),
|
|
54
|
-
const t =
|
|
53
|
+
}), E = (e) => {
|
|
54
|
+
const t = v();
|
|
55
55
|
if (!t || e !== void 0 && t.pointerId !== e) return;
|
|
56
56
|
t.stopInteraction?.();
|
|
57
|
-
const
|
|
58
|
-
w(null),
|
|
57
|
+
const o = a();
|
|
58
|
+
w(null), i && i.hasPointerCapture(t.pointerId) && i.releasePointerCapture(t.pointerId), t.startedFromPanSurface && t.moved && (m = !0, U()), h(o);
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}),
|
|
63
|
-
const e =
|
|
60
|
+
b(() => {
|
|
61
|
+
v() || d(M(n.viewport));
|
|
62
|
+
}), b(() => {
|
|
63
|
+
const e = i;
|
|
64
64
|
if (!e) return;
|
|
65
|
-
const t = (
|
|
66
|
-
!m ||
|
|
65
|
+
const t = (o) => {
|
|
66
|
+
!m || g(o.target) !== "pan_surface" || (C(), o.preventDefault(), o.stopPropagation());
|
|
67
67
|
};
|
|
68
|
-
e.addEventListener("click", t, !0), e.addEventListener("wheel",
|
|
68
|
+
e.addEventListener("click", t, !0), e.addEventListener("wheel", P, {
|
|
69
69
|
passive: !1
|
|
70
|
-
}),
|
|
71
|
-
e.removeEventListener("click", t, !0), e.removeEventListener("wheel",
|
|
70
|
+
}), A(() => {
|
|
71
|
+
e.removeEventListener("click", t, !0), e.removeEventListener("wheel", P);
|
|
72
72
|
});
|
|
73
|
-
}),
|
|
74
|
-
|
|
73
|
+
}), A(() => {
|
|
74
|
+
p(), E(), C();
|
|
75
75
|
});
|
|
76
|
-
const
|
|
76
|
+
const Z = (e) => {
|
|
77
77
|
if (e.button !== 0 || n.disablePanZoom) return;
|
|
78
|
-
const t =
|
|
79
|
-
t !== "local_surface" && (
|
|
78
|
+
const t = g(e.target), o = t === "pan_surface";
|
|
79
|
+
t !== "local_surface" && (p(), C(), o || (e.preventDefault(), i?.setPointerCapture(e.pointerId)), w({
|
|
80
80
|
pointerId: e.pointerId,
|
|
81
81
|
startClientX: e.clientX,
|
|
82
82
|
startClientY: e.clientY,
|
|
83
|
-
startViewport:
|
|
83
|
+
startViewport: a(),
|
|
84
84
|
moved: !1,
|
|
85
|
-
startedFromPanSurface:
|
|
86
|
-
stopInteraction:
|
|
85
|
+
startedFromPanSurface: o,
|
|
86
|
+
stopInteraction: o ? void 0 : y({
|
|
87
87
|
kind: "drag",
|
|
88
88
|
cursor: "grabbing"
|
|
89
89
|
})
|
|
90
90
|
}));
|
|
91
|
-
},
|
|
92
|
-
const t =
|
|
91
|
+
}, W = (e) => {
|
|
92
|
+
const t = v();
|
|
93
93
|
if (!t || t.pointerId !== e.pointerId) return;
|
|
94
|
-
const
|
|
95
|
-
if (!(t.moved || Math.abs(
|
|
96
|
-
t.moved || (e.preventDefault(),
|
|
94
|
+
const o = e.clientX - t.startClientX, r = e.clientY - t.startClientY;
|
|
95
|
+
if (!(t.moved || Math.abs(o) > Y || Math.abs(r) > Y)) return;
|
|
96
|
+
t.moved || (e.preventDefault(), i?.hasPointerCapture(e.pointerId) || i?.setPointerCapture(e.pointerId));
|
|
97
97
|
const s = {
|
|
98
98
|
...t.startViewport,
|
|
99
|
-
x: t.startViewport.x +
|
|
100
|
-
y: t.startViewport.y +
|
|
99
|
+
x: t.startViewport.x + o,
|
|
100
|
+
y: t.startViewport.y + r
|
|
101
101
|
};
|
|
102
102
|
t.moved || w({
|
|
103
103
|
...t,
|
|
104
104
|
moved: !0,
|
|
105
|
-
stopInteraction: t.stopInteraction ??
|
|
105
|
+
stopInteraction: t.stopInteraction ?? y({
|
|
106
106
|
kind: "drag",
|
|
107
107
|
cursor: "grabbing"
|
|
108
108
|
})
|
|
109
109
|
}), d(s);
|
|
110
|
-
}, Z = (e) => {
|
|
111
|
-
P(e.pointerId);
|
|
112
110
|
}, O = (e) => {
|
|
113
|
-
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
if (!
|
|
119
|
-
|
|
111
|
+
E(e.pointerId);
|
|
112
|
+
}, z = (e) => {
|
|
113
|
+
E(e.pointerId);
|
|
114
|
+
}, P = (e) => {
|
|
115
|
+
const t = i?.getBoundingClientRect();
|
|
116
|
+
if (!t || re({
|
|
117
|
+
target: e.target,
|
|
118
|
+
disablePanZoom: !!n.disablePanZoom,
|
|
119
|
+
wheelInteractiveSelector: F()
|
|
120
|
+
}).kind !== "canvas_zoom") return;
|
|
120
121
|
e.preventDefault();
|
|
121
|
-
const
|
|
122
|
-
if (Math.abs(u -
|
|
123
|
-
const
|
|
124
|
-
x: c -
|
|
125
|
-
y: s -
|
|
122
|
+
const r = a(), c = e.clientX - t.left, s = e.clientY - t.top, S = fe(e, i), u = de(r.scale * Math.exp(-S * $()), k(), V());
|
|
123
|
+
if (Math.abs(u - r.scale) < 1e-4) return;
|
|
124
|
+
const j = (c - r.x) / r.scale, q = (s - r.y) / r.scale, I = {
|
|
125
|
+
x: c - j * u,
|
|
126
|
+
y: s - q * u,
|
|
126
127
|
scale: u
|
|
127
128
|
};
|
|
128
|
-
d(
|
|
129
|
-
},
|
|
130
|
-
if (
|
|
131
|
-
const t =
|
|
129
|
+
d(I), H(I);
|
|
130
|
+
}, B = (e) => {
|
|
131
|
+
if (g(e.target) !== "canvas") return;
|
|
132
|
+
const t = i?.getBoundingClientRect();
|
|
132
133
|
if (!t) return;
|
|
133
134
|
e.preventDefault();
|
|
134
|
-
const
|
|
135
|
+
const o = e.clientX - t.left, r = e.clientY - t.top, c = a();
|
|
135
136
|
n.onCanvasContextMenu?.({
|
|
136
137
|
clientX: e.clientX,
|
|
137
138
|
clientY: e.clientY,
|
|
138
|
-
localX:
|
|
139
|
-
localY:
|
|
140
|
-
worldX: (
|
|
141
|
-
worldY: (
|
|
139
|
+
localX: o,
|
|
140
|
+
localY: r,
|
|
141
|
+
worldX: (o - c.x) / c.scale,
|
|
142
|
+
worldY: (r - c.y) / c.scale
|
|
142
143
|
});
|
|
143
144
|
};
|
|
144
145
|
return (() => {
|
|
145
|
-
var e =
|
|
146
|
-
e.$$contextmenu =
|
|
147
|
-
var
|
|
148
|
-
return typeof
|
|
149
|
-
var c = D("floe-infinite-canvas",
|
|
150
|
-
return c !==
|
|
146
|
+
var e = ae(), t = e.firstChild;
|
|
147
|
+
e.$$contextmenu = B, e.addEventListener("pointercancel", z), e.$$pointerup = O, e.$$pointermove = W, e.$$pointerdown = Z;
|
|
148
|
+
var o = i;
|
|
149
|
+
return typeof o == "function" ? ee(o, e) : i = e, x(t, () => n.children), x(e, () => n.overlay?.(a()), null), G((r) => {
|
|
150
|
+
var c = D("floe-infinite-canvas", N() && "is-panning", n.disablePanZoom && "is-locked", n.class), s = n.ariaLabel ?? "Infinite canvas", S = D("floe-infinite-canvas__viewport", n.contentClass), u = `translate(${a().x}px, ${a().y}px) scale(${a().scale})`;
|
|
151
|
+
return c !== r.e && T(e, r.e = c), s !== r.t && J(e, "aria-label", r.t = s), S !== r.a && T(t, r.a = S), u !== r.o && K(t, "transform", r.o = u), r;
|
|
151
152
|
}, {
|
|
152
153
|
e: void 0,
|
|
153
154
|
t: void 0,
|
|
@@ -156,7 +157,7 @@ function ve(n) {
|
|
|
156
157
|
}), e;
|
|
157
158
|
})();
|
|
158
159
|
}
|
|
159
|
-
|
|
160
|
+
te(["pointerdown", "pointermove", "pointerup", "contextmenu"]);
|
|
160
161
|
export {
|
|
161
|
-
|
|
162
|
+
Ce as InfiniteCanvas
|
|
162
163
|
};
|
|
@@ -7,7 +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, WORKBENCH_WIDGET_SHELL_ATTR, DEFAULT_WORKBENCH_WIDGET_SHELL_SELECTOR, isLocalInteractionSurfaceTarget, resolveSurfaceInteractionTargetRole, resolveWorkbenchWidgetEventOwnership, type SurfaceInteractionRoutingOptions, type SurfaceInteractionTargetRole, type WorkbenchWidgetEventOwnership, type WorkbenchWidgetEventOwnershipOptions, } from './localInteractionSurface';
|
|
10
|
+
export { CANVAS_WHEEL_INTERACTIVE_ATTR, DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR, LOCAL_INTERACTION_SURFACE_ATTR, DEFAULT_LOCAL_INTERACTION_SURFACE_SELECTOR, WORKBENCH_WIDGET_SHELL_ATTR, DEFAULT_WORKBENCH_WIDGET_SHELL_SELECTOR, isLocalInteractionSurfaceTarget, resolveSurfaceInteractionTargetRole, resolveSurfaceWheelRouting, resolveWorkbenchWidgetEventOwnership, type SurfaceInteractionRoutingOptions, type SurfaceInteractionTargetRole, type SurfaceWheelLocalReason, type SurfaceWheelRoutingDecision, type SurfaceWheelRoutingOptions, type WorkbenchWidgetEventOwnership, type WorkbenchWidgetEventOwnershipOptions, } from './localInteractionSurface';
|
|
11
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';
|
|
12
12
|
export { Tabs, TabPanel, type TabsProps, type TabPanelProps, type TabItem, type TabsFeatures, type TabsSlotClassNames, type TabsIndicatorMode, type TabsIndicatorColorToken, } from './Tabs';
|
|
13
13
|
export { DirectoryPicker, type DirectoryPickerProps } from './DirectoryPicker';
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
export declare const LOCAL_INTERACTION_SURFACE_ATTR = "data-floe-local-interaction-surface";
|
|
2
2
|
export declare const DEFAULT_LOCAL_INTERACTION_SURFACE_SELECTOR = "[data-floe-local-interaction-surface=\"true\"]";
|
|
3
|
+
export declare const CANVAS_WHEEL_INTERACTIVE_ATTR = "data-floe-canvas-wheel-interactive";
|
|
4
|
+
export declare const DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR = "[data-floe-canvas-wheel-interactive=\"true\"]";
|
|
3
5
|
export declare const WORKBENCH_WIDGET_SHELL_ATTR = "data-floe-workbench-widget-shell";
|
|
4
6
|
export declare const DEFAULT_WORKBENCH_WIDGET_SHELL_SELECTOR = "[data-floe-workbench-widget-shell=\"true\"]";
|
|
5
7
|
export type SurfaceInteractionTargetRole = 'canvas' | 'local_surface' | 'pan_surface';
|
|
8
|
+
export type SurfaceWheelLocalReason = 'typing_element' | 'local_interaction_surface' | 'wheel_interactive';
|
|
9
|
+
export type SurfaceWheelRoutingDecision = {
|
|
10
|
+
kind: 'canvas_zoom';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'local_surface';
|
|
13
|
+
reason: SurfaceWheelLocalReason;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'ignore';
|
|
16
|
+
reason: 'pan_zoom_disabled';
|
|
17
|
+
};
|
|
6
18
|
export type WorkbenchWidgetEventOwnership = 'outside_widget' | 'widget_local' | 'widget_shell';
|
|
7
19
|
export interface SurfaceInteractionRoutingOptions {
|
|
8
20
|
target: EventTarget | null;
|
|
@@ -14,6 +26,13 @@ export interface WorkbenchWidgetEventOwnershipOptions extends SurfaceInteraction
|
|
|
14
26
|
widgetRoot: Element | EventTarget | null;
|
|
15
27
|
shellSelector?: string;
|
|
16
28
|
}
|
|
29
|
+
export interface SurfaceWheelRoutingOptions {
|
|
30
|
+
target: EventTarget | null;
|
|
31
|
+
disablePanZoom: boolean;
|
|
32
|
+
localInteractionSurfaceSelector?: string;
|
|
33
|
+
wheelInteractiveSelector?: string;
|
|
34
|
+
}
|
|
17
35
|
export declare function resolveSurfaceInteractionTargetRole(options: SurfaceInteractionRoutingOptions): SurfaceInteractionTargetRole;
|
|
36
|
+
export declare function resolveSurfaceWheelRouting(options: SurfaceWheelRoutingOptions): SurfaceWheelRoutingDecision;
|
|
18
37
|
export declare function isLocalInteractionSurfaceTarget(options: SurfaceInteractionRoutingOptions): boolean;
|
|
19
38
|
export declare function resolveWorkbenchWidgetEventOwnership(options: WorkbenchWidgetEventOwnershipOptions): WorkbenchWidgetEventOwnership;
|
|
@@ -1,33 +1,48 @@
|
|
|
1
|
-
import { isTypingElement as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
import { isTypingElement as a } from "../../utils/dom.js";
|
|
2
|
+
const u = "data-floe-local-interaction-surface", i = `[${u}="true"]`, f = "data-floe-canvas-wheel-interactive", E = `[${f}="true"]`, _ = "data-floe-workbench-widget-shell", T = `[${_}="true"]`;
|
|
3
|
+
function c(e) {
|
|
4
4
|
return typeof Element < "u" && e instanceof Element ? e : typeof Node < "u" && e instanceof Node ? e.parentElement : null;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function s(e) {
|
|
7
7
|
const {
|
|
8
|
-
target:
|
|
9
|
-
interactiveSelector:
|
|
10
|
-
panSurfaceSelector:
|
|
11
|
-
localInteractionSurfaceSelector:
|
|
12
|
-
} = e,
|
|
13
|
-
return
|
|
8
|
+
target: t,
|
|
9
|
+
interactiveSelector: l,
|
|
10
|
+
panSurfaceSelector: r,
|
|
11
|
+
localInteractionSurfaceSelector: n = i
|
|
12
|
+
} = e, o = t instanceof Element ? t : null;
|
|
13
|
+
return o ? o.closest(r) !== null ? "pan_surface" : a(o) || o.closest(l) !== null || o.closest(n) !== null ? "local_surface" : "canvas" : "canvas";
|
|
14
14
|
}
|
|
15
15
|
function d(e) {
|
|
16
|
-
|
|
16
|
+
const {
|
|
17
|
+
target: t,
|
|
18
|
+
localInteractionSurfaceSelector: l = i,
|
|
19
|
+
wheelInteractiveSelector: r = E
|
|
20
|
+
} = e, n = c(t);
|
|
21
|
+
return n ? a(n) ? "typing_element" : n.closest(l) !== null ? "local_interaction_surface" : n.closest(r) !== null ? "wheel_interactive" : null : null;
|
|
22
|
+
}
|
|
23
|
+
function R(e) {
|
|
24
|
+
const t = d(e);
|
|
25
|
+
return t ? { kind: "local_surface", reason: t } : e.disablePanZoom ? { kind: "ignore", reason: "pan_zoom_disabled" } : { kind: "canvas_zoom" };
|
|
26
|
+
}
|
|
27
|
+
function A(e) {
|
|
28
|
+
return s(e) !== "canvas";
|
|
17
29
|
}
|
|
18
|
-
function
|
|
30
|
+
function L(e) {
|
|
19
31
|
const {
|
|
20
|
-
widgetRoot:
|
|
21
|
-
shellSelector:
|
|
22
|
-
} = e,
|
|
23
|
-
return !
|
|
32
|
+
widgetRoot: t,
|
|
33
|
+
shellSelector: l = T
|
|
34
|
+
} = e, r = c(t), n = c(e.target);
|
|
35
|
+
return !r || !n || !r.contains(n) ? "outside_widget" : s(e) !== "canvas" ? "widget_local" : n === r || n.closest(l) !== null ? "widget_shell" : "widget_local";
|
|
24
36
|
}
|
|
25
37
|
export {
|
|
26
|
-
|
|
27
|
-
E as
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
f as CANVAS_WHEEL_INTERACTIVE_ATTR,
|
|
39
|
+
E as DEFAULT_CANVAS_WHEEL_INTERACTIVE_SELECTOR,
|
|
40
|
+
i as DEFAULT_LOCAL_INTERACTION_SURFACE_SELECTOR,
|
|
41
|
+
T as DEFAULT_WORKBENCH_WIDGET_SHELL_SELECTOR,
|
|
42
|
+
u as LOCAL_INTERACTION_SURFACE_ATTR,
|
|
43
|
+
_ as WORKBENCH_WIDGET_SHELL_ATTR,
|
|
44
|
+
A as isLocalInteractionSurfaceTarget,
|
|
45
|
+
s as resolveSurfaceInteractionTargetRole,
|
|
46
|
+
R as resolveSurfaceWheelRouting,
|
|
47
|
+
L as resolveWorkbenchWidgetEventOwnership
|
|
33
48
|
};
|
|
@@ -4,6 +4,10 @@ export interface WorkbenchCanvasProps {
|
|
|
4
4
|
widgetDefinitions: readonly WorkbenchWidgetDefinition[];
|
|
5
5
|
widgets: readonly WorkbenchWidgetItem[];
|
|
6
6
|
viewport: WorkbenchViewport;
|
|
7
|
+
canvasFrameSize: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
7
11
|
selectedWidgetId: string | null;
|
|
8
12
|
optimisticFrontWidgetId: string | null;
|
|
9
13
|
locked: boolean;
|