@floegence/floe-webapp-core 0.94.0 → 0.95.0

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.
@@ -1,66 +1,71 @@
1
- import { createComponent as l, Portal as x, insert as c, effect as v, className as h, setStyleProperty as f, template as i, delegateEvents as g } from "solid-js/web";
2
- import { Show as d, For as p } from "solid-js";
3
- import { cn as $ } from "../../utils/cn.js";
4
- import { Plus as w } from "../icons/index.js";
5
- var k = /* @__PURE__ */ i('<div class="fixed inset-0 z-[9998]">'), b = /* @__PURE__ */ i('<div role=menu><div class="px-2 py-1 text-caption font-semibold uppercase tracking-wider text-[var(--floe-ink-quiet)] flex items-center gap-1.5">Add widget here'), y = /* @__PURE__ */ i('<div class="px-3 py-3 text-xs text-[var(--floe-ink-soft)] text-center">No widgets registered'), _ = /* @__PURE__ */ i('<button type=button role=menuitem class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-xs hover:bg-[var(--floe-state-hover)] transition-colors text-left cursor-pointer"><span class="text-xs text-foreground">'), C = /* @__PURE__ */ i('<div class="w-4 h-4 flex-shrink-0">');
6
- function N(r) {
7
- return l(d, {
1
+ import { createComponent as n, Portal as x, insert as a, effect as v, className as h, setStyleProperty as d, template as s, delegateEvents as g } from "solid-js/web";
2
+ import { ContextMenuActionItems as p } from "../ui/ContextMenuActions.js";
3
+ import { Show as f, For as $ } from "solid-js";
4
+ import { cn as w } from "../../utils/cn.js";
5
+ import { Plus as k } from "../icons/index.js";
6
+ var b = /* @__PURE__ */ s('<div class="fixed inset-0 z-[9998]">'), y = /* @__PURE__ */ s('<div role=menu><div class="px-2 py-1 text-caption font-semibold uppercase tracking-wider text-[var(--floe-ink-quiet)] flex items-center gap-1.5">Add widget here'), C = /* @__PURE__ */ s('<div class="px-3 py-3 text-xs text-[var(--floe-ink-soft)] text-center">No widgets registered'), _ = /* @__PURE__ */ s('<button type=button role=menuitem class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-xs hover:bg-[var(--floe-state-hover)] transition-colors text-left cursor-pointer"><span class="text-xs text-foreground">'), D = /* @__PURE__ */ s('<div class="w-4 h-4 flex-shrink-0">');
7
+ function M(r) {
8
+ return n(f, {
8
9
  get when() {
9
10
  return r.open;
10
11
  },
11
12
  get children() {
12
- return l(x, {
13
+ return n(x, {
13
14
  get children() {
14
15
  return [(() => {
15
- var t = k();
16
- return t.$$contextmenu = (a) => {
17
- a.preventDefault(), r.onDismiss();
18
- }, t.$$click = () => r.onDismiss(), t;
16
+ var e = b();
17
+ return e.$$contextmenu = (l) => {
18
+ l.preventDefault(), r.onDismiss();
19
+ }, e.$$click = () => r.onDismiss(), e;
19
20
  })(), (() => {
20
- var t = b(), a = t.firstChild, u = a.firstChild;
21
- return c(a, l(w, {
21
+ var e = y(), l = e.firstChild, u = l.firstChild;
22
+ return a(e, n(p, {
23
+ get onClose() {
24
+ return r.onDismiss;
25
+ }
26
+ }), l), a(l, n(k, {
22
27
  class: "w-2.5 h-2.5"
23
- }), u), c(t, l(d, {
28
+ }), u), a(e, n(f, {
24
29
  get when() {
25
30
  return r.items.length > 0;
26
31
  },
27
32
  get fallback() {
28
- return y();
33
+ return C();
29
34
  },
30
35
  get children() {
31
- return l(p, {
36
+ return n($, {
32
37
  get each() {
33
38
  return r.items;
34
39
  },
35
- children: (e) => (() => {
36
- var n = _(), o = n.firstChild;
37
- return n.$$click = () => {
38
- r.onSelect(e.type);
39
- }, c(n, l(d, {
40
+ children: (t) => (() => {
41
+ var o = _(), i = o.firstChild;
42
+ return o.$$click = () => {
43
+ r.onSelect(t.type);
44
+ }, a(o, n(f, {
40
45
  get when() {
41
- return e.icon;
46
+ return t.icon;
42
47
  },
43
48
  get fallback() {
44
- return C();
49
+ return D();
45
50
  },
46
- children: (s) => {
47
- const m = s();
48
- return l(m, {
51
+ children: (c) => {
52
+ const m = c();
53
+ return n(m, {
49
54
  class: "w-4 h-4 text-[var(--floe-ink-soft)] flex-shrink-0"
50
55
  });
51
56
  }
52
- }), o), c(o, () => e.name), n;
57
+ }), i), a(i, () => t.name), o;
53
58
  })()
54
59
  });
55
60
  }
56
- }), null), v((e) => {
57
- var n = $("fixed z-[9999] min-w-[180px] max-h-[320px] overflow-y-auto", "bg-popover border border-[var(--floe-line)] rounded-panel shadow-[var(--floe-elevation-float-strong)]", "animate-in fade-in slide-in-from-top-1 duration-[var(--floe-duration-fast)]", "p-1"), o = `${r.y}px`, s = `${r.x}px`;
58
- return n !== e.e && h(t, e.e = n), o !== e.t && f(t, "top", e.t = o), s !== e.a && f(t, "left", e.a = s), e;
61
+ }), null), v((t) => {
62
+ var o = w("fixed z-[9999] min-w-[180px] max-h-[320px] overflow-y-auto", "bg-popover border border-[var(--floe-line)] rounded-panel shadow-[var(--floe-elevation-float-strong)]", "animate-in fade-in slide-in-from-top-1 duration-[var(--floe-duration-fast)]", "p-1"), i = `${r.y}px`, c = `${r.x}px`;
63
+ return o !== t.e && h(e, t.e = o), i !== t.t && d(e, "top", t.t = i), c !== t.a && d(e, "left", t.a = c), t;
59
64
  }, {
60
65
  e: void 0,
61
66
  t: void 0,
62
67
  a: void 0
63
- }), t;
68
+ }), e;
64
69
  })()];
65
70
  }
66
71
  });
@@ -69,5 +74,5 @@ function N(r) {
69
74
  }
70
75
  g(["click", "contextmenu"]);
71
76
  export {
72
- N as DeckContextMenu
77
+ M as DeckContextMenu
73
78
  };
@@ -1,13 +1,14 @@
1
- import { effect as F, className as L, style as O, template as p, use as A } from "solid-js/web";
2
- import { onMount as D, onCleanup as V, createEffect as g } from "solid-js";
3
- import { useTheme as b } from "../../context/ThemeContext.js";
4
- import { useResizeObserver as q } from "../../hooks/useResizeObserver.js";
5
- import { resolveCodeEditorLanguageSpec as w } from "./languages.js";
6
- import { applyFloeMonacoTheme as U } from "./monacoTheme.js";
7
- import { ensureMonacoEnvironment as N } from "./monacoEnvironment.js";
8
- import { loadMonacoEditorApi as P } from "./monacoStandaloneRuntime.js";
9
- var _ = /* @__PURE__ */ p("<div>");
10
- const I = {
1
+ import { effect as V, className as q, style as U, template as k, use as B } from "solid-js/web";
2
+ import { useContextMenuActions as N } from "../ui/ContextMenuActions.js";
3
+ import { onMount as P, onCleanup as _, createEffect as M } from "solid-js";
4
+ import { useTheme as $ } from "../../context/ThemeContext.js";
5
+ import { useResizeObserver as K } from "../../hooks/useResizeObserver.js";
6
+ import { resolveCodeEditorLanguageSpec as G } from "./languages.js";
7
+ import { applyFloeMonacoTheme as H } from "./monacoTheme.js";
8
+ import { ensureMonacoEnvironment as X } from "./monacoEnvironment.js";
9
+ import { loadMonacoEditorApi as Y } from "./monacoStandaloneRuntime.js";
10
+ var j = /* @__PURE__ */ k("<div>");
11
+ const A = {
11
12
  readOnly: !0,
12
13
  automaticLayout: !1,
13
14
  minimap: {
@@ -19,99 +20,129 @@ const I = {
19
20
  tabSize: 2,
20
21
  fontFamily: "var(--font-mono)"
21
22
  };
22
- let $ = 0;
23
- function B(t, c, r) {
24
- return t.Uri.parse(`inmemory://model/${c}/${encodeURIComponent(r)}`);
23
+ let J = 0;
24
+ function Q(t, f, c) {
25
+ return t.Uri.parse(`inmemory://model/${f}/${encodeURIComponent(c)}`);
25
26
  }
26
- function H(t, c) {
27
- if (!t || !c) return "";
28
- const r = t.getSelection();
29
- return !r || r.isEmpty() ? "" : c.getValueInRange(r);
27
+ function R(t, f) {
28
+ if (!t || !f) return "";
29
+ const c = t.getSelection();
30
+ return !c || c.isEmpty() ? "" : f.getValueInRange(c);
30
31
  }
31
- function Y(t) {
32
- const c = b();
33
- let r;
34
- const x = ++$;
35
- let l, n, o, u, y = null, h = 0;
36
- const R = q(() => r), S = () => {
37
- const e = c.resolvedTheme(), i = c.shellPreset();
38
- l && U(l.editor, e, i);
39
- }, m = () => !n || !o ? null : {
40
- editor: n,
41
- model: o,
42
- getValue: () => n.getValue(),
43
- getSelectedText: () => H(n, o),
44
- focus: () => n.focus()
45
- }, C = () => {
46
- const e = m();
32
+ function se(t) {
33
+ const f = $(), c = N();
34
+ let m;
35
+ const O = ++J;
36
+ let s, o, i, h, p = null, E = 0;
37
+ const F = K(() => m), S = () => {
38
+ const e = f.resolvedTheme(), a = f.shellPreset();
39
+ s && H(s.editor, e, a);
40
+ }, y = () => !o || !i ? null : {
41
+ editor: o,
42
+ model: i,
43
+ getValue: () => o.getValue(),
44
+ getSelectedText: () => R(o, i),
45
+ focus: () => o.focus()
46
+ }, L = () => {
47
+ const e = y();
47
48
  if (!e) return;
48
- const i = e.model.uri.toString();
49
- i !== y && (y = i, t.onReady?.(e));
50
- }, M = () => {
51
- const e = m();
49
+ const a = e.model.uri.toString();
50
+ a !== p && (p = a, t.onReady?.(e));
51
+ }, b = () => {
52
+ const e = y();
52
53
  e && t.onSelectionChange?.(e.getSelectedText(), e);
53
- }, T = async () => {
54
- if (!n || !l) return;
55
- const e = ++h, i = w(t.language);
56
- let a = i.id;
54
+ }, I = async () => {
55
+ if (!o || !s) return;
56
+ const e = ++E, a = G(t.language);
57
+ let l = a.id;
57
58
  try {
58
- await i.load?.();
59
+ await a.load?.();
59
60
  } catch {
60
- if (e !== h) return;
61
- a = "plaintext";
61
+ if (e !== E) return;
62
+ l = "plaintext";
62
63
  }
63
- if (!n || e !== h) return;
64
- const d = B(l, x, t.path);
65
- if (o && o.uri.toString() === d.toString()) {
66
- o.getLanguageId() !== a && l.editor.setModelLanguage(o, a), o.getValue() !== t.value && o.setValue(t.value), C(), M();
64
+ if (!o || e !== E) return;
65
+ const u = Q(s, O, t.path);
66
+ if (i && i.uri.toString() === u.toString()) {
67
+ i.getLanguageId() !== l && s.editor.setModelLanguage(i, l), i.getValue() !== t.value && i.setValue(t.value), L(), b();
67
68
  return;
68
69
  }
69
- const s = l.editor.createModel(t.value, a, d);
70
- o?.dispose(), o = s, n.setModel(o), C(), M();
70
+ const g = s.editor.createModel(t.value, l, u);
71
+ i?.dispose(), i = g, o.setModel(i), L(), b();
71
72
  };
72
- return D(() => {
73
- let e = !1, i, a;
73
+ return P(() => {
74
+ let e = !1, a, l, u, g = [], x = [];
74
75
  (async () => {
75
- if (!r || (N(), l = await P(t.runtimeOptions), e || !r) || (n = l.editor.create(r, {
76
+ if (!m || (X(), s = await Y(t.runtimeOptions), e || !m)) return;
77
+ o = s.editor.create(m, {
76
78
  model: null,
77
- ...I,
79
+ ...A,
78
80
  ...t.options ?? {}
79
- }), S(), await T(), e || !n)) return;
80
- const s = t.onContentChange, E = t.onChange, z = t.onSelectionChange;
81
- i = n.onDidChangeModelContent((f) => {
82
- const v = m();
83
- v && (s?.(f, v), E && E(v.getValue()));
84
- }), a = n.onDidChangeCursorSelection(() => {
85
- const f = m();
86
- f && z?.(f.getSelectedText(), f);
87
81
  });
88
- })().catch((s) => {
89
- console.error("Failed to initialize Monaco editor runtime", s);
90
- }), V(() => {
91
- e = !0, i?.dispose(), a?.dispose(), u && cancelAnimationFrame(u), n?.dispose(), o?.dispose(), l = void 0, n = void 0, o = void 0;
82
+ const r = m, T = r.getBoundingClientRect();
83
+ g = (c?.resolve({
84
+ target: r,
85
+ x: T.left,
86
+ y: T.top,
87
+ selection: ""
88
+ }) ?? []).map((n) => o.addAction({
89
+ id: n.id,
90
+ label: n.label,
91
+ contextMenuGroupId: "navigation",
92
+ contextMenuOrder: 0,
93
+ run: () => {
94
+ const d = x.find((C) => C.id === n.id);
95
+ d && !d.disabled && d.onSelect();
96
+ }
97
+ }));
98
+ const v = (n) => {
99
+ if (n instanceof KeyboardEvent && n.key !== "ContextMenu" && !(n.shiftKey && n.key === "F10") || n instanceof MouseEvent && n.type === "pointerdown" && n.button !== 2) return;
100
+ const d = c?.claim(), C = r.getBoundingClientRect();
101
+ x = d?.actions ?? c?.resolve({
102
+ target: r,
103
+ x: n instanceof MouseEvent ? n.clientX : C.left + 8,
104
+ y: n instanceof MouseEvent ? n.clientY : C.top + 24,
105
+ selection: R(o, i)
106
+ }) ?? [];
107
+ };
108
+ if (r.addEventListener("pointerdown", v, !0), r.addEventListener("contextmenu", v, !0), r.addEventListener("keydown", v, !0), u = () => {
109
+ x = [], r.removeEventListener("pointerdown", v, !0), r.removeEventListener("contextmenu", v, !0), r.removeEventListener("keydown", v, !0);
110
+ }, S(), await I(), e || !o) return;
111
+ const z = t.onContentChange, w = t.onChange, D = t.onSelectionChange;
112
+ a = o.onDidChangeModelContent((n) => {
113
+ const d = y();
114
+ d && (z?.(n, d), w && w(d.getValue()));
115
+ }), l = o.onDidChangeCursorSelection(() => {
116
+ const n = y();
117
+ n && D?.(n.getSelectedText(), n);
118
+ });
119
+ })().catch((r) => {
120
+ console.error("Failed to initialize Monaco editor runtime", r);
121
+ }), _(() => {
122
+ e = !0, a?.dispose(), l?.dispose(), u?.(), g.forEach((r) => r.dispose()), h && cancelAnimationFrame(h), o?.dispose(), i?.dispose(), s = void 0, o = void 0, i = void 0;
92
123
  });
93
- }), g(() => {
124
+ }), M(() => {
94
125
  S();
95
- }), g(() => {
96
- n && n.updateOptions({
97
- ...I,
126
+ }), M(() => {
127
+ o && o.updateOptions({
128
+ ...A,
98
129
  ...t.options ?? {}
99
130
  });
100
- }), g(() => {
101
- t.path, t.language, t.value, T();
102
- }), g(() => {
103
- const e = R();
104
- !e || !n || (u && cancelAnimationFrame(u), u = requestAnimationFrame(() => {
105
- n?.layout({
131
+ }), M(() => {
132
+ t.path, t.language, t.value, I();
133
+ }), M(() => {
134
+ const e = F();
135
+ !e || !o || (h && cancelAnimationFrame(h), h = requestAnimationFrame(() => {
136
+ o?.layout({
106
137
  width: e.width,
107
138
  height: e.height
108
139
  });
109
140
  }));
110
141
  }), (() => {
111
- var e = _(), i = r;
112
- return typeof i == "function" ? A(i, e) : r = e, F((a) => {
113
- var d = t.class, s = t.style;
114
- return d !== a.e && L(e, a.e = d), a.t = O(e, s, a.t), a;
142
+ var e = j(), a = m;
143
+ return typeof a == "function" ? B(a, e) : m = e, V((l) => {
144
+ var u = t.class, g = t.style;
145
+ return u !== l.e && q(e, l.e = u), l.t = U(e, g, l.t), l;
115
146
  }, {
116
147
  e: void 0,
117
148
  t: void 0
@@ -119,5 +150,5 @@ function Y(t) {
119
150
  })();
120
151
  }
121
152
  export {
122
- Y as CodeEditor
153
+ se as CodeEditor
123
154
  };