@floegence/floe-webapp-core 0.26.2 → 0.26.5

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,146 +1,160 @@
1
- import { createComponent as i, Portal as M, insert as l, use as O, Dynamic as L, effect as y, className as C, setAttribute as z, template as c, delegateEvents as F } from "solid-js/web";
2
- import { createSignal as I, createEffect as w, onCleanup as S, createMemo as K, Show as g, For as D } from "solid-js";
3
- import { cn as E } from "../../utils/cn.js";
4
- import { useCommand as R } from "../../context/CommandContext.js";
5
- import { Search as j } from "../icons/index.js";
6
- import { lockBodyStyle as B } from "../../utils/bodyStyleLock.js";
7
- import { useResolvedFloeConfig as N } from "../../context/FloeConfigContext.js";
8
- var T = /* @__PURE__ */ c('<div class="fixed inset-0 z-50 bg-background/60 backdrop-blur-sm animate-in fade-in">'), U = /* @__PURE__ */ c('<div><div class="flex items-center gap-3 px-4 pt-1 border-b border-border"><input type=text><kbd class="text-xs text-muted-foreground px-1.5 py-0.5 rounded bg-muted font-mono"></kbd></div><div class="max-h-80 overflow-y-auto py-2">'), q = /* @__PURE__ */ c('<div class="px-4 py-8 text-center text-sm text-muted-foreground">'), G = /* @__PURE__ */ c('<div><div class="px-4 py-1 text-xs font-semibold text-muted-foreground uppercase tracking-wider">'), H = /* @__PURE__ */ c('<span class="w-5 h-5 flex items-center justify-center text-muted-foreground">'), J = /* @__PURE__ */ c('<span class="ml-2 text-muted-foreground text-xs">'), Q = /* @__PURE__ */ c('<kbd class="text-xs text-muted-foreground px-1.5 py-0.5 rounded bg-muted font-mono">'), V = /* @__PURE__ */ c('<button type=button><div class="flex-1 text-left"><span>');
9
- function ne() {
10
- const t = R(), $ = N();
11
- let x;
12
- const [k, f] = I(0);
13
- w(() => {
14
- t.isOpen() && x && (x.focus(), f(0));
15
- }), w(() => {
16
- t.search(), f(0);
17
- }), w(() => {
18
- if (!t.isOpen()) return;
19
- const n = (o) => {
20
- const e = t.filteredCommands();
21
- switch (o.key) {
22
- case "Escape":
23
- o.preventDefault(), t.close();
24
- break;
25
- case "ArrowDown":
26
- o.preventDefault(), f((a) => Math.min(a + 1, e.length - 1));
27
- break;
28
- case "ArrowUp":
29
- o.preventDefault(), f((a) => Math.max(a - 1, 0));
30
- break;
31
- case "Enter":
32
- o.preventDefault(), e[k()] && t.execute(e[k()].id);
33
- break;
34
- }
35
- };
36
- window.addEventListener("keydown", n), S(() => window.removeEventListener("keydown", n));
37
- }), w(() => {
38
- if (!t.isOpen()) return;
39
- const n = B({
40
- overflow: "hidden"
41
- });
42
- S(n);
1
+ import { createComponent as s, Portal as K, insert as o, use as S, Dynamic as R, effect as y, className as C, setAttribute as z, template as d, delegateEvents as I } from "solid-js/web";
2
+ import { createSignal as T, createEffect as E, createMemo as j, Show as g, For as O } from "solid-js";
3
+ import { cn as D } from "../../utils/cn.js";
4
+ import { useCommand as B } from "../../context/CommandContext.js";
5
+ import { Search as H } from "../icons/index.js";
6
+ import { useResolvedFloeConfig as L } from "../../context/FloeConfigContext.js";
7
+ import { useOverlayMask as N } from "../../hooks/useOverlayMask.js";
8
+ import { matchKeybind as U } from "../../utils/keybind.js";
9
+ var W = /* @__PURE__ */ d('<div class="fixed inset-0 z-50 bg-background/60 backdrop-blur-sm animate-in fade-in">'), q = /* @__PURE__ */ d('<div><div class="flex items-center gap-3 px-4 pt-1 border-b border-border"><input type=text><kbd class="text-xs text-muted-foreground px-1.5 py-0.5 rounded bg-muted font-mono"></kbd></div><div class="max-h-80 overflow-y-auto overscroll-contain py-2">'), G = /* @__PURE__ */ d('<div class="px-4 py-8 text-center text-sm text-muted-foreground">'), J = /* @__PURE__ */ d('<div><div class="px-4 py-1 text-xs font-semibold text-muted-foreground uppercase tracking-wider">'), Q = /* @__PURE__ */ d('<span class="w-5 h-5 flex items-center justify-center text-muted-foreground">'), V = /* @__PURE__ */ d('<span class="ml-2 text-muted-foreground text-xs">'), X = /* @__PURE__ */ d('<kbd class="text-xs text-muted-foreground px-1.5 py-0.5 rounded bg-muted font-mono">'), Y = /* @__PURE__ */ d('<button type=button><div class="flex-1 text-left"><span>');
10
+ function se() {
11
+ const r = B(), x = L();
12
+ let h, k;
13
+ const [w, f] = T(0);
14
+ N({
15
+ open: r.isOpen,
16
+ root: () => k,
17
+ onClose: () => r.close(),
18
+ lockBodyScroll: !0,
19
+ trapFocus: !0,
20
+ closeOnEscape: !0,
21
+ blockHotkeys: !0,
22
+ // Prevent scroll bleed on the backdrop while keeping the results list scrollable.
23
+ blockWheel: "outside",
24
+ blockTouchMove: "outside",
25
+ restoreFocus: !0
26
+ }), E(() => {
27
+ r.isOpen() && h && (h.focus(), f(0));
28
+ }), E(() => {
29
+ r.search(), f(0);
43
30
  });
44
- const P = K(() => {
45
- const n = t.filteredCommands(), o = /* @__PURE__ */ new Map();
46
- return n.forEach((e, a) => {
47
- const h = e.category ?? "Commands", p = o.get(h);
31
+ const P = (e) => {
32
+ if (U(e, x.config.commands.palette.keybind)) {
33
+ e.preventDefault(), r.close();
34
+ return;
35
+ }
36
+ const l = r.filteredCommands();
37
+ switch (e.key) {
38
+ case "ArrowDown": {
39
+ e.preventDefault();
40
+ const t = l.length;
41
+ if (t <= 0) return;
42
+ f((i) => Math.max(0, Math.min(i + 1, t - 1)));
43
+ break;
44
+ }
45
+ case "ArrowUp": {
46
+ e.preventDefault();
47
+ const t = l.length;
48
+ if (t <= 0) return;
49
+ f((i) => Math.max(0, Math.min(i - 1, t - 1)));
50
+ break;
51
+ }
52
+ case "Enter":
53
+ e.preventDefault(), l[w()] && r.execute(l[w()].id);
54
+ break;
55
+ }
56
+ }, A = j(() => {
57
+ const e = r.filteredCommands(), l = /* @__PURE__ */ new Map();
58
+ return e.forEach((t, i) => {
59
+ const v = t.category ?? "Commands", p = l.get(v);
48
60
  p ? p.push({
49
- cmd: e,
50
- index: a
51
- }) : o.set(h, [{
52
- cmd: e,
53
- index: a
61
+ cmd: t,
62
+ index: i
63
+ }) : l.set(v, [{
64
+ cmd: t,
65
+ index: i
54
66
  }]);
55
- }), Array.from(o.entries());
67
+ }), Array.from(l.entries());
56
68
  });
57
- return i(g, {
69
+ return s(g, {
58
70
  get when() {
59
- return t.isOpen();
71
+ return r.isOpen();
60
72
  },
61
73
  get children() {
62
- return i(M, {
74
+ return s(K, {
63
75
  get children() {
64
76
  return [(() => {
65
- var n = T();
66
- return n.$$click = () => t.close(), n;
77
+ var e = W();
78
+ return e.$$click = () => r.close(), e;
67
79
  })(), (() => {
68
- var n = U(), o = n.firstChild, e = o.firstChild, a = e.nextSibling, h = o.nextSibling;
69
- l(o, i(j, {
80
+ var e = q(), l = e.firstChild, t = l.firstChild, i = t.nextSibling, v = l.nextSibling;
81
+ e.$$keydown = P;
82
+ var p = k;
83
+ typeof p == "function" ? S(p, e) : k = e, o(l, s(H, {
70
84
  class: "w-5 h-5 text-muted-foreground flex-shrink-0"
71
- }), e), e.$$input = (r) => t.setSearch(r.currentTarget.value);
72
- var p = x;
73
- return typeof p == "function" ? O(p, e) : x = e, l(a, () => $.config.strings.commandPalette.esc), l(h, i(g, {
85
+ }), t), t.$$input = (n) => r.setSearch(n.currentTarget.value);
86
+ var M = h;
87
+ return typeof M == "function" ? S(M, t) : h = t, o(i, () => x.config.strings.commandPalette.esc), o(v, s(g, {
74
88
  get when() {
75
- return t.filteredCommands().length > 0;
89
+ return r.filteredCommands().length > 0;
76
90
  },
77
91
  get fallback() {
78
92
  return (() => {
79
- var r = q();
80
- return l(r, () => $.config.strings.commandPalette.empty), r;
93
+ var n = G();
94
+ return o(n, () => x.config.strings.commandPalette.empty), n;
81
95
  })();
82
96
  },
83
97
  get children() {
84
- return i(D, {
98
+ return s(O, {
85
99
  get each() {
86
- return P();
100
+ return A();
87
101
  },
88
- children: ([r, v]) => (() => {
89
- var m = G(), b = m.firstChild;
90
- return l(b, r), l(m, i(D, {
91
- each: v,
92
- children: (d) => (() => {
93
- var u = V(), _ = u.firstChild, A = _.firstChild;
94
- return u.addEventListener("mouseenter", () => f(d.index)), u.$$click = () => t.execute(d.cmd.id), l(u, i(g, {
102
+ children: ([n, b]) => (() => {
103
+ var m = J(), $ = m.firstChild;
104
+ return o($, n), o(m, s(O, {
105
+ each: b,
106
+ children: (c) => (() => {
107
+ var u = Y(), _ = u.firstChild, F = _.firstChild;
108
+ return u.addEventListener("mouseenter", () => f(c.index)), u.$$click = () => r.execute(c.cmd.id), o(u, s(g, {
95
109
  get when() {
96
- return d.cmd.icon;
110
+ return c.cmd.icon;
97
111
  },
98
112
  get children() {
99
- var s = H();
100
- return l(s, i(L, {
113
+ var a = Q();
114
+ return o(a, s(R, {
101
115
  get component() {
102
- return d.cmd.icon;
116
+ return c.cmd.icon;
103
117
  },
104
118
  class: "w-5 h-5"
105
- })), s;
119
+ })), a;
106
120
  }
107
- }), _), l(A, () => d.cmd.title), l(_, i(g, {
121
+ }), _), o(F, () => c.cmd.title), o(_, s(g, {
108
122
  get when() {
109
- return d.cmd.description;
123
+ return c.cmd.description;
110
124
  },
111
125
  get children() {
112
- var s = J();
113
- return l(s, () => d.cmd.description), s;
126
+ var a = V();
127
+ return o(a, () => c.cmd.description), a;
114
128
  }
115
- }), null), l(u, i(g, {
129
+ }), null), o(u, s(g, {
116
130
  get when() {
117
- return d.cmd.keybind;
131
+ return c.cmd.keybind;
118
132
  },
119
133
  get children() {
120
- var s = Q();
121
- return l(s, () => t.getKeybindDisplay(d.cmd.keybind)), s;
134
+ var a = X();
135
+ return o(a, () => r.getKeybindDisplay(c.cmd.keybind)), a;
122
136
  }
123
- }), null), y(() => C(u, E("w-full flex items-center gap-3 px-4 py-2 text-sm cursor-pointer", "transition-colors duration-75", "focus:outline-none", k() === d.index ? "bg-accent text-accent-foreground" : "hover:bg-accent/50"))), u;
137
+ }), null), y(() => C(u, D("w-full flex items-center gap-3 px-4 py-2 text-sm cursor-pointer", "transition-colors duration-75", "focus:outline-none", w() === c.index ? "bg-accent text-accent-foreground" : "hover:bg-accent/50"))), u;
124
138
  })()
125
139
  }), null), m;
126
140
  })()
127
141
  });
128
142
  }
129
- })), y((r) => {
130
- var v = E("fixed left-1/2 top-[20%] z-50 -translate-x-1/2", "w-full max-w-xl", "bg-popover text-popover-foreground rounded-lg shadow-2xl", "border border-border", "animate-in fade-in slide-in-from-top-4", "overflow-hidden"), m = $.config.strings.commandPalette.placeholder, b = E("flex-1 h-12 bg-transparent text-sm", "placeholder:text-muted-foreground", "focus:outline-none");
131
- return v !== r.e && C(n, r.e = v), m !== r.t && z(e, "placeholder", r.t = m), b !== r.a && C(e, r.a = b), r;
143
+ })), y((n) => {
144
+ var b = D("fixed left-1/2 top-[20%] z-50 -translate-x-1/2", "w-full max-w-xl", "bg-popover text-popover-foreground rounded-lg shadow-2xl", "border border-border", "animate-in fade-in slide-in-from-top-4", "overflow-hidden"), m = x.config.strings.commandPalette.placeholder, $ = D("flex-1 h-12 bg-transparent text-sm", "placeholder:text-muted-foreground", "focus:outline-none");
145
+ return b !== n.e && C(e, n.e = b), m !== n.t && z(t, "placeholder", n.t = m), $ !== n.a && C(t, n.a = $), n;
132
146
  }, {
133
147
  e: void 0,
134
148
  t: void 0,
135
149
  a: void 0
136
- }), y(() => e.value = t.search()), n;
150
+ }), y(() => t.value = r.search()), e;
137
151
  })()];
138
152
  }
139
153
  });
140
154
  }
141
155
  });
142
156
  }
143
- F(["click", "input"]);
157
+ I(["click", "keydown", "input"]);
144
158
  export {
145
- ne as CommandPalette
159
+ se as CommandPalette
146
160
  };
@@ -1,121 +1,98 @@
1
- import { createComponent as o, Portal as E, insert as l, effect as b, setAttribute as v, className as _, template as c, use as D, delegateEvents as T } from "solid-js/web";
2
- import { createUniqueId as O, createEffect as $, onCleanup as x, Show as s } from "solid-js";
3
- import { cn as L } from "../../utils/cn.js";
4
- import { Button as w } from "./Button.js";
5
- import { X as z } from "../icons/index.js";
6
- import { lockBodyStyle as A } from "../../utils/bodyStyleLock.js";
7
- import { useResolvedFloeConfig as F } from "../../context/FloeConfigContext.js";
8
- var I = /* @__PURE__ */ c('<div class="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm animate-in fade-in cursor-pointer">'), j = /* @__PURE__ */ c('<h2 class="text-sm font-semibold">'), H = /* @__PURE__ */ c('<p class="mt-0.5 text-xs text-muted-foreground">'), M = /* @__PURE__ */ c('<div class="flex items-start justify-between p-3 border-b border-border"><div>'), S = /* @__PURE__ */ c('<div class="flex items-center justify-end gap-2 p-3 border-t border-border">'), q = /* @__PURE__ */ c('<div role=dialog aria-modal=true tabindex=-1><div class="flex-1 overflow-auto p-3">'), B = /* @__PURE__ */ c("<div>");
9
- function k(e) {
10
- const a = ["a[href]", "button:not([disabled])", "input:not([disabled])", "select:not([disabled])", "textarea:not([disabled])", '[tabindex]:not([tabindex="-1"])', '[contenteditable="true"]'].join(",");
11
- return Array.from(e.querySelectorAll(a)).filter((f) => f instanceof HTMLElement);
12
- }
13
- function K(e) {
14
- const a = O(), f = () => `dialog-${a}-title`, y = () => `dialog-${a}-description`;
15
- let m;
16
- return $(() => {
17
- if (!e.open || typeof document > "u") return;
18
- const n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
19
- setTimeout(() => {
20
- const t = m;
21
- if (!t) return;
22
- (k(t)[0] ?? t).focus();
23
- }, 0);
24
- const d = (t) => {
25
- if (t.key === "Escape") {
26
- e.onOpenChange(!1);
27
- return;
28
- }
29
- if (t.key !== "Tab") return;
30
- const i = m;
31
- if (!i) return;
32
- const r = k(i);
33
- if (!r.length) {
34
- t.preventDefault(), i.focus();
35
- return;
36
- }
37
- const u = r[0], C = r[r.length - 1], g = document.activeElement instanceof HTMLElement ? document.activeElement : null;
38
- t.shiftKey ? (g === u || !g || !i.contains(g)) && (t.preventDefault(), C.focus()) : g === C && (t.preventDefault(), u.focus());
39
- };
40
- document.addEventListener("keydown", d, !0), x(() => document.removeEventListener("keydown", d, !0)), x(() => n?.focus());
41
- }), $(() => {
42
- if (!e.open) return;
43
- const n = A({
44
- overflow: "hidden"
45
- });
46
- x(n);
47
- }), o(s, {
1
+ import { createComponent as n, Portal as C, insert as l, effect as s, setAttribute as u, className as $, template as o, use as w, delegateEvents as k } from "solid-js/web";
2
+ import { createUniqueId as _, Show as c } from "solid-js";
3
+ import { cn as y } from "../../utils/cn.js";
4
+ import { Button as f } from "./Button.js";
5
+ import { X as O } from "../icons/index.js";
6
+ import { useResolvedFloeConfig as z } from "../../context/FloeConfigContext.js";
7
+ import { useOverlayMask as D } from "../../hooks/useOverlayMask.js";
8
+ var I = /* @__PURE__ */ o('<div class="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm animate-in fade-in cursor-pointer">'), F = /* @__PURE__ */ o('<h2 class="text-sm font-semibold">'), T = /* @__PURE__ */ o('<p class="mt-0.5 text-xs text-muted-foreground">'), j = /* @__PURE__ */ o('<div class="flex items-start justify-between p-3 border-b border-border"><div>'), B = /* @__PURE__ */ o('<div class="flex items-center justify-end gap-2 p-3 border-t border-border">'), E = /* @__PURE__ */ o('<div role=dialog aria-modal=true tabindex=-1><div class="flex-1 overflow-auto overscroll-contain p-3">'), M = /* @__PURE__ */ o("<div>");
9
+ function R(e) {
10
+ const a = _(), m = () => `dialog-${a}-title`, h = () => `dialog-${a}-description`;
11
+ let g;
12
+ return D({
13
+ open: () => e.open,
14
+ root: () => g,
15
+ onClose: () => e.onOpenChange(!1),
16
+ lockBodyScroll: !0,
17
+ trapFocus: !0,
18
+ closeOnEscape: !0,
19
+ blockHotkeys: !0,
20
+ // Block scroll bleed outside the dialog while keeping the dialog content scrollable.
21
+ blockWheel: "outside",
22
+ blockTouchMove: "outside",
23
+ restoreFocus: !0
24
+ }), n(c, {
48
25
  get when() {
49
26
  return e.open;
50
27
  },
51
28
  get children() {
52
- return o(E, {
29
+ return n(C, {
53
30
  get children() {
54
31
  return [(() => {
55
- var n = I();
56
- return n.$$click = () => e.onOpenChange(!1), n;
32
+ var r = I();
33
+ return r.$$click = () => e.onOpenChange(!1), r;
57
34
  })(), (() => {
58
- var n = q(), h = n.firstChild, d = m;
59
- return typeof d == "function" ? D(d, n) : m = n, l(n, o(s, {
35
+ var r = E(), v = r.firstChild, b = g;
36
+ return typeof b == "function" ? w(b, r) : g = r, l(r, n(c, {
60
37
  get when() {
61
38
  return e.title || e.description;
62
39
  },
63
40
  get children() {
64
- var t = M(), i = t.firstChild;
65
- return l(i, o(s, {
41
+ var t = j(), d = t.firstChild;
42
+ return l(d, n(c, {
66
43
  get when() {
67
44
  return e.title;
68
45
  },
69
46
  get children() {
70
- var r = j();
71
- return l(r, () => e.title), b(() => v(r, "id", f())), r;
47
+ var i = F();
48
+ return l(i, () => e.title), s(() => u(i, "id", m())), i;
72
49
  }
73
- }), null), l(i, o(s, {
50
+ }), null), l(d, n(c, {
74
51
  get when() {
75
52
  return e.description;
76
53
  },
77
54
  get children() {
78
- var r = H();
79
- return l(r, () => e.description), b(() => v(r, "id", y())), r;
55
+ var i = T();
56
+ return l(i, () => e.description), s(() => u(i, "id", h())), i;
80
57
  }
81
- }), null), l(t, o(w, {
58
+ }), null), l(t, n(f, {
82
59
  variant: "ghost",
83
60
  size: "icon",
84
61
  class: "h-6 w-6 -mr-1 bg-transparent text-muted-foreground hover:bg-red-500 hover:text-white",
85
62
  onClick: () => e.onOpenChange(!1),
86
63
  "aria-label": "Close",
87
64
  get children() {
88
- return o(z, {
65
+ return n(O, {
89
66
  class: "w-3.5 h-3.5"
90
67
  });
91
68
  }
92
69
  }), null), t;
93
70
  }
94
- }), h), l(h, () => e.children), l(n, o(s, {
71
+ }), v), l(v, () => e.children), l(r, n(c, {
95
72
  get when() {
96
73
  return e.footer;
97
74
  },
98
75
  get children() {
99
- var t = S();
76
+ var t = B();
100
77
  return l(t, () => e.footer), t;
101
78
  }
102
- }), null), b((t) => {
103
- var i = L("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2", "w-full max-w-md max-h-[85vh]", "bg-card text-card-foreground rounded-md shadow-lg", "border border-border", "animate-in fade-in zoom-in-95", "flex flex-col", e.class), r = e.title ? f() : void 0, u = e.description ? y() : void 0;
104
- return i !== t.e && _(n, t.e = i), r !== t.t && v(n, "aria-labelledby", t.t = r), u !== t.a && v(n, "aria-describedby", t.a = u), t;
79
+ }), null), s((t) => {
80
+ var d = y("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2", "w-full max-w-md max-h-[85vh]", "bg-card text-card-foreground rounded-md shadow-lg", "border border-border", "animate-in fade-in zoom-in-95", "flex flex-col", e.class), i = e.title ? m() : void 0, x = e.description ? h() : void 0;
81
+ return d !== t.e && $(r, t.e = d), i !== t.t && u(r, "aria-labelledby", t.t = i), x !== t.a && u(r, "aria-describedby", t.a = x), t;
105
82
  }, {
106
83
  e: void 0,
107
84
  t: void 0,
108
85
  a: void 0
109
- }), n;
86
+ }), r;
110
87
  })()];
111
88
  }
112
89
  });
113
90
  }
114
91
  });
115
92
  }
116
- function Q(e) {
117
- const a = F();
118
- return o(K, {
93
+ function W(e) {
94
+ const a = z();
95
+ return n(R, {
119
96
  get open() {
120
97
  return e.open;
121
98
  },
@@ -129,7 +106,7 @@ function Q(e) {
129
106
  return e.description;
130
107
  },
131
108
  get footer() {
132
- return [o(w, {
109
+ return [n(f, {
133
110
  variant: "ghost",
134
111
  onClick: () => e.onOpenChange(!1),
135
112
  get disabled() {
@@ -138,7 +115,7 @@ function Q(e) {
138
115
  get children() {
139
116
  return e.cancelText ?? a.config.strings.confirmDialog.cancel;
140
117
  }
141
- }), o(w, {
118
+ }), n(f, {
142
119
  get variant() {
143
120
  return e.variant === "destructive" ? "destructive" : "primary";
144
121
  },
@@ -154,12 +131,12 @@ function Q(e) {
154
131
  })];
155
132
  },
156
133
  get children() {
157
- return e.children ?? B();
134
+ return e.children ?? M();
158
135
  }
159
136
  });
160
137
  }
161
- T(["click"]);
138
+ k(["click"]);
162
139
  export {
163
- Q as ConfirmDialog,
164
- K as Dialog
140
+ W as ConfirmDialog,
141
+ R as Dialog
165
142
  };