@floegence/floe-webapp-core 0.95.0 → 0.97.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.
- package/dist/components/html-preview/SandboxedHtmlFrame.d.ts +5 -0
- package/dist/components/html-preview/SandboxedHtmlFrame.js +92 -49
- package/dist/components/notes/useNotesOverlayModel.d.ts +3 -1
- package/dist/components/notes/useNotesOverlayModel.js +63 -63
- package/dist/components/ui/ContextMenuActions.d.ts +5 -0
- package/dist/components/ui/ContextMenuActions.js +140 -136
- package/dist/components/ui/RetainedPanel.d.ts +9 -0
- package/dist/components/ui/RetainedPanel.js +31 -0
- package/dist/components/ui/contextSource.d.ts +7 -1
- package/dist/components/ui/contextSource.js +54 -31
- package/dist/components/ui/index.d.ts +2 -1
- package/dist/components/workbench/WorkbenchSurface.js +48 -45
- package/dist/full.js +572 -569
- package/dist/styles.css +1 -1
- package/dist/ui.css +11 -1
- package/dist/ui.js +179 -176
- package/package.json +1 -1
|
@@ -1,65 +1,76 @@
|
|
|
1
|
-
import { createComponent as f, insert as
|
|
1
|
+
import { createComponent as f, insert as b, effect as E, className as k, setAttribute as M, memo as q, template as L, delegateEvents as F } from "solid-js/web";
|
|
2
2
|
import { useResizeObserver as H } from "../../hooks/useResizeObserver.js";
|
|
3
|
-
import {
|
|
4
|
-
import { SurfaceFloatingLayer as
|
|
5
|
-
import { handleMenuKeyboardNavigation as
|
|
6
|
-
var B = /* @__PURE__ */
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
import { Show as T, useContext as A, For as p, createSignal as D, onMount as R, onCleanup as z, createContext as P, createMemo as K } from "solid-js";
|
|
4
|
+
import { SurfaceFloatingLayer as N } from "./SurfaceFloatingLayer.js";
|
|
5
|
+
import { handleMenuKeyboardNavigation as _ } from "./menuUtils.js";
|
|
6
|
+
var B = /* @__PURE__ */ L("<span aria-hidden=true>"), O = /* @__PURE__ */ L("<button type=button role=menuitem><span>"), X = /* @__PURE__ */ L("<button type=button role=menuitem class=floe-context-action><span>");
|
|
7
|
+
const C = P(), W = () => A(C);
|
|
8
|
+
function I(e) {
|
|
9
|
+
return f(T, {
|
|
10
|
+
get when() {
|
|
11
|
+
return e.icon;
|
|
12
|
+
},
|
|
13
|
+
children: (i) => (() => {
|
|
14
|
+
var a = B();
|
|
15
|
+
return b(a, () => i()()), E(() => k(a, `floe-context-action-icon ${e.class ?? ""}`)), a;
|
|
16
|
+
})()
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function Z(e) {
|
|
20
|
+
let i, a, r;
|
|
21
|
+
const c = /* @__PURE__ */ new Set(), [t, o] = D(), u = () => {
|
|
22
|
+
const n = i;
|
|
23
|
+
return i = void 0, a = void 0, r = void 0, n;
|
|
24
|
+
}, s = (n) => {
|
|
25
|
+
if (e.enabled === !1 || n.defaultPrevented || n instanceof KeyboardEvent && n.key !== "ContextMenu" && !(n.shiftKey && n.key === "F10")) return;
|
|
26
|
+
const l = n.composedPath().find((h) => h instanceof HTMLElement);
|
|
16
27
|
if (!l || l.closest('[inert], [hidden], [role="menu"], [data-floe-context-menu-native]')) return;
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
return
|
|
28
|
+
const g = l.getBoundingClientRect(), d = n instanceof MouseEvent && (n.clientX !== 0 || n.clientY !== 0), v = l instanceof HTMLInputElement || l instanceof HTMLTextAreaElement ? l instanceof HTMLInputElement && l.type === "password" ? "" : l.value.slice(l.selectionStart ?? 0, l.selectionEnd ?? 0) : (() => {
|
|
29
|
+
const h = document.getSelection();
|
|
30
|
+
return h?.rangeCount && h.getRangeAt(0).intersectsNode(l) ? h.toString() : "";
|
|
20
31
|
})(), w = {
|
|
21
32
|
target: l,
|
|
22
|
-
x:
|
|
23
|
-
y:
|
|
24
|
-
selection:
|
|
25
|
-
},
|
|
33
|
+
x: d ? n.clientX : g.left + 8,
|
|
34
|
+
y: d ? n.clientY : g.bottom,
|
|
35
|
+
selection: v
|
|
36
|
+
}, y = e.actions(w), x = {
|
|
26
37
|
origin: w,
|
|
27
|
-
actions:
|
|
38
|
+
actions: y
|
|
28
39
|
}, $ = {
|
|
29
40
|
origin: w,
|
|
30
|
-
actions: [...
|
|
41
|
+
actions: [...y, ...e.editing ? j(w, e.editing.labels, e.editing.onError) : []]
|
|
31
42
|
};
|
|
32
43
|
if (!x.actions.length) return;
|
|
33
|
-
|
|
44
|
+
i = x, a = n, r = $;
|
|
34
45
|
const S = setTimeout(() => {
|
|
35
|
-
|
|
46
|
+
i === x && (i = void 0, a = void 0, r = void 0), c.delete(S);
|
|
36
47
|
}, 0);
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
|
|
48
|
+
c.add(S);
|
|
49
|
+
}, m = (n) => {
|
|
50
|
+
i && a === n && !n.defaultPrevented && (n.preventDefault(), o(r), u());
|
|
40
51
|
};
|
|
41
|
-
return
|
|
42
|
-
document.addEventListener("contextmenu",
|
|
43
|
-
|
|
52
|
+
return R(() => {
|
|
53
|
+
document.addEventListener("contextmenu", s, !0), document.addEventListener("keydown", s, !0), window.addEventListener("contextmenu", m), window.addEventListener("keydown", m), z(() => {
|
|
54
|
+
c.forEach(clearTimeout), i = void 0, a = void 0, r = void 0, document.removeEventListener("contextmenu", s, !0), document.removeEventListener("keydown", s, !0), window.removeEventListener("contextmenu", m), window.removeEventListener("keydown", m);
|
|
44
55
|
});
|
|
45
|
-
}), f(
|
|
56
|
+
}), f(C.Provider, {
|
|
46
57
|
value: {
|
|
47
|
-
claim:
|
|
48
|
-
resolve: (
|
|
58
|
+
claim: u,
|
|
59
|
+
resolve: (n) => e.enabled === !1 ? [] : e.actions(n)
|
|
49
60
|
},
|
|
50
61
|
get children() {
|
|
51
|
-
return [
|
|
62
|
+
return [q(() => e.children), f(T, {
|
|
52
63
|
get when() {
|
|
53
|
-
return
|
|
64
|
+
return t();
|
|
54
65
|
},
|
|
55
66
|
keyed: !0,
|
|
56
|
-
children: (
|
|
57
|
-
request:
|
|
67
|
+
children: (n) => f(Y, {
|
|
68
|
+
request: n,
|
|
58
69
|
get label() {
|
|
59
|
-
return
|
|
70
|
+
return e.label;
|
|
60
71
|
},
|
|
61
72
|
get zIndex() {
|
|
62
|
-
return
|
|
73
|
+
return e.zIndex;
|
|
63
74
|
},
|
|
64
75
|
onClose: () => o(void 0)
|
|
65
76
|
})
|
|
@@ -67,111 +78,103 @@ function W(n) {
|
|
|
67
78
|
}
|
|
68
79
|
});
|
|
69
80
|
}
|
|
70
|
-
function
|
|
71
|
-
const
|
|
81
|
+
function ee(e) {
|
|
82
|
+
const i = A(C)?.claim(), a = () => i?.actions.filter((r) => !e.excludeIds?.includes(r.id)) ?? [];
|
|
72
83
|
return f(p, {
|
|
73
84
|
get each() {
|
|
74
|
-
return
|
|
85
|
+
return a();
|
|
75
86
|
},
|
|
76
|
-
children: (
|
|
77
|
-
var
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
get
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
})()
|
|
88
|
-
}), e), g(e, () => i.label), k((o) => {
|
|
89
|
-
var s = n.itemClass ?? "floe-context-action", a = i.id, d = i.disabled;
|
|
90
|
-
return s !== o.e && q(r, o.e = s), a !== o.t && M(r, "data-context-action-id", o.t = a), d !== o.a && (r.disabled = o.a = d), o;
|
|
87
|
+
children: (r) => (() => {
|
|
88
|
+
var c = O(), t = c.firstChild;
|
|
89
|
+
return c.$$click = () => {
|
|
90
|
+
e.onClose(), r.onSelect();
|
|
91
|
+
}, b(c, f(I, {
|
|
92
|
+
get icon() {
|
|
93
|
+
return r.icon;
|
|
94
|
+
}
|
|
95
|
+
}), t), b(t, () => r.label), E((o) => {
|
|
96
|
+
var u = e.itemClass ?? "floe-context-action", s = r.id, m = r.disabled;
|
|
97
|
+
return u !== o.e && k(c, o.e = u), s !== o.t && M(c, "data-context-action-id", o.t = s), m !== o.a && (c.disabled = o.a = m), o;
|
|
91
98
|
}, {
|
|
92
99
|
e: void 0,
|
|
93
100
|
t: void 0,
|
|
94
101
|
a: void 0
|
|
95
|
-
}),
|
|
102
|
+
}), c;
|
|
96
103
|
})()
|
|
97
104
|
});
|
|
98
105
|
}
|
|
99
|
-
function
|
|
100
|
-
let
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
106
|
+
function Y(e) {
|
|
107
|
+
let i;
|
|
108
|
+
const a = H(() => i), r = K(() => {
|
|
109
|
+
if (!a() || !i) return {
|
|
103
110
|
width: 208,
|
|
104
|
-
height: 8 +
|
|
111
|
+
height: 8 + e.request.actions.length * 30
|
|
105
112
|
};
|
|
106
|
-
const
|
|
113
|
+
const t = i.getBoundingClientRect();
|
|
107
114
|
return {
|
|
108
|
-
width:
|
|
109
|
-
height:
|
|
115
|
+
width: t.width,
|
|
116
|
+
height: t.height
|
|
110
117
|
};
|
|
111
|
-
}),
|
|
112
|
-
|
|
118
|
+
}), c = (t = !1) => {
|
|
119
|
+
e.onClose(), t && e.request.origin.target.isConnected && e.request.origin.target.focus({
|
|
113
120
|
preventScroll: !0
|
|
114
121
|
});
|
|
115
122
|
};
|
|
116
|
-
return
|
|
117
|
-
|
|
123
|
+
return R(() => {
|
|
124
|
+
i.querySelector('[role="menuitem"]:not(:disabled)')?.focus({
|
|
118
125
|
preventScroll: !0
|
|
119
126
|
});
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
}, o = () =>
|
|
123
|
-
document.addEventListener("pointerdown",
|
|
124
|
-
document.removeEventListener("pointerdown",
|
|
127
|
+
const t = (u) => {
|
|
128
|
+
u.target instanceof Node && !i.contains(u.target) && c();
|
|
129
|
+
}, o = () => c();
|
|
130
|
+
document.addEventListener("pointerdown", t, !0), document.addEventListener("focusin", t, !0), document.addEventListener("scroll", t, !0), window.addEventListener("resize", o), window.addEventListener("blur", o), z(() => {
|
|
131
|
+
document.removeEventListener("pointerdown", t, !0), document.removeEventListener("focusin", t, !0), document.removeEventListener("scroll", t, !0), window.removeEventListener("resize", o), window.removeEventListener("blur", o);
|
|
125
132
|
});
|
|
126
|
-
}), f(
|
|
133
|
+
}), f(N, {
|
|
127
134
|
get owner() {
|
|
128
|
-
return
|
|
135
|
+
return e.request.origin.target;
|
|
129
136
|
},
|
|
130
137
|
get position() {
|
|
131
|
-
return
|
|
138
|
+
return e.request.origin;
|
|
132
139
|
},
|
|
133
140
|
get estimatedSize() {
|
|
134
|
-
return
|
|
141
|
+
return r();
|
|
135
142
|
},
|
|
136
143
|
role: "menu",
|
|
137
144
|
get "aria-label"() {
|
|
138
|
-
return
|
|
145
|
+
return e.label;
|
|
139
146
|
},
|
|
140
|
-
layerRef: (
|
|
141
|
-
|
|
147
|
+
layerRef: (t) => {
|
|
148
|
+
i = t;
|
|
142
149
|
},
|
|
143
150
|
class: "floe-context-actions",
|
|
144
151
|
get style() {
|
|
145
152
|
return {
|
|
146
|
-
"z-index":
|
|
153
|
+
"z-index": e.zIndex
|
|
147
154
|
};
|
|
148
155
|
},
|
|
149
|
-
onContextMenu: (
|
|
150
|
-
onKeyDown: (
|
|
156
|
+
onContextMenu: (t) => t.preventDefault(),
|
|
157
|
+
onKeyDown: (t) => _(t, {
|
|
151
158
|
onActivate: (o) => o.click(),
|
|
152
|
-
onDismiss: () =>
|
|
159
|
+
onDismiss: () => c(!0),
|
|
153
160
|
preventDefaultOnTab: !0
|
|
154
161
|
}),
|
|
155
162
|
get children() {
|
|
156
163
|
return f(p, {
|
|
157
164
|
get each() {
|
|
158
|
-
return
|
|
165
|
+
return e.request.actions;
|
|
159
166
|
},
|
|
160
|
-
children: (
|
|
161
|
-
var o =
|
|
167
|
+
children: (t) => (() => {
|
|
168
|
+
var o = X(), u = o.firstChild;
|
|
162
169
|
return o.$$click = () => {
|
|
163
|
-
|
|
164
|
-
},
|
|
165
|
-
get
|
|
166
|
-
return
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
})()
|
|
172
|
-
}), s), g(s, () => e.label), k((a) => {
|
|
173
|
-
var d = e.id, t = e.disabled;
|
|
174
|
-
return d !== a.e && M(o, "data-context-action-id", a.e = d), t !== a.t && (o.disabled = a.t = t), a;
|
|
170
|
+
c(), t.onSelect();
|
|
171
|
+
}, b(o, f(I, {
|
|
172
|
+
get icon() {
|
|
173
|
+
return t.icon;
|
|
174
|
+
}
|
|
175
|
+
}), u), b(u, () => t.label), E((s) => {
|
|
176
|
+
var m = t.id, n = t.disabled;
|
|
177
|
+
return m !== s.e && M(o, "data-context-action-id", s.e = m), n !== s.t && (o.disabled = s.t = n), s;
|
|
175
178
|
}, {
|
|
176
179
|
e: void 0,
|
|
177
180
|
t: void 0
|
|
@@ -181,58 +184,59 @@ function X(n) {
|
|
|
181
184
|
}
|
|
182
185
|
});
|
|
183
186
|
}
|
|
184
|
-
function
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
+
function j(e, i, a) {
|
|
188
|
+
const r = e.target.closest('input, textarea, [contenteditable]:not([contenteditable="false"])'), c = r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement ? r : null, t = document.getSelection()?.rangeCount ? document.getSelection().getRangeAt(0).cloneRange() : void 0, o = c?.selectionStart, u = c?.selectionEnd, s = () => {
|
|
189
|
+
if (r?.focus({
|
|
187
190
|
preventScroll: !0
|
|
188
|
-
}),
|
|
189
|
-
else if (
|
|
190
|
-
const
|
|
191
|
-
|
|
191
|
+
}), c && o != null && u != null) c.setSelectionRange(o, u);
|
|
192
|
+
else if (t) {
|
|
193
|
+
const d = document.getSelection();
|
|
194
|
+
d?.removeAllRanges(), d?.addRange(t);
|
|
192
195
|
}
|
|
193
|
-
},
|
|
196
|
+
}, m = (d) => () => {
|
|
194
197
|
try {
|
|
195
|
-
Promise.resolve(
|
|
196
|
-
} catch (
|
|
197
|
-
|
|
198
|
+
Promise.resolve(d()).catch(a);
|
|
199
|
+
} catch (v) {
|
|
200
|
+
a(v);
|
|
198
201
|
}
|
|
199
|
-
},
|
|
200
|
-
id: `edit.${
|
|
201
|
-
label:
|
|
202
|
-
onSelect:
|
|
203
|
-
if (
|
|
204
|
-
|
|
202
|
+
}, n = (d) => ({
|
|
203
|
+
id: `edit.${d}`,
|
|
204
|
+
label: i[d],
|
|
205
|
+
onSelect: m(async () => {
|
|
206
|
+
if (s(), d === "selectAll" && c) {
|
|
207
|
+
c.select();
|
|
205
208
|
return;
|
|
206
209
|
}
|
|
207
|
-
if (document.execCommand(
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
210
|
+
if (document.execCommand(d) || d !== "paste") return;
|
|
211
|
+
const v = await navigator.clipboard.readText();
|
|
212
|
+
if (r?.isConnected && (s(), !document.execCommand("insertText", !1, v)))
|
|
210
213
|
throw new Error("Clipboard insertion is unavailable.");
|
|
211
214
|
})
|
|
212
215
|
}), l = [];
|
|
213
|
-
|
|
216
|
+
r && l.push(n("undo"), n("redo"), n("cut")), e.selection && l.push({
|
|
214
217
|
id: "edit.copy",
|
|
215
|
-
label:
|
|
216
|
-
onSelect:
|
|
217
|
-
}),
|
|
218
|
-
const
|
|
219
|
-
if (
|
|
220
|
-
const
|
|
218
|
+
label: i.copy,
|
|
219
|
+
onSelect: m(() => navigator.clipboard.writeText(e.selection))
|
|
220
|
+
}), r && l.push(n("paste"), n("selectAll"));
|
|
221
|
+
const g = e.target.closest("a[href]");
|
|
222
|
+
if (g && ["http:", "https:", "mailto:"].includes(g.protocol)) {
|
|
223
|
+
const d = g.href;
|
|
221
224
|
l.push({
|
|
222
225
|
id: "link.open",
|
|
223
|
-
label:
|
|
224
|
-
onSelect: () => window.open(
|
|
226
|
+
label: i.openLink,
|
|
227
|
+
onSelect: () => window.open(d, "_blank", "noopener,noreferrer")
|
|
225
228
|
}), l.push({
|
|
226
229
|
id: "link.copy",
|
|
227
|
-
label:
|
|
228
|
-
onSelect:
|
|
230
|
+
label: i.copyLink,
|
|
231
|
+
onSelect: m(() => navigator.clipboard.writeText(d))
|
|
229
232
|
});
|
|
230
233
|
}
|
|
231
234
|
return l;
|
|
232
235
|
}
|
|
233
236
|
F(["click"]);
|
|
234
237
|
export {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
I as ContextMenuActionIcon,
|
|
239
|
+
ee as ContextMenuActionItems,
|
|
240
|
+
Z as ContextMenuActions,
|
|
241
|
+
W as useContextMenuActions
|
|
238
242
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
export interface RetainedPanelProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'hidden' | 'inert' | 'style' | 'aria-hidden'> {
|
|
3
|
+
active: boolean;
|
|
4
|
+
}
|
|
5
|
+
/** A retained document layer. Its positioned parent owns the viewport dimensions.
|
|
6
|
+
* Visibility changes preserve layout, scroll and embedded document identity.
|
|
7
|
+
* Mounting, ordering, media activation and disposal remain the caller's responsibility.
|
|
8
|
+
*/
|
|
9
|
+
export declare function RetainedPanel(props: RetainedPanelProps): JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { spread as n, mergeProps as a, insert as o, template as l } from "solid-js/web";
|
|
2
|
+
import { splitProps as s } from "solid-js";
|
|
3
|
+
var d = /* @__PURE__ */ l("<div>");
|
|
4
|
+
function c(i) {
|
|
5
|
+
const [e, r] = s(i, ["active", "children"]);
|
|
6
|
+
return (() => {
|
|
7
|
+
var t = d();
|
|
8
|
+
return n(t, a(r, {
|
|
9
|
+
"data-floe-retained-panel": "",
|
|
10
|
+
get "aria-hidden"() {
|
|
11
|
+
return e.active ? void 0 : "true";
|
|
12
|
+
},
|
|
13
|
+
get inert() {
|
|
14
|
+
return !e.active;
|
|
15
|
+
},
|
|
16
|
+
get style() {
|
|
17
|
+
return {
|
|
18
|
+
position: "absolute",
|
|
19
|
+
inset: "0",
|
|
20
|
+
"min-width": "0",
|
|
21
|
+
"min-height": "0",
|
|
22
|
+
visibility: e.active ? "visible" : "hidden",
|
|
23
|
+
"pointer-events": e.active ? void 0 : "none"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}), !1, !0), o(t, () => e.children), t;
|
|
27
|
+
})();
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
c as RetainedPanel
|
|
31
|
+
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export interface ContextSource<T> {
|
|
2
2
|
id: string;
|
|
3
3
|
element: HTMLElement;
|
|
4
|
-
read: () => T;
|
|
4
|
+
read: (target?: EventTarget | null) => T;
|
|
5
|
+
/** An unavailable inner owner remains a boundary; never substitute its parent. */
|
|
6
|
+
enabled?: () => boolean;
|
|
7
|
+
/** Navigation and chrome can be targets without becoming active reading sources. */
|
|
8
|
+
activateOnInteraction?: boolean;
|
|
5
9
|
}
|
|
6
10
|
export interface ContextSourceSnapshot<T> {
|
|
7
11
|
id: string;
|
|
@@ -21,5 +25,7 @@ export declare function createContextSourceRegistry<T>(doc: Document): {
|
|
|
21
25
|
/** Hosts may forward activation from their authenticated embedded channel. */
|
|
22
26
|
activate(id: string): void;
|
|
23
27
|
capture(target?: EventTarget | null): ContextSourceSnapshot<T> | undefined;
|
|
28
|
+
/** Explicit-target capture never inherits an unrelated or cached selection. */
|
|
29
|
+
captureTarget(target: EventTarget, selectedText?: string): ContextSourceSnapshot<T> | undefined;
|
|
24
30
|
dispose(): void;
|
|
25
31
|
};
|
|
@@ -1,59 +1,82 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
const
|
|
5
|
-
const t =
|
|
1
|
+
function g(i) {
|
|
2
|
+
const r = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
let o, a = "";
|
|
4
|
+
const u = (e) => e.enabled?.() !== !1 && e.element.isConnected && !e.element.closest('[hidden], [inert], [aria-hidden="true"]'), f = (e) => {
|
|
5
|
+
const t = i.activeElement;
|
|
6
6
|
if (t && e.element.contains(t) && (t instanceof HTMLTextAreaElement || t instanceof HTMLInputElement))
|
|
7
7
|
return t instanceof HTMLInputElement && t.type === "password" ? "" : t.value.slice(t.selectionStart ?? 0, t.selectionEnd ?? 0);
|
|
8
|
-
const n =
|
|
8
|
+
const n = i.getSelection();
|
|
9
9
|
return n?.anchorNode && n.focusNode && e.element.contains(n.anchorNode) && e.element.contains(n.focusNode) ? n.toString() : "";
|
|
10
|
-
},
|
|
10
|
+
}, c = (e) => {
|
|
11
11
|
if (!(e instanceof Node)) return;
|
|
12
|
-
let t;
|
|
13
|
-
for (
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
let t = e;
|
|
13
|
+
for (; t; ) {
|
|
14
|
+
const n = l.get(t);
|
|
15
|
+
if (n) return n;
|
|
16
|
+
t = t.parentNode ?? (t instanceof ShadowRoot ? t.host : null);
|
|
17
|
+
}
|
|
16
18
|
}, v = (e) => {
|
|
17
|
-
!e || !
|
|
18
|
-
},
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
(
|
|
19
|
+
!e || !u(e) || (e !== o && (a = ""), o = e, a = f(e));
|
|
20
|
+
}, m = (e) => {
|
|
21
|
+
if (o) {
|
|
22
|
+
const n = f(o);
|
|
23
|
+
(n || o.element.contains(i.activeElement)) && (a = n);
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const t = c(e.composedPath()[0] ?? e.target);
|
|
26
|
+
t?.activateOnInteraction !== !1 && v(t);
|
|
27
|
+
}, h = () => {
|
|
28
|
+
if (!o) return;
|
|
29
|
+
const e = f(o);
|
|
30
|
+
(e || o.element.contains(i.activeElement) || i.activeElement === i.body) && (a = e);
|
|
28
31
|
};
|
|
29
|
-
return
|
|
32
|
+
return i.addEventListener("pointerdown", m, !0), i.addEventListener("focusin", m, !0), i.addEventListener("selectionchange", h), {
|
|
30
33
|
register(e) {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
const t = r.get(e.id);
|
|
35
|
+
return t && l.get(t.element) === t && l.delete(t.element), r.set(e.id, e), l.set(e.element, e), () => {
|
|
36
|
+
r.get(e.id) === e && r.delete(e.id), l.get(e.element) === e && l.delete(e.element), o === e && (o = void 0, a = "");
|
|
33
37
|
};
|
|
34
38
|
},
|
|
35
39
|
/** Hosts may forward activation from their authenticated embedded channel. */
|
|
36
40
|
activate(e) {
|
|
37
|
-
v(
|
|
41
|
+
v(r.get(e));
|
|
38
42
|
},
|
|
39
43
|
capture(e) {
|
|
40
|
-
const t = e ?
|
|
41
|
-
if (!t || !
|
|
44
|
+
const t = e ? c(e) : o;
|
|
45
|
+
if (!t || !u(t) || r.get(t.id) !== t) return;
|
|
42
46
|
const n = t.element.getBoundingClientRect();
|
|
43
47
|
if (!(n.width <= 0 || n.height <= 0))
|
|
44
48
|
return {
|
|
45
49
|
id: t.id,
|
|
46
50
|
element: t.element,
|
|
47
|
-
value: t.read(),
|
|
48
|
-
selection:
|
|
51
|
+
value: t.read(e),
|
|
52
|
+
selection: f(t) || (t === o ? a : ""),
|
|
49
53
|
rect: { x: n.x, y: n.y, width: n.width, height: n.height }
|
|
50
54
|
};
|
|
51
55
|
},
|
|
56
|
+
/** Explicit-target capture never inherits an unrelated or cached selection. */
|
|
57
|
+
captureTarget(e, t = "") {
|
|
58
|
+
const n = c(e);
|
|
59
|
+
if (!n || !u(n) || r.get(n.id) !== n) return;
|
|
60
|
+
const s = n.element.getBoundingClientRect();
|
|
61
|
+
if (!(s.width <= 0 || s.height <= 0))
|
|
62
|
+
return {
|
|
63
|
+
id: n.id,
|
|
64
|
+
element: n.element,
|
|
65
|
+
value: n.read(e),
|
|
66
|
+
selection: (() => {
|
|
67
|
+
const d = i.getSelection();
|
|
68
|
+
return t && d?.toString() === t && d.anchorNode && d.focusNode && (c(d.anchorNode) !== n || c(d.focusNode) !== n) ? "" : t;
|
|
69
|
+
})(),
|
|
70
|
+
rect: { x: s.x, y: s.y, width: s.width, height: s.height }
|
|
71
|
+
};
|
|
72
|
+
},
|
|
52
73
|
dispose() {
|
|
53
|
-
|
|
74
|
+
i.removeEventListener("pointerdown", m, !0), i.removeEventListener("focusin", m, !0), i.removeEventListener("selectionchange", h);
|
|
75
|
+
for (const e of r.values()) l.delete(e.element);
|
|
76
|
+
r.clear(), o = void 0, a = "";
|
|
54
77
|
}
|
|
55
78
|
};
|
|
56
79
|
}
|
|
57
80
|
export {
|
|
58
|
-
|
|
81
|
+
g as createContextSourceRegistry
|
|
59
82
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ContextMenuActions, ContextMenuActionItems, useContextMenuActions, type ContextMenuEditingLabels, type ContextMenuActionRequest, type ContextMenuAction, type ContextMenuRequest, } from './ContextMenuActions';
|
|
1
|
+
export { ContextMenuActions, ContextMenuActionItems, ContextMenuActionIcon, useContextMenuActions, type ContextMenuEditingLabels, type ContextMenuActionRequest, type ContextMenuAction, type ContextMenuRequest, } from './ContextMenuActions';
|
|
2
2
|
export { createContextSourceRegistry, type ContextSource, type ContextSourceSnapshot, } from './contextSource';
|
|
3
3
|
export { PromptCard, capturePromptCardAnchor, type PromptCardProps } from './PromptCard';
|
|
4
4
|
export { FeedbackIndicator, type FeedbackIndicatorProps, type FeedbackIndicatorEntry, } from './FeedbackIndicator';
|
|
@@ -67,3 +67,4 @@ export { Slider, type SliderProps } from './Slider';
|
|
|
67
67
|
export { Calendar, type CalendarProps } from './Calendar';
|
|
68
68
|
export { DatePicker, DateRangePicker, type DatePickerProps, type DateRangePickerProps, type DateRange, } from './DatePicker';
|
|
69
69
|
export { parseCalendarDate, formatCalendarDate, addCalendarDays, addCalendarMonths, calendarDays, } from './calendarModel';
|
|
70
|
+
export { RetainedPanel, type RetainedPanelProps } from './RetainedPanel';
|